summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 23:13:57 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 23:13:57 +0000
commit56200f01b42fc298eb187eac78b82c85eacedac0 (patch)
tree2fdbc217ace5744c3e5afd1c9f3fa3aa25df5cd1
parent4a3ce97a93e8b43082c4ae243ac8127c92890b28 (diff)
downloadchromium_src-56200f01b42fc298eb187eac78b82c85eacedac0.zip
chromium_src-56200f01b42fc298eb187eac78b82c85eacedac0.tar.gz
chromium_src-56200f01b42fc298eb187eac78b82c85eacedac0.tar.bz2
Refactor WebGraphicsContext3DInProcess and TestWebGraphicsContext3D
This needs https://bugs.webkit.org/show_bug.cgi?id=76593 to land first. This also removes WebKitPlatformSupport::createGraphicsContext3D implementations that are not called any more after the above. BUG=None TEST=chrome with accelerated content, DRT, test_shell_tests Review URL: http://codereview.chromium.org/9226036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120431 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/render_view_impl.cc18
-rw-r--r--content/renderer/renderer_webkitplatformsupport_impl.cc34
-rw-r--r--content/renderer/renderer_webkitplatformsupport_impl.h1
-rw-r--r--ui/gfx/compositor/compositor.cc11
-rw-r--r--ui/gfx/compositor/test_web_graphics_context_3d.cc7
-rw-r--r--ui/gfx/compositor/test_web_graphics_context_3d.h6
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_impl.cc164
-rw-r--r--webkit/gpu/webgraphicscontext3d_in_process_impl.h19
-rw-r--r--webkit/support/test_webkit_platform_support.cc34
-rw-r--r--webkit/support/test_webkit_platform_support.h1
-rw-r--r--webkit/support/webkit_support.cc24
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.cc13
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h1
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc8
14 files changed, 164 insertions, 177 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 240d426..767523e 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -1493,20 +1493,16 @@ WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D(
// The WebGraphicsContext3DInProcessImpl code path is used for
// layout tests (though not through this code) as well as for
// debugging and bringing up new ports.
- scoped_ptr<WebGraphicsContext3D> context;
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) {
- context.reset(new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- gfx::kNullPluginWindow, NULL));
+ return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
+ attributes, webview(), direct);
} else {
-#if defined(ENABLE_GPU)
- context.reset(new WebGraphicsContext3DCommandBufferImpl());
-#else
- return NULL;
-#endif
+ scoped_ptr<WebGraphicsContext3D> context(
+ new WebGraphicsContext3DCommandBufferImpl());
+ if (!context->initialize(attributes, webview(), direct))
+ return NULL;
+ return context.release();
}
- if (!context->initialize(attributes, webview(), direct))
- return NULL;
- return context.release();
}
void RenderViewImpl::didAddMessageToConsole(
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 7e0f796..5e62910 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -36,7 +36,6 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebBlobRegistry.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyPath.h"
@@ -565,42 +564,21 @@ RendererWebKitPlatformSupportImpl::sharedWorkerRepository() {
}
WebKit::WebGraphicsContext3D*
-RendererWebKitPlatformSupportImpl::createGraphicsContext3D() {
- // The WebGraphicsContext3DInProcessImpl code path is used for
- // layout tests (though not through this code) as well as for
- // debugging and bringing up new ports.
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) {
- return new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- gfx::kNullPluginWindow, NULL);
- } else {
-#if defined(ENABLE_GPU)
- return new WebGraphicsContext3DCommandBufferImpl();
-#else
- return NULL;
-#endif
- }
-}
-
-WebKit::WebGraphicsContext3D*
RendererWebKitPlatformSupportImpl::createOffscreenGraphicsContext3D(
const WebGraphicsContext3D::Attributes& attributes) {
// The WebGraphicsContext3DInProcessImpl code path is used for
// layout tests (though not through this code) as well as for
// debugging and bringing up new ports.
- scoped_ptr<WebGraphicsContext3D> context;
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) {
- context.reset(new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- gfx::kNullPluginWindow, NULL));
+ return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
+ attributes, NULL, false);
} else {
-#if defined(ENABLE_GPU)
+ scoped_ptr<WebGraphicsContext3D> context;
context.reset(new WebGraphicsContext3DCommandBufferImpl());
-#else
- return NULL;
-#endif
+ if (!context->initialize(attributes, NULL, false))
+ return NULL;
+ return context.release();
}
- if (!context->initialize(attributes, NULL, false))
- return NULL;
- return context.release();
}
double RendererWebKitPlatformSupportImpl::audioHardwareSampleRate() {
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.h b/content/renderer/renderer_webkitplatformsupport_impl.h
index b8fe5b3..9b56977 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.h
+++ b/content/renderer/renderer_webkitplatformsupport_impl.h
@@ -82,7 +82,6 @@ class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
const WebKit::WebString& keyPath) OVERRIDE;
virtual WebKit::WebFileSystem* fileSystem() OVERRIDE;
virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository() OVERRIDE;
- virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() OVERRIDE;
virtual WebKit::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes);
virtual double audioHardwareSampleRate() OVERRIDE;
diff --git a/ui/gfx/compositor/compositor.cc b/ui/gfx/compositor/compositor.cc
index 54d5b80..507e9d2 100644
--- a/ui/gfx/compositor/compositor.cc
+++ b/ui/gfx/compositor/compositor.cc
@@ -252,15 +252,16 @@ WebKit::WebGraphicsContext3D* Compositor::createContext3D() {
WebKit::WebGraphicsContext3D* context;
if (test_compositor_enabled) {
// Use context that results in no rendering to the screen.
- context = new TestWebGraphicsContext3D();
+ TestWebGraphicsContext3D* test_context = new TestWebGraphicsContext3D();
+ test_context->Initialize();
+ context = test_context;
} else {
gfx::GLShareGroup* share_group =
SharedResources::GetInstance()->GetShareGroup();
- context = new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- widget_, share_group);
+ WebKit::WebGraphicsContext3D::Attributes attrs;
+ context = webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWindow(
+ attrs, widget_, share_group);
}
- WebKit::WebGraphicsContext3D::Attributes attrs;
- context->initialize(attrs, 0, true);
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kDisableUIVsync)) {
diff --git a/ui/gfx/compositor/test_web_graphics_context_3d.cc b/ui/gfx/compositor/test_web_graphics_context_3d.cc
index 2d8286c..2692a3b 100644
--- a/ui/gfx/compositor/test_web_graphics_context_3d.cc
+++ b/ui/gfx/compositor/test_web_graphics_context_3d.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,13 +12,10 @@ namespace ui {
TestWebGraphicsContext3D::TestWebGraphicsContext3D() {}
TestWebGraphicsContext3D::~TestWebGraphicsContext3D() {}
-bool TestWebGraphicsContext3D::initialize(Attributes attributes,
- WebKit::WebView* view,
- bool render_directly_to_web_view) {
+void TestWebGraphicsContext3D::Initialize() {
gl_surface_ = new gfx::GLSurfaceStub;
gl_context_ = new gfx::GLContextStub;
gl_context_->MakeCurrent(gl_surface_.get());
- return true;
}
bool TestWebGraphicsContext3D::makeContextCurrent() {
diff --git a/ui/gfx/compositor/test_web_graphics_context_3d.h b/ui/gfx/compositor/test_web_graphics_context_3d.h
index 8732f70..e96748e 100644
--- a/ui/gfx/compositor/test_web_graphics_context_3d.h
+++ b/ui/gfx/compositor/test_web_graphics_context_3d.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -25,9 +25,7 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D {
TestWebGraphicsContext3D();
virtual ~TestWebGraphicsContext3D();
- virtual bool initialize(Attributes attributes,
- WebKit::WebView* view,
- bool render_directly_to_web_view);
+ void Initialize();
virtual bool makeContextCurrent();
virtual int width();
virtual int height();
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
index c3cc48f..60d7781 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
+++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc
@@ -44,10 +44,11 @@ struct WebGraphicsContext3DInProcessImpl::ShaderSourceEntry {
};
WebGraphicsContext3DInProcessImpl::WebGraphicsContext3DInProcessImpl(
- gfx::AcceleratedWidget window,
- gfx::GLShareGroup* share_group)
+ gfx::GLSurface* surface,
+ gfx::GLContext* context,
+ bool render_directly_to_web_view)
: initialized_(false),
- render_directly_to_web_view_(false),
+ render_directly_to_web_view_(render_directly_to_web_view),
is_gles2_(false),
have_ext_framebuffer_object_(false),
have_ext_framebuffer_multisample_(false),
@@ -65,10 +66,10 @@ WebGraphicsContext3DInProcessImpl::WebGraphicsContext3DInProcessImpl(
#ifdef FLIP_FRAMEBUFFER_VERTICALLY
scanline_(0),
#endif
+ gl_context_(context),
+ gl_surface_(surface),
fragment_compiler_(0),
- vertex_compiler_(0),
- window_(window),
- share_group_(share_group) {
+ vertex_compiler_(0) {
}
WebGraphicsContext3DInProcessImpl::~WebGraphicsContext3DInProcessImpl() {
@@ -105,50 +106,43 @@ WebGraphicsContext3DInProcessImpl::~WebGraphicsContext3DInProcessImpl() {
AngleDestroyCompilers();
}
-bool WebGraphicsContext3DInProcessImpl::initialize(
+WebGraphicsContext3DInProcessImpl*
+WebGraphicsContext3DInProcessImpl::CreateForWebView(
WebGraphicsContext3D::Attributes attributes,
- WebView* webView,
+ WebView* web_view,
bool render_directly_to_web_view) {
if (!gfx::GLSurface::InitializeOneOff())
- return false;
+ return NULL;
- render_directly_to_web_view_ = render_directly_to_web_view;
+ bool is_gles2 = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2;
gfx::GLShareGroup* share_group = 0;
-
- is_gles2_ = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2;
-
- if (window_ != gfx::kNullPluginWindow) {
- share_group = share_group_;
- gl_surface_ = gfx::GLSurface::CreateViewGLSurface(false, window_);
- } else {
- if (!render_directly_to_web_view) {
- // Pick up the compositor's context to share resources with.
- WebGraphicsContext3D* view_context = webView ?
- webView->graphicsContext3D() : NULL;
- if (view_context) {
- WebGraphicsContext3DInProcessImpl* contextImpl =
- static_cast<WebGraphicsContext3DInProcessImpl*>(view_context);
- share_group = contextImpl->gl_context_->share_group();
- } else {
- // The compositor's context didn't get created
- // successfully, so conceptually there is no way we can
- // render successfully to the WebView.
- render_directly_to_web_view_ = false;
- }
+ if (!render_directly_to_web_view) {
+ // Pick up the compositor's context to share resources with.
+ WebGraphicsContext3D* view_context = web_view ?
+ web_view->graphicsContext3D() : NULL;
+ if (view_context) {
+ WebGraphicsContext3DInProcessImpl* contextImpl =
+ static_cast<WebGraphicsContext3DInProcessImpl*>(view_context);
+ share_group = contextImpl->gl_context_->share_group();
+ } else {
+ // The compositor's context didn't get created
+ // successfully, so conceptually there is no way we can
+ // render successfully to the WebView.
+ render_directly_to_web_view = false;
}
- // This implementation always renders offscreen regardless of
- // whether render_directly_to_web_view is true. Both DumpRenderTree
- // and test_shell paint first to an intermediate offscreen buffer
- // and from there to the window, and WebViewImpl::paint already
- // correctly handles the case where the compositor is active but
- // the output needs to go to a WebCanvas.
- gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false,
- gfx::Size(1, 1));
}
- if (!gl_surface_.get()) {
- if (!is_gles2_)
- return false;
+ // This implementation always renders offscreen regardless of whether
+ // render_directly_to_web_view is true. Both DumpRenderTree and test_shell
+ // paint first to an intermediate offscreen buffer and from there to the
+ // window, and WebViewImpl::paint already correctly handles the case where the
+ // compositor is active but the output needs to go to a WebCanvas.
+ scoped_refptr<gfx::GLSurface> gl_surface =
+ gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1));
+
+ if (!gl_surface.get()) {
+ if (!is_gles2)
+ return NULL;
// Embedded systems have smaller limit on number of GL contexts. Sometimes
// failure of GL context creation is because of existing GL contexts
@@ -157,24 +151,26 @@ bool WebGraphicsContext3DInProcessImpl::initialize(
// a page unload event, iterate down any live WebGraphicsContext3D instances
// and force them to drop their contexts, sending a context lost event if
// necessary.
- if (webView) webView->mainFrame()->collectGarbage();
+ if (web_view) web_view->mainFrame()->collectGarbage();
- gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false,
- gfx::Size(1, 1));
- if (!gl_surface_.get())
- return false;
+ gl_surface = gfx::GLSurface::CreateOffscreenGLSurface(false,
+ gfx::Size(1, 1));
+ if (!gl_surface.get())
+ return NULL;
}
// TODO(kbr): This implementation doesn't yet support lost contexts
// and therefore can't yet properly support GPU switching.
gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
- gl_context_ = gfx::GLContext::CreateGLContext(share_group,
- gl_surface_.get(),
- gpu_preference);
- if (!gl_context_.get()) {
- if (!is_gles2_)
- return false;
+ scoped_refptr<gfx::GLContext> gl_context = gfx::GLContext::CreateGLContext(
+ share_group,
+ gl_surface.get(),
+ gpu_preference);
+
+ if (!gl_context.get()) {
+ if (!is_gles2)
+ return NULL;
// Embedded systems have smaller limit on number of GL contexts. Sometimes
// failure of GL context creation is because of existing GL contexts
@@ -183,14 +179,56 @@ bool WebGraphicsContext3DInProcessImpl::initialize(
// a page unload event, iterate down any live WebGraphicsContext3D instances
// and force them to drop their contexts, sending a context lost event if
// necessary.
- if (webView) webView->mainFrame()->collectGarbage();
-
- gl_context_ = gfx::GLContext::CreateGLContext(share_group,
- gl_surface_.get(),
- gpu_preference);
- if (!gl_context_.get())
- return false;
+ if (web_view)
+ web_view->mainFrame()->collectGarbage();
+
+ gl_context = gfx::GLContext::CreateGLContext(share_group,
+ gl_surface.get(),
+ gpu_preference);
+ if (!gl_context.get())
+ return NULL;
}
+ scoped_ptr<WebGraphicsContext3DInProcessImpl> context(
+ new WebGraphicsContext3DInProcessImpl(
+ gl_surface.get(), gl_context.get(), render_directly_to_web_view));
+ if (!context->Initialize(attributes))
+ return NULL;
+ return context.release();
+}
+
+WebGraphicsContext3DInProcessImpl*
+WebGraphicsContext3DInProcessImpl::CreateForWindow(
+ WebGraphicsContext3D::Attributes attributes,
+ gfx::AcceleratedWidget window,
+ gfx::GLShareGroup* share_group) {
+ if (!gfx::GLSurface::InitializeOneOff())
+ return NULL;
+
+ scoped_refptr<gfx::GLSurface> gl_surface =
+ gfx::GLSurface::CreateViewGLSurface(false, window);
+ if (!gl_surface.get())
+ return NULL;
+
+ gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
+
+ scoped_refptr<gfx::GLContext> gl_context = gfx::GLContext::CreateGLContext(
+ share_group,
+ gl_surface.get(),
+ gpu_preference);
+ if (!gl_context.get())
+ return NULL;
+ scoped_ptr<WebGraphicsContext3DInProcessImpl> context(
+ new WebGraphicsContext3DInProcessImpl(
+ gl_surface.get(), gl_context.get(), true));
+ if (!context->Initialize(attributes))
+ return NULL;
+ return context.release();
+}
+
+bool WebGraphicsContext3DInProcessImpl::Initialize(
+ WebGraphicsContext3D::Attributes attributes) {
+ is_gles2_ = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2;
+
attributes_ = attributes;
@@ -202,7 +240,7 @@ bool WebGraphicsContext3DInProcessImpl::initialize(
// edges in some CSS 3D samples. Third, we don't have multisampling
// support for the compositor in the normal case at the time of this
// writing.
- if (render_directly_to_web_view)
+ if (render_directly_to_web_view_)
attributes_.antialias = false;
if (!gl_context_->MakeCurrent(gl_surface_.get())) {
@@ -324,7 +362,7 @@ WebGLId WebGraphicsContext3DInProcessImpl::getPlatformTextureId() {
}
void WebGraphicsContext3DInProcessImpl::prepareTexture() {
- if (window_ != gfx::kNullPluginWindow) {
+ if (!gl_surface_->IsOffscreen()) {
gl_surface_->SwapBuffers();
} else if (!render_directly_to_web_view_) {
// We need to prepare our rendering results for the compositor.
@@ -358,7 +396,7 @@ void WebGraphicsContext3DInProcessImpl::reshape(int width, int height) {
makeContextCurrent();
bool must_restore_fbo = false;
- if (window_ == gfx::kNullPluginWindow)
+ if (gl_surface_->IsOffscreen())
must_restore_fbo = AllocateOffscreenFrameBuffer(width, height);
gl_surface_->Resize(gfx::Size(width, height));
diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.h b/webkit/gpu/webgraphicscontext3d_in_process_impl.h
index df4accb..a89cacc 100644
--- a/webkit/gpu/webgraphicscontext3d_in_process_impl.h
+++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.h
@@ -57,14 +57,21 @@ class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D {
// is gfx::kNullPluginWindow, then it creates an offscreen context.
// share_group is the group this context shares namespaces with. It's only
// used for window-bound countexts.
- WebGraphicsContext3DInProcessImpl(gfx::AcceleratedWidget window,
- gfx::GLShareGroup* share_group);
+ WebGraphicsContext3DInProcessImpl(gfx::GLSurface* surface,
+ gfx::GLContext* context,
+ bool render_directly_to_webview);
virtual ~WebGraphicsContext3DInProcessImpl();
+ static WebGraphicsContext3DInProcessImpl* CreateForWebView(
+ WebGraphicsContext3D::Attributes attributes,
+ WebView* web_view,
+ bool render_directly_to_webview);
+ static WebGraphicsContext3DInProcessImpl* CreateForWindow(
+ WebGraphicsContext3D::Attributes attributes,
+ gfx::AcceleratedWidget window,
+ gfx::GLShareGroup* share_group);
//----------------------------------------------------------------------
// WebGraphicsContext3D methods
- virtual bool initialize(
- WebGraphicsContext3D::Attributes attributes, WebView*, bool);
virtual bool makeContextCurrent();
virtual int width();
@@ -456,6 +463,8 @@ class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D {
#endif
private:
+ bool Initialize(Attributes attributes);
+
// ANGLE related.
struct ShaderSourceEntry;
@@ -522,8 +531,6 @@ class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D {
ShHandle fragment_compiler_;
ShHandle vertex_compiler_;
- gfx::AcceleratedWidget window_;
- scoped_refptr<gfx::GLShareGroup> share_group_;
};
} // namespace gpu
diff --git a/webkit/support/test_webkit_platform_support.cc b/webkit/support/test_webkit_platform_support.cc
index 7b99f166..f811083 100644
--- a/webkit/support/test_webkit_platform_support.cc
+++ b/webkit/support/test_webkit_platform_support.cc
@@ -374,36 +374,22 @@ TestWebKitPlatformSupport::sharedWorkerRepository() {
}
WebKit::WebGraphicsContext3D*
-TestWebKitPlatformSupport::createGraphicsContext3D() {
- switch (webkit_support::GetGraphicsContext3DImplementation()) {
- case webkit_support::IN_PROCESS:
- return new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- gfx::kNullPluginWindow, NULL);
- case webkit_support::IN_PROCESS_COMMAND_BUFFER:
- return new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl();
- default:
- CHECK(false) << "Unknown GraphicsContext3D Implementation";
- return NULL;
- }
-}
-
-WebKit::WebGraphicsContext3D*
TestWebKitPlatformSupport::createOffscreenGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes) {
- scoped_ptr<WebKit::WebGraphicsContext3D> context;
switch (webkit_support::GetGraphicsContext3DImplementation()) {
case webkit_support::IN_PROCESS:
- context.reset(new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- gfx::kNullPluginWindow, NULL));
- break;
- case webkit_support::IN_PROCESS_COMMAND_BUFFER:
- context.reset(
+ return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
+ attributes, NULL, false);
+ case webkit_support::IN_PROCESS_COMMAND_BUFFER: {
+ scoped_ptr<WebKit::WebGraphicsContext3D> context(
new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl());
- break;
+ if (!context->initialize(attributes, NULL, false))
+ return NULL;
+ return context.release();
+ }
}
- if (!context->initialize(attributes, NULL, false))
- return NULL;
- return context.release();
+ NOTREACHED();
+ return NULL;
}
double TestWebKitPlatformSupport::audioHardwareSampleRate() {
diff --git a/webkit/support/test_webkit_platform_support.h b/webkit/support/test_webkit_platform_support.h
index ea09d60..b0bb350 100644
--- a/webkit/support/test_webkit_platform_support.h
+++ b/webkit/support/test_webkit_platform_support.h
@@ -90,7 +90,6 @@ class TestWebKitPlatformSupport :
#endif
virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository() OVERRIDE;
- virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() OVERRIDE;
virtual WebKit::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes&);
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
index f37d538..8c312ef 100644
--- a/webkit/support/webkit_support.cc
+++ b/webkit/support/webkit_support.cc
@@ -74,6 +74,8 @@ using WebKit::WebPlugin;
using WebKit::WebPluginParams;
using WebKit::WebString;
using WebKit::WebURL;
+using webkit::gpu::WebGraphicsContext3DInProcessImpl;
+using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
namespace {
@@ -381,20 +383,20 @@ WebKit::WebGraphicsContext3D* CreateGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes,
WebKit::WebView* web_view,
bool direct) {
- scoped_ptr<WebKit::WebGraphicsContext3D> context;
switch (webkit_support::GetGraphicsContext3DImplementation()) {
case webkit_support::IN_PROCESS:
- context.reset(new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- gfx::kNullPluginWindow, NULL));
- break;
- case webkit_support::IN_PROCESS_COMMAND_BUFFER:
- context.reset(
- new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl());
- break;
+ return WebGraphicsContext3DInProcessImpl::CreateForWebView(
+ attributes, web_view, direct);
+ case webkit_support::IN_PROCESS_COMMAND_BUFFER: {
+ scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context(
+ new WebGraphicsContext3DInProcessCommandBufferImpl());
+ if (!context->initialize(attributes, web_view, direct))
+ return NULL;
+ return context.release();
+ }
}
- if (!context->initialize(attributes, web_view, direct))
- return NULL;
- return context.release();
+ NOTREACHED();
+ return NULL;
}
void RegisterMockedURL(const WebKit::WebURL& url,
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.cc b/webkit/tools/test_shell/test_shell_webkit_init.cc
index 647092f..5fd7761 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.cc
+++ b/webkit/tools/test_shell/test_shell_webkit_init.cc
@@ -300,20 +300,11 @@ TestShellWebKitInit::sharedWorkerRepository() {
return NULL;
}
-WebKit::WebGraphicsContext3D* TestShellWebKitInit::createGraphicsContext3D() {
- return new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- gfx::kNullPluginWindow, NULL);
-}
-
WebKit::WebGraphicsContext3D*
TestShellWebKitInit::createOffscreenGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes) {
- scoped_ptr<WebGraphicsContext3D> context(
- new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- gfx::kNullPluginWindow, NULL));
- if (!context->initialize(attributes, NULL, false))
- return NULL;
- return context.release();
+ return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
+ attributes, NULL, false);
}
void TestShellWebKitInit::GetPlugins(
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index 223cdf3..b94f5c4 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -106,7 +106,6 @@ class TestShellWebKitInit : public webkit_glue::WebKitPlatformSupportImpl {
#endif
virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository() OVERRIDE;
- virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D() OVERRIDE;
virtual WebKit::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
const WebKit::WebGraphicsContext3D::Attributes& attributes);
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 91737f6..36040cf 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -340,12 +340,8 @@ WebGraphicsContext3D* TestWebViewDelegate::createGraphicsContext3D(
bool direct) {
if (!shell_->webView())
return NULL;
- scoped_ptr<WebGraphicsContext3D> context(
- new webkit::gpu::WebGraphicsContext3DInProcessImpl(
- gfx::kNullPluginWindow, NULL));
- if (!context->initialize(attributes, shell_->webView(), direct))
- return NULL;
- return context.release();
+ return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView(
+ attributes, shell_->webView(), direct);
}
void TestWebViewDelegate::didAddMessageToConsole(