diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 04:58:13 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 04:58:13 +0000 |
commit | 3a98aed97f290e0660ae4558fa77ee932562705d (patch) | |
tree | cd655db01ee515d0eadbd1161f338c2470771432 /webkit | |
parent | d772b7e3192bd8a5e01ece2ace019649ea51bb1f (diff) | |
download | chromium_src-3a98aed97f290e0660ae4558fa77ee932562705d.zip chromium_src-3a98aed97f290e0660ae4558fa77ee932562705d.tar.gz chromium_src-3a98aed97f290e0660ae4558fa77ee932562705d.tar.bz2 |
Remove base::Callback from ContextProvider creation.
Currently a Callback is given to ContextProvider's creation methods
that is able to create a WebGraphicsContext3D and return it to the
provider. This callback is called synchronously during the create
method, and only one time.
Instead of requiring this indirection through a Callback, we can instead
just pass a WebGraphicsContext3D to the ContextProvider when it is
created, directly.
R=piman, sievers
BUG=258625
Review URL: https://chromiumcodereview.appspot.com/23247002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/common/gpu/context_provider_in_process.cc | 41 | ||||
-rw-r--r-- | webkit/common/gpu/context_provider_in_process.h | 12 |
2 files changed, 17 insertions, 36 deletions
diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc index 9b4352f..b7e3cc4 100644 --- a/webkit/common/gpu/context_provider_in_process.cc +++ b/webkit/common/gpu/context_provider_in_process.cc @@ -78,16 +78,15 @@ class ContextProviderInProcess::MemoryAllocationCallbackProxy // static scoped_refptr<ContextProviderInProcess> ContextProviderInProcess::Create( - const CreateCallback& create_callback) { - scoped_refptr<ContextProviderInProcess> provider = - new ContextProviderInProcess; - if (!provider->InitializeOnMainThread(create_callback)) + scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d) { + if (!context3d) return NULL; - return provider; + return new ContextProviderInProcess(context3d.Pass()); } -static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> -CreateOffscreenContext() { +// static +scoped_refptr<ContextProviderInProcess> +ContextProviderInProcess::CreateOffscreen() { WebKit::WebGraphicsContext3D::Attributes attributes; attributes.depth = false; attributes.stencil = true; @@ -95,19 +94,17 @@ CreateOffscreenContext() { attributes.shareResources = true; attributes.noAutomaticFlushes = true; - return WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( - attributes).Pass(); + return Create( + WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( + attributes)); } -// static -scoped_refptr<ContextProviderInProcess> -ContextProviderInProcess::CreateOffscreen() { - return Create(base::Bind(&CreateOffscreenContext)); -} - -ContextProviderInProcess::ContextProviderInProcess() - : destroyed_(false) { +ContextProviderInProcess::ContextProviderInProcess( + scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d) + : context3d_(context3d.Pass()), + destroyed_(false) { DCHECK(main_thread_checker_.CalledOnValidThread()); + DCHECK(context3d_); context_thread_checker_.DetachFromThread(); } @@ -116,16 +113,6 @@ ContextProviderInProcess::~ContextProviderInProcess() { context_thread_checker_.CalledOnValidThread()); } -bool ContextProviderInProcess::InitializeOnMainThread( - const CreateCallback& create_callback) { - DCHECK(!context3d_); - DCHECK(main_thread_checker_.CalledOnValidThread()); - DCHECK(!create_callback.is_null()); - - context3d_ = create_callback.Run(); - return context3d_; -} - 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 7953b30..2379dd2 100644 --- a/webkit/common/gpu/context_provider_in_process.h +++ b/webkit/common/gpu/context_provider_in_process.h @@ -25,12 +25,8 @@ class GrContextForWebGraphicsContext3D; class WEBKIT_GPU_EXPORT ContextProviderInProcess : NON_EXPORTED_BASE(public cc::ContextProvider) { public: - typedef base::Callback< - scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(void)> - CreateCallback; - static scoped_refptr<ContextProviderInProcess> Create( - const CreateCallback& create_callback); + scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d); // Calls Create() with a default factory method for creating an offscreen // context. @@ -52,12 +48,10 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess OVERRIDE; protected: - ContextProviderInProcess(); + ContextProviderInProcess( + scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d); virtual ~ContextProviderInProcess(); - bool InitializeOnMainThread( - const CreateCallback& create_callback); - void OnLostContext(); void OnSwapBuffersComplete(); void OnMemoryAllocationChanged( |