summaryrefslogtreecommitdiffstats
path: root/webkit/common
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-14 22:25:34 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-14 22:25:34 +0000
commit3d6b512787ee94398b001e6fbf3e748bfac79190 (patch)
treeb83a79a932e7aa207104452f3b4b336bd00585a3 /webkit/common
parentc30903d6d1ca12b172b1d1d2008a91620f9861cd (diff)
downloadchromium_src-3d6b512787ee94398b001e6fbf3e748bfac79190.zip
chromium_src-3d6b512787ee94398b001e6fbf3e748bfac79190.tar.gz
chromium_src-3d6b512787ee94398b001e6fbf3e748bfac79190.tar.bz2
aura: Allow in process ContextProvider to hold onscreen contexts.
This will allow us to use them in an OutputSurface. For the common offscreen context case, we want to still share code so add a CreateOffscreen() method to the context provider so we don't have to replicate the WGC3D::Attributes decisions around the codebase. R=piman@chromium.org BUG=258625 Review URL: https://codereview.chromium.org/23072008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217677 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/common')
-rw-r--r--webkit/common/gpu/context_provider_in_process.cc47
-rw-r--r--webkit/common/gpu/context_provider_in_process.h21
-rw-r--r--webkit/common/gpu/test_context_provider_factory.cc2
-rw-r--r--webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc12
-rw-r--r--webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h23
5 files changed, 67 insertions, 38 deletions
diff --git a/webkit/common/gpu/context_provider_in_process.cc b/webkit/common/gpu/context_provider_in_process.cc
index e56da80..1e42ab0 100644
--- a/webkit/common/gpu/context_provider_in_process.cc
+++ b/webkit/common/gpu/context_provider_in_process.cc
@@ -4,6 +4,7 @@
#include "webkit/common/gpu/context_provider_in_process.h"
+#include "base/bind.h"
#include "base/callback_helpers.h"
#include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
@@ -53,6 +54,35 @@ class ContextProviderInProcess::MemoryAllocationCallbackProxy
ContextProviderInProcess* provider_;
};
+// static
+scoped_refptr<ContextProviderInProcess> ContextProviderInProcess::Create(
+ const CreateCallback& create_callback) {
+ scoped_refptr<ContextProviderInProcess> provider =
+ new ContextProviderInProcess;
+ if (!provider->InitializeOnMainThread(create_callback))
+ return NULL;
+ return provider;
+}
+
+static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
+CreateOffscreenContext() {
+ WebKit::WebGraphicsContext3D::Attributes attributes;
+ attributes.depth = false;
+ attributes.stencil = true;
+ attributes.antialias = false;
+ attributes.shareResources = true;
+ attributes.noAutomaticFlushes = true;
+
+ return WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
+ attributes).Pass();
+}
+
+// static
+scoped_refptr<ContextProviderInProcess>
+ContextProviderInProcess::CreateOffscreen() {
+ return Create(base::Bind(&CreateOffscreenContext));
+}
+
ContextProviderInProcess::ContextProviderInProcess()
: destroyed_(false) {
DCHECK(main_thread_checker_.CalledOnValidThread());
@@ -64,22 +94,13 @@ ContextProviderInProcess::~ContextProviderInProcess() {
context_thread_checker_.CalledOnValidThread());
}
-bool ContextProviderInProcess::InitializeOnMainThread() {
+bool ContextProviderInProcess::InitializeOnMainThread(
+ const CreateCallback& create_callback) {
DCHECK(!context3d_);
DCHECK(main_thread_checker_.CalledOnValidThread());
+ DCHECK(!create_callback.is_null());
- WebKit::WebGraphicsContext3D::Attributes attributes;
- attributes.depth = false;
- attributes.stencil = true;
- attributes.antialias = false;
- attributes.shareResources = true;
- attributes.noAutomaticFlushes = true;
-
- using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
- context3d_ =
- WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
- attributes);
-
+ context3d_ = create_callback.Run();
return context3d_;
}
diff --git a/webkit/common/gpu/context_provider_in_process.h b/webkit/common/gpu/context_provider_in_process.h
index b427abe..169a1a8 100644
--- a/webkit/common/gpu/context_provider_in_process.h
+++ b/webkit/common/gpu/context_provider_in_process.h
@@ -19,17 +19,21 @@ class WebGraphicsContext3D;
namespace webkit {
namespace gpu {
class GrContextForWebGraphicsContext3D;
+class WebGraphicsContext3DInProcessCommandBufferImpl;
class WEBKIT_GPU_EXPORT ContextProviderInProcess
: NON_EXPORTED_BASE(public cc::ContextProvider) {
public:
- static scoped_refptr<ContextProviderInProcess> Create() {
- scoped_refptr<ContextProviderInProcess> provider =
- new ContextProviderInProcess;
- if (!provider->InitializeOnMainThread())
- return NULL;
- return provider;
- }
+ typedef base::Callback<
+ scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(void)>
+ CreateCallback;
+
+ static scoped_refptr<ContextProviderInProcess> Create(
+ const CreateCallback& create_callback);
+
+ // Calls Create() with a default factory method for creating an offscreen
+ // context.
+ static scoped_refptr<ContextProviderInProcess> CreateOffscreen();
virtual bool BindToCurrentThread() OVERRIDE;
virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE;
@@ -43,7 +47,8 @@ class WEBKIT_GPU_EXPORT ContextProviderInProcess
ContextProviderInProcess();
virtual ~ContextProviderInProcess();
- bool InitializeOnMainThread();
+ bool InitializeOnMainThread(
+ const CreateCallback& create_callback);
void OnLostContext();
void OnMemoryAllocationChanged(bool nonzero_allocation);
diff --git a/webkit/common/gpu/test_context_provider_factory.cc b/webkit/common/gpu/test_context_provider_factory.cc
index 88464c0..7e4f04f 100644
--- a/webkit/common/gpu/test_context_provider_factory.cc
+++ b/webkit/common/gpu/test_context_provider_factory.cc
@@ -27,7 +27,7 @@ TestContextProviderFactory::~TestContextProviderFactory() {}
scoped_refptr<cc::ContextProvider> TestContextProviderFactory::
OffscreenContextProviderForMainThread() {
if (!main_thread_.get() || main_thread_->DestroyedOnMainThread()) {
- main_thread_ = ContextProviderInProcess::Create();
+ main_thread_ = ContextProviderInProcess::CreateOffscreen();
if (main_thread_.get() && !main_thread_->BindToCurrentThread())
main_thread_ = NULL;
}
diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
index 886e40f..66c7a53 100644
--- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
+++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
@@ -66,11 +66,11 @@ static base::LazyInstance<GLES2Initializer> g_gles2_initializer =
} // namespace anonymous
// static
-scoped_ptr<WebKit::WebGraphicsContext3D>
+scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
const WebKit::WebGraphicsContext3D::Attributes& attributes,
gfx::AcceleratedWidget window) {
- scoped_ptr<WebKit::WebGraphicsContext3D> context;
+ scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context;
if (gfx::GLSurface::InitializeOneOff()) {
context.reset(new WebGraphicsContext3DInProcessCommandBufferImpl(
scoped_ptr< ::gpu::GLInProcessContext>(), attributes, false, window));
@@ -79,7 +79,7 @@ WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
}
// static
-scoped_ptr<WebKit::WebGraphicsContext3D>
+scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
const WebKit::WebGraphicsContext3D::Attributes& attributes) {
return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
@@ -87,10 +87,10 @@ WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
attributes,
true,
gfx::kNullAcceleratedWidget))
- .PassAs<WebKit::WebGraphicsContext3D>();
+ .Pass();
}
-scoped_ptr<WebKit::WebGraphicsContext3D>
+scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
scoped_ptr< ::gpu::GLInProcessContext> context,
const WebKit::WebGraphicsContext3D::Attributes& attributes) {
@@ -100,7 +100,7 @@ WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
attributes,
true /* is_offscreen. Not used. */,
gfx::kNullAcceleratedWidget /* window. Not used. */))
- .PassAs<WebKit::WebGraphicsContext3D>();
+ .Pass();
}
WebGraphicsContext3DInProcessCommandBufferImpl::
diff --git a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
index d3620b4..f96607d 100644
--- a/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
+++ b/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
@@ -48,16 +48,19 @@ namespace gpu {
class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
: public NON_EXPORTED_BASE(WebKit::WebGraphicsContext3D) {
public:
- static scoped_ptr<WebKit::WebGraphicsContext3D> CreateViewContext(
- const WebKit::WebGraphicsContext3D::Attributes& attributes,
- gfx::AcceleratedWidget window);
-
- static scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext(
- const WebKit::WebGraphicsContext3D::Attributes& attributes);
-
- static scoped_ptr<WebKit::WebGraphicsContext3D> WrapContext(
- scoped_ptr< ::gpu::GLInProcessContext> context,
- const WebKit::WebGraphicsContext3D::Attributes& attributes);
+ static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
+ CreateViewContext(
+ const WebKit::WebGraphicsContext3D::Attributes& attributes,
+ gfx::AcceleratedWidget window);
+
+ static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
+ CreateOffscreenContext(
+ const WebKit::WebGraphicsContext3D::Attributes& attributes);
+
+ static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
+ WrapContext(
+ scoped_ptr< ::gpu::GLInProcessContext> context,
+ const WebKit::WebGraphicsContext3D::Attributes& attributes);
virtual ~WebGraphicsContext3DInProcessCommandBufferImpl();