diff options
5 files changed, 49 insertions, 57 deletions
diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc index 53baa9b..b9cea16 100644 --- a/content/renderer/gpu/renderer_gl_context.cc +++ b/content/renderer/gpu/renderer_gl_context.cc @@ -82,7 +82,6 @@ RendererGLContext::~RendererGLContext() { RendererGLContext* RendererGLContext::CreateViewContext( GpuChannelHost* channel, int render_view_id, - bool share_resources, RendererGLContext* share_group, const char* allowed_extensions, const int32* attrib_list, @@ -93,8 +92,6 @@ RendererGLContext* RendererGLContext::CreateViewContext( true, render_view_id, gfx::Size(), - share_resources, - false, share_group, allowed_extensions, attrib_list, @@ -110,7 +107,6 @@ RendererGLContext* RendererGLContext::CreateViewContext( RendererGLContext* RendererGLContext::CreateOffscreenContext( GpuChannelHost* channel, const gfx::Size& size, - bool share_resources, RendererGLContext* share_group, const char* allowed_extensions, const int32* attrib_list, @@ -121,8 +117,6 @@ RendererGLContext* RendererGLContext::CreateOffscreenContext( false, 0, size, - share_resources, - false, share_group, allowed_extensions, attrib_list, @@ -291,8 +285,6 @@ RendererGLContext::RendererGLContext(GpuChannelHost* channel) bool RendererGLContext::Initialize(bool onscreen, int render_view_id, const gfx::Size& size, - bool share_resources, - bool bind_generates_resource, RendererGLContext* share_group, const char* allowed_extensions, const int32* attrib_list, @@ -307,6 +299,8 @@ bool RendererGLContext::Initialize(bool onscreen, // Ensure the gles2 library is initialized first in a thread safe way. g_gles2_initializer.Get(); + bool share_resources = true; + bool bind_generates_resources = true; std::vector<int32> attribs; while (attrib_list) { int32 attrib = *attrib_list++; @@ -323,6 +317,12 @@ bool RendererGLContext::Initialize(bool onscreen, attribs.push_back(attrib); attribs.push_back(*attrib_list++); break; + case SHARE_RESOURCES: + share_resources = !!(*attrib_list++); + break; + case BIND_GENERATES_RESOURCES: + bind_generates_resources = !!(*attrib_list++); + break; case NONE: attribs.push_back(attrib); attrib_list = NULL; @@ -408,7 +408,7 @@ bool RendererGLContext::Initialize(bool onscreen, transfer_buffer.ptr, transfer_buffer_id_, share_resources, - bind_generates_resource); + bind_generates_resources); return true; } diff --git a/content/renderer/gpu/renderer_gl_context.h b/content/renderer/gpu/renderer_gl_context.h index 5013dc9..efd1f1d 100644 --- a/content/renderer/gpu/renderer_gl_context.h +++ b/content/renderer/gpu/renderer_gl_context.h @@ -35,27 +35,30 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { public: // These are the same error codes as used by EGL. enum Error { - SUCCESS = 0x3000, - NOT_INITIALIZED = 0x3001, - BAD_ATTRIBUTE = 0x3004, - BAD_RendererGLContext = 0x3006, - CONTEXT_LOST = 0x300E + SUCCESS = 0x3000, + NOT_INITIALIZED = 0x3001, + BAD_ATTRIBUTE = 0x3004, + BAD_RendererGLContext = 0x3006, + CONTEXT_LOST = 0x300E }; - // RendererGLContext configuration attributes. These are the same as used by - // EGL. Attributes are matched using a closest fit algorithm. + // RendererGLContext configuration attributes. Those in the 16-bit range are + // the same as used by EGL. Those outside the 16-bit range are unique to + // Chromium. Attributes are matched using a closest fit algorithm. enum Attribute { - ALPHA_SIZE = 0x3021, - BLUE_SIZE = 0x3022, - GREEN_SIZE = 0x3023, - RED_SIZE = 0x3024, - DEPTH_SIZE = 0x3025, - STENCIL_SIZE = 0x3026, - SAMPLES = 0x3031, - SAMPLE_BUFFERS = 0x3032, - HEIGHT = 0x3056, - WIDTH = 0x3057, - NONE = 0x3038 // Attrib list = terminator + ALPHA_SIZE = 0x3021, + BLUE_SIZE = 0x3022, + GREEN_SIZE = 0x3023, + RED_SIZE = 0x3024, + DEPTH_SIZE = 0x3025, + STENCIL_SIZE = 0x3026, + SAMPLES = 0x3031, + SAMPLE_BUFFERS = 0x3032, + HEIGHT = 0x3056, + WIDTH = 0x3057, + NONE = 0x3038, // Attrib list = terminator + SHARE_RESOURCES = 0x10000, + BIND_GENERATES_RESOURCES = 0x10001 }; // Reasons that a lost context might have been provoked. @@ -100,7 +103,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { static RendererGLContext* CreateViewContext( GpuChannelHost* channel, int render_view_id, - bool share_resources, RendererGLContext* share_group, const char* allowed_extensions, const int32* attrib_list, @@ -117,7 +119,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { static RendererGLContext* CreateOffscreenContext( GpuChannelHost* channel, const gfx::Size& size, - bool share_resources, RendererGLContext* share_group, const char* allowed_extensions, const int32* attrib_list, @@ -179,8 +180,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> { bool Initialize(bool onscreen, int render_view_id, const gfx::Size& size, - bool share_resources, - bool bind_generates_resource, RendererGLContext* share_group, const char* allowed_extensions, const int32* attrib_list, diff --git a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc index f868526..b9e45dc 100644 --- a/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc @@ -33,7 +33,7 @@ #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" static base::LazyInstance<std::set<WebGraphicsContext3DCommandBufferImpl*> > - g_all_contexts(base::LINKER_INITIALIZED); + g_all_shared_contexts(base::LINKER_INITIALIZED); WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() : context_(NULL), @@ -54,7 +54,7 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() WebGraphicsContext3DCommandBufferImpl:: ~WebGraphicsContext3DCommandBufferImpl() { - g_all_contexts.Pointer()->erase(this); + g_all_shared_contexts.Pointer()->erase(this); delete context_; } @@ -95,6 +95,8 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize( RendererGLContext::STENCIL_SIZE, stencil_size, RendererGLContext::SAMPLES, samples, RendererGLContext::SAMPLE_BUFFERS, sample_buffers, + RendererGLContext::SHARE_RESOURCES, attributes.shareResources ? 1 : 0, + RendererGLContext::BIND_GENERATES_RESOURCES, 0, RendererGLContext::NONE, }; @@ -115,14 +117,10 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize( if (web_view && web_view->mainFrame()) active_url = GURL(web_view->mainFrame()->document().url()); - // HACK: Assume this is a WebGL context by looking for the noExtensions - // attribute. WebGL contexts must not go in the share group because they - // rely on destruction of the context to clean up owned resources. Putting - // them in a share group would prevent this from happening. RendererGLContext* share_group = NULL; - if (!attributes.noExtensions) { - share_group = g_all_contexts.Pointer()->empty() ? - NULL : (*g_all_contexts.Pointer()->begin())->context_; + if (attributes.shareResources) { + share_group = g_all_shared_contexts.Pointer()->empty() ? + NULL : (*g_all_shared_contexts.Pointer()->begin())->context_; } render_directly_to_web_view_ = render_directly_to_web_view; @@ -136,7 +134,6 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize( context_ = RendererGLContext::CreateViewContext( host, renderview->routing_id(), - !attributes.noExtensions, share_group, preferred_extensions, attribs, @@ -150,7 +147,6 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize( context_ = RendererGLContext::CreateOffscreenContext( host, gfx::Size(1, 1), - !attributes.noExtensions, share_group, preferred_extensions, attribs, @@ -190,8 +186,8 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize( attributes_.antialias = samples > 0; } - if (!attributes.noExtensions) - g_all_contexts.Pointer()->insert(this); + if (attributes.shareResources) + g_all_shared_contexts.Pointer()->insert(this); return true; } diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc index 0d5480b..866dc19 100644 --- a/content/renderer/render_widget_fullscreen_pepper.cc +++ b/content/renderer/render_widget_fullscreen_pepper.cc @@ -344,12 +344,13 @@ void RenderWidgetFullscreenPepper::CreateContext() { RendererGLContext::STENCIL_SIZE, 0, RendererGLContext::SAMPLES, 0, RendererGLContext::SAMPLE_BUFFERS, 0, + RendererGLContext::SHARE_RESOURCES, 0, + RendererGLContext::BIND_GENERATES_RESOURCES, 1, RendererGLContext::NONE, }; context_ = RendererGLContext::CreateViewContext( host, routing_id(), - false, NULL, "GL_OES_packed_depth_stencil GL_OES_depth24", attribs, diff --git a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc index 4c4f05e..ae81c98 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc @@ -198,8 +198,8 @@ const int32 kCommandBufferSize = 1024 * 1024; const int32 kTransferBufferSize = 1024 * 1024; static base::LazyInstance< - std::set<WebGraphicsContext3DInProcessCommandBufferImpl*> > g_all_contexts( - base::LINKER_INITIALIZED); + std::set<WebGraphicsContext3DInProcessCommandBufferImpl*> > + g_all_shared_contexts(base::LINKER_INITIALIZED); // Singleton used to initialize and terminate the gles2 library. class GLES2Initializer { @@ -575,7 +575,7 @@ WebGraphicsContext3DInProcessCommandBufferImpl:: WebGraphicsContext3DInProcessCommandBufferImpl:: ~WebGraphicsContext3DInProcessCommandBufferImpl() { - g_all_contexts.Pointer()->erase(this); + g_all_shared_contexts.Pointer()->erase(this); } // This string should only be passed for WebGL contexts. Nothing ELSE!!! @@ -627,14 +627,10 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::initialize( } } - // HACK: Assume this is a WebGL context by looking for the noExtensions - // attribute. WebGL contexts must not go in the share group because they - // rely on destruction of the context to clean up owned resources. Putting - // them in a share group would prevent this from happening. WebGraphicsContext3DInProcessCommandBufferImpl* context_group = NULL; - if (!attributes.noExtensions) - context_group = g_all_contexts.Pointer()->empty() ? - NULL : *g_all_contexts.Pointer()->begin(); + if (attributes.shareResources) + context_group = g_all_shared_contexts.Pointer()->empty() ? + NULL : *g_all_shared_contexts.Pointer()->begin(); context_ = GLInProcessContext::CreateOffscreenContext( parent_context, @@ -672,8 +668,8 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::initialize( } makeContextCurrent(); - if (!attributes.noExtensions) - g_all_contexts.Pointer()->insert(this); + if (attributes.shareResources) + g_all_shared_contexts.Pointer()->insert(this); return true; } |