diff options
author | vangelis@chromium.org <vangelis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-30 22:34:22 +0000 |
---|---|---|
committer | vangelis@chromium.org <vangelis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-30 22:34:22 +0000 |
commit | 591766b91bc6482d9a7d5505cb848f6ff972b86b (patch) | |
tree | 8d0832c76612efe33bd2e2e17df870664a272a6d /chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc | |
parent | 8f1f425108ab4325eebe4cd2a899a2b89f36d872 (diff) | |
download | chromium_src-591766b91bc6482d9a7d5505cb848f6ff972b86b.zip chromium_src-591766b91bc6482d9a7d5505cb848f6ff972b86b.tar.gz chromium_src-591766b91bc6482d9a7d5505cb848f6ff972b86b.tar.bz2 |
Parent the GL context used by WebGL to the GL context attached to the WebView (and used by the compositor) if
gpu compositing is enabled.
BUG=47870
TEST=none
Review URL: http://codereview.chromium.org/2838031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc')
-rw-r--r-- | chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc | 30 |
1 files changed, 22 insertions, 8 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. |