diff options
author | jamesr <jamesr@chromium.org> | 2014-08-25 13:54:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-25 21:00:53 +0000 |
commit | 3a29ee299da15e9cd97edf3cf84dc32602a5854f (patch) | |
tree | 544964b56ebb308e83bda1e16c85c0cb7250028c | |
parent | e6ecfd8f595f7df1a9b1ac055851f7bf691dbc9c (diff) | |
download | chromium_src-3a29ee299da15e9cd97edf3cf84dc32602a5854f.zip chromium_src-3a29ee299da15e9cd97edf3cf84dc32602a5854f.tar.gz chromium_src-3a29ee299da15e9cd97edf3cf84dc32602a5854f.tar.bz2 |
Update mojo surfaces bindings and mojo/cc/ glue
This provides a SurfacesService that can provide SurfacePtr and id
namespaces in one call, since both are needed to do anything useful. This
also updates the mojo/cc/ bindings to get closer to binding a cc using
client (like html_viewer) with surfaces, although it's not 100% there.
R=sky@chromium.org
Review URL: https://codereview.chromium.org/504443002
Cr-Commit-Position: refs/heads/master@{#291759}
22 files changed, 260 insertions, 45 deletions
diff --git a/mojo/cc/BUILD.gn b/mojo/cc/BUILD.gn index 66ebae6..7fbe9ff 100644 --- a/mojo/cc/BUILD.gn +++ b/mojo/cc/BUILD.gn @@ -9,12 +9,17 @@ source_set("cc") { deps = [ "//base", "//cc", + "//cc/surfaces", "//skia", "//gpu/command_buffer/client:gles2_implementation", + "//mojo/services/public/cpp/surfaces", + "//mojo/services/public/interfaces/surfaces", ] + mojo_gles2_for_shared_library sources = [ "context_provider_mojo.cc", "context_provider_mojo.h", + "output_surface_mojo.cc", + "output_surface_mojo.h", ] } diff --git a/mojo/cc/context_provider_mojo.h b/mojo/cc/context_provider_mojo.h index 32ef876..1e300d4 100644 --- a/mojo/cc/context_provider_mojo.h +++ b/mojo/cc/context_provider_mojo.h @@ -45,6 +45,8 @@ class ContextProviderMojo : public cc::ContextProvider { ScopedMessagePipeHandle command_buffer_handle_; MojoGLES2Context context_; bool context_lost_; + + DISALLOW_COPY_AND_ASSIGN(ContextProviderMojo); }; } // namespace mojo diff --git a/mojo/cc/output_surface_mojo.cc b/mojo/cc/output_surface_mojo.cc new file mode 100644 index 0000000..05c6a84 --- /dev/null +++ b/mojo/cc/output_surface_mojo.cc @@ -0,0 +1,49 @@ +// Copyright 2014 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 "mojo/cc/output_surface_mojo.h" + +#include "cc/output/compositor_frame.h" +#include "cc/output/output_surface_client.h" +#include "mojo/services/public/cpp/geometry/geometry_type_converters.h" +#include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h" + +namespace mojo { + +OutputSurfaceMojo::OutputSurfaceMojo( + const scoped_refptr<cc::ContextProvider>& context_provider, + SurfacePtr surface, + uint32_t id_namespace) + : cc::OutputSurface(context_provider), + surface_(surface.Pass()), + id_allocator_(id_namespace) { + surface_.set_client(this); +} + +OutputSurfaceMojo::~OutputSurfaceMojo() { +} + +void OutputSurfaceMojo::ReturnResources(Array<ReturnedResourcePtr> resources) { +} + +void OutputSurfaceMojo::SwapBuffers(cc::CompositorFrame* frame) { + gfx::Size frame_size = + frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); + if (frame_size != surface_size_) { + if (!surface_id_.is_null()) { + surface_->DestroySurface(SurfaceId::From(surface_id_)); + } + surface_id_ = id_allocator_.GenerateId(); + surface_->CreateSurface(SurfaceId::From(surface_id_), + Size::From(frame_size)); + surface_size_ = frame_size; + } + + surface_->SubmitFrame(SurfaceId::From(surface_id_), Frame::From(*frame)); + + client_->DidSwapBuffers(); + client_->DidSwapBuffersComplete(); +} + +} // namespace mojo diff --git a/mojo/cc/output_surface_mojo.h b/mojo/cc/output_surface_mojo.h new file mode 100644 index 0000000..fbde931 --- /dev/null +++ b/mojo/cc/output_surface_mojo.h @@ -0,0 +1,38 @@ +// Copyright 2014 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. + +#ifndef MOJO_CC_OUTPUT_SURFACE_MOJO_H_ +#define MOJO_CC_OUTPUT_SURFACE_MOJO_H_ + +#include "cc/output/output_surface.h" +#include "cc/surfaces/surface_id.h" +#include "cc/surfaces/surface_id_allocator.h" +#include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" + +namespace mojo { + +class OutputSurfaceMojo : public cc::OutputSurface, public SurfaceClient { + public: + OutputSurfaceMojo(const scoped_refptr<cc::ContextProvider>& context_provider, + SurfacePtr surface, + uint32_t id_namespace); + virtual ~OutputSurfaceMojo(); + + // SurfaceClient implementation. + virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; + + // cc::OutputSurface implementation. + virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE; + + private: + SurfacePtr surface_; + cc::SurfaceIdAllocator id_allocator_; + cc::SurfaceId surface_id_; + gfx::Size surface_size_; + + DISALLOW_COPY_AND_ASSIGN(OutputSurfaceMojo); +}; +} + +#endif // MOJO_CC_OUTPUT_SURFACE_MOJO_H_ diff --git a/mojo/examples/surfaces_app/child_gl_app.cc b/mojo/examples/surfaces_app/child_gl_app.cc index ae6ca0c..230948d 100644 --- a/mojo/examples/surfaces_app/child_gl_app.cc +++ b/mojo/examples/surfaces_app/child_gl_app.cc @@ -4,9 +4,11 @@ #include "base/threading/platform_thread.h" #include "mojo/examples/surfaces_app/child_gl_impl.h" +#include "mojo/public/c/system/main.h" #include "mojo/public/cpp/application/application_connection.h" #include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/application_impl.h" +#include "mojo/public/cpp/application/application_runner_chromium.h" #include "mojo/public/cpp/bindings/string.h" #include "mojo/services/public/interfaces/gpu/gpu.mojom.h" @@ -50,10 +52,9 @@ class ChildGLApp : public ApplicationDelegate, public InterfaceFactory<Child> { }; } // namespace examples +} // namespace mojo -// static -ApplicationDelegate* ApplicationDelegate::Create() { - return new examples::ChildGLApp(); +MojoResult MojoMain(MojoHandle shell_handle) { + mojo::ApplicationRunnerChromium runner(new mojo::examples::ChildGLApp); + return runner.Run(shell_handle); } - -} // namespace mojo diff --git a/mojo/examples/surfaces_app/child_gl_impl.cc b/mojo/examples/surfaces_app/child_gl_impl.cc index ec135fe..72374fb 100644 --- a/mojo/examples/surfaces_app/child_gl_impl.cc +++ b/mojo/examples/surfaces_app/child_gl_impl.cc @@ -44,9 +44,12 @@ static void ContextLostThunk(void*) { ChildGLImpl::ChildGLImpl(ApplicationConnection* surfaces_service_connection, CommandBufferPtr command_buffer) - : start_time_(base::TimeTicks::Now()), next_resource_id_(1) { - surfaces_service_connection->ConnectToService(&surface_); - surface_.set_client(this); + : start_time_(base::TimeTicks::Now()), + next_resource_id_(1), + weak_factory_(this) { + surfaces_service_connection->ConnectToService(&surfaces_service_); + surfaces_service_->CreateSurfaceConnection(base::Bind( + &ChildGLImpl::SurfaceConnectionCreated, weak_factory_.GetWeakPtr())); context_ = MojoGLES2CreateContext(command_buffer.PassMessagePipe().release().value(), &ContextLostThunk, @@ -71,14 +74,15 @@ void ChildGLImpl::ProduceFrame( cube_.set_color( SkColorGetR(color_), SkColorGetG(color_), SkColorGetB(color_)); produce_callback_ = callback; - if (allocator_) - AllocateSurface(); + AllocateSurface(); } -void ChildGLImpl::SetIdNamespace(uint32_t id_namespace) { +void ChildGLImpl::SurfaceConnectionCreated(SurfacePtr surface, + uint32_t id_namespace) { + surface_ = surface.Pass(); + surface_.set_client(this); allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); - if (!produce_callback_.is_null()) - AllocateSurface(); + AllocateSurface(); } void ChildGLImpl::ReturnResources(Array<ReturnedResourcePtr> resources) { diff --git a/mojo/examples/surfaces_app/child_gl_impl.h b/mojo/examples/surfaces_app/child_gl_impl.h index e990591..57a6b23 100644 --- a/mojo/examples/surfaces_app/child_gl_impl.h +++ b/mojo/examples/surfaces_app/child_gl_impl.h @@ -7,6 +7,7 @@ #include "base/containers/hash_tables.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "cc/surfaces/surface_id.h" #include "cc/surfaces/surface_id_allocator.h" @@ -16,6 +17,7 @@ #include "mojo/public/cpp/bindings/string.h" #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" +#include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/size.h" @@ -37,7 +39,6 @@ class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient { virtual ~ChildGLImpl(); // SurfaceClient implementation - virtual void SetIdNamespace(uint32_t id_namespace) OVERRIDE; virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; private: @@ -47,12 +48,14 @@ class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient { SizePtr size, const mojo::Callback<void(SurfaceIdPtr id)>& callback) OVERRIDE; + void SurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); void AllocateSurface(); void Draw(); SkColor color_; gfx::Size size_; scoped_ptr<cc::SurfaceIdAllocator> allocator_; + SurfacesServicePtr surfaces_service_; SurfacePtr surface_; MojoGLES2Context context_; cc::SurfaceId id_; @@ -61,6 +64,7 @@ class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient { base::TimeTicks start_time_; uint32_t next_resource_id_; base::hash_map<uint32_t, GLuint> id_to_tex_map_; + base::WeakPtrFactory<ChildGLImpl> weak_factory_; DISALLOW_COPY_AND_ASSIGN(ChildGLImpl); }; diff --git a/mojo/examples/surfaces_app/child_impl.cc b/mojo/examples/surfaces_app/child_impl.cc index afefe09..963afb6 100644 --- a/mojo/examples/surfaces_app/child_impl.cc +++ b/mojo/examples/surfaces_app/child_impl.cc @@ -28,13 +28,16 @@ using cc::SolidColorDrawQuad; using cc::DelegatedFrameData; using cc::CompositorFrame; -ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection) { - surfaces_service_connection->ConnectToService(&surface_); - surface_.set_client(this); +ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection) + : weak_factory_(this) { + surfaces_service_connection->ConnectToService(&surfaces_service_); + surfaces_service_->CreateSurfaceConnection(base::Bind( + &ChildImpl::SurfaceConnectionCreated, weak_factory_.GetWeakPtr())); } ChildImpl::~ChildImpl() { - surface_->DestroySurface(mojo::SurfaceId::From(id_)); + if (surface_) + surface_->DestroySurface(mojo::SurfaceId::From(id_)); } void ChildImpl::ProduceFrame( @@ -48,7 +51,10 @@ void ChildImpl::ProduceFrame( Draw(); } -void ChildImpl::SetIdNamespace(uint32_t id_namespace) { +void ChildImpl::SurfaceConnectionCreated(SurfacePtr surface, + uint32_t id_namespace) { + surface_ = surface.Pass(); + surface_.set_client(this); allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); if (!produce_callback_.is_null()) Draw(); diff --git a/mojo/examples/surfaces_app/child_impl.h b/mojo/examples/surfaces_app/child_impl.h index 338b17f..ca65db0 100644 --- a/mojo/examples/surfaces_app/child_impl.h +++ b/mojo/examples/surfaces_app/child_impl.h @@ -6,12 +6,14 @@ #define MOJO_EXAMPLES_SURFACES_APP_CHILD_IMPL_H_ #include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" #include "cc/surfaces/surface_id.h" #include "cc/surfaces/surface_id_allocator.h" #include "mojo/examples/surfaces_app/child.mojom.h" #include "mojo/public/cpp/bindings/string.h" #include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" +#include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/size.h" @@ -41,7 +43,6 @@ class ChildImpl : public InterfaceImpl<Child>, public SurfaceClient { virtual ~ChildImpl(); // SurfaceClient implementation - virtual void SetIdNamespace(uint32_t id_namespace) OVERRIDE; virtual void ReturnResources( Array<ReturnedResourcePtr> resources) OVERRIDE; @@ -52,14 +53,17 @@ class ChildImpl : public InterfaceImpl<Child>, public SurfaceClient { SizePtr size, const mojo::Callback<void(SurfaceIdPtr id)>& callback) OVERRIDE; + void SurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace); void Draw(); SkColor color_; gfx::Size size_; scoped_ptr<cc::SurfaceIdAllocator> allocator_; + SurfacesServicePtr surfaces_service_; SurfacePtr surface_; cc::SurfaceId id_; mojo::Callback<void(SurfaceIdPtr id)> produce_callback_; + base::WeakPtrFactory<ChildImpl> weak_factory_; DISALLOW_COPY_AND_ASSIGN(ChildImpl); }; diff --git a/mojo/examples/surfaces_app/surfaces_app.cc b/mojo/examples/surfaces_app/surfaces_app.cc index b97e40f..5bb4ee9 100644 --- a/mojo/examples/surfaces_app/surfaces_app.cc +++ b/mojo/examples/surfaces_app/surfaces_app.cc @@ -18,6 +18,8 @@ #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h" #include "mojo/services/public/interfaces/gpu/gpu.mojom.h" #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h" +#include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" +#include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" #include "ui/gfx/rect.h" namespace mojo { @@ -41,8 +43,10 @@ class SurfacesApp : public ApplicationDelegate, connection->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_); - connection->ConnectToService("mojo:mojo_surfaces_service", &surfaces_); - surfaces_.set_client(this); + connection->ConnectToService("mojo:mojo_surfaces_service", + &surfaces_service_); + surfaces_service_->CreateSurfaceConnection(base::Bind( + &SurfacesApp::SurfaceConnectionCreated, base::Unretained(this))); size_ = gfx::Size(800, 600); @@ -61,7 +65,6 @@ class SurfacesApp : public ApplicationDelegate, Size::From(child_size_), base::Bind(&SurfacesApp::ChildTwoProducedFrame, base::Unretained(this))); - embedder_.reset(new Embedder(surfaces_.get())); return true; } @@ -91,8 +94,10 @@ class SurfacesApp : public ApplicationDelegate, base::TimeDelta::FromMilliseconds(50)); } - // SurfaceClient implementation. - virtual void SetIdNamespace(uint32_t id_namespace) OVERRIDE { + void SurfaceConnectionCreated(SurfacePtr surface, uint32_t id_namespace) { + surface_ = surface.Pass(); + surface_.set_client(this); + embedder_.reset(new Embedder(surface_.get())); allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); CreateSurfaceIfReady(); } @@ -124,7 +129,7 @@ class SurfacesApp : public ApplicationDelegate, CommandBufferPtr cb; gpu_service_->CreateOnscreenGLES2Context( native_viewport_id_, Size::From(size_), Get(&cb)); - surfaces_->CreateGLES2BoundSurface( + surface_->CreateGLES2BoundSurface( cb.Pass(), SurfaceId::From(onscreen_id_), Size::From(size_)); Draw(10); } @@ -136,7 +141,8 @@ class SurfacesApp : public ApplicationDelegate, } private: - SurfacePtr surfaces_; + SurfacesServicePtr surfaces_service_; + SurfacePtr surface_; cc::SurfaceId onscreen_id_; uint64_t native_viewport_id_; scoped_ptr<cc::SurfaceIdAllocator> allocator_; diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp index 609dc17..3eaff73 100644 --- a/mojo/mojo.gyp +++ b/mojo/mojo.gyp @@ -369,13 +369,22 @@ 'dependencies': [ '../base/base.gyp:base', '../cc/cc.gyp:cc', + '../cc/cc.gyp:cc_surfaces', '../skia/skia.gyp:skia', '../gpu/gpu.gyp:gles2_implementation', + 'mojo_geometry_lib', + 'mojo_surfaces_bindings', + 'mojo_surfaces_lib', '<(mojo_gles2_for_loadable_module)', ], + 'export_dependent_settings': [ + 'mojo_surfaces_bindings', + ], 'sources': [ 'cc/context_provider_mojo.cc', 'cc/context_provider_mojo.h', + 'cc/output_surface_mojo.cc', + 'cc/output_surface_mojo.h', ], }, ], diff --git a/mojo/mojo_services.gypi b/mojo/mojo_services.gypi index 981b1c7..498f35d 100644 --- a/mojo/mojo_services.gypi +++ b/mojo/mojo_services.gypi @@ -443,6 +443,8 @@ 'services/surfaces/surfaces_impl.h', 'services/surfaces/surfaces_service_application.cc', 'services/surfaces/surfaces_service_application.h', + 'services/surfaces/surfaces_service_impl.cc', + 'services/surfaces/surfaces_service_impl.h', ], }, { @@ -582,8 +584,9 @@ 'target_name': 'mojo_surfaces_bindings', 'type': 'static_library', 'sources': [ - 'services/public/interfaces/surfaces/surfaces.mojom', 'services/public/interfaces/surfaces/surface_id.mojom', + 'services/public/interfaces/surfaces/surfaces.mojom', + 'services/public/interfaces/surfaces/surfaces_service.mojom', 'services/public/interfaces/surfaces/quads.mojom', ], 'includes': [ 'public/tools/bindings/mojom_bindings_generator.gypi' ], diff --git a/mojo/services/public/interfaces/surfaces/BUILD.gn b/mojo/services/public/interfaces/surfaces/BUILD.gn index 27d56b6..3e03006 100644 --- a/mojo/services/public/interfaces/surfaces/BUILD.gn +++ b/mojo/services/public/interfaces/surfaces/BUILD.gn @@ -7,9 +7,10 @@ import("//mojo/public/tools/bindings/mojom.gni") # GYP version: mojo/mojo_services.gypi:mojo_surfaces_bindings mojom("surfaces") { sources = [ - "surfaces.mojom", - "surface_id.mojom", "quads.mojom", + "surface_id.mojom", + "surfaces.mojom", + "surfaces_service.mojom", ] deps = [ diff --git a/mojo/services/public/interfaces/surfaces/surfaces.mojom b/mojo/services/public/interfaces/surfaces/surfaces.mojom index 0aead1e..8299cb3 100644 --- a/mojo/services/public/interfaces/surfaces/surfaces.mojom +++ b/mojo/services/public/interfaces/surfaces/surfaces.mojom @@ -52,13 +52,16 @@ struct Frame { }; interface SurfaceClient { - SetIdNamespace(uint32 id); ReturnResources(ReturnedResource[] resources); }; [Client=SurfaceClient] interface Surface { + // The id is created by the client and must be unique and contain the + // connection's namespace in the upper 32 bits. CreateSurface(SurfaceId id, Size size); + + // The client can only submit frames to surfaces created with this connection. SubmitFrame(SurfaceId id, Frame frame); DestroySurface(SurfaceId id); diff --git a/mojo/services/public/interfaces/surfaces/surfaces_service.mojom b/mojo/services/public/interfaces/surfaces/surfaces_service.mojom new file mode 100644 index 0000000..76faeec --- /dev/null +++ b/mojo/services/public/interfaces/surfaces/surfaces_service.mojom @@ -0,0 +1,15 @@ +// Copyright 2014 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. + +import "mojo/services/public/interfaces/surfaces/surfaces.mojom" + +module mojo { + +// Use this interface to request connections to the surfaces service. Each +// connection is associated with an id namespace +interface SurfacesService { + CreateSurfaceConnection() => (Surface surface, uint32 id_namespace); +}; + +} diff --git a/mojo/services/surfaces/surfaces_impl.cc b/mojo/services/surfaces/surfaces_impl.cc index 410e8d0..5316ea3 100644 --- a/mojo/services/surfaces/surfaces_impl.cc +++ b/mojo/services/surfaces/surfaces_impl.cc @@ -26,10 +26,6 @@ SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager, SurfacesImpl::~SurfacesImpl() { } -void SurfacesImpl::OnConnectionEstablished() { - client()->SetIdNamespace(id_namespace_); -} - void SurfacesImpl::CreateSurface(SurfaceIdPtr id, mojo::SizePtr size) { cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { diff --git a/mojo/services/surfaces/surfaces_impl.h b/mojo/services/surfaces/surfaces_impl.h index ac9a397..bf6f37b 100644 --- a/mojo/services/surfaces/surfaces_impl.h +++ b/mojo/services/surfaces/surfaces_impl.h @@ -37,9 +37,6 @@ class SurfacesImpl : public InterfaceImpl<Surface>, Client* client); virtual ~SurfacesImpl(); - // InterfaceImpl<Surface> implementation. - virtual void OnConnectionEstablished() OVERRIDE; - // Surface implementation. virtual void CreateSurface(SurfaceIdPtr id, mojo::SizePtr size) OVERRIDE; virtual void SubmitFrame(SurfaceIdPtr id, FramePtr frame) OVERRIDE; diff --git a/mojo/services/surfaces/surfaces_service_application.cc b/mojo/services/surfaces/surfaces_service_application.cc index f372e66..3169b4e 100644 --- a/mojo/services/surfaces/surfaces_service_application.cc +++ b/mojo/services/surfaces/surfaces_service_application.cc @@ -8,6 +8,7 @@ #include "mojo/public/c/system/main.h" #include "mojo/public/cpp/application/application_runner_chromium.h" +#include "mojo/services/surfaces/surfaces_service_impl.h" namespace mojo { @@ -24,9 +25,10 @@ bool SurfacesServiceApplication::ConfigureIncomingConnection( return true; } -void SurfacesServiceApplication::Create(ApplicationConnection* connection, - InterfaceRequest<Surface> request) { - BindToRequest(new SurfacesImpl(&manager_, next_id_namespace_++, this), +void SurfacesServiceApplication::Create( + ApplicationConnection* connection, + InterfaceRequest<SurfacesService> request) { + BindToRequest(new SurfacesServiceImpl(&manager_, &next_id_namespace_, this), &request); } diff --git a/mojo/services/surfaces/surfaces_service_application.h b/mojo/services/surfaces/surfaces_service_application.h index bf45a81..5b33179 100644 --- a/mojo/services/surfaces/surfaces_service_application.h +++ b/mojo/services/surfaces/surfaces_service_application.h @@ -8,13 +8,15 @@ #include "base/macros.h" #include "cc/surfaces/surface_manager.h" #include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/interface_factory.h" +#include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" #include "mojo/services/surfaces/surfaces_impl.h" namespace mojo { class ApplicationConnection; class SurfacesServiceApplication : public ApplicationDelegate, - public InterfaceFactory<Surface>, + public InterfaceFactory<SurfacesService>, public SurfacesImpl::Client { public: SurfacesServiceApplication(); @@ -24,9 +26,9 @@ class SurfacesServiceApplication : public ApplicationDelegate, virtual bool ConfigureIncomingConnection( ApplicationConnection* connection) OVERRIDE; - // InterfaceFactory<Surface> implementation. + // InterfaceFactory<SurfacsServicee> implementation. virtual void Create(ApplicationConnection* connection, - InterfaceRequest<Surface> request) OVERRIDE; + InterfaceRequest<SurfacesService> request) OVERRIDE; // SurfacesImpl::Client implementation. virtual void FrameSubmitted() OVERRIDE; diff --git a/mojo/services/surfaces/surfaces_service_impl.cc b/mojo/services/surfaces/surfaces_service_impl.cc new file mode 100644 index 0000000..919f8a5 --- /dev/null +++ b/mojo/services/surfaces/surfaces_service_impl.cc @@ -0,0 +1,27 @@ +// Copyright 2014 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 "mojo/services/surfaces/surfaces_service_impl.h" + +namespace mojo { + +SurfacesServiceImpl::SurfacesServiceImpl(cc::SurfaceManager* manager, + uint32_t* next_id_namespace, + SurfacesImpl::Client* client) + : manager_(manager), + next_id_namespace_(next_id_namespace), + client_(client) { +} +SurfacesServiceImpl::~SurfacesServiceImpl() { +} + +void SurfacesServiceImpl::CreateSurfaceConnection( + const Callback<void(SurfacePtr, uint32_t)>& callback) { + uint32_t id_namespace = (*next_id_namespace_)++; + SurfacePtr surface; + BindToProxy(new SurfacesImpl(manager_, id_namespace, client_), &surface); + callback.Run(surface.Pass(), id_namespace); +} + +} // namespace mojo diff --git a/mojo/services/surfaces/surfaces_service_impl.h b/mojo/services/surfaces/surfaces_service_impl.h new file mode 100644 index 0000000..21dd185 --- /dev/null +++ b/mojo/services/surfaces/surfaces_service_impl.h @@ -0,0 +1,41 @@ +// Copyright 2014 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. + +#ifndef MOJO_SERVICES_SURFACES_SURFACES_SERVICE_IMPL_H_ +#define MOJO_SERVICES_SURFACES_SURFACES_SERVICE_IMPL_H_ + +#include "base/macros.h" +#include "mojo/services/public/interfaces/surfaces/surfaces_service.mojom.h" +#include "mojo/services/surfaces/surfaces_impl.h" + +namespace cc { +class SurfaceManager; +} + +namespace mojo { + +class SurfacesServiceImpl : public InterfaceImpl<SurfacesService> { + public: + // The instances pointed to by |manager|, |next_id_namespace| and |client| are + // owned by the caller and must outlive the SurfacesServiceImpl instance. + SurfacesServiceImpl(cc::SurfaceManager* manager, + uint32_t* next_id_namespace, + SurfacesImpl::Client* client); + virtual ~SurfacesServiceImpl(); + + // InterfaceImpl<SurfacesService> implementation. + virtual void CreateSurfaceConnection(const mojo::Callback< + void(mojo::SurfacePtr, uint32_t)>& callback) OVERRIDE; + + private: + cc::SurfaceManager* manager_; + uint32_t* next_id_namespace_; + SurfacesImpl::Client* client_; + + DISALLOW_COPY_AND_ASSIGN(SurfacesServiceImpl); +}; + +} // namespace mojo + +#endif // MOJO_SERVICES_SURFACES_SURFACES_SERVICE_IMPL_H_ diff --git a/mojo/shell/in_process_dynamic_service_runner.cc b/mojo/shell/in_process_dynamic_service_runner.cc index eee3f17..25431a8 100644 --- a/mojo/shell/in_process_dynamic_service_runner.cc +++ b/mojo/shell/in_process_dynamic_service_runner.cc @@ -134,7 +134,7 @@ void InProcessDynamicServiceRunner::Run() { MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( app_library_.GetFunctionPointer("MojoMain")); if (!main_function) { - LOG(ERROR) << "Entrypoint MojoMain not found"; + LOG(ERROR) << "Entrypoint MojoMain not found: " << app_path_.value(); break; } |