2011-01-26 Kenneth Russell <kbr@google.com>
authorkbr@google.com <kbr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jan 2011 22:06:45 +0000 (22:06 +0000)
committerkbr@google.com <kbr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Jan 2011 22:06:45 +0000 (22:06 +0000)
        Reviewed by James Robinson.

        Fix multisampling support in DrawingBuffer
        https://bugs.webkit.org/show_bug.cgi?id=53154

        Plumbed GL_ANGLE_framebuffer_multisample and
        GL_ANGLE_framebuffer_blit (exposed as the unified extension
        GL_CHROMIUM_framebuffer_multisample) through WebGraphicsContext3D.

        * public/WebGraphicsContext3D.h:
        * src/Extensions3DChromium.cpp:
        (WebCore::Extensions3DChromium::blitFramebuffer):
        (WebCore::Extensions3DChromium::renderbufferStorageMultisample):
        * src/GraphicsContext3DChromium.cpp:
        (WebCore::GraphicsContext3DInternal::supportsExtension):
        (WebCore::GraphicsContext3DInternal::ensureExtensionEnabled):
        * src/GraphicsContext3DInternal.h:
2011-01-26  Kenneth Russell  <kbr@google.com>

        Reviewed by James Robinson.

        Fix multisampling support in DrawingBuffer
        https://bugs.webkit.org/show_bug.cgi?id=53154

        In DrawingBuffer's multisampling code path, fixed enum usage and a
        bug where it would incorrectly redefine the depth and stencil
        buffers. Hooked up multisampling code path in Chromium port.

        Tested manually with some accelerated 2D canvas content.
        Multisampling isn't being switched on for the accelerated 2D
        canvas at the current time because it will increase fill rate
        requirements and cause a large number of rebaselines.

        * platform/graphics/Extensions3D.h:
        * platform/graphics/chromium/DrawingBufferChromium.cpp:
        (WebCore::DrawingBuffer::publishToPlatformLayer):
        * platform/graphics/chromium/Extensions3DChromium.h:
        * platform/graphics/gpu/DrawingBuffer.cpp:
        (WebCore::DrawingBuffer::create):
        (WebCore::DrawingBuffer::reset):
        * platform/graphics/opengl/Extensions3DOpenGL.cpp:
        (WebCore::Extensions3DOpenGL::supports):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76717 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Extensions3D.h
Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp
Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h
Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebGraphicsContext3D.h
Source/WebKit/chromium/src/Extensions3DChromium.cpp
Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
Source/WebKit/chromium/src/GraphicsContext3DInternal.h

index 37d5cb4..c120bd6 100644 (file)
@@ -1,3 +1,29 @@
+2011-01-26  Kenneth Russell  <kbr@google.com>
+
+        Reviewed by James Robinson.
+
+        Fix multisampling support in DrawingBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=53154
+
+        In DrawingBuffer's multisampling code path, fixed enum usage and a
+        bug where it would incorrectly redefine the depth and stencil
+        buffers. Hooked up multisampling code path in Chromium port.
+
+        Tested manually with some accelerated 2D canvas content.
+        Multisampling isn't being switched on for the accelerated 2D
+        canvas at the current time because it will increase fill rate
+        requirements and cause a large number of rebaselines.
+
+        * platform/graphics/Extensions3D.h:
+        * platform/graphics/chromium/DrawingBufferChromium.cpp:
+        (WebCore::DrawingBuffer::publishToPlatformLayer):
+        * platform/graphics/chromium/Extensions3DChromium.h:
+        * platform/graphics/gpu/DrawingBuffer.cpp:
+        (WebCore::DrawingBuffer::create):
+        (WebCore::DrawingBuffer::reset):
+        * platform/graphics/opengl/Extensions3DOpenGL.cpp:
+        (WebCore::Extensions3DOpenGL::supports):
+
 2011-01-26  Tony Chang  <tony@chromium.org>
 
         Unreviewed.
index 1a2b7a1..6d6efe5 100644 (file)
@@ -52,6 +52,7 @@ public:
     //   GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample
     //   GL_OES_texture_float
     //   GL_OES_standard_derivatives
+    //   GL_OES_rgb8_rgba8
 
     // Takes full name of extension; for example,
     // "GL_EXT_texture_format_BGRA8888".
@@ -87,6 +88,10 @@ public:
 
         // GL_OES_standard_derivatives names
         FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B,
+
+        // GL_OES_rgb8_rgba8 names
+        RGB8_OES = 0x8051,
+        RGBA8_OES = 0x8058,
     };
 
     // GL_ARB_robustness
index 9d9ef5c..86b4063 100644 (file)
@@ -119,6 +119,8 @@ void DrawingBuffer::publishToPlatformLayer()
         
     if (m_callback)
         m_callback->willPublish();
+    if (multisample())
+        commit();
     unsigned parentTexture = m_internal->platformLayer->textureId();
     // FIXME: We do the copy in the canvas' (child) context so that it executes in the correct order relative to
     // other commands in the child context.  This ensures that the parent texture always contains a complete
index d120424..92fb7b3 100644 (file)
@@ -44,8 +44,8 @@ public:
     virtual bool supports(const String&);
     virtual void ensureEnabled(const String&);
     virtual int getGraphicsResetStatusARB();
-    virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter) { }
-    virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) { }
+    virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter);
+    virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height);
 
     enum {
         // GL_CHROMIUM_map_sub (enums inherited from GL_ARB_vertex_buffer_object)
index fd905c9..2a83fcf 100644 (file)
@@ -41,10 +41,11 @@ namespace WebCore {
 PassRefPtr<DrawingBuffer> DrawingBuffer::create(GraphicsContext3D* context, const IntSize& size)
 {
     Extensions3D* extensions = context->getExtensions();
-    bool multisampleSupported = extensions->supports("GL_ANGLE_framebuffer_blit") && extensions->supports("GL_ANGLE_framebuffer_multisample");
+    bool multisampleSupported = extensions->supports("GL_ANGLE_framebuffer_blit") && extensions->supports("GL_ANGLE_framebuffer_multisample") && extensions->supports("GL_OES_rgb8_rgba8");
     if (multisampleSupported) {
         extensions->ensureEnabled("GL_ANGLE_framebuffer_blit");
         extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample");
+        extensions->ensureEnabled("GL_OES_rgb8_rgba8");
     }
     bool packedDepthStencilSupported = extensions->supports("GL_OES_packed_depth_stencil");
     if (packedDepthStencilSupported)
@@ -153,13 +154,15 @@ void DrawingBuffer::reset(const IntSize& newSize)
     m_context->makeContextCurrent();
     
     const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes();
-    unsigned long internalColorFormat, colorFormat;
+    unsigned long internalColorFormat, colorFormat, internalRenderbufferFormat;
     if (attributes.alpha) {
         internalColorFormat = GraphicsContext3D::RGBA;
         colorFormat = GraphicsContext3D::RGBA;
+        internalRenderbufferFormat = Extensions3D::RGBA8_OES;
     } else {
         internalColorFormat = GraphicsContext3D::RGB;
         colorFormat = GraphicsContext3D::RGB;
+        internalRenderbufferFormat = Extensions3D::RGB8_OES;
     }
 
 
@@ -173,7 +176,7 @@ void DrawingBuffer::reset(const IntSize& newSize)
         m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
 
         m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
-        m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalColorFormat, m_size.width(), m_size.height());
+        m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.width(), m_size.height());
         m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
         resizeDepthStencil(sampleCount);
         if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
@@ -190,7 +193,8 @@ void DrawingBuffer::reset(const IntSize& newSize)
     m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE);
     m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0);
     m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
-    resizeDepthStencil(0);
+    if (!multisample())
+        resizeDepthStencil(0);
     if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
         // Cleanup
         clear();
index 806136f..df45147 100644 (file)
@@ -79,6 +79,10 @@ bool Extensions3DOpenGL::supports(const String& name)
     if (name == "GL_ANGLE_framebuffer_multisample")
         return m_availableExtensions.contains("GL_EXT_framebuffer_multisample");
 
+    // Desktop GL always supports GL_OES_rgb8_rgba8.
+    if (name == "GL_OES_rgb8_rgba8")
+        return true;
+
     // If GL_ARB_texture_float is available then we report GL_OES_texture_float and
     // GL_OES_texture_half_float as available.
     if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float")
index a989b87..17769f0 100644 (file)
@@ -1,3 +1,23 @@
+2011-01-26  Kenneth Russell  <kbr@google.com>
+
+        Reviewed by James Robinson.
+
+        Fix multisampling support in DrawingBuffer
+        https://bugs.webkit.org/show_bug.cgi?id=53154
+
+        Plumbed GL_ANGLE_framebuffer_multisample and
+        GL_ANGLE_framebuffer_blit (exposed as the unified extension
+        GL_CHROMIUM_framebuffer_multisample) through WebGraphicsContext3D.
+
+        * public/WebGraphicsContext3D.h:
+        * src/Extensions3DChromium.cpp:
+        (WebCore::Extensions3DChromium::blitFramebuffer):
+        (WebCore::Extensions3DChromium::renderbufferStorageMultisample):
+        * src/GraphicsContext3DChromium.cpp:
+        (WebCore::GraphicsContext3DInternal::supportsExtension):
+        (WebCore::GraphicsContext3DInternal::ensureExtensionEnabled):
+        * src/GraphicsContext3DInternal.h:
+
 2011-01-26  Tony Chang  <tony@chromium.org>
 
         Unreviewed.
index 6568d1c..82fe81a 100644 (file)
@@ -140,6 +140,10 @@ public:
     virtual WebString getRequestableExtensionsCHROMIUM() = 0;
     virtual void requestExtensionCHROMIUM(const char*) = 0;
 
+    // GL_CHROMIUM_framebuffer_multisample
+    virtual void blitFramebufferCHROMIUM(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, unsigned mask, unsigned filter) = 0;
+    virtual void renderbufferStorageMultisampleCHROMIUM(unsigned long target, int samples, unsigned internalformat, unsigned width, unsigned height) = 0;
+
     // The entry points below map directly to the OpenGL ES 2.0 API.
     // See: http://www.khronos.org/registry/gles/
     // and: http://www.khronos.org/opengles/sdk/docs/man/
index 98fe957..52c2e12 100644 (file)
@@ -62,6 +62,16 @@ int Extensions3DChromium::getGraphicsResetStatusARB()
     return m_internal->isContextLost() ? static_cast<int>(Extensions3D::UNKNOWN_CONTEXT_RESET_ARB) : static_cast<int>(GraphicsContext3D::NO_ERROR);
 }
 
+void Extensions3DChromium::blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter)
+{
+    m_internal->blitFramebufferCHROMIUM(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+}
+
+void Extensions3DChromium::renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height)
+{
+    m_internal->renderbufferStorageMultisampleCHROMIUM(target, samples, internalformat, width, height);
+}
+
 void* Extensions3DChromium::mapBufferSubDataCHROMIUM(unsigned target, int offset, int size, unsigned access)
 {
     return m_internal->mapBufferSubDataCHROMIUM(target, offset, size, access);
index e23ef46..3bef105 100644 (file)
@@ -364,6 +364,12 @@ rt GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7
     return m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8, a9);   \
 }
 
+#define DELEGATE_TO_IMPL_10(name, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) \
+void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9, t10 a10) \
+{ \
+    m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); \
+}
+
 DELEGATE_TO_IMPL_R(makeContextCurrent, bool)
 
 bool GraphicsContext3DInternal::isGLES2Compliant() const
@@ -691,6 +697,14 @@ void splitStringHelper(const String& str, HashSet<String>& set)
         set.add(substrings[i]);
 }
 
+String mapExtensionName(const String& name)
+{
+    if (name == "GL_ANGLE_framebuffer_blit"
+        || name == "GL_ANGLE_framebuffer_multisample")
+        return "GL_CHROMIUM_framebuffer_multisample";
+    return name;
+}
+
 } // anonymous namespace
 
 void GraphicsContext3DInternal::initializeExtensions()
@@ -710,25 +724,27 @@ void GraphicsContext3DInternal::initializeExtensions()
 bool GraphicsContext3DInternal::supportsExtension(const String& name)
 {
     initializeExtensions();
-    return m_enabledExtensions.contains(name) || m_requestableExtensions.contains(name);
+    String mappedName = mapExtensionName(name);
+    return m_enabledExtensions.contains(mappedName) || m_requestableExtensions.contains(mappedName);
 }
 
 bool GraphicsContext3DInternal::ensureExtensionEnabled(const String& name)
 {
     initializeExtensions();
 
-    if (m_enabledExtensions.contains(name))
+    String mappedName = mapExtensionName(name);
+    if (m_enabledExtensions.contains(mappedName))
         return true;
 
-    if (m_requestableExtensions.contains(name)) {
-        m_impl->requestExtensionCHROMIUM(name.ascii().data());
+    if (m_requestableExtensions.contains(mappedName)) {
+        m_impl->requestExtensionCHROMIUM(mappedName.ascii().data());
         m_enabledExtensions.clear();
         m_requestableExtensions.clear();
         m_initializedAvailableExtensions = false;
     }
 
     initializeExtensions();
-    return m_enabledExtensions.contains(name);
+    return m_enabledExtensions.contains(mappedName);
 }
 
 DELEGATE_TO_IMPL_4R(mapBufferSubDataCHROMIUM, GC3Denum, GC3Dsizeiptr, GC3Dsizei, GC3Denum, void*)
@@ -736,6 +752,8 @@ DELEGATE_TO_IMPL_1(unmapBufferSubDataCHROMIUM, const void*)
 DELEGATE_TO_IMPL_9R(mapTexSubImage2DCHROMIUM, GC3Denum, GC3Dint, GC3Dint, GC3Dint, GC3Dsizei, GC3Dsizei, GC3Denum, GC3Denum, GC3Denum, void*)
 DELEGATE_TO_IMPL_1(unmapTexSubImage2DCHROMIUM, const void*)
 DELEGATE_TO_IMPL_2(copyTextureToParentTextureCHROMIUM, Platform3DObject, Platform3DObject)
+DELEGATE_TO_IMPL_10(blitFramebufferCHROMIUM, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dbitfield, GC3Denum)
+DELEGATE_TO_IMPL_5(renderbufferStorageMultisampleCHROMIUM, GC3Denum, GC3Dsizei, GC3Denum, GC3Dsizei, GC3Dsizei)
 
 //----------------------------------------------------------------------
 // GraphicsContext3D
index 18e3089..0a70613 100644 (file)
@@ -258,6 +258,10 @@ public:
     bool supportsCopyTextureToParentTextureCHROMIUM();
     void copyTextureToParentTextureCHROMIUM(Platform3DObject texture, Platform3DObject parentTexture);
 
+    // GL_CHROMIUM_framebuffer_multisample
+    void blitFramebufferCHROMIUM(GC3Dint srcX0, GC3Dint srcY0, GC3Dint srcX1, GC3Dint srcY1, GC3Dint dstX0, GC3Dint dstY0, GC3Dint dstX1, GC3Dint dstY1, GC3Dbitfield mask, GC3Denum filter);
+    void renderbufferStorageMultisampleCHROMIUM(GC3Denum target, GC3Dsizei samples, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height);
+
 private:
     OwnPtr<WebKit::WebGraphicsContext3D> m_impl;
     OwnPtr<Extensions3DChromium> m_extensions;