diff options
author | tdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-16 22:26:36 +0000 |
---|---|---|
committer | tdanderson@chromium.org <tdanderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-16 22:26:36 +0000 |
commit | a930ada2a5e1c0e73d26db49f3bd6d57d802866d (patch) | |
tree | cd59d7298f931bb48e597fffb2545bc9b2815cf2 | |
parent | 123647ba46a3b243a9985b2e9f79e40368e16e75 (diff) | |
download | chromium_src-a930ada2a5e1c0e73d26db49f3bd6d57d802866d.zip chromium_src-a930ada2a5e1c0e73d26db49f3bd6d57d802866d.tar.gz chromium_src-a930ada2a5e1c0e73d26db49f3bd6d57d802866d.tar.bz2 |
Revert of Mojo multiple command buffer support and sample (patchset #6 of https://codereview.chromium.org/451753003/)
Reason for revert:
Reverting because this closed the tree due to a failed compile step on Linux Builder (dbg)(32). See http://build.chromium.org/p/chromium.linux/builders/Linux%20Builder%20%28dbg%29%2832%29/builds/27701
Original issue's description:
> Mojo multiple command buffer support and sample
>
> TBR=danakj@chromium.org for DEPS file shuffle that moves a "+ui/gfx"
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=290157
TBR=darin@chromium.org,piman@chromium.org,jamesr@chromium.org
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/478103002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290162 0039d316-1c4b-4281-b951-d872f2087c98
34 files changed, 155 insertions, 732 deletions
diff --git a/mojo/examples/compositor_app/compositor_app.cc b/mojo/examples/compositor_app/compositor_app.cc index c169d14..513379e 100644 --- a/mojo/examples/compositor_app/compositor_app.cc +++ b/mojo/examples/compositor_app/compositor_app.cc @@ -11,7 +11,6 @@ #include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/system/core.h" #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" -#include "mojo/services/public/interfaces/gpu/gpu.mojom.h" #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h" #include "ui/gfx/rect.h" @@ -29,22 +28,22 @@ class SampleApp : public ApplicationDelegate, public NativeViewportClient { viewport_->Create(Rect::From(gfx::Rect(10, 10, 800, 600))); viewport_->Show(); - // TODO(jamesr): Should be mojo:mojo_gpu_service - app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_); + MessagePipe pipe; + viewport_->CreateGLES2Context( + MakeRequest<CommandBuffer>(pipe.handle0.Pass())); + host_.reset(new CompositorHost(pipe.handle1.Pass())); } - virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE { - CommandBufferPtr cb; - gpu_service_->CreateOnscreenGLES2Context( - native_viewport_id, Size::From(gfx::Size(800, 600)), Get(&cb)); - host_.reset(new CompositorHost(cb.PassMessagePipe())); + virtual void OnCreated() OVERRIDE { } - virtual void OnDestroyed() OVERRIDE { base::MessageLoop::current()->Quit(); } + virtual void OnDestroyed(const mojo::Callback<void()>& callback) OVERRIDE { + base::MessageLoop::current()->Quit(); + callback.Run(); + } virtual void OnBoundsChanged(RectPtr bounds) OVERRIDE { - if (host_) - host_->SetSize(gfx::Size(bounds->width, bounds->height)); + host_->SetSize(gfx::Size(bounds->width, bounds->height)); } virtual void OnEvent(EventPtr event, @@ -54,7 +53,6 @@ class SampleApp : public ApplicationDelegate, public NativeViewportClient { private: NativeViewportPtr viewport_; - GpuPtr gpu_service_; scoped_ptr<CompositorHost> host_; DISALLOW_COPY_AND_ASSIGN(SampleApp); }; diff --git a/mojo/examples/pepper_container_app/pepper_container_app.cc b/mojo/examples/pepper_container_app/pepper_container_app.cc index 8d80a47..e74ae8c 100644 --- a/mojo/examples/pepper_container_app/pepper_container_app.cc +++ b/mojo/examples/pepper_container_app/pepper_container_app.cc @@ -14,7 +14,6 @@ #include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/system/core.h" -#include "mojo/services/public/interfaces/gpu/gpu.mojom.h" #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h" #include "ppapi/c/pp_rect.h" #include "ppapi/shared_impl/proxy_lock.h" @@ -36,9 +35,6 @@ class PepperContainerApp: public ApplicationDelegate, app->ConnectToService("mojo:mojo_native_viewport_service", &viewport_); viewport_.set_client(this); - // TODO(jamesr): Should be mojo:mojo_gpu_service - app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_); - RectPtr rect(Rect::New()); rect->x = 10; rect->y = 10; @@ -49,8 +45,7 @@ class PepperContainerApp: public ApplicationDelegate, } // NativeViewportClient implementation. - virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE { - native_viewport_id_ = native_viewport_id; + virtual void OnCreated() OVERRIDE { ppapi::ProxyAutoLock lock; plugin_instance_ = plugin_module_->CreateInstance().Pass(); @@ -58,7 +53,7 @@ class PepperContainerApp: public ApplicationDelegate, plugin_instance_.reset(); } - virtual void OnDestroyed() OVERRIDE { + virtual void OnDestroyed(const mojo::Callback<void()>& callback) OVERRIDE { ppapi::ProxyAutoLock lock; if (plugin_instance_) { @@ -67,6 +62,7 @@ class PepperContainerApp: public ApplicationDelegate, } base::MessageLoop::current()->Quit(); + callback.Run(); } virtual void OnBoundsChanged(RectPtr bounds) OVERRIDE { @@ -89,20 +85,14 @@ class PepperContainerApp: public ApplicationDelegate, // MojoPpapiGlobals::Delegate implementation. virtual ScopedMessagePipeHandle CreateGLES2Context() OVERRIDE { CommandBufferPtr command_buffer; - SizePtr size = Size::New(); - size->width = 800; - size->width = 600; - gpu_service_->CreateOnscreenGLES2Context( - native_viewport_id_, size.Pass(), Get(&command_buffer)); + viewport_->CreateGLES2Context(Get(&command_buffer)); return command_buffer.PassMessagePipe(); } private: MojoPpapiGlobals ppapi_globals_; - uint64_t native_viewport_id_; NativeViewportPtr viewport_; - GpuPtr gpu_service_; scoped_refptr<PluginModule> plugin_module_; scoped_ptr<PluginInstance> plugin_instance_; diff --git a/mojo/examples/sample_app/sample_app.cc b/mojo/examples/sample_app/sample_app.cc index f1bcb72..ceebd61 100644 --- a/mojo/examples/sample_app/sample_app.cc +++ b/mojo/examples/sample_app/sample_app.cc @@ -12,7 +12,6 @@ #include "mojo/public/cpp/system/core.h" #include "mojo/public/cpp/system/macros.h" #include "mojo/public/cpp/utility/run_loop.h" -#include "mojo/services/public/interfaces/gpu/gpu.mojom.h" #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h" namespace examples { @@ -31,9 +30,6 @@ class SampleApp : public mojo::ApplicationDelegate, app->ConnectToService("mojo:mojo_native_viewport_service", &viewport_); viewport_.set_client(this); - // TODO(jamesr): Should be mojo:mojo_gpu_service - app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_); - mojo::RectPtr rect(mojo::Rect::New()); rect->x = 10; rect->y = 10; @@ -41,27 +37,27 @@ class SampleApp : public mojo::ApplicationDelegate, rect->height = 600; viewport_->Create(rect.Pass()); viewport_->Show(); - } - virtual void OnCreated(uint64_t native_viewport_id) MOJO_OVERRIDE { - mojo::SizePtr size = mojo::Size::New(); - size->width = 800; - size->height = 600; mojo::CommandBufferPtr command_buffer; - gpu_service_->CreateOnscreenGLES2Context( - native_viewport_id, size.Pass(), Get(&command_buffer)); + viewport_->CreateGLES2Context(Get(&command_buffer)); gles2_client_.reset(new GLES2ClientImpl(command_buffer.Pass())); } - virtual void OnDestroyed() MOJO_OVERRIDE { mojo::RunLoop::current()->Quit(); } + virtual void OnCreated() MOJO_OVERRIDE { + } + + virtual void OnDestroyed( + const mojo::Callback<void()>& callback) MOJO_OVERRIDE { + mojo::RunLoop::current()->Quit(); + callback.Run(); + } virtual void OnBoundsChanged(mojo::RectPtr bounds) MOJO_OVERRIDE { assert(bounds); mojo::SizePtr size(mojo::Size::New()); size->width = bounds->width; size->height = bounds->height; - if (gles2_client_) - gles2_client_->SetSize(*size); + gles2_client_->SetSize(*size); } virtual void OnEvent(mojo::EventPtr event, @@ -75,7 +71,6 @@ class SampleApp : public mojo::ApplicationDelegate, private: scoped_ptr<GLES2ClientImpl> gles2_client_; mojo::NativeViewportPtr viewport_; - mojo::GpuPtr gpu_service_; DISALLOW_COPY_AND_ASSIGN(SampleApp); }; diff --git a/mojo/examples/surfaces_app/DEPS b/mojo/examples/surfaces_app/DEPS index 239026f..edcc6c6 100644 --- a/mojo/examples/surfaces_app/DEPS +++ b/mojo/examples/surfaces_app/DEPS @@ -1,8 +1,6 @@ include_rules = [ "+cc", - "+gpu/GLES2", + "+ui/gfx", "+gpu/command_buffer/client", - "+third_party/khronos/GLES2", "+third_party/skia/include", - "+ui/gfx", ] diff --git a/mojo/examples/surfaces_app/child_gl_app.cc b/mojo/examples/surfaces_app/child_gl_app.cc deleted file mode 100644 index ae6ca0c..0000000 --- a/mojo/examples/surfaces_app/child_gl_app.cc +++ /dev/null @@ -1,59 +0,0 @@ -// 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 "base/threading/platform_thread.h" -#include "mojo/examples/surfaces_app/child_gl_impl.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/bindings/string.h" -#include "mojo/services/public/interfaces/gpu/gpu.mojom.h" - -namespace mojo { -namespace examples { - -class ChildGLApp : public ApplicationDelegate, public InterfaceFactory<Child> { - public: - ChildGLApp() {} - virtual ~ChildGLApp() {} - - virtual void Initialize(ApplicationImpl* app) OVERRIDE { - surfaces_service_connection_ = - app->ConnectToApplication("mojo:mojo_surfaces_service"); - // TODO(jamesr): Should be mojo:mojo_gpu_service - app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_); - } - - // ApplicationDelegate implementation. - virtual bool ConfigureIncomingConnection( - ApplicationConnection* connection) OVERRIDE { - connection->AddService(this); - return true; - } - - // InterfaceFactory<Child> implementation. - virtual void Create(ApplicationConnection* connection, - InterfaceRequest<Child> request) OVERRIDE { - CommandBufferPtr command_buffer; - gpu_service_->CreateOffscreenGLES2Context(Get(&command_buffer)); - BindToRequest( - new ChildGLImpl(surfaces_service_connection_, command_buffer.Pass()), - &request); - } - - private: - ApplicationConnection* surfaces_service_connection_; - GpuPtr gpu_service_; - - DISALLOW_COPY_AND_ASSIGN(ChildGLApp); -}; - -} // namespace examples - -// static -ApplicationDelegate* ApplicationDelegate::Create() { - return new examples::ChildGLApp(); -} - -} // namespace mojo diff --git a/mojo/examples/surfaces_app/child_gl_impl.cc b/mojo/examples/surfaces_app/child_gl_impl.cc deleted file mode 100644 index e669761..0000000 --- a/mojo/examples/surfaces_app/child_gl_impl.cc +++ /dev/null @@ -1,182 +0,0 @@ -// 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/examples/surfaces_app/child_gl_impl.h" - -#ifndef GL_GLEXT_PROTOTYPES -#define GL_GLEXT_PROTOTYPES -#endif - -#include "base/bind.h" -#include "base/message_loop/message_loop.h" -#include "cc/output/compositor_frame.h" -#include "cc/output/delegated_frame_data.h" -#include "cc/quads/render_pass.h" -#include "cc/quads/texture_draw_quad.h" -#include "gpu/GLES2/gl2chromium.h" -#include "gpu/GLES2/gl2extchromium.h" -#include "mojo/examples/surfaces_app/surfaces_util.h" -#include "mojo/public/cpp/application/application_connection.h" -#include "mojo/public/cpp/environment/environment.h" -#include "mojo/services/public/cpp/geometry/geometry_type_converters.h" -#include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h" -#include "mojo/services/public/interfaces/surfaces/surface_id.mojom.h" -#include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" -#include "third_party/khronos/GLES2/gl2.h" -#include "third_party/khronos/GLES2/gl2ext.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/transform.h" - -namespace mojo { -namespace examples { - -using cc::RenderPass; -using cc::DrawQuad; -using cc::TextureDrawQuad; -using cc::DelegatedFrameData; -using cc::CompositorFrame; - -static void ContextLostThunk(void*) { - LOG(FATAL) << "Context lost"; -} - -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); - context_ = - MojoGLES2CreateContext(command_buffer.PassMessagePipe().release().value(), - &ContextLostThunk, - this, - Environment::GetDefaultAsyncWaiter()); - DCHECK(context_); - MojoGLES2MakeCurrent(context_); -} - -ChildGLImpl::~ChildGLImpl() { - MojoGLES2DestroyContext(context_); - surface_->DestroySurface(mojo::SurfaceId::From(id_)); -} - -void ChildGLImpl::ProduceFrame( - ColorPtr color, - SizePtr size, - const mojo::Callback<void(SurfaceIdPtr id)>& callback) { - color_ = color.To<SkColor>(); - size_ = size.To<gfx::Size>(); - cube_.Init(size_.width(), size_.height()); - cube_.set_color( - SkColorGetR(color_), SkColorGetG(color_), SkColorGetB(color_)); - produce_callback_ = callback; - if (allocator_) - AllocateSurface(); -} - -void ChildGLImpl::SetIdNamespace(uint32_t id_namespace) { - allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); - if (!produce_callback_.is_null()) - AllocateSurface(); -} - -void ChildGLImpl::ReturnResources(Array<ReturnedResourcePtr> resources) { - for (size_t i = 0; i < resources.size(); ++i) { - cc::ReturnedResource res = resources[i].To<cc::ReturnedResource>(); - GLuint returned_texture = id_to_tex_map_[res.id]; - glDeleteTextures(1, &returned_texture); - } -} - -void ChildGLImpl::AllocateSurface() { - if (produce_callback_.is_null() || !allocator_) - return; - - id_ = allocator_->GenerateId(); - surface_->CreateSurface(mojo::SurfaceId::From(id_), mojo::Size::From(size_)); - produce_callback_.Run(SurfaceId::From(id_)); - Draw(); -} - -void ChildGLImpl::Draw() { - // First, generate a GL texture and draw the cube into it. - GLuint texture = 0u; - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - glTexImage2D(GL_TEXTURE_2D, - 0, - GL_RGBA, - size_.width(), - size_.height(), - 0, - GL_RGBA, - GL_UNSIGNED_BYTE, - 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - GLuint fbo = 0u; - glGenFramebuffers(1, &fbo); - glBindFramebuffer(GL_FRAMEBUFFER, fbo); - glFramebufferTexture2D( - GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); - DCHECK_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), - glCheckFramebufferStatus(GL_FRAMEBUFFER)); - glClearColor(1, 0, 0, 0.5); - cube_.UpdateForTimeDelta(0.16f); - cube_.Draw(); - - // Then, put the texture into a mailbox. - gpu::Mailbox mailbox = gpu::Mailbox::Generate(); - glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); - GLuint sync_point = glInsertSyncPointCHROMIUM(); - gpu::MailboxHolder holder(mailbox, GL_TEXTURE_2D, sync_point); - - // Then, put the mailbox into a TransferableResource - cc::TransferableResource resource; - resource.id = next_resource_id_++; - id_to_tex_map_[resource.id] = texture; - resource.format = cc::RGBA_8888; - resource.filter = GL_LINEAR; - resource.size = size_; - resource.mailbox_holder = holder; - resource.is_repeated = false; - resource.is_software = false; - - gfx::Rect rect(size_); - RenderPass::Id id(1, 1); - scoped_ptr<RenderPass> pass = RenderPass::Create(); - pass->SetNew(id, rect, rect, gfx::Transform()); - - CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size_); - - TextureDrawQuad* texture_quad = - pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); - float vertex_opacity[4] = {1.0f, 1.0f, 0.2f, 1.0f}; - texture_quad->SetNew(pass->shared_quad_state_list.back(), - rect, - rect, - rect, - resource.id, - true, - gfx::PointF(), - gfx::PointF(1.f, 1.f), - SK_ColorBLUE, - vertex_opacity, - false); - - scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData); - delegated_frame_data->render_pass_list.push_back(pass.Pass()); - delegated_frame_data->resource_list.push_back(resource); - - scoped_ptr<CompositorFrame> frame(new CompositorFrame); - frame->delegated_frame_data = delegated_frame_data.Pass(); - - surface_->SubmitFrame(mojo::SurfaceId::From(id_), mojo::Frame::From(*frame)); - - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&ChildGLImpl::Draw, base::Unretained(this)), - base::TimeDelta::FromMilliseconds(50)); -} - -} // namespace examples -} // namespace mojo diff --git a/mojo/examples/surfaces_app/child_gl_impl.h b/mojo/examples/surfaces_app/child_gl_impl.h deleted file mode 100644 index e990591..0000000 --- a/mojo/examples/surfaces_app/child_gl_impl.h +++ /dev/null @@ -1,71 +0,0 @@ -// 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_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ -#define MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ - -#include "base/containers/hash_tables.h" -#include "base/memory/scoped_ptr.h" -#include "base/time/time.h" -#include "cc/surfaces/surface_id.h" -#include "cc/surfaces/surface_id_allocator.h" -#include "mojo/examples/sample_app/spinning_cube.h" -#include "mojo/examples/surfaces_app/child.mojom.h" -#include "mojo/public/c/gles2/gles2.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 "third_party/skia/include/core/SkColor.h" -#include "ui/gfx/size.h" - -namespace cc { -class CompositorFrame; -} - -namespace mojo { - -class ApplicationConnection; - -namespace examples { - -// Simple example of a child app using surfaces + GL. -class ChildGLImpl : public InterfaceImpl<Child>, public SurfaceClient { - public: - ChildGLImpl(ApplicationConnection* surfaces_service_connection, - CommandBufferPtr command_buffer); - virtual ~ChildGLImpl(); - - // SurfaceClient implementation - virtual void SetIdNamespace(uint32_t id_namespace) OVERRIDE; - virtual void ReturnResources(Array<ReturnedResourcePtr> resources) OVERRIDE; - - private: - // Child implementation. - virtual void ProduceFrame( - ColorPtr color, - SizePtr size, - const mojo::Callback<void(SurfaceIdPtr id)>& callback) OVERRIDE; - - void AllocateSurface(); - void Draw(); - - SkColor color_; - gfx::Size size_; - scoped_ptr<cc::SurfaceIdAllocator> allocator_; - SurfacePtr surface_; - MojoGLES2Context context_; - cc::SurfaceId id_; - ::examples::SpinningCube cube_; - Callback<void(SurfaceIdPtr id)> produce_callback_; - base::TimeTicks start_time_; - uint32_t next_resource_id_; - base::hash_map<uint32_t, GLuint> id_to_tex_map_; - - DISALLOW_COPY_AND_ASSIGN(ChildGLImpl); -}; - -} // namespace examples -} // namespace mojo - -#endif // MOJO_EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_ diff --git a/mojo/examples/surfaces_app/embedder.cc b/mojo/examples/surfaces_app/embedder.cc index 1896717..a23a958 100644 --- a/mojo/examples/surfaces_app/embedder.cc +++ b/mojo/examples/surfaces_app/embedder.cc @@ -36,7 +36,7 @@ void Embedder::ProduceFrame(cc::SurfaceId child_one, cc::SurfaceId child_two, const gfx::Size& child_size, const gfx::Size& size, - int offset) { + double rotation_degrees) { gfx::Rect rect(size); RenderPass::Id pass_id(1, 1); scoped_ptr<RenderPass> pass = RenderPass::Create(); @@ -45,7 +45,7 @@ void Embedder::ProduceFrame(cc::SurfaceId child_one, gfx::Transform one_transform; one_transform.Translate(10 + child_size.width() / 2, 50 + child_size.height() / 2); - one_transform.Translate(0, offset); + one_transform.Rotate(rotation_degrees); one_transform.Translate(-child_size.width() / 2, -child_size.height() / 2); CreateAndAppendSimpleSharedQuadState(pass.get(), one_transform, size); @@ -58,7 +58,7 @@ void Embedder::ProduceFrame(cc::SurfaceId child_one, gfx::Transform two_transform; two_transform.Translate(10 + size.width() / 2 + child_size.width() / 2, 50 + child_size.height() / 2); - two_transform.Translate(0, 200 - offset); + two_transform.Rotate(-rotation_degrees * 0.76); two_transform.Translate(-child_size.width() / 2, -child_size.height() / 2); CreateAndAppendSimpleSharedQuadState(pass.get(), two_transform, size); diff --git a/mojo/examples/surfaces_app/embedder.h b/mojo/examples/surfaces_app/embedder.h index 3be6a42..56212f3 100644 --- a/mojo/examples/surfaces_app/embedder.h +++ b/mojo/examples/surfaces_app/embedder.h @@ -31,7 +31,7 @@ class Embedder { cc::SurfaceId child_two, const gfx::Size& child_size, const gfx::Size& size, - int offset); + double rotation_degrees); private: cc::SurfaceId id_; diff --git a/mojo/examples/surfaces_app/surfaces_app.cc b/mojo/examples/surfaces_app/surfaces_app.cc index d5f4684..6b7a9e9 100644 --- a/mojo/examples/surfaces_app/surfaces_app.cc +++ b/mojo/examples/surfaces_app/surfaces_app.cc @@ -14,7 +14,6 @@ #include "mojo/services/gles2/command_buffer.mojom.h" #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" #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 "ui/gfx/rect.h" @@ -25,7 +24,7 @@ class SurfacesApp : public ApplicationDelegate, public SurfaceClient, public NativeViewportClient { public: - SurfacesApp() : native_viewport_id_(0) {} + SurfacesApp() {} virtual ~SurfacesApp() {} // ApplicationDelegate implementation @@ -35,10 +34,6 @@ class SurfacesApp : public ApplicationDelegate, &viewport_); viewport_.set_client(this); - // TODO(jamesr): Should be mojo:mojo_gpu_service - connection->ConnectToService("mojo:mojo_native_viewport_service", - &gpu_service_); - connection->ConnectToService("mojo:mojo_surfaces_service", &surfaces_); surfaces_.set_client(this); @@ -49,8 +44,7 @@ class SurfacesApp : public ApplicationDelegate, child_size_ = gfx::Size(size_.width() / 3, size_.height() / 2); connection->ConnectToService("mojo:mojo_surfaces_child_app", &child_one_); - connection->ConnectToService("mojo:mojo_surfaces_child_gl_app", - &child_two_); + connection->ConnectToService("mojo:mojo_surfaces_child_app", &child_two_); child_one_->ProduceFrame(Color::From(SK_ColorBLUE), Size::From(child_size_), base::Bind(&SurfacesApp::ChildOneProducedFrame, @@ -65,34 +59,40 @@ class SurfacesApp : public ApplicationDelegate, void ChildOneProducedFrame(SurfaceIdPtr id) { child_one_id_ = id.To<cc::SurfaceId>(); - Draw(10); + Draw(45.0); } void ChildTwoProducedFrame(SurfaceIdPtr id) { child_two_id_ = id.To<cc::SurfaceId>(); - Draw(10); + Draw(45.0); } - void Draw(int offset) { - if (onscreen_id_.is_null() || child_one_id_.is_null() || - child_two_id_.is_null()) + void Draw(double rotation_degrees) { + if (onscreen_id_.is_null()) { + onscreen_id_ = allocator_->GenerateId(); + CommandBufferPtr cb; + viewport_->CreateGLES2Context(Get(&cb)); + surfaces_->CreateGLES2BoundSurface( + cb.Pass(), + SurfaceId::From(onscreen_id_), + Size::From(size_)); + embedder_->SetSurfaceId(onscreen_id_); + } + if (child_one_id_.is_null() || child_two_id_.is_null()) return; - int bounced_offset = offset; - if (offset > 200) - bounced_offset = 400 - offset; embedder_->ProduceFrame( - child_one_id_, child_two_id_, child_size_, size_, bounced_offset); + child_one_id_, child_two_id_, child_size_, size_, rotation_degrees); base::MessageLoop::current()->PostDelayedTask( FROM_HERE, base::Bind( - &SurfacesApp::Draw, base::Unretained(this), (offset + 2) % 400), - base::TimeDelta::FromMilliseconds(50)); + &SurfacesApp::Draw, base::Unretained(this), rotation_degrees + 2.0), + base::TimeDelta::FromMilliseconds(17)); } // SurfaceClient implementation. virtual void SetIdNamespace(uint32_t id_namespace) OVERRIDE { allocator_.reset(new cc::SurfaceIdAllocator(id_namespace)); - CreateSurfaceIfReady(); + Draw(45.0); } virtual void ReturnResources( Array<ReturnedResourcePtr> resources) OVERRIDE { @@ -100,34 +100,11 @@ class SurfacesApp : public ApplicationDelegate, } // NativeViewportClient implementation - virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE { - native_viewport_id_ = native_viewport_id; - CreateSurfaceIfReady(); - } - - // We can't create our GLES2-bound surface until we have our id namespace from - // the surfaces service and our native viewport id from the native viewport - // service. There's no way of knowing which we'll get first, so we just start - // whenever both arrive. - void CreateSurfaceIfReady() { - if (!onscreen_id_.is_null()) - return; - if (native_viewport_id_ == 0) - return; - if (!allocator_) - return; - - onscreen_id_ = allocator_->GenerateId(); - embedder_->SetSurfaceId(onscreen_id_); - CommandBufferPtr cb; - gpu_service_->CreateOnscreenGLES2Context( - native_viewport_id_, Size::From(size_), Get(&cb)); - surfaces_->CreateGLES2BoundSurface( - cb.Pass(), SurfaceId::From(onscreen_id_), Size::From(size_)); - Draw(10); - } + virtual void OnCreated() OVERRIDE {} virtual void OnBoundsChanged(mojo::RectPtr bounds) OVERRIDE {} - virtual void OnDestroyed() OVERRIDE {} + virtual void OnDestroyed(const mojo::Callback<void()>& callback) OVERRIDE { + callback.Run(); + } virtual void OnEvent(mojo::EventPtr event, const mojo::Callback<void()>& callback) OVERRIDE { callback.Run(); @@ -136,7 +113,6 @@ class SurfacesApp : public ApplicationDelegate, private: SurfacePtr surfaces_; cc::SurfaceId onscreen_id_; - uint64_t native_viewport_id_; scoped_ptr<cc::SurfaceIdAllocator> allocator_; scoped_ptr<Embedder> embedder_; ChildPtr child_one_; @@ -147,7 +123,6 @@ class SurfacesApp : public ApplicationDelegate, gfx::Size child_size_; NativeViewportPtr viewport_; - GpuPtr gpu_service_; DISALLOW_COPY_AND_ASSIGN(SurfacesApp); }; diff --git a/mojo/gles2/command_buffer_client_impl.cc b/mojo/gles2/command_buffer_client_impl.cc index 233573f..84c67ab 100644 --- a/mojo/gles2/command_buffer_client_impl.cc +++ b/mojo/gles2/command_buffer_client_impl.cc @@ -208,14 +208,14 @@ void CommandBufferClientImpl::DestroyGpuMemoryBuffer(int32 id) { } uint32 CommandBufferClientImpl::InsertSyncPoint() { - // TODO(jamesr): Optimize this. - WaitForGetOffsetInRange(last_put_offset_, last_put_offset_); + // TODO(piman) + NOTIMPLEMENTED(); return 0; } uint32 CommandBufferClientImpl::InsertFutureSyncPoint() { - // TODO(jamesr): Optimize this. - WaitForGetOffsetInRange(last_put_offset_, last_put_offset_); + // TODO(piman) + NOTIMPLEMENTED(); return 0; } diff --git a/mojo/gles2/gles2_impl.cc b/mojo/gles2/gles2_impl.cc index 8cfcff1..3d46ecd 100644 --- a/mojo/gles2/gles2_impl.cc +++ b/mojo/gles2/gles2_impl.cc @@ -9,7 +9,6 @@ #include "gpu/GLES2/gl2extchromium.h" #include "gpu/command_buffer/client/gles2_interface.h" #include "mojo/gles2/gles2_context.h" -#include "mojo/gles2/gles2_impl_export.h" using mojo::gles2::GLES2Context; diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp index 5544e96..69678c5 100644 --- a/mojo/mojo.gyp +++ b/mojo/mojo.gyp @@ -49,7 +49,6 @@ 'mojo_surfaces_app', 'mojo_surfaces_app', 'mojo_surfaces_child_app', - 'mojo_surfaces_child_gl_app', 'mojo_surfaces_lib', 'mojo_surfaces_lib_unittests', 'mojo_surfaces_service', diff --git a/mojo/mojo_examples.gypi b/mojo/mojo_examples.gypi index d618683..81b0a4f 100644 --- a/mojo/mojo_examples.gypi +++ b/mojo/mojo_examples.gypi @@ -76,7 +76,6 @@ 'mojo_base.gyp:mojo_environment_standalone', 'mojo_base.gyp:mojo_utility', 'mojo_geometry_bindings', - 'mojo_gpu_bindings', 'mojo_native_viewport_bindings', '<(mojo_gles2_for_loadable_module)', '<(mojo_system_for_loadable_module)', @@ -171,7 +170,6 @@ 'mojo_cc_support', 'mojo_geometry_bindings', 'mojo_geometry_lib', - 'mojo_gpu_bindings', 'mojo_native_viewport_bindings', '<(mojo_gles2_for_loadable_module)', '<(mojo_system_for_loadable_module)', @@ -279,7 +277,6 @@ 'mojo_base.gyp:mojo_common_lib', 'mojo_base.gyp:mojo_environment_chromium', 'mojo_geometry_bindings', - 'mojo_gpu_bindings', 'mojo_native_viewport_bindings', '<(mojo_gles2_for_loadable_module)', '<(mojo_system_for_loadable_module)', @@ -377,7 +374,6 @@ 'mojo_base.gyp:mojo_environment_chromium', 'mojo_geometry_bindings', 'mojo_geometry_lib', - 'mojo_gpu_bindings', 'mojo_native_viewport_bindings', 'mojo_surfaces_bindings', 'mojo_surfaces_app_bindings', @@ -445,39 +441,6 @@ 'public/cpp/application/lib/mojo_main_chromium.cc', ], }, - { - 'target_name': 'mojo_surfaces_child_gl_app', - 'type': 'loadable_module', - 'dependencies': [ - '../base/base.gyp:base', - '../cc/cc.gyp:cc', - '../cc/cc.gyp:cc_surfaces', - '../skia/skia.gyp:skia', - '../ui/gfx/gfx.gyp:gfx', - '../ui/gfx/gfx.gyp:gfx_geometry', - 'mojo_base.gyp:mojo_application_chromium', - 'mojo_base.gyp:mojo_common_lib', - 'mojo_base.gyp:mojo_environment_chromium', - 'mojo_geometry_bindings', - 'mojo_geometry_lib', - 'mojo_gpu_bindings', - 'mojo_surfaces_app_bindings', - 'mojo_surfaces_bindings', - 'mojo_surfaces_lib', - '<(mojo_gles2_for_loadable_module)', - '<(mojo_system_for_loadable_module)', - ], - 'sources': [ - 'examples/surfaces_app/child_gl_app.cc', - 'examples/surfaces_app/child_gl_impl.cc', - 'examples/surfaces_app/child_gl_impl.h', - 'examples/surfaces_app/surfaces_util.cc', - 'examples/surfaces_app/surfaces_util.h', - 'examples/sample_app/spinning_cube.cc', - 'examples/sample_app/spinning_cube.h', - 'public/cpp/application/lib/mojo_main_chromium.cc', - ], - } ], 'conditions': [ ['use_aura==1', { diff --git a/mojo/mojo_services.gypi b/mojo/mojo_services.gypi index c11005a..9064ad9 100644 --- a/mojo/mojo_services.gypi +++ b/mojo/mojo_services.gypi @@ -218,23 +218,6 @@ ], }, { - # GN version: //mojo/services/public/interfaces/gpu - 'target_name': 'mojo_gpu_bindings', - 'type': 'static_library', - 'sources': [ - 'services/public/interfaces/gpu/gpu.mojom', - ], - 'includes': [ 'public/tools/bindings/mojom_bindings_generator.gypi' ], - 'export_dependent_settings': [ - 'mojo_base.gyp:mojo_cpp_bindings', - ], - 'dependencies': [ - 'mojo_base.gyp:mojo_cpp_bindings', - 'mojo_base.gyp:mojo_gles2_bindings', - 'mojo_geometry_bindings', - ], - }, - { # GN version: //mojo/services/public/interfaces/native_viewport 'target_name': 'mojo_native_viewport_bindings', 'type': 'static_library', @@ -263,19 +246,16 @@ '../ui/events/events.gyp:events', '../ui/gfx/gfx.gyp:gfx', '../ui/gfx/gfx.gyp:gfx_geometry', - 'mojo_base.gyp:mojo_application_chromium', 'mojo_base.gyp:mojo_common_lib', 'mojo_base.gyp:mojo_environment_chromium', + 'mojo_base.gyp:mojo_application_chromium', 'mojo_geometry_bindings', 'mojo_geometry_lib', 'mojo_gles2_service', - 'mojo_gpu_bindings', 'mojo_input_events_lib', 'mojo_native_viewport_bindings', ], 'sources': [ - 'services/native_viewport/gpu_impl.cc', - 'services/native_viewport/gpu_impl.h', 'services/native_viewport/native_viewport_impl.cc', 'services/native_viewport/native_viewport_impl.h', 'services/native_viewport/platform_viewport.h', @@ -416,7 +396,6 @@ 'mojo_cc_support', 'mojo_geometry_bindings', 'mojo_geometry_lib', - 'mojo_gpu_bindings', 'mojo_surfaces_bindings', 'mojo_surfaces_lib', '<(mojo_gles2_for_loadable_module)', @@ -691,7 +670,6 @@ 'mojo_native_viewport_bindings', 'mojo_view_manager_bindings', 'mojo_view_manager_common', - 'mojo_gpu_bindings', '<(mojo_gles2_for_component)', '<(mojo_system_for_component)', ], diff --git a/mojo/services/gles2/command_buffer_impl.cc b/mojo/services/gles2/command_buffer_impl.cc index 1c25887..d3b9137 100644 --- a/mojo/services/gles2/command_buffer_impl.cc +++ b/mojo/services/gles2/command_buffer_impl.cc @@ -45,25 +45,9 @@ class MemoryTrackerStub : public gpu::gles2::MemoryTracker { } // anonymous namespace -CommandBufferImpl::CommandBufferImpl( - gfx::GLShareGroup* share_group, - gpu::gles2::MailboxManager* mailbox_manager) - : widget_(gfx::kNullAcceleratedWidget), - size_(1, 1), - share_group_(share_group), - mailbox_manager_(mailbox_manager) { -} - -CommandBufferImpl::CommandBufferImpl( - gfx::AcceleratedWidget widget, - const gfx::Size& size, - gfx::GLShareGroup* share_group, - gpu::gles2::MailboxManager* mailbox_manager) - : widget_(widget), - size_(size), - share_group_(share_group), - mailbox_manager_(mailbox_manager) { -} +CommandBufferImpl::CommandBufferImpl(gfx::AcceleratedWidget widget, + const gfx::Size& size) + : widget_(widget), size_(size) {} CommandBufferImpl::~CommandBufferImpl() { client()->DidDestroy(); @@ -82,26 +66,24 @@ void CommandBufferImpl::Initialize( bool CommandBufferImpl::DoInitialize( mojo::ScopedSharedBufferHandle shared_state) { - if (widget_ == gfx::kNullAcceleratedWidget) - surface_ = gfx::GLSurface::CreateOffscreenGLSurface(size_); - else - surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); + // TODO(piman): offscreen surface. + surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); if (!surface_.get()) return false; - // TODO(piman): virtual contexts, gpu preference. - context_ = gfx::GLContext::CreateGLContext( - share_group_, surface_.get(), gfx::PreferIntegratedGpu); - if (!context_.get()) + // TODO(piman): context sharing, virtual contexts, gpu preference. + scoped_refptr<gfx::GLContext> context = gfx::GLContext::CreateGLContext( + NULL, surface_.get(), gfx::PreferIntegratedGpu); + if (!context.get()) return false; - if (!context_->MakeCurrent(surface_.get())) + if (!context->MakeCurrent(surface_.get())) return false; // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but // only needs to be per-thread. scoped_refptr<gpu::gles2::ContextGroup> context_group = - new gpu::gles2::ContextGroup(mailbox_manager_, + new gpu::gles2::ContextGroup(NULL, new MemoryTrackerStub, new gpu::gles2::ShaderTranslatorCache, NULL, @@ -124,7 +106,7 @@ bool CommandBufferImpl::DoInitialize( // TODO(piman): attributes. std::vector<int32> attrib_vector; if (!decoder_->Initialize(surface_, - context_, + context, false /* offscreen */, size_, disallowed_features, @@ -155,11 +137,6 @@ void CommandBufferImpl::SetGetBuffer(int32_t buffer) { } void CommandBufferImpl::Flush(int32_t put_offset) { - if (!context_->MakeCurrent(surface_.get())) { - DLOG(WARNING) << "Context lost"; - client()->LostContext(gpu::error::kUnknown); - return; - } command_buffer_->Flush(put_offset); } diff --git a/mojo/services/gles2/command_buffer_impl.h b/mojo/services/gles2/command_buffer_impl.h index d6b5bd8..fc90d34 100644 --- a/mojo/services/gles2/command_buffer_impl.h +++ b/mojo/services/gles2/command_buffer_impl.h @@ -18,13 +18,10 @@ class GpuScheduler; class GpuControlService; namespace gles2 { class GLES2Decoder; -class MailboxManager; } } namespace gfx { -class GLContext; -class GLShareGroup; class GLSurface; } @@ -32,14 +29,8 @@ namespace mojo { class CommandBufferImpl : public InterfaceImpl<CommandBuffer> { public: - // Offscreen. - CommandBufferImpl(gfx::GLShareGroup* share_group, - gpu::gles2::MailboxManager* mailbox_manager); - // Onscreen. CommandBufferImpl(gfx::AcceleratedWidget widget, - const gfx::Size& size, - gfx::GLShareGroup* share_group, - gpu::gles2::MailboxManager* mailbox_manager); + const gfx::Size& size); virtual ~CommandBufferImpl(); virtual void Initialize(CommandBufferSyncClientPtr sync_client, @@ -68,10 +59,7 @@ class CommandBufferImpl : public InterfaceImpl<CommandBuffer> { scoped_ptr<gpu::CommandBufferService> command_buffer_; scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; scoped_ptr<gpu::GpuScheduler> scheduler_; - scoped_refptr<gfx::GLContext> context_; scoped_refptr<gfx::GLSurface> surface_; - scoped_refptr<gfx::GLShareGroup> share_group_; - scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); }; diff --git a/mojo/services/native_viewport/BUILD.gn b/mojo/services/native_viewport/BUILD.gn index cbadba3c..b1089d1 100644 --- a/mojo/services/native_viewport/BUILD.gn +++ b/mojo/services/native_viewport/BUILD.gn @@ -24,8 +24,6 @@ static_library("native_viewport") { ] sources = [ - "gpu_impl.cc", - "gpu_impl.h", "native_viewport_impl.cc", "native_viewport_impl.h", "platform_viewport.h", diff --git a/mojo/services/native_viewport/DEPS b/mojo/services/native_viewport/DEPS index ffbe51c..29ee0b7 100644 --- a/mojo/services/native_viewport/DEPS +++ b/mojo/services/native_viewport/DEPS @@ -1,14 +1,10 @@ include_rules = [ - "+gpu/command_buffer/service/mailbox_manager.h", "+mojo/services/public/cpp/geometry", "+mojo/services/public/cpp/input_events", - "+mojo/services/public/interfaces/gpu", "+mojo/services/public/interfaces/native_viewport", - "+mojo/services/public/interfaces/geometry", "+mojo/services/gles2", "+ui/events", "+ui/gfx", - "+ui/gl", "+ui/ozone/public", "+ui/platform_window", ] diff --git a/mojo/services/native_viewport/gpu_impl.cc b/mojo/services/native_viewport/gpu_impl.cc deleted file mode 100644 index 18d498f..0000000 --- a/mojo/services/native_viewport/gpu_impl.cc +++ /dev/null @@ -1,42 +0,0 @@ -// 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/native_viewport/gpu_impl.h" - -#include "gpu/command_buffer/service/mailbox_manager.h" -#include "mojo/services/gles2/command_buffer_impl.h" -#include "mojo/services/public/cpp/geometry/geometry_type_converters.h" -#include "ui/gl/gl_share_group.h" - -namespace mojo { - -GpuImpl::GpuImpl( - const scoped_refptr<gfx::GLShareGroup>& share_group, - const scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager) - : share_group_(share_group), mailbox_manager_(mailbox_manager) { -} - -GpuImpl::~GpuImpl() { -} - -void GpuImpl::CreateOnscreenGLES2Context( - uint64_t native_viewport_id, - SizePtr size, - InterfaceRequest<CommandBuffer> command_buffer_request) { - BindToRequest(new CommandBufferImpl(reinterpret_cast<gfx::AcceleratedWidget>( - native_viewport_id), - size.To<gfx::Size>(), - share_group_.get(), - mailbox_manager_.get()), - &command_buffer_request); -} - -void GpuImpl::CreateOffscreenGLES2Context( - InterfaceRequest<CommandBuffer> command_buffer_request) { - BindToRequest( - new CommandBufferImpl(share_group_.get(), mailbox_manager_.get()), - &command_buffer_request); -} - -} // namespace mojo diff --git a/mojo/services/native_viewport/gpu_impl.h b/mojo/services/native_viewport/gpu_impl.h deleted file mode 100644 index 5068061..0000000 --- a/mojo/services/native_viewport/gpu_impl.h +++ /dev/null @@ -1,49 +0,0 @@ -// 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 "base/macros.h" -#include "base/memory/ref_counted.h" -#include "mojo/public/cpp/bindings/interface_impl.h" -#include "mojo/public/cpp/bindings/interface_request.h" -#include "mojo/services/gles2/command_buffer.mojom.h" -#include "mojo/services/public/interfaces/geometry/geometry.mojom.h" -#include "mojo/services/public/interfaces/gpu/gpu.mojom.h" - -namespace gfx { -class GLShareGroup; -} - -namespace gpu { -namespace gles2 { -class MailboxManager; -} -} - -namespace mojo { - -class GpuImpl : public InterfaceImpl<Gpu> { - public: - GpuImpl(const scoped_refptr<gfx::GLShareGroup>& share_group, - const scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager); - - virtual ~GpuImpl(); - - virtual void CreateOnscreenGLES2Context( - uint64_t native_viewport_id, - SizePtr size, - InterfaceRequest<CommandBuffer> command_buffer_request) OVERRIDE; - - virtual void CreateOffscreenGLES2Context( - InterfaceRequest<CommandBuffer> command_buffer_request) OVERRIDE; - - private: - // We need to share these across all NativeViewport instances so that contexts - // they create can share resources with each other via mailboxes. - scoped_refptr<gfx::GLShareGroup> share_group_; - scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; - - DISALLOW_COPY_AND_ASSIGN(GpuImpl); -}; - -} // namespace mojo diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc index e662a6d..8755dfd 100644 --- a/mojo/services/native_viewport/native_viewport_impl.cc +++ b/mojo/services/native_viewport/native_viewport_impl.cc @@ -4,7 +4,6 @@ #include "mojo/services/native_viewport/native_viewport_impl.h" -#include "base/bind.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/time/time.h" @@ -39,6 +38,7 @@ NativeViewportImpl::~NativeViewportImpl() { void NativeViewportImpl::Create(RectPtr bounds) { platform_viewport_ = PlatformViewport::Create(this); platform_viewport_->Init(bounds.To<gfx::Rect>()); + client()->OnCreated(); OnBoundsChanged(bounds.To<gfx::Rect>()); } @@ -51,6 +51,7 @@ void NativeViewportImpl::Hide() { } void NativeViewportImpl::Close() { + command_buffer_.reset(); DCHECK(platform_viewport_); platform_viewport_->Close(); } @@ -59,14 +60,25 @@ void NativeViewportImpl::SetBounds(RectPtr bounds) { platform_viewport_->SetBounds(bounds.To<gfx::Rect>()); } +void NativeViewportImpl::CreateGLES2Context( + InterfaceRequest<CommandBuffer> command_buffer_request) { + if (command_buffer_ || command_buffer_request_.is_pending()) { + LOG(ERROR) << "Can't create multiple contexts on a NativeViewport"; + return; + } + command_buffer_request_ = command_buffer_request.Pass(); + CreateCommandBufferIfNeeded(); +} + void NativeViewportImpl::OnBoundsChanged(const gfx::Rect& bounds) { + CreateCommandBufferIfNeeded(); client()->OnBoundsChanged(Rect::From(bounds)); } void NativeViewportImpl::OnAcceleratedWidgetAvailable( gfx::AcceleratedWidget widget) { widget_ = widget; - client()->OnCreated(reinterpret_cast<uint64_t>(widget)); + CreateCommandBufferIfNeeded(); } bool NativeViewportImpl::OnEvent(ui::Event* ui_event) { @@ -96,12 +108,31 @@ bool NativeViewportImpl::OnEvent(ui::Event* ui_event) { } void NativeViewportImpl::OnDestroyed() { - client()->OnDestroyed(); + client()->OnDestroyed(base::Bind(&NativeViewportImpl::AckDestroyed, + base::Unretained(this))); } void NativeViewportImpl::AckEvent() { waiting_for_event_ack_ = false; } +void NativeViewportImpl::CreateCommandBufferIfNeeded() { + if (!command_buffer_request_.is_pending()) + return; + DCHECK(!command_buffer_.get()); + if (widget_ == gfx::kNullAcceleratedWidget) + return; + gfx::Size size = platform_viewport_->GetSize(); + if (size.IsEmpty()) + return; + command_buffer_.reset( + new CommandBufferImpl(widget_, platform_viewport_->GetSize())); + WeakBindToRequest(command_buffer_.get(), &command_buffer_request_); +} + +void NativeViewportImpl::AckDestroyed() { + command_buffer_.reset(); +} + } // namespace mojo diff --git a/mojo/services/native_viewport/native_viewport_impl.h b/mojo/services/native_viewport/native_viewport_impl.h index b57c36a..5d26da5 100644 --- a/mojo/services/native_viewport/native_viewport_impl.h +++ b/mojo/services/native_viewport/native_viewport_impl.h @@ -6,6 +6,7 @@ #define MOJO_SERVICES_NATIVE_VIEWPORT_IMPL_H_ #include "base/memory/weak_ptr.h" +#include "mojo/services/gles2/command_buffer_impl.h" #include "mojo/services/native_viewport/platform_viewport.h" #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h" @@ -27,6 +28,8 @@ class NativeViewportImpl : public InterfaceImpl<NativeViewport>, virtual void Hide() OVERRIDE; virtual void Close() OVERRIDE; virtual void SetBounds(RectPtr bounds) OVERRIDE; + virtual void CreateGLES2Context( + InterfaceRequest<CommandBuffer> command_buffer_request) OVERRIDE; // PlatformViewport::Delegate implementation. virtual void OnBoundsChanged(const gfx::Rect& bounds) OVERRIDE; @@ -36,11 +39,15 @@ class NativeViewportImpl : public InterfaceImpl<NativeViewport>, virtual void OnDestroyed() OVERRIDE; void AckEvent(); + void CreateCommandBufferIfNeeded(); private: + void AckDestroyed(); gfx::AcceleratedWidget widget_; scoped_ptr<PlatformViewport> platform_viewport_; + InterfaceRequest<CommandBuffer> command_buffer_request_; + scoped_ptr<CommandBufferImpl> command_buffer_; bool waiting_for_event_ack_; base::WeakPtrFactory<NativeViewportImpl> weak_factory_; }; diff --git a/mojo/services/public/interfaces/gpu/BUILD.gn b/mojo/services/public/interfaces/gpu/BUILD.gn deleted file mode 100644 index feb4b18..0000000 --- a/mojo/services/public/interfaces/gpu/BUILD.gn +++ /dev/null @@ -1,17 +0,0 @@ -# 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/public/tools/bindings/mojom.gni") - -# GYP version: mojo/mojo_services.gypi:mojo_gpu_bindings -mojom("gpu") { - sources = [ - "gpu.mojom", - ] - - deps = [ - "//mojo/services/gles2:bindings", - "//mojo/services/public/interfaces/geometry", - ] -} diff --git a/mojo/services/public/interfaces/gpu/gpu.mojom b/mojo/services/public/interfaces/gpu/gpu.mojom deleted file mode 100644 index d6629cd..0000000 --- a/mojo/services/public/interfaces/gpu/gpu.mojom +++ /dev/null @@ -1,15 +0,0 @@ -// 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/gles2/command_buffer.mojom" -import "mojo/services/public/interfaces/geometry/geometry.mojom" - -module mojo { - -interface Gpu { - CreateOnscreenGLES2Context(uint64 native_viewport_id, Size size, CommandBuffer& gles2_client); - CreateOffscreenGLES2Context(CommandBuffer& gles2_client); -}; - -} diff --git a/mojo/services/public/interfaces/native_viewport/BUILD.gn b/mojo/services/public/interfaces/native_viewport/BUILD.gn index 4af1751..1dfecae 100644 --- a/mojo/services/public/interfaces/native_viewport/BUILD.gn +++ b/mojo/services/public/interfaces/native_viewport/BUILD.gn @@ -13,7 +13,6 @@ mojom("native_viewport") { deps = [ "//mojo/services/gles2:bindings", "//mojo/services/public/interfaces/geometry", - "//mojo/services/public/interfaces/gpu", "//mojo/services/public/interfaces/input_events", ] } diff --git a/mojo/services/public/interfaces/native_viewport/native_viewport.mojom b/mojo/services/public/interfaces/native_viewport/native_viewport.mojom index c1a9742..b168104 100644 --- a/mojo/services/public/interfaces/native_viewport/native_viewport.mojom +++ b/mojo/services/public/interfaces/native_viewport/native_viewport.mojom @@ -15,12 +15,13 @@ interface NativeViewport { Hide(); Close(); SetBounds(Rect bounds); + CreateGLES2Context(CommandBuffer& gles2_client); }; interface NativeViewportClient { - OnCreated(uint64 native_viewport_id); + OnCreated(); OnBoundsChanged(Rect bounds); - OnDestroyed(); + OnDestroyed() => (); OnEvent(Event event) => (); }; diff --git a/mojo/services/surfaces/surfaces_impl.cc b/mojo/services/surfaces/surfaces_impl.cc index 7f24a0f..5d33d49 100644 --- a/mojo/services/surfaces/surfaces_impl.cc +++ b/mojo/services/surfaces/surfaces_impl.cc @@ -44,9 +44,7 @@ void SurfacesImpl::SubmitFrame(SurfaceIdPtr id, FramePtr frame_ptr) { cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { // Bad message, do something bad to the caller? - LOG(FATAL) << "Received frame for id " << cc_id.id << " namespace " - << cc::SurfaceIdAllocator::NamespaceForId(cc_id) - << " should be namespace " << id_namespace_; + NOTREACHED(); return; } factory_.SubmitFrame(id.To<cc::SurfaceId>(), mojo::ConvertTo(frame_ptr)); @@ -71,9 +69,7 @@ void SurfacesImpl::CreateGLES2BoundSurface(CommandBufferPtr gles2_client, cc::SurfaceId cc_id = id.To<cc::SurfaceId>(); if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) { // Bad message, do something bad to the caller? - LOG(FATAL) << "Received request for id " << cc_id.id << " namespace " - << cc::SurfaceIdAllocator::NamespaceForId(cc_id) - << " should be namespace " << id_namespace_; + NOTREACHED(); return; } if (!display_) { diff --git a/mojo/services/view_manager/DEPS b/mojo/services/view_manager/DEPS index d6658e5..5933b40 100644 --- a/mojo/services/view_manager/DEPS +++ b/mojo/services/view_manager/DEPS @@ -1,6 +1,5 @@ include_rules = [ "+cc", - "+gpu/command_buffer/service/mailbox_manager.h", "+mojo/aura", "+mojo/cc", "+mojo/geometry", diff --git a/mojo/services/view_manager/root_view_manager.cc b/mojo/services/view_manager/root_view_manager.cc index 2b73375..d44535d 100644 --- a/mojo/services/view_manager/root_view_manager.cc +++ b/mojo/services/view_manager/root_view_manager.cc @@ -7,7 +7,6 @@ #include "base/auto_reset.h" #include "base/scoped_observer.h" #include "mojo/public/cpp/application/application_connection.h" -#include "mojo/services/public/interfaces/gpu/gpu.mojom.h" #include "mojo/services/view_manager/root_node_manager.h" #include "mojo/services/view_manager/root_view_manager_delegate.h" #include "mojo/services/view_manager/screen_impl.h" @@ -82,18 +81,14 @@ RootViewManager::RootViewManager( NativeViewportPtr viewport; app_connection->ConnectToService( "mojo:mojo_native_viewport_service", &viewport); - GpuPtr gpu_service; - // TODO(jamesr): Should be mojo:mojo_gpu_service - app_connection->ConnectToService("mojo:mojo_native_viewport_service", - &gpu_service); window_tree_host_.reset(new WindowTreeHostImpl( - viewport.Pass(), - gpu_service.Pass(), - gfx::Rect(800, 600), - base::Bind(&RootViewManager::OnCompositorCreated, base::Unretained(this)), - native_viewport_closed_callback, - base::Bind(&RootNodeManager::DispatchNodeInputEventToWindowManager, - base::Unretained(root_node_manager_)))); + viewport.Pass(), + gfx::Rect(800, 600), + base::Bind(&RootViewManager::OnCompositorCreated, + base::Unretained(this)), + native_viewport_closed_callback, + base::Bind(&RootNodeManager::DispatchNodeInputEventToWindowManager, + base::Unretained(root_node_manager_)))); } RootViewManager::~RootViewManager() { diff --git a/mojo/services/view_manager/window_tree_host_impl.cc b/mojo/services/view_manager/window_tree_host_impl.cc index 267bdca..9f201b0 100644 --- a/mojo/services/view_manager/window_tree_host_impl.cc +++ b/mojo/services/view_manager/window_tree_host_impl.cc @@ -67,21 +67,29 @@ void RootLayoutManager::SetChildBounds(aura::Window* child, WindowTreeHostImpl::WindowTreeHostImpl( NativeViewportPtr viewport, - GpuPtr gpu_service, const gfx::Rect& bounds, const Callback<void()>& compositor_created_callback, const Callback<void()>& native_viewport_closed_callback, const Callback<void(EventPtr)>& event_received_callback) : native_viewport_(viewport.Pass()), - gpu_service_(gpu_service.Pass()), - widget_(gfx::kNullAcceleratedWidget), compositor_created_callback_(compositor_created_callback), native_viewport_closed_callback_(native_viewport_closed_callback), event_received_callback_(event_received_callback), bounds_(bounds) { native_viewport_.set_client(this); native_viewport_->Create(Rect::From(bounds)); - native_viewport_->Show(); + + MessagePipe pipe; + native_viewport_->CreateGLES2Context( + MakeRequest<CommandBuffer>(pipe.handle0.Pass())); + + // The ContextFactory must exist before any Compositors are created. + if (context_factory_) { + delete context_factory_; + context_factory_ = NULL; + } + context_factory_ = new ContextFactoryImpl(pipe.handle1.Pass()); + aura::Env::GetInstance()->set_context_factory(context_factory_); window()->SetLayoutManager(new RootLayoutManager()); } @@ -99,11 +107,13 @@ ui::EventSource* WindowTreeHostImpl::GetEventSource() { } gfx::AcceleratedWidget WindowTreeHostImpl::GetAcceleratedWidget() { - return widget_; + NOTIMPLEMENTED() << "GetAcceleratedWidget"; + return gfx::kNullAcceleratedWidget; } void WindowTreeHostImpl::Show() { window()->Show(); + native_viewport_->Show(); } void WindowTreeHostImpl::Hide() { @@ -158,35 +168,21 @@ ui::EventProcessor* WindowTreeHostImpl::GetEventProcessor() { //////////////////////////////////////////////////////////////////////////////// // WindowTreeHostImpl, NativeViewportClient implementation: -void WindowTreeHostImpl::OnCreated(uint64_t native_viewport_id) { - LOG(ERROR) << "OnCreated " << native_viewport_id; - CommandBufferPtr cb; - gpu_service_->CreateOnscreenGLES2Context( - native_viewport_id, Size::From(bounds_.size()), Get(&cb)); - widget_ = reinterpret_cast<gfx::AcceleratedWidget>(native_viewport_id); - - // The ContextFactory must exist before any Compositors are created. - if (context_factory_) { - delete context_factory_; - context_factory_ = NULL; - } - context_factory_ = new ContextFactoryImpl(cb.PassMessagePipe()); - aura::Env::GetInstance()->set_context_factory(context_factory_); - - CreateCompositor(gfx::kNullAcceleratedWidget); +void WindowTreeHostImpl::OnCreated() { + CreateCompositor(GetAcceleratedWidget()); compositor_created_callback_.Run(); } void WindowTreeHostImpl::OnBoundsChanged(RectPtr bounds) { bounds_ = bounds.To<gfx::Rect>(); - if (context_factory_) - OnHostResized(bounds_.size()); + OnHostResized(bounds_.size()); } -void WindowTreeHostImpl::OnDestroyed() { +void WindowTreeHostImpl::OnDestroyed(const mojo::Callback<void()>& callback) { DestroyCompositor(); native_viewport_closed_callback_.Run(); // TODO(beng): quit the message loop once we are on our own thread. + callback.Run(); } void WindowTreeHostImpl::OnEvent(EventPtr event, diff --git a/mojo/services/view_manager/window_tree_host_impl.h b/mojo/services/view_manager/window_tree_host_impl.h index b222d68..877b818 100644 --- a/mojo/services/view_manager/window_tree_host_impl.h +++ b/mojo/services/view_manager/window_tree_host_impl.h @@ -6,7 +6,6 @@ #define MOJO_AURA_WINDOW_TREE_HOST_MOJO_H_ #include "base/bind.h" -#include "mojo/services/public/interfaces/gpu/gpu.mojom.h" #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom.h" #include "ui/aura/window_tree_host.h" #include "ui/events/event_source.h" @@ -25,12 +24,12 @@ class WindowTreeHostImpl : public aura::WindowTreeHost, public ui::EventSource, public NativeViewportClient { public: - WindowTreeHostImpl(NativeViewportPtr viewport, - GpuPtr gpu_service, - const gfx::Rect& bounds, - const Callback<void()>& compositor_created_callback, - const Callback<void()>& native_viewport_closed_callback, - const Callback<void(EventPtr)>& event_received_callback); + WindowTreeHostImpl( + NativeViewportPtr viewport, + const gfx::Rect& bounds, + const Callback<void()>& compositor_created_callback, + const Callback<void()>& native_viewport_closed_callback, + const Callback<void(EventPtr)>& event_received_callback); virtual ~WindowTreeHostImpl(); gfx::Rect bounds() const { return bounds_; } @@ -55,8 +54,8 @@ class WindowTreeHostImpl : public aura::WindowTreeHost, virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; // Overridden from NativeViewportClient: - virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE; - virtual void OnDestroyed() OVERRIDE; + virtual void OnCreated() OVERRIDE; + virtual void OnDestroyed(const mojo::Callback<void()>& callback) OVERRIDE; virtual void OnBoundsChanged(RectPtr bounds) OVERRIDE; virtual void OnEvent(EventPtr event, const mojo::Callback<void()>& callback) OVERRIDE; @@ -64,8 +63,6 @@ class WindowTreeHostImpl : public aura::WindowTreeHost, static ContextFactoryImpl* context_factory_; NativeViewportPtr native_viewport_; - GpuPtr gpu_service_; - gfx::AcceleratedWidget widget_; Callback<void()> compositor_created_callback_; Callback<void()> native_viewport_closed_callback_; Callback<void(EventPtr)> event_received_callback_; diff --git a/mojo/shell/DEPS b/mojo/shell/DEPS index d5f92c5..7b96bb6 100644 --- a/mojo/shell/DEPS +++ b/mojo/shell/DEPS @@ -1,6 +1,5 @@ include_rules = [ "+dbus", - "+gpu", "+mojo/embedder", "+net", "+ui/gl", diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc index 19e97c5..a6585e2 100644 --- a/mojo/shell/context.cc +++ b/mojo/shell/context.cc @@ -11,7 +11,6 @@ #include "base/memory/scoped_vector.h" #include "base/strings/string_split.h" #include "build/build_config.h" -#include "gpu/command_buffer/service/mailbox_manager.h" #include "mojo/application_manager/application_loader.h" #include "mojo/application_manager/application_manager.h" #include "mojo/application_manager/background_shell_application_loader.h" @@ -19,7 +18,6 @@ #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/services/native_viewport/gpu_impl.h" #include "mojo/services/native_viewport/native_viewport_impl.h" #include "mojo/shell/dynamic_application_loader.h" #include "mojo/shell/in_process_dynamic_service_runner.h" @@ -27,7 +25,6 @@ #include "mojo/shell/switches.h" #include "mojo/shell/ui_application_loader_android.h" #include "mojo/spy/spy.h" -#include "ui/gl/gl_share_group.h" #if defined(OS_LINUX) #include "mojo/shell/dbus_application_loader_linux.h" @@ -98,12 +95,9 @@ void InitContentHandlers(DynamicApplicationLoader* loader, class Context::NativeViewportApplicationLoader : public ApplicationLoader, public ApplicationDelegate, - public InterfaceFactory<NativeViewport>, - public InterfaceFactory<Gpu> { + public InterfaceFactory<NativeViewport> { public: - NativeViewportApplicationLoader() - : share_group_(new gfx::GLShareGroup), - mailbox_manager_(new gpu::gles2::MailboxManager) {} + NativeViewportApplicationLoader() {} virtual ~NativeViewportApplicationLoader() {} private: @@ -122,8 +116,7 @@ class Context::NativeViewportApplicationLoader // ApplicationDelegate implementation. virtual bool ConfigureIncomingConnection( mojo::ApplicationConnection* connection) OVERRIDE { - connection->AddService<NativeViewport>(this); - connection->AddService<Gpu>(this); + connection->AddService(this); return true; } @@ -133,15 +126,6 @@ class Context::NativeViewportApplicationLoader BindToRequest(new NativeViewportImpl, &request); } - // InterfaceFactory<Gpu> implementation. - virtual void Create(ApplicationConnection* connection, - InterfaceRequest<Gpu> request) OVERRIDE { - BindToRequest(new GpuImpl(share_group_.get(), mailbox_manager_.get()), - &request); - } - - scoped_refptr<gfx::GLShareGroup> share_group_; - scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; scoped_ptr<ApplicationImpl> app_; DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader); }; |