Commit 9b3bd4f8 authored by erg's avatar erg Committed by Commit bot

core_services: Add mojo:surfaces_service to core_services.

In addition to the normal separation of MojoMain() into its own build
target, this patch also renames a class and moves a class into the
surfaces:: namespace. This was done because they were non-unique
symbol names in the resultant binary.

(There were two classes named mojo::ContextProviderMojo and had
different implementations.)

BUG=477435

Review URL: https://codereview.chromium.org/1138293002

Cr-Commit-Position: refs/heads/master@{#329444}
parent a68b0442
...@@ -7,12 +7,24 @@ import("//third_party/mojo/src/mojo/public/mojo_application.gni") ...@@ -7,12 +7,24 @@ import("//third_party/mojo/src/mojo/public/mojo_application.gni")
mojo_native_application("surfaces") { mojo_native_application("surfaces") {
output_name = "surfaces_service" output_name = "surfaces_service"
sources = [ sources = [
"context_provider_mojo.cc", "main.cc",
"context_provider_mojo.h", ]
deps = [
":lib",
"//mojo/environment:chromium",
"//third_party/mojo/src/mojo/public/cpp/system",
]
}
source_set("lib") {
sources = [
"display_factory_impl.cc", "display_factory_impl.cc",
"display_factory_impl.h", "display_factory_impl.h",
"display_impl.cc", "display_impl.cc",
"display_impl.h", "display_impl.h",
"surfaces_context_provider.cc",
"surfaces_context_provider.h",
"surfaces_impl.cc", "surfaces_impl.cc",
"surfaces_impl.h", "surfaces_impl.h",
"surfaces_output_surface.cc", "surfaces_output_surface.cc",
...@@ -36,11 +48,9 @@ mojo_native_application("surfaces") { ...@@ -36,11 +48,9 @@ mojo_native_application("surfaces") {
"//mojo/common:tracing_impl", "//mojo/common:tracing_impl",
"//mojo/converters/geometry", "//mojo/converters/geometry",
"//mojo/converters/surfaces", "//mojo/converters/surfaces",
"//mojo/environment:chromium",
"//third_party/mojo/src/mojo/public/c/gles2", "//third_party/mojo/src/mojo/public/c/gles2",
"//third_party/mojo/src/mojo/public/cpp/bindings", "//third_party/mojo/src/mojo/public/cpp/bindings",
"//third_party/mojo/src/mojo/public/cpp/environment", "//third_party/mojo/src/mojo/public/cpp/environment",
"//third_party/mojo/src/mojo/public/cpp/system",
"//ui/gfx/geometry", "//ui/gfx/geometry",
"//ui/mojo/geometry:interfaces", "//ui/mojo/geometry:interfaces",
] ]
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "cc/output/compositor_frame.h" #include "cc/output/compositor_frame.h"
#include "cc/surfaces/display.h" #include "cc/surfaces/display.h"
#include "components/surfaces/context_provider_mojo.h" #include "components/surfaces/surfaces_context_provider.h"
#include "components/surfaces/surfaces_output_surface.h" #include "components/surfaces/surfaces_output_surface.h"
#include "components/surfaces/surfaces_scheduler.h" #include "components/surfaces/surfaces_scheduler.h"
#include "mojo/converters/geometry/geometry_type_converters.h" #include "mojo/converters/geometry/geometry_type_converters.h"
...@@ -46,8 +46,8 @@ void DisplayImpl::OnContextCreated(mojo::CommandBufferPtr gles2_client) { ...@@ -46,8 +46,8 @@ void DisplayImpl::OnContextCreated(mojo::CommandBufferPtr gles2_client) {
cc::RendererSettings settings; cc::RendererSettings settings;
display_.reset(new cc::Display(this, manager_, nullptr, nullptr, settings)); display_.reset(new cc::Display(this, manager_, nullptr, nullptr, settings));
scheduler_->AddDisplay(display_.get()); scheduler_->AddDisplay(display_.get());
display_->Initialize(make_scoped_ptr(new mojo::DirectOutputSurface( display_->Initialize(make_scoped_ptr(new surfaces::DirectOutputSurface(
new mojo::ContextProviderMojo(gles2_client.PassMessagePipe())))); new surfaces::SurfacesContextProvider(gles2_client.PassMessagePipe()))));
factory_.Create(cc_id_); factory_.Create(cc_id_);
display_->SetSurfaceId(cc_id_, 1.f); display_->SetSurfaceId(cc_id_, 1.f);
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/surfaces/surfaces_service_application.h"
#include "mojo/application/application_runner_chromium.h"
#include "third_party/mojo/src/mojo/public/c/system/main.h"
MojoResult MojoMain(MojoHandle shell_handle) {
mojo::ApplicationRunnerChromium runner(
new surfaces::SurfacesServiceApplication);
return runner.Run(shell_handle);
}
...@@ -2,82 +2,83 @@ ...@@ -2,82 +2,83 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/surfaces/context_provider_mojo.h" #include "components/surfaces/surfaces_context_provider.h"
#include "base/logging.h" #include "base/logging.h"
#include "third_party/mojo/src/mojo/public/cpp/environment/environment.h" #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h"
namespace mojo { namespace surfaces {
ContextProviderMojo::ContextProviderMojo( SurfacesContextProvider::SurfacesContextProvider(
ScopedMessagePipeHandle command_buffer_handle) mojo::ScopedMessagePipeHandle command_buffer_handle)
: command_buffer_handle_(command_buffer_handle.Pass()), : command_buffer_handle_(command_buffer_handle.Pass()),
context_(nullptr), context_(nullptr),
context_lost_(false) { context_lost_(false) {
} }
bool ContextProviderMojo::BindToCurrentThread() { bool SurfacesContextProvider::BindToCurrentThread() {
DCHECK(command_buffer_handle_.is_valid()); DCHECK(command_buffer_handle_.is_valid());
context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(), context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(),
&ContextLostThunk, this, &ContextLostThunk, this,
Environment::GetDefaultAsyncWaiter()); mojo::Environment::GetDefaultAsyncWaiter());
DCHECK(context_); DCHECK(context_);
return !!context_; return !!context_;
} }
gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() { gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() {
if (!context_) if (!context_)
return nullptr; return nullptr;
return static_cast<gpu::gles2::GLES2Interface*>( return static_cast<gpu::gles2::GLES2Interface*>(
MojoGLES2GetGLES2Interface(context_)); MojoGLES2GetGLES2Interface(context_));
} }
gpu::ContextSupport* ContextProviderMojo::ContextSupport() { gpu::ContextSupport* SurfacesContextProvider::ContextSupport() {
if (!context_) if (!context_)
return nullptr; return nullptr;
return static_cast<gpu::ContextSupport*>( return static_cast<gpu::ContextSupport*>(
MojoGLES2GetContextSupport(context_)); MojoGLES2GetContextSupport(context_));
} }
class GrContext* ContextProviderMojo::GrContext() { class GrContext* SurfacesContextProvider::GrContext() {
return NULL; return NULL;
} }
void ContextProviderMojo::InvalidateGrContext(uint32_t state) { void SurfacesContextProvider::InvalidateGrContext(uint32_t state) {
} }
cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() { cc::ContextProvider::Capabilities
SurfacesContextProvider::ContextCapabilities() {
return capabilities_; return capabilities_;
} }
void ContextProviderMojo::SetupLock() { void SurfacesContextProvider::SetupLock() {
} }
base::Lock* ContextProviderMojo::GetLock() { base::Lock* SurfacesContextProvider::GetLock() {
return &context_lock_; return &context_lock_;
} }
bool ContextProviderMojo::IsContextLost() { bool SurfacesContextProvider::IsContextLost() {
return context_lost_; return context_lost_;
} }
bool ContextProviderMojo::DestroyedOnMainThread() { bool SurfacesContextProvider::DestroyedOnMainThread() {
return !context_; return !context_;
} }
void ContextProviderMojo::SetLostContextCallback( void SurfacesContextProvider::SetLostContextCallback(
const LostContextCallback& lost_context_callback) { const LostContextCallback& lost_context_callback) {
lost_context_callback_ = lost_context_callback; lost_context_callback_ = lost_context_callback;
} }
ContextProviderMojo::~ContextProviderMojo() { SurfacesContextProvider::~SurfacesContextProvider() {
if (context_) if (context_)
MojoGLES2DestroyContext(context_); MojoGLES2DestroyContext(context_);
} }
void ContextProviderMojo::ContextLost() { void SurfacesContextProvider::ContextLost() {
context_lost_ = true; context_lost_ = true;
if (!lost_context_callback_.is_null()) if (!lost_context_callback_.is_null())
lost_context_callback_.Run(); lost_context_callback_.Run();
} }
} // namespace mojo } // namespace surfaces
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_SURFACES_CONTEXT_PROVIDER_MOJO_H_ #ifndef COMPONENTS_SURFACES_SURFACES_CONTEXT_PROVIDER_H_
#define COMPONENTS_SURFACES_CONTEXT_PROVIDER_MOJO_H_ #define COMPONENTS_SURFACES_SURFACES_CONTEXT_PROVIDER_H_
#include "base/macros.h" #include "base/macros.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
...@@ -11,11 +11,12 @@ ...@@ -11,11 +11,12 @@
#include "third_party/mojo/src/mojo/public/c/gles2/gles2.h" #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h"
#include "third_party/mojo/src/mojo/public/cpp/system/core.h" #include "third_party/mojo/src/mojo/public/cpp/system/core.h"
namespace mojo { namespace surfaces {
class ContextProviderMojo : public cc::ContextProvider { class SurfacesContextProvider : public cc::ContextProvider {
public: public:
explicit ContextProviderMojo(ScopedMessagePipeHandle command_buffer_handle); explicit SurfacesContextProvider(
mojo::ScopedMessagePipeHandle command_buffer_handle);
// cc::ContextProvider implementation. // cc::ContextProvider implementation.
bool BindToCurrentThread() override; bool BindToCurrentThread() override;
...@@ -37,26 +38,26 @@ class ContextProviderMojo : public cc::ContextProvider { ...@@ -37,26 +38,26 @@ class ContextProviderMojo : public cc::ContextProvider {
base::Lock* GetLock() override; base::Lock* GetLock() override;
protected: protected:
friend class base::RefCountedThreadSafe<ContextProviderMojo>; friend class base::RefCountedThreadSafe<SurfacesContextProvider>;
~ContextProviderMojo() override; ~SurfacesContextProvider() override;
private: private:
static void ContextLostThunk(void* closure) { static void ContextLostThunk(void* closure) {
static_cast<ContextProviderMojo*>(closure)->ContextLost(); static_cast<SurfacesContextProvider*>(closure)->ContextLost();
} }
void ContextLost(); void ContextLost();
cc::ContextProvider::Capabilities capabilities_; cc::ContextProvider::Capabilities capabilities_;
ScopedMessagePipeHandle command_buffer_handle_; mojo::ScopedMessagePipeHandle command_buffer_handle_;
MojoGLES2Context context_; MojoGLES2Context context_;
bool context_lost_; bool context_lost_;
LostContextCallback lost_context_callback_; LostContextCallback lost_context_callback_;
base::Lock context_lock_; base::Lock context_lock_;
DISALLOW_COPY_AND_ASSIGN(ContextProviderMojo); DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider);
}; };
} // namespace mojo } // namespace surfaces
#endif // COMPONENTS_SURFACES_CONTEXT_PROVIDER_MOJO_H_ #endif // COMPONENTS_SURFACES_SURFACES_CONTEXT_PROVIDER_H_
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "gpu/command_buffer/client/context_support.h" #include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/client/gles2_interface.h"
namespace mojo { namespace surfaces {
DirectOutputSurface::DirectOutputSurface( DirectOutputSurface::DirectOutputSurface(
const scoped_refptr<cc::ContextProvider>& context_provider) const scoped_refptr<cc::ContextProvider>& context_provider)
...@@ -39,4 +39,4 @@ void DirectOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { ...@@ -39,4 +39,4 @@ void DirectOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
client_->DidSwapBuffers(); client_->DidSwapBuffers();
} }
} // namespace mojo } // namespace surfaces
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "cc/output/output_surface.h" #include "cc/output/output_surface.h"
namespace mojo { namespace surfaces {
// An OutputSurface implementation that directly draws and // An OutputSurface implementation that directly draws and
// swaps to an actual GL surface. // swaps to an actual GL surface.
...@@ -24,6 +24,6 @@ class DirectOutputSurface : public cc::OutputSurface { ...@@ -24,6 +24,6 @@ class DirectOutputSurface : public cc::OutputSurface {
base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_;
}; };
} // namespace mojo } // namespace surfaes
#endif // COMPONENTS_SURFACES_SURFACES_OUTPUT_SURFACE_H_ #endif // COMPONENTS_SURFACES_SURFACES_OUTPUT_SURFACE_H_
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include "components/surfaces/display_factory_impl.h" #include "components/surfaces/display_factory_impl.h"
#include "components/surfaces/surfaces_impl.h" #include "components/surfaces/surfaces_impl.h"
#include "components/surfaces/surfaces_scheduler.h" #include "components/surfaces/surfaces_scheduler.h"
#include "mojo/application/application_runner_chromium.h"
#include "third_party/mojo/src/mojo/public/c/system/main.h"
namespace surfaces { namespace surfaces {
...@@ -46,9 +44,3 @@ void SurfacesServiceApplication::Create( ...@@ -46,9 +44,3 @@ void SurfacesServiceApplication::Create(
} }
} // namespace surfaces } // namespace surfaces
MojoResult MojoMain(MojoHandle shell_handle) {
mojo::ApplicationRunnerChromium runner(
new surfaces::SurfacesServiceApplication);
return runner.Run(shell_handle);
}
...@@ -18,6 +18,8 @@ void InitCoreServicesForContext(mojo::runner::Context* context) { ...@@ -18,6 +18,8 @@ void InitCoreServicesForContext(mojo::runner::Context* context) {
manager->RegisterApplicationPackageAlias( manager->RegisterApplicationPackageAlias(
GURL("mojo:network_service"), GURL("mojo:core_services"), "Network"); GURL("mojo:network_service"), GURL("mojo:core_services"), "Network");
#endif #endif
manager->RegisterApplicationPackageAlias(
GURL("mojo:surfaces_service"), GURL("mojo:core_services"), "Surfaces");
manager->RegisterApplicationPackageAlias(GURL("mojo:tracing"), manager->RegisterApplicationPackageAlias(GURL("mojo:tracing"),
GURL("mojo:core_services"), "Core"); GURL("mojo:core_services"), "Core");
manager->RegisterApplicationPackageAlias(GURL("mojo:view_manager"), manager->RegisterApplicationPackageAlias(GURL("mojo:view_manager"),
......
...@@ -17,6 +17,7 @@ mojo_native_application("core_services") { ...@@ -17,6 +17,7 @@ mojo_native_application("core_services") {
deps = [ deps = [
"//base", "//base",
"//components/clipboard:lib", "//components/clipboard:lib",
"//components/surfaces:lib",
"//components/view_manager:view_manager_lib", "//components/view_manager:view_manager_lib",
"//mandoline/ui/browser:kiosk_wm_lib", "//mandoline/ui/browser:kiosk_wm_lib",
"//mojo/application", "//mojo/application",
......
include_rules = [ include_rules = [
"+components/clipboard", "+components/clipboard",
"+components/kiosk_wm", "+components/kiosk_wm",
"+components/surfaces",
"+components/view_manager", "+components/view_manager",
"+mojo/application", "+mojo/application",
"+mojo/common", "+mojo/common",
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "components/clipboard/clipboard_application_delegate.h" #include "components/clipboard/clipboard_application_delegate.h"
#include "components/surfaces/surfaces_service_application.h"
#include "components/view_manager/view_manager_app.h" #include "components/view_manager/view_manager_app.h"
#include "mandoline/ui/browser/browser.h" #include "mandoline/ui/browser/browser.h"
#include "mojo/common/message_pump_mojo.h" #include "mojo/common/message_pump_mojo.h"
...@@ -129,6 +130,8 @@ void CoreServicesApplicationDelegate::StartApplication( ...@@ -129,6 +130,8 @@ void CoreServicesApplicationDelegate::StartApplication(
else if (url == "mojo://network_service/") else if (url == "mojo://network_service/")
delegate.reset(new NetworkServiceDelegate); delegate.reset(new NetworkServiceDelegate);
#endif #endif
else if (url == "mojo://surfaces_service/")
delegate.reset(new surfaces::SurfacesServiceApplication);
else if (url == "mojo://tracing/") else if (url == "mojo://tracing/")
delegate.reset(new tracing::TracingApp); delegate.reset(new tracing::TracingApp);
else if (url == "mojo://view_manager/") else if (url == "mojo://view_manager/")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment