Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(886)

Unified Diff: content/browser/android/in_process/synchronous_compositor_factory_impl.cc

Issue 143023005: Support multiple service instances with GLInProcessContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/android/in_process/synchronous_compositor_factory_impl.cc
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 5024ff86fa1e78cbc8c7aff83e1ef4a5c30f14f8..5f0ba09f70ee1f33e965cd5c1497f07eaaf2af31 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
@@ -51,6 +51,7 @@ using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
SynchronousCompositorFactoryImpl::SynchronousCompositorFactoryImpl()
: wrapped_gl_context_for_main_thread_(NULL),
+ wrapped_gl_context_for_compositor_thread_(NULL),
num_hardware_compositors_(0) {
SynchronousCompositorFactory::SetInstance(this);
}
@@ -83,10 +84,12 @@ SynchronousCompositorFactoryImpl::GetOffscreenContextProviderForMainThread() {
bool failed = false;
if ((!offscreen_context_for_main_thread_.get() ||
offscreen_context_for_main_thread_->DestroyedOnMainThread())) {
+ scoped_ptr<gpu::GLInProcessContext> context = CreateOffscreenContext();
+ wrapped_gl_context_for_main_thread_ = context.get();
offscreen_context_for_main_thread_ =
webkit::gpu::ContextProviderInProcess::Create(
- CreateOffscreenContext(),
- "Compositor-Offscreen");
+ WrapContext(context.Pass()),
+ "Compositor-Offscreen-main-thread");
failed = !offscreen_context_for_main_thread_.get() ||
!offscreen_context_for_main_thread_->BindToCurrentThread();
}
@@ -109,8 +112,18 @@ scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl::
base::AutoLock lock(offscreen_context_for_compositor_thread_lock_);
if (!offscreen_context_for_compositor_thread_.get() ||
offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) {
+ scoped_ptr<gpu::GLInProcessContext> context = CreateOffscreenContext();
+ wrapped_gl_context_for_compositor_thread_ = context.get();
offscreen_context_for_compositor_thread_ =
- webkit::gpu::ContextProviderInProcess::CreateOffscreen();
+ webkit::gpu::ContextProviderInProcess::Create(
+ WrapContext(context.Pass()),
+ "Compositor-Offscreen-compositor-thread");
+ failed = !offscreen_context_for_compositor_thread_.get() ||
+ !offscreen_context_for_compositor_thread_->BindToCurrentThread();
+ }
+ if (failed) {
+ offscreen_context_for_compositor_thread_ = NULL;
+ wrapped_gl_context_for_compositor_thread_ = NULL;
}
return offscreen_context_for_compositor_thread_;
}
@@ -178,11 +191,6 @@ scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
SynchronousCompositorFactoryImpl::CreateOffscreenContext() {
const gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
- blink::WebGraphicsContext3D::Attributes attributes;
- attributes.antialias = false;
- attributes.shareResources = true;
- attributes.noAutomaticFlushes = true;
-
gpu::GLInProcessContextAttribs in_process_attribs;
WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
attributes, &in_process_attribs);
@@ -190,14 +198,23 @@ SynchronousCompositorFactoryImpl::CreateOffscreenContext() {
gpu::GLInProcessContext::CreateContext(true,
NULL,
gfx::Size(1, 1),
- attributes.shareResources,
+ true /* share_resources */,
in_process_attribs,
gpu_preference));
+ return context.Pass();
+}
- wrapped_gl_context_for_main_thread_ = context.get();
+scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
+SynchronousCompositorFactoryImpl::WrapContext(
+ scoped_ptr<gpu::GLInProcessContext> context) {
if (!context.get())
return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>();
+ blink::WebGraphicsContext3D::Attributes attributes;
+ attributes.antialias = false;
+ attributes.shareResources = true;
+ attributes.noAutomaticFlushes = true;
+
return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(
WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
context.Pass(), attributes));

Powered by Google App Engine
This is Rietveld 408576698