Skip to content

Commit

Permalink
Allow specification of the share group in WebGraphicsContext3DInProce…
Browse files Browse the repository at this point in the history
…ssImpl

BUG=None
TEST=Aura + WebKit compositor


Review URL: http://codereview.chromium.org/8301019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105691 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
piman@chromium.org committed Oct 15, 2011
1 parent 2dba717 commit 52ee7cf
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion content/renderer/renderer_webkitplatformsupport_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ RendererWebKitPlatformSupportImpl::createGraphicsContext3D() {
// debugging and bringing up new ports.
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) {
return new webkit::gpu::WebGraphicsContext3DInProcessImpl(
gfx::kNullPluginWindow);
gfx::kNullPluginWindow, NULL);
} else {
#if defined(ENABLE_GPU)
return new WebGraphicsContext3DCommandBufferImpl();
Expand Down
38 changes: 20 additions & 18 deletions webkit/gpu/webgraphicscontext3d_in_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ struct WebGraphicsContext3DInProcessImpl::ShaderSourceEntry {
};

WebGraphicsContext3DInProcessImpl::WebGraphicsContext3DInProcessImpl(
gfx::PluginWindowHandle window)
gfx::PluginWindowHandle window,
gfx::GLShareGroup* share_group)
: initialized_(false),
render_directly_to_web_view_(false),
is_gles2_(false),
Expand All @@ -66,7 +67,8 @@ WebGraphicsContext3DInProcessImpl::WebGraphicsContext3DInProcessImpl(
#endif
fragment_compiler_(0),
vertex_compiler_(0),
window_(window) {
window_(window),
share_group_(share_group) {
}

WebGraphicsContext3DInProcessImpl::~WebGraphicsContext3DInProcessImpl() {
Expand Down Expand Up @@ -114,27 +116,27 @@ bool WebGraphicsContext3DInProcessImpl::initialize(
render_directly_to_web_view_ = render_directly_to_web_view;
gfx::GLShareGroup* share_group = 0;

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;
}
}

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;
}
}
// 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
Expand Down
7 changes: 6 additions & 1 deletion webkit/gpu/webgraphicscontext3d_in_process_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace gfx {
class GLContext;
class GLSurface;
class GLShareGroup;
}

using WebKit::WGC3Dchar;
Expand Down Expand Up @@ -54,7 +55,10 @@ class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D {
public:
// Creates a WebGraphicsContext3DInProcessImpl for a given window. If window
// is gfx::kNullPluginWindow, then it creates an offscreen context.
WebGraphicsContext3DInProcessImpl(gfx::PluginWindowHandle window);
// share_group is the group this context shares namespaces with. It's only
// used for window-bound countexts.
WebGraphicsContext3DInProcessImpl(gfx::PluginWindowHandle window,
gfx::GLShareGroup* share_group);
virtual ~WebGraphicsContext3DInProcessImpl();

//----------------------------------------------------------------------
Expand Down Expand Up @@ -493,6 +497,7 @@ class WebGraphicsContext3DInProcessImpl : public WebGraphicsContext3D {
ShHandle fragment_compiler_;
ShHandle vertex_compiler_;
gfx::PluginWindowHandle window_;
scoped_refptr<gfx::GLShareGroup> share_group_;
};

} // namespace gpu
Expand Down
2 changes: 1 addition & 1 deletion webkit/support/test_webkit_platform_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ TestWebKitPlatformSupport::createGraphicsContext3D() {
switch (webkit_support::GetGraphicsContext3DImplementation()) {
case webkit_support::IN_PROCESS:
return new webkit::gpu::WebGraphicsContext3DInProcessImpl(
gfx::kNullPluginWindow);
gfx::kNullPluginWindow, NULL);
case webkit_support::IN_PROCESS_COMMAND_BUFFER:
return new webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl();
default:
Expand Down
2 changes: 1 addition & 1 deletion webkit/tools/test_shell/test_shell_webkit_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,5 @@ TestShellWebKitInit::sharedWorkerRepository() {

WebKit::WebGraphicsContext3D* TestShellWebKitInit::createGraphicsContext3D() {
return new webkit::gpu::WebGraphicsContext3DInProcessImpl(
gfx::kNullPluginWindow);
gfx::kNullPluginWindow, NULL);
}

0 comments on commit 52ee7cf

Please sign in to comment.