[WebGL] Resizing and entering/exiting full screen draws garbage
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jan 2014 01:51:38 +0000 (01:51 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Jan 2014 01:51:38 +0000 (01:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127077

Reviewed by Dean Jackson.

* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
(WebCore::GraphicsContext3D::reshapeFBOs): Simplified logic regarding FBO switching.
(WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary): Make sure a few things
are turned off that might affect blitting data from one FBO to another.
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::prepareTexture): Actually turn dithering off!
(WebCore::GraphicsContext3D::reshape): Mark the context as dirty when resizing so that
the GL view is redrawn during resizing events.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

index 8c3af0e..479187b 100644 (file)
@@ -1,3 +1,19 @@
+2014-01-15  Brent Fulgham  <bfulgham@apple.com>
+
+        [WebGL] Resizing and entering/exiting full screen draws garbage
+        https://bugs.webkit.org/show_bug.cgi?id=127077
+
+        Reviewed by Dean Jackson.
+
+        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
+        (WebCore::GraphicsContext3D::reshapeFBOs): Simplified logic regarding FBO switching.
+        (WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary): Make sure a few things
+        are turned off that might affect blitting data from one FBO to another.
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::prepareTexture): Actually turn dithering off!
+        (WebCore::GraphicsContext3D::reshape): Mark the context as dirty when resizing so that
+        the GL view is redrawn during resizing events.
+
 2014-01-15  Roger Fong  <roger_fong@apple.com>
 
         Remove unnecessary call to webGLContextCreated
index 79c6fd8..63941e8 100644 (file)
@@ -101,8 +101,6 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
 #endif
     }
 
-    bool mustRestoreFBO = false;
-
     // Resize multisample FBO.
     if (m_attrs.antialias) {
         GLint maxSampleCount;
@@ -110,10 +108,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
         GLint sampleCount = std::min(8, maxSampleCount);
         if (sampleCount > maxSampleCount)
             sampleCount = maxSampleCount;
-        if (m_state.boundFBO != m_multisampleFBO) {
-            ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
-            mustRestoreFBO = true;
-        }
+        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
         ::glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, sampleCount, m_internalColorFormat, width, height);
         ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_multisampleColorBuffer);
@@ -133,11 +128,7 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
     }
 
     // resize regular FBO
-    if (m_state.boundFBO != m_fbo) {
-        mustRestoreFBO = true;
-        ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
-    }
-
+    ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
     ASSERT(m_texture);
 #if PLATFORM(IOS)
     ::glBindRenderbuffer(GL_RENDERBUFFER, m_texture);
@@ -164,15 +155,20 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
             ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
         ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
     }
+
     if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) {
         // FIXME: cleanup
         notImplemented();
     }
 
+    bool mustRestoreFBO = true;
     if (m_attrs.antialias) {
         ::glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_multisampleFBO);
         if (m_state.boundFBO == m_multisampleFBO)
             mustRestoreFBO = false;
+    } else {
+        if (m_state.boundFBO == m_fbo)
+            mustRestoreFBO = false;
     }
 
     return mustRestoreFBO;
@@ -181,7 +177,9 @@ bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
 void GraphicsContext3D::resolveMultisamplingIfNecessary(const IntRect& rect)
 {
     TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
-    TemporaryOpenGLSetting scopedDither(GL_SCISSOR_TEST, GL_FALSE);
+    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
+    TemporaryOpenGLSetting scopedDepth(GL_DEPTH_TEST, GL_FALSE);
+    TemporaryOpenGLSetting scopedStencil(GL_STENCIL_TEST, GL_FALSE);
 
     ::glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
     ::glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
index 1c581e6..cc3d398 100644 (file)
@@ -208,7 +208,7 @@ void GraphicsContext3D::prepareTexture()
     makeContextCurrent();
 
     TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
-    TemporaryOpenGLSetting scopedDither(GL_SCISSOR_TEST, GL_FALSE);
+    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
     
     if (m_attrs.antialias)
         resolveMultisamplingIfNecessary();
@@ -269,6 +269,8 @@ void GraphicsContext3D::reshape(int width, int height)
     if (width == m_currentWidth && height == m_currentHeight)
         return;
 
+    markContextChanged();
+
 #if (PLATFORM(EFL) || PLATFORM(NIX)) && USE(GRAPHICS_SURFACE)
     ::glFlush(); // Make sure all GL calls have been committed before resizing.
     createGraphicsSurfaces(IntSize(width, height));
@@ -280,13 +282,16 @@ void GraphicsContext3D::reshape(int width, int height)
     makeContextCurrent();
     validateAttributes();
 
+    TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
+    TemporaryOpenGLSetting scopedDither(GL_DITHER, GL_FALSE);
+    
     bool mustRestoreFBO = reshapeFBOs(IntSize(width, height));
 
     // Initialize renderbuffers to 0.
     GLfloat clearColor[] = {0, 0, 0, 0}, clearDepth = 0;
     GLint clearStencil = 0;
     GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE;
-    GLuint stencilMask = 0xffffffff;
+    GLuint stencilMask = 0xffffffff, stencilMaskBack = 0xffffffff;
     GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
     ::glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
     ::glClearColor(0, 0, 0, 0);
@@ -303,13 +308,12 @@ void GraphicsContext3D::reshape(int width, int height)
         ::glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil);
         ::glClearStencil(0);
         ::glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask));
+        ::glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, reinterpret_cast<GLint*>(&stencilMaskBack));
         ::glStencilMaskSeparate(GL_FRONT, 0xffffffff);
+        ::glStencilMaskSeparate(GL_BACK, 0xffffffff);
         clearMask |= GL_STENCIL_BUFFER_BIT;
     }
 
-    TemporaryOpenGLSetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);
-    TemporaryOpenGLSetting scopedDither(GL_SCISSOR_TEST, GL_FALSE);
-
     ::glClear(clearMask);
 
     ::glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
@@ -321,6 +325,7 @@ void GraphicsContext3D::reshape(int width, int height)
     if (m_attrs.stencil) {
         ::glClearStencil(clearStencil);
         ::glStencilMaskSeparate(GL_FRONT, stencilMask);
+        ::glStencilMaskSeparate(GL_BACK, stencilMaskBack);
     }
 
     if (mustRestoreFBO)