diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-14 14:20:43 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-14 14:20:43 +0000 |
commit | 9cdd71579d57869f215155a772aa5f15c27df48c (patch) | |
tree | fe0ee59411c779a52485a5bade355c6db92c7846 | |
parent | 7943f0d7b4f0b2866905c64f78d21651caab4a25 (diff) | |
download | chromium_src-9cdd71579d57869f215155a772aa5f15c27df48c.zip chromium_src-9cdd71579d57869f215155a772aa5f15c27df48c.tar.gz chromium_src-9cdd71579d57869f215155a772aa5f15c27df48c.tar.bz2 |
Use ContextProvider subclass to provide WGC3D pointers
Some cc::ContextProvider instances will also need to provide WebGraphicsContext3D*
interfaces to the underlying GL context, but not all. This adds a subclass of ContextProvider
in content:: to use for these users. The compositor itself doesn't need the WGC3D
accessor so it just uses the base class.
BUG=181120
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=244383
Review URL: https://codereview.chromium.org/126093010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244697 0039d316-1c4b-4281-b951-d872f2087c98
17 files changed, 103 insertions, 48 deletions
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc index 5fc68f3..3c86bd5 100644 --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc @@ -12,6 +12,8 @@ #include "webkit/common/gpu/context_provider_in_process.h" #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" +using webkit::gpu::ContextProviderWebContext; + namespace content { namespace { @@ -73,7 +75,7 @@ SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() { return synchronous_input_event_filter(); } -scoped_refptr<cc::ContextProvider> +scoped_refptr<ContextProviderWebContext> SynchronousCompositorFactoryImpl::GetOffscreenContextProviderForMainThread() { // This check only guarantees the main thread context is created after // a compositor did successfully initialize hardware draw in the past. diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.h b/content/browser/android/in_process/synchronous_compositor_factory_impl.h index 40bcbac..1e7987f 100644 --- a/content/browser/android/in_process/synchronous_compositor_factory_impl.h +++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.h @@ -9,6 +9,7 @@ #include "content/browser/android/in_process/synchronous_input_event_filter.h" #include "content/renderer/android/synchronous_compositor_factory.h" #include "content/renderer/media/android/stream_texture_factory_android_synchronous_impl.h" +#include "webkit/common/gpu/context_provider_web_context.h" namespace gpu { class GLInProcessContext; @@ -33,7 +34,7 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory { virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(int routing_id) OVERRIDE; virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE; - virtual scoped_refptr<cc::ContextProvider> + virtual scoped_refptr<webkit::gpu::ContextProviderWebContext> GetOffscreenContextProviderForMainThread() OVERRIDE; // This is called on both renderer main thread (offscreen context creation // path shared between cross-process and in-process platforms) and renderer @@ -66,7 +67,8 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory { // Only guards construction and destruction of // |offscreen_context_for_compositor_thread_|, not usage. base::Lock offscreen_context_for_compositor_thread_lock_; - scoped_refptr<cc::ContextProvider> offscreen_context_for_main_thread_; + scoped_refptr<webkit::gpu::ContextProviderWebContext> + offscreen_context_for_main_thread_; // This is a pointer to the context owned by // |offscreen_context_for_main_thread_|. gpu::GLInProcessContext* wrapped_gl_context_for_main_thread_; diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc index 05de220..f9dfef6 100644 --- a/content/common/gpu/client/context_provider_command_buffer.cc +++ b/content/common/gpu/client/context_provider_command_buffer.cc @@ -87,6 +87,15 @@ int ContextProviderCommandBuffer::GetGPUProcessID() { return context3d_->GetGPUProcessID(); } +WebGraphicsContext3DCommandBufferImpl* +ContextProviderCommandBuffer::WebContext3D() { + DCHECK(context3d_); + DCHECK(lost_context_callback_proxy_); // Is bound to thread. + DCHECK(context_thread_checker_.CalledOnValidThread()); + + return context3d_.get(); +} + bool ContextProviderCommandBuffer::BindToCurrentThread() { // This is called on the thread the context will be used. DCHECK(context_thread_checker_.CalledOnValidThread()); @@ -110,12 +119,8 @@ bool ContextProviderCommandBuffer::BindToCurrentThread() { return true; } -WebGraphicsContext3DCommandBufferImpl* -ContextProviderCommandBuffer::Context3d() { - DCHECK(lost_context_callback_proxy_); // Is bound to thread. - DCHECK(context_thread_checker_.CalledOnValidThread()); - - return context3d_.get(); +blink::WebGraphicsContext3D* ContextProviderCommandBuffer::Context3d() { + return NULL; } gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { diff --git a/content/common/gpu/client/context_provider_command_buffer.h b/content/common/gpu/client/context_provider_command_buffer.h index d61e05c..24a04b1 100644 --- a/content/common/gpu/client/context_provider_command_buffer.h +++ b/content/common/gpu/client/context_provider_command_buffer.h @@ -12,6 +12,7 @@ #include "cc/output/context_provider.h" #include "content/common/content_export.h" #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" +#include "webkit/common/gpu/context_provider_web_context.h" namespace webkit { namespace gpu { @@ -24,7 +25,7 @@ namespace content { // Implementation of cc::ContextProvider that provides a // WebGraphicsContext3DCommandBufferImpl context and a GrContext. class CONTENT_EXPORT ContextProviderCommandBuffer - : NON_EXPORTED_BASE(public cc::ContextProvider) { + : NON_EXPORTED_BASE(public webkit::gpu::ContextProviderWebContext) { public: static scoped_refptr<ContextProviderCommandBuffer> Create( scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, @@ -38,9 +39,12 @@ class CONTENT_EXPORT ContextProviderCommandBuffer leak_on_destroy_ = true; } + // ContextProviderWebContext implementation. + virtual WebGraphicsContext3DCommandBufferImpl* WebContext3D() OVERRIDE; + // cc::ContextProvider implementation. virtual bool BindToCurrentThread() OVERRIDE; - virtual WebGraphicsContext3DCommandBufferImpl* Context3d() OVERRIDE; + virtual blink::WebGraphicsContext3D* Context3d() OVERRIDE; virtual gpu::gles2::GLES2Interface* ContextGL() OVERRIDE; virtual gpu::ContextSupport* ContextSupport() OVERRIDE; virtual class GrContext* GrContext() OVERRIDE; diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index 0a49f24..b7dd3cf02 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -518,6 +518,8 @@ 'renderer/webcrypto/webcrypto_impl_openssl.cc', 'renderer/webcrypto/webcrypto_util.cc', 'renderer/webcrypto/webcrypto_util.h', + 'renderer/webgraphicscontext3d_provider_impl.cc', + 'renderer/webgraphicscontext3d_provider_impl.h', 'renderer/webpublicsuffixlist_impl.cc', 'renderer/webpublicsuffixlist_impl.h', 'renderer/websharedworker_proxy.cc', diff --git a/content/renderer/android/synchronous_compositor_factory.h b/content/renderer/android/synchronous_compositor_factory.h index 77c0500..18a907e 100644 --- a/content/renderer/android/synchronous_compositor_factory.h +++ b/content/renderer/android/synchronous_compositor_factory.h @@ -17,6 +17,12 @@ class ContextProvider; class OutputSurface; } +namespace webkit { +namespace gpu { +class ContextProviderWebContext; +} +} + namespace content { class InputHandlerManagerClient; @@ -41,7 +47,7 @@ class SynchronousCompositorFactory { // The factory maintains ownership of the returned interface. virtual InputHandlerManagerClient* GetInputHandlerManagerClient() = 0; - virtual scoped_refptr<cc::ContextProvider> + virtual scoped_refptr<webkit::gpu::ContextProviderWebContext> GetOffscreenContextProviderForMainThread() = 0; virtual scoped_refptr<cc::ContextProvider> GetOffscreenContextProviderForCompositorThread() = 0; diff --git a/content/renderer/media/renderer_gpu_video_accelerator_factories.cc b/content/renderer/media/renderer_gpu_video_accelerator_factories.cc index 4420352..34c1e2d 100644 --- a/content/renderer/media/renderer_gpu_video_accelerator_factories.cc +++ b/content/renderer/media/renderer_gpu_video_accelerator_factories.cc @@ -58,14 +58,12 @@ RendererGpuVideoAcceleratorFactories::GetContext3d() { DCHECK(task_runner_->BelongsToCurrentThread()); if (!context_provider_) return NULL; - WebGraphicsContext3DCommandBufferImpl* context = - context_provider_->Context3d(); - if (context->isContextLost()) { + if (context_provider_->IsContextLost()) { context_provider_->VerifyContexts(); context_provider_ = NULL; return NULL; } - return context; + return context_provider_->WebContext3D(); } void RendererGpuVideoAcceleratorFactories::AsyncBindContext() { diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 1e6d1d5..5b681189 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -948,7 +948,7 @@ RenderThreadImpl::OffscreenCompositorContextProvider() { return offscreen_compositor_contexts_; } -scoped_refptr<cc::ContextProvider> +scoped_refptr<webkit::gpu::ContextProviderWebContext> RenderThreadImpl::SharedMainThreadContextProvider() { DCHECK(IsMainThread()); #if defined(OS_ANDROID) diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index c9e4142..c16fc65 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h @@ -59,6 +59,7 @@ class Extension; namespace webkit { namespace gpu { +class ContextProviderWebContext; class GrContextForWebGraphicsContext3D; } } @@ -263,7 +264,8 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread, scoped_refptr<RendererGpuVideoAcceleratorFactories> GetGpuFactories(); scoped_refptr<cc::ContextProvider> OffscreenCompositorContextProvider(); - scoped_refptr<cc::ContextProvider> SharedMainThreadContextProvider(); + scoped_refptr<webkit::gpu::ContextProviderWebContext> + SharedMainThreadContextProvider(); // AudioRendererMixerManager instance which manages renderer side mixer // instances shared based on configured audio parameters. Lazily created on diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 47c30fb..14b9722 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -5911,7 +5911,7 @@ WebMediaPlayer* RenderViewImpl::CreateAndroidWebMediaPlayer( SynchronousCompositorFactory::GetInstance(); stream_texture_factory = factory->CreateStreamTextureFactory(routing_id_); } else { - scoped_refptr<cc::ContextProvider> context_provider = + scoped_refptr<webkit::gpu::ContextProviderWebContext> context_provider = RenderThreadImpl::current()->SharedMainThreadContextProvider(); if (!context_provider.get()) { @@ -5920,7 +5920,7 @@ WebMediaPlayer* RenderViewImpl::CreateAndroidWebMediaPlayer( } stream_texture_factory.reset(new StreamTextureFactoryImpl( - context_provider->Context3d(), gpu_channel_host, routing_id_)); + context_provider->WebContext3D(), gpu_channel_host, routing_id_)); } scoped_ptr<WebMediaPlayerAndroid> web_media_player_android( diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc index c7fa271..8644a9c 100644 --- a/content/renderer/renderer_webkitplatformsupport_impl.cc +++ b/content/renderer/renderer_webkitplatformsupport_impl.cc @@ -48,6 +48,7 @@ #include "content/renderer/renderer_clipboard_client.h" #include "content/renderer/webclipboard_impl.h" #include "content/renderer/webcrypto/webcrypto_impl.h" +#include "content/renderer/webgraphicscontext3d_provider_impl.h" #include "content/renderer/webpublicsuffixlist_impl.h" #include "gpu/config/gpu_info.h" #include "ipc/ipc_sync_message_filter.h" @@ -70,7 +71,7 @@ #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" #include "ui/gfx/color_profile.h" #include "url/gurl.h" -#include "webkit/common/gpu/webgraphicscontext3d_provider_impl.h" +#include "webkit/common/gpu/context_provider_web_context.h" #include "webkit/common/quota/quota_types.h" #include "webkit/glue/simple_webmimeregistry_impl.h" #include "webkit/glue/webfileutilities_impl.h" @@ -968,11 +969,11 @@ RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D( blink::WebGraphicsContext3DProvider* RendererWebKitPlatformSupportImpl:: createSharedOffscreenGraphicsContext3DProvider() { - scoped_refptr<cc::ContextProvider> provider = + scoped_refptr<webkit::gpu::ContextProviderWebContext> provider = RenderThreadImpl::current()->SharedMainThreadContextProvider(); if (!provider) return NULL; - return new webkit::gpu::WebGraphicsContext3DProviderImpl(provider); + return new WebGraphicsContext3DProviderImpl(provider); } //------------------------------------------------------------------------------ diff --git a/webkit/common/gpu/webgraphicscontext3d_provider_impl.cc b/content/renderer/webgraphicscontext3d_provider_impl.cc index 5629131..7a31a05 100644 --- a/webkit/common/gpu/webgraphicscontext3d_provider_impl.cc +++ b/content/renderer/webgraphicscontext3d_provider_impl.cc @@ -1,27 +1,25 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// 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 "webkit/common/gpu/webgraphicscontext3d_provider_impl.h" +#include "content/renderer/webgraphicscontext3d_provider_impl.h" -#include "cc/output/context_provider.h" +#include "webkit/common/gpu/context_provider_web_context.h" -namespace webkit { -namespace gpu { +namespace content { WebGraphicsContext3DProviderImpl::WebGraphicsContext3DProviderImpl( - scoped_refptr<cc::ContextProvider> provider) + scoped_refptr<webkit::gpu::ContextProviderWebContext> provider) : provider_(provider) {} WebGraphicsContext3DProviderImpl::~WebGraphicsContext3DProviderImpl() {} blink::WebGraphicsContext3D* WebGraphicsContext3DProviderImpl::context3d() { - return provider_->Context3d(); + return provider_->WebContext3D(); } GrContext* WebGraphicsContext3DProviderImpl::grContext() { return provider_->GrContext(); } -} // namespace gpu -} // namespace webkit +} // namespace content diff --git a/webkit/common/gpu/webgraphicscontext3d_provider_impl.h b/content/renderer/webgraphicscontext3d_provider_impl.h index 794df13..80c2106 100644 --- a/webkit/common/gpu/webgraphicscontext3d_provider_impl.h +++ b/content/renderer/webgraphicscontext3d_provider_impl.h @@ -1,25 +1,28 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// 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 WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ -#define WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ +#ifndef CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ +#define CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" +#include "content/common/content_export.h" #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" -#include "webkit/common/gpu/webkit_gpu_export.h" - -namespace cc { class ContextProvider; } namespace webkit { namespace gpu { +class ContextProviderWebContext; +} // namespace webkit +} // namespace gpu -class WEBKIT_GPU_EXPORT WebGraphicsContext3DProviderImpl +namespace content { + +class CONTENT_EXPORT WebGraphicsContext3DProviderImpl : public NON_EXPORTED_BASE(blink::WebGraphicsContext3DProvider) { public: explicit WebGraphicsContext3DProviderImpl( - scoped_refptr<cc::ContextProvider> provider); + scoped_refptr<webkit::gpu::ContextProviderWebContext> provider); virtual ~WebGraphicsContext3DProviderImpl(); // WebGraphicsContext3DProvider implementation. @@ -27,10 +30,9 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DProviderImpl virtual GrContext* grContext() OVERRIDE; private: - scoped_refptr<cc::ContextProvider> provider_; + scoped_refptr<webkit::gpu::ContextProviderWebContext> provider_; }; -} // namespace gpu -} // namespace webkit +} // namespace content -#endif // WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ +#endif // CONTENT_RENDERER_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_ diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc index ba293ba..70d9d34 100644 --- a/webkit/common/gpu/context_provider_in_process.cc +++ b/webkit/common/gpu/context_provider_in_process.cc @@ -77,6 +77,13 @@ ContextProviderInProcess::~ContextProviderInProcess() { context_thread_checker_.CalledOnValidThread()); } +blink::WebGraphicsContext3D* ContextProviderInProcess::WebContext3D() { + DCHECK(lost_context_callback_proxy_); // Is bound to thread. + DCHECK(context_thread_checker_.CalledOnValidThread()); + + return context3d_.get(); +} + bool ContextProviderInProcess::BindToCurrentThread() { DCHECK(context3d_); diff --git a/webkit/common/gpu/context_provider_in_process.h b/webkit/common/gpu/context_provider_in_process.h index 72098b2..2abc7f3 100644 --- a/webkit/common/gpu/context_provider_in_process.h +++ b/webkit/common/gpu/context_provider_in_process.h @@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/synchronization/lock.h" #include "base/threading/thread_checker.h" -#include "cc/output/context_provider.h" +#include "webkit/common/gpu/context_provider_web_context.h" #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" #include "webkit/common/gpu/webkit_gpu_export.h" @@ -20,7 +20,7 @@ namespace gpu { class GrContextForWebGraphicsContext3D; class WEBKIT_GPU_EXPORT ContextProviderInProcess - : NON_EXPORTED_BASE(public cc::ContextProvider) { + : NON_EXPORTED_BASE(public ContextProviderWebContext) { public: static scoped_refptr<ContextProviderInProcess> Create( scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, @@ -30,6 +30,7 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess // context. static scoped_refptr<ContextProviderInProcess> CreateOffscreen(); + virtual blink::WebGraphicsContext3D* WebContext3D() OVERRIDE; virtual bool BindToCurrentThread() OVERRIDE; virtual Capabilities ContextCapabilities() OVERRIDE; virtual blink::WebGraphicsContext3D* Context3d() OVERRIDE; diff --git a/webkit/common/gpu/context_provider_web_context.h b/webkit/common/gpu/context_provider_web_context.h new file mode 100644 index 0000000..9f04bf9 --- /dev/null +++ b/webkit/common/gpu/context_provider_web_context.h @@ -0,0 +1,26 @@ +// 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 WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_WEB_CONTEXT_H_ +#define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_WEB_CONTEXT_H_ + +#include "cc/output/context_provider.h" + +namespace blink { class WebGraphicsContext3D; } + +namespace webkit { +namespace gpu { + +class ContextProviderWebContext : public cc::ContextProvider { + public: + virtual blink::WebGraphicsContext3D* WebContext3D() = 0; + + protected: + virtual ~ContextProviderWebContext() {} +}; + +} // namespace gpu +} // namespace webkit + +#endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_WEB_CONTEXT_H_ diff --git a/webkit/common/gpu/webkit_gpu.gyp b/webkit/common/gpu/webkit_gpu.gyp index 1ef6b8c..bc2081c 100644 --- a/webkit/common/gpu/webkit_gpu.gyp +++ b/webkit/common/gpu/webkit_gpu.gyp @@ -33,14 +33,13 @@ # This list contains all .h and .cc in gpu except for test code. 'context_provider_in_process.cc', 'context_provider_in_process.h', + 'context_provider_web_context.h', 'grcontext_for_webgraphicscontext3d.cc', 'grcontext_for_webgraphicscontext3d.h', 'test_context_provider_factory.cc', 'test_context_provider_factory.h', 'webgraphicscontext3d_in_process_command_buffer_impl.cc', 'webgraphicscontext3d_in_process_command_buffer_impl.h', - 'webgraphicscontext3d_provider_impl.cc', - 'webgraphicscontext3d_provider_impl.h', ], 'defines': [ 'WEBKIT_GPU_IMPLEMENTATION', |