summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authordongseong.hwang@intel.com <dongseong.hwang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-11 19:48:41 +0000
committerdongseong.hwang@intel.com <dongseong.hwang@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-11 19:50:31 +0000
commit807567a6e3b472ac30f5501156090e7ecc7edd7f (patch)
treee740119f3d934ba99fc5f44bb5ccb85d279b4cec /content
parent8ed8bf43124192671eaf134d014f148a9dd12bea (diff)
downloadchromium_src-807567a6e3b472ac30f5501156090e7ecc7edd7f.zip
chromium_src-807567a6e3b472ac30f5501156090e7ecc7edd7f.tar.gz
chromium_src-807567a6e3b472ac30f5501156090e7ecc7edd7f.tar.bz2
Unify shared main thread context provider code among Clank, Android WebView and other platforms.
Android WebView manages shared main thread context provider in SynchronousCompositorFactory, while others manage it in RenderThreadImpl. This CL unifies all code in RenderThreadImpl. In addition, there is slight logic change in Android WebView. Currently Android WebView doesn't bind the context to the main thread when the context exists, while others always bind it to the main thread. It could cause a strange bug, and this CL fixes the potential bug. BUG=N/A Review URL: https://codereview.chromium.org/449793002 Cr-Commit-Position: refs/heads/master@{#288769} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288769 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/android/in_process/synchronous_compositor_factory_impl.cc27
-rw-r--r--content/browser/android/in_process/synchronous_compositor_factory_impl.h7
-rw-r--r--content/renderer/android/synchronous_compositor_factory.h4
-rw-r--r--content/renderer/render_thread_impl.cc37
-rw-r--r--content/renderer/render_thread_impl.h3
5 files changed, 39 insertions, 39 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 45e5aa1..5c13410 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
@@ -168,25 +168,14 @@ SynchronousCompositorFactoryImpl::GetInputHandlerManagerClient() {
return synchronous_input_event_filter();
}
-scoped_refptr<ContextProviderWebContext> SynchronousCompositorFactoryImpl::
- GetSharedOffscreenContextProviderForMainThread() {
- bool failed = false;
- if ((!offscreen_context_for_main_thread_.get() ||
- offscreen_context_for_main_thread_->DestroyedOnMainThread())) {
- scoped_ptr<gpu::GLInProcessContext> context =
- CreateOffscreenContext(GetDefaultAttribs());
- offscreen_context_for_main_thread_ =
- webkit::gpu::ContextProviderInProcess::Create(
- WrapContext(context.Pass()),
- "Compositor-Offscreen-main-thread");
- failed = !offscreen_context_for_main_thread_.get() ||
- !offscreen_context_for_main_thread_->BindToCurrentThread();
- }
-
- if (failed) {
- offscreen_context_for_main_thread_ = NULL;
- }
- return offscreen_context_for_main_thread_;
+scoped_refptr<ContextProviderWebContext>
+SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider(
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ const std::string& debug_name) {
+ scoped_ptr<gpu::GLInProcessContext> context =
+ CreateOffscreenContext(attributes);
+ return webkit::gpu::ContextProviderInProcess::Create(
+ WrapContext(context.Pass()), debug_name);
}
scoped_refptr<cc::ContextProvider> SynchronousCompositorFactoryImpl::
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 63eba9d..0c3cb7c 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.h
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.h
@@ -39,7 +39,9 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
OVERRIDE;
virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE;
virtual scoped_refptr<webkit::gpu::ContextProviderWebContext>
- GetSharedOffscreenContextProviderForMainThread() OVERRIDE;
+ CreateOffscreenContextProvider(
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ const std::string& debug_name) OVERRIDE;
virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
int view_id) OVERRIDE;
virtual blink::WebGraphicsContext3D* CreateOffscreenGraphicsContext3D(
@@ -67,9 +69,6 @@ class SynchronousCompositorFactoryImpl : public SynchronousCompositorFactory {
SynchronousInputEventFilter synchronous_input_event_filter_;
- scoped_refptr<webkit::gpu::ContextProviderWebContext>
- offscreen_context_for_main_thread_;
-
scoped_refptr<gpu::InProcessCommandBuffer::Service> service_;
scoped_ptr<gpu::GLInProcessContext> share_context_;
scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
diff --git a/content/renderer/android/synchronous_compositor_factory.h b/content/renderer/android/synchronous_compositor_factory.h
index 84122cd..c21d82ac 100644
--- a/content/renderer/android/synchronous_compositor_factory.h
+++ b/content/renderer/android/synchronous_compositor_factory.h
@@ -52,7 +52,9 @@ class SynchronousCompositorFactory {
virtual InputHandlerManagerClient* GetInputHandlerManagerClient() = 0;
virtual scoped_refptr<webkit::gpu::ContextProviderWebContext>
- GetSharedOffscreenContextProviderForMainThread() = 0;
+ CreateOffscreenContextProvider(
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ const std::string& debug_name) = 0;
virtual scoped_refptr<StreamTextureFactory> CreateStreamTextureFactory(
int frame_id) = 0;
virtual blink::WebGraphicsContext3D* CreateOffscreenGraphicsContext3D(
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index fc52eda..37fa090 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -301,6 +301,16 @@ bool ShouldUseMojoChannel() {
switches::kEnableRendererMojoChannel);
}
+blink::WebGraphicsContext3D::Attributes GetOffscreenAttribs() {
+ blink::WebGraphicsContext3D::Attributes attributes;
+ attributes.shareResources = true;
+ attributes.depth = false;
+ attributes.stencil = false;
+ attributes.antialias = false;
+ attributes.noAutomaticFlushes = true;
+ return attributes;
+}
+
} // namespace
// For measuring memory usage after each task. Behind a command line flag.
@@ -1127,12 +1137,7 @@ RenderThreadImpl::GetGpuFactories() {
scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
RenderThreadImpl::CreateOffscreenContext3d() {
- blink::WebGraphicsContext3D::Attributes attributes;
- attributes.shareResources = true;
- attributes.depth = false;
- attributes.stencil = false;
- attributes.antialias = false;
- attributes.noAutomaticFlushes = true;
+ blink::WebGraphicsContext3D::Attributes attributes(GetOffscreenAttribs());
bool lose_context_when_out_of_memory = true;
scoped_refptr<GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync(
@@ -1150,16 +1155,20 @@ RenderThreadImpl::CreateOffscreenContext3d() {
scoped_refptr<webkit::gpu::ContextProviderWebContext>
RenderThreadImpl::SharedMainThreadContextProvider() {
DCHECK(IsMainThread());
-#if defined(OS_ANDROID)
- if (SynchronousCompositorFactory* factory =
- SynchronousCompositorFactory::GetInstance())
- return factory->GetSharedOffscreenContextProviderForMainThread();
-#endif
-
if (!shared_main_thread_contexts_ ||
shared_main_thread_contexts_->DestroyedOnMainThread()) {
- shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create(
- CreateOffscreenContext3d(), "Offscreen-MainThread");
+ shared_main_thread_contexts_ = NULL;
+#if defined(OS_ANDROID)
+ if (SynchronousCompositorFactory* factory =
+ SynchronousCompositorFactory::GetInstance()) {
+ shared_main_thread_contexts_ = factory->CreateOffscreenContextProvider(
+ GetOffscreenAttribs(), "Offscreen-MainThread");
+ }
+#endif
+ if (!shared_main_thread_contexts_) {
+ shared_main_thread_contexts_ = ContextProviderCommandBuffer::Create(
+ CreateOffscreenContext3d(), "Offscreen-MainThread");
+ }
}
if (shared_main_thread_contexts_ &&
!shared_main_thread_contexts_->BindToCurrentThread())
diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h
index 421850e..012e2a2 100644
--- a/content/renderer/render_thread_impl.h
+++ b/content/renderer/render_thread_impl.h
@@ -538,7 +538,8 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread,
scoped_ptr<InputHandlerManager> input_handler_manager_;
scoped_refptr<IPC::ForwardingMessageFilter> compositor_output_surface_filter_;
- scoped_refptr<ContextProviderCommandBuffer> shared_main_thread_contexts_;
+ scoped_refptr<webkit::gpu::ContextProviderWebContext>
+ shared_main_thread_contexts_;
ObserverList<RenderProcessObserver> observers_;