diff options
-rw-r--r-- | chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc | 30 | ||||
-rw-r--r-- | chrome/renderer/webgraphicscontext3d_command_buffer_impl.h | 3 |
2 files changed, 22 insertions, 11 deletions
diff --git a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc index 7501c2c..bffb690 100644 --- a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc +++ b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc @@ -10,9 +10,13 @@ #include <algorithm> +#include "base/command_line.h" #include "base/logging.h" +#include "chrome/common/chrome_switches.h" #include "chrome/renderer/gpu_channel_host.h" #include "chrome/renderer/render_thread.h" +#include "chrome/renderer/webgles2context_impl.h" +#include "third_party/WebKit/WebKit/chromium/public/WebView.h" WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() : context_(NULL), @@ -28,16 +32,26 @@ WebGraphicsContext3DCommandBufferImpl:: } } -// TODO(vangelis): Properly implement this method once the upstream WebKit -// changes have landed. bool WebGraphicsContext3DCommandBufferImpl::initialize( WebGraphicsContext3D::Attributes attributes, - WebKit::WebView*) { - return initialize(attributes); -} + WebKit::WebView* web_view) { + bool compositing_enabled = CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableAcceleratedCompositing); + ggl::Context* parent_context = NULL; + // If GPU compositing is enabled we need to create a GL context that shares + // resources with the compositor's context. + if (compositing_enabled) { + // Asking for the GLES2Context on the WebView will force one to be created + // if it doesn't already exist. When the compositor is created for the view + // it will use the same context. + WebKit::WebGLES2Context* view_gles2_context = web_view->gles2Context(); + if (!view_gles2_context) + return false; + WebGLES2ContextImpl* context_impl = + static_cast<WebGLES2ContextImpl*>(view_gles2_context); + parent_context = context_impl->context(); + } -bool WebGraphicsContext3DCommandBufferImpl::initialize( - WebGraphicsContext3D::Attributes attributes) { RenderThread* render_thread = RenderThread::current(); if (!render_thread) return false; @@ -45,7 +59,7 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize( if (!host) return false; DCHECK(host->ready()); - context_ = ggl::CreateOffscreenContext(host, NULL, gfx::Size(1, 1)); + context_ = ggl::CreateOffscreenContext(host, parent_context, gfx::Size(1, 1)); if (!context_) return false; // TODO(gman): Remove this. diff --git a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.h b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.h index 8c7f7b2..d1a7d2c 100644 --- a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.h +++ b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.h @@ -39,9 +39,6 @@ class WebGraphicsContext3DCommandBufferImpl //---------------------------------------------------------------------- // WebGraphicsContext3D methods - // TODO(vangelis): Remove this version of initialize() once the changes - // to WebGraphicsContext3D have been checked in upstream. - virtual bool initialize(WebGraphicsContext3D::Attributes attributes); virtual bool initialize(WebGraphicsContext3D::Attributes attributes, WebKit::WebView*); |