[Qt][WK2] Clipping is broken
authornoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 01:20:20 +0000 (01:20 +0000)
committernoam.rosenthal@nokia.com <noam.rosenthal@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Feb 2012 01:20:20 +0000 (01:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78677

It's not necessary to add a full-viewport rect to the scissor clip stack.
It creates a situation where if there's a clip in the page, we return to
the viewport clip instead of applying the WebView's clip we got from the
scenegraph.

Also, it's unnecessary to clip before we paint the layer's content, we should
only clip afterwards, before painting the children.

Reviewed by Kenneth Rohde Christiansen.

No new functionality.

* platform/graphics/opengl/TextureMapperGL.cpp:
(WebCore::BitmapTextureGL::size):
(WebCore::scissorClip):
(WebCore):
(WebCore::TextureMapperGL::beginScissorClip):
(WebCore::TextureMapperGL::endScissorClip):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintSelfAndChildren):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/opengl/TextureMapperGL.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

index 100f4ba..a351f94 100644 (file)
@@ -1,5 +1,31 @@
 2012-02-20  No'am Rosenthal  <noam.rosenthal@nokia.com>
 
+        [Qt][WK2] Clipping is broken
+        https://bugs.webkit.org/show_bug.cgi?id=78677
+
+        It's not necessary to add a full-viewport rect to the scissor clip stack.
+        It creates a situation where if there's a clip in the page, we return to
+        the viewport clip instead of applying the WebView's clip we got from the
+        scenegraph.
+
+        Also, it's unnecessary to clip before we paint the layer's content, we should
+        only clip afterwards, before painting the children. 
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        No new functionality.
+
+        * platform/graphics/opengl/TextureMapperGL.cpp:
+        (WebCore::BitmapTextureGL::size):
+        (WebCore::scissorClip):
+        (WebCore):
+        (WebCore::TextureMapperGL::beginScissorClip):
+        (WebCore::TextureMapperGL::endScissorClip):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::paintSelfAndChildren):
+
+2012-02-20  No'am Rosenthal  <noam.rosenthal@nokia.com>
+
         [Texmap] Layers and tiles appear to have missing pixels in their right/bottom borders
         https://bugs.webkit.org/show_bug.cgi?id=78961
 
index 390e4a8..c034618 100644 (file)
@@ -809,7 +809,6 @@ void TextureMapperGL::bindSurface(BitmapTexture *surfacePointer)
         GL_CMD(glStencilFunc(data().sharedGLData().stencilIndex > 1 ? GL_EQUAL : GL_ALWAYS, data().sharedGLData().stencilIndex - 1, data().sharedGLData().stencilIndex - 1))
         GL_CMD(glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP))
         GL_CMD(glViewport(0, 0, viewportSize.width(), viewportSize.height()))
-        data().sharedGLData().clipStack.append(IntRect(data().viewport[0], data().viewport[1], data().viewport[2], data().viewport[3]));
         return;
     }
 
@@ -835,8 +834,15 @@ bool TextureMapperGL::beginScissorClip(const TransformationMatrix& modelViewMatr
     }
 
     // Intersect with previous clip.
-    if (!data().sharedGLData().clipStack.isEmpty())
-        rect.intersect(data().sharedGLData().clipStack.last());
+    for (int i = data().sharedGLData().clipStack.size() - 1; i >= 0; --i) {
+        const IntRect& prevRect = data().sharedGLData().clipStack[i];
+        if (prevRect.isEmpty())
+            continue;
+
+        // We only need the last valid clip.
+        rect.intersect(prevRect);
+        break;
+    }
 
     scissorClip(rect);
     data().sharedGLData().clipStack.append(rect);
@@ -861,6 +867,7 @@ void TextureMapperGL::beginClip(const TransformationMatrix& modelViewMatrix, con
 {
     if (beginScissorClip(modelViewMatrix, targetRect))
         return;
+
     data().initStencil();
     TextureMapperGLData::SharedGLData::ShaderProgramIndex program = TextureMapperGLData::SharedGLData::ClipProgram;
     const TextureMapperGLData::SharedGLData::ProgramInfo& programInfo = data().sharedGLData().programs[program];
index 5f3862b..8dd4eb8 100644 (file)
@@ -175,16 +175,19 @@ void TextureMapperLayer::sortByZOrder(Vector<TextureMapperLayer* >& array, int f
 
 void TextureMapperLayer::paintSelfAndChildren(const TextureMapperPaintOptions& options)
 {
-    bool hasClip = m_state.masksToBounds && !m_children.isEmpty();
-    if (hasClip)
-        options.textureMapper->beginClip(TransformationMatrix(options.transform).multiply(m_transform.combined()), FloatRect(0, 0, m_size.width(), m_size.height()));
-
     paintSelf(options);
 
-    for (size_t i = 0; i < m_children.size(); ++i)
+    if (m_children.isEmpty())
+        return;
+
+    bool shouldClip = m_state.masksToBounds || m_state.maskLayer;
+    if (shouldClip)
+        options.textureMapper->beginClip(TransformationMatrix(options.transform).multiply(m_transform.combined()), FloatRect(0, 0, m_size.width(), m_size.height()));
+
+    for (int i = 0; i < m_children.size(); ++i)
         m_children[i]->paintRecursive(options);
 
-    if (hasClip)
+    if (shouldClip)
         options.textureMapper->endClip();
 }