Chromium Code Reviews| Index: content/renderer/render_thread_impl.cc |
| diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc |
| index 975e13ec35cacd44864906732b0242d882a1e803..5329e868965ce9da799d35f8904480e6800f17a9 100644 |
| --- a/content/renderer/render_thread_impl.cc |
| +++ b/content/renderer/render_thread_impl.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/debug/trace_event.h" |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "base/metrics/field_trial.h" |
| #include "base/metrics/histogram.h" |
| #include "base/metrics/stats_table.h" |
| @@ -98,6 +99,7 @@ |
| #include "ui/base/ui_base_switches.h" |
| #include "v8/include/v8.h" |
| #include "webkit/glue/webkit_glue.h" |
| +#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
| #if defined(OS_WIN) |
| #include <windows.h> |
| @@ -281,12 +283,16 @@ RenderThreadImpl* RenderThreadImpl::current() { |
| // When we run plugins in process, we actually run them on the render thread, |
| // which means that we need to make the render thread pump UI events. |
| -RenderThreadImpl::RenderThreadImpl() { |
| +RenderThreadImpl::RenderThreadImpl() |
| + : shared_context_main_thread_(this), |
|
piman
2013/02/11 19:15:30
nit: you'll need the ALLOW_THIS_IN_INITIALIZER_LIS
danakj
2013/02/11 20:53:36
Done.
|
| + shared_context_compositor_thread_(this) { |
| Init(); |
| } |
| RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) |
| - : ChildThread(channel_name) { |
| + : ChildThread(channel_name), |
| + shared_context_main_thread_(this), |
| + shared_context_compositor_thread_(this) { |
| Init(); |
| } |
| @@ -1124,6 +1130,55 @@ GpuChannelHost* RenderThreadImpl::EstablishGpuChannelSync( |
| return GetGpuChannel(); |
| } |
| +WebKit::WebGraphicsContext3D* RenderThreadImpl:: |
| + OffscreenContext3dForMainThread() { |
| + DCHECK(IsMainThread()); |
| + return shared_context_main_thread_.Context3d(); |
| +} |
| +WebKit::WebGraphicsContext3D* RenderThreadImpl:: |
| + OffscreenContext3dForCompositorThread() { |
| + DCHECK(IsMainThread()); |
| + return shared_context_compositor_thread_.Context3d(); |
| +} |
| + |
| +GrContext* RenderThreadImpl::OffscreenGrContextForMainThread() { |
| + DCHECK(IsMainThread()); |
| + return shared_context_main_thread_.GrContext(); |
| +} |
| + |
| +GrContext* RenderThreadImpl::OffscreenGrContextForCompositorThread() { |
| + DCHECK(IsMainThread()); |
| + return shared_context_compositor_thread_.GrContext(); |
| +} |
| + |
| +WebKit::WebGraphicsContext3D* RenderThreadImpl::CreateOffscreenContext() { |
| + WebKit::WebGraphicsContext3D::Attributes attributes; |
| + attributes.shareResources = true; |
| + attributes.depth = false; |
| + attributes.stencil = false; |
| + attributes.antialias = false; |
| + attributes.noAutomaticFlushes = true; |
| + |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { |
| + return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( |
| + attributes, false); |
| + } |
| + |
| + GURL url("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"); |
| + scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
|
piman
2013/02/11 19:15:30
use WebGraphicsContext3DCommandBufferImpl::CreateO
danakj
2013/02/11 20:53:36
Oh, nice. Done.
|
| + new WebGraphicsContext3DCommandBufferImpl( |
| + 0, |
| + url, |
| + this, |
| + base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>())); |
| + if (!context->Initialize( |
| + attributes, |
| + false, |
| + CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) |
| + return NULL; |
| + return context.release(); |
| +} |
| + |
| WebKit::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( |
| WebKit::WebMediaStreamCenterClient* client) { |
| #if defined(OS_ANDROID) |