diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-27 01:01:04 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-27 01:01:04 +0000 |
commit | 25d478179a5d334f1c691948e0c13990a88dfbf3 (patch) | |
tree | 824210b4fb043d47b8ba5faa852da1612fcb30c1 /content | |
parent | 583844c2df50f0f2188aab7eed3fbcc40e499511 (diff) | |
download | chromium_src-25d478179a5d334f1c691948e0c13990a88dfbf3.zip chromium_src-25d478179a5d334f1c691948e0c13990a88dfbf3.tar.gz chromium_src-25d478179a5d334f1c691948e0c13990a88dfbf3.tar.bz2 |
Use 3D graphics context shareResources flag to decide whether a context should share resources.
Before, it abused the noExtensions flag to determine to disable share groups for WebGL, which was awful.
This patch is dependent on https://bugs.webkit.org/show_bug.cgi?id=66516.
See also http://codereview.chromium.org/7669072 where I perpetrated the aforementioned hack.
BUG=92356
Review URL: http://codereview.chromium.org/7669072
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98527 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.cc | 18 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.h | 43 | ||||
-rw-r--r-- | content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc | 22 | ||||
-rw-r--r-- | content/renderer/render_widget_fullscreen_pepper.cc | 3 |
4 files changed, 41 insertions, 45 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, |