Title: [101472] trunk/Source
Revision
101472
Author
[email protected]
Date
2011-11-30 03:00:06 -0800 (Wed, 30 Nov 2011)

Log Message

[Chromium] Avoid ASSERT_NOT_REACHED() from creating FBO with content texture of size 0
https://bugs.webkit.org/show_bug.cgi?id=73266

Source/WebCore:

Remove render surface layers with no children after clipping to
the parent layer.

Move the check for empty render surfaces after the piece of code
used to apply the parent's clip, as we might end up calling
renderSurface->clearLayerList().

Render surfaces with no children or visible content are unexpected
especially at draw time where we might try to create a content
texture and FBO with a size of zero, which will fail. This fixes
an ASSERT_NOT_REACHED() for checkFramebufferStatus() != COMPLETE

Patch by Daniel Sievers <[email protected]> on 2011-11-30
Reviewed by James Robinson.

Added unit test.

* platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
(WebCore::calculateDrawTransformsAndVisibilityInternal):

Source/WebKit/chromium:

Patch by Daniel Sievers <[email protected]> on 2011-11-30
Reviewed by James Robinson.

* tests/CCLayerTreeHostCommonTest.cpp:
(WebCore::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (101471 => 101472)


--- trunk/Source/WebCore/ChangeLog	2011-11-30 10:56:23 UTC (rev 101471)
+++ trunk/Source/WebCore/ChangeLog	2011-11-30 11:00:06 UTC (rev 101472)
@@ -1,3 +1,27 @@
+2011-11-30  Daniel Sievers  <[email protected]>
+
+        [Chromium] Avoid ASSERT_NOT_REACHED() from creating FBO with content texture of size 0
+        https://bugs.webkit.org/show_bug.cgi?id=73266
+
+        Remove render surface layers with no children after clipping to
+        the parent layer.
+
+        Move the check for empty render surfaces after the piece of code
+        used to apply the parent's clip, as we might end up calling
+        renderSurface->clearLayerList().
+
+        Render surfaces with no children or visible content are unexpected
+        especially at draw time where we might try to create a content
+        texture and FBO with a size of zero, which will fail. This fixes
+        an ASSERT_NOT_REACHED() for checkFramebufferStatus() != COMPLETE
+
+        Reviewed by James Robinson.
+
+        Added unit test.
+
+        * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
+        (WebCore::calculateDrawTransformsAndVisibilityInternal):
+
 2011-11-30  Pavel Feldman  <[email protected]>
 
         Web Inspector: do not report worker-related events unless inspector agent is enabled.

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp (101471 => 101472)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp	2011-11-30 10:56:23 UTC (rev 101471)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp	2011-11-30 11:00:06 UTC (rev 101472)
@@ -378,22 +378,6 @@
         }
     }
 
-    if (layer->renderSurface() && !layer->renderSurface()->layerList().size()) {
-        // If a render surface has no layer list, then it and none of its
-        // children needed to get drawn. Therefore, it should be the last layer
-        // in the render surface list and we can trivially remove it.
-        if (layer != rootLayer) {
-            ASSERT(renderSurfaceLayerList.last() == layer);
-            renderSurfaceLayerList.removeLast();
-            layer->clearRenderSurface();
-        }
-        return;
-    }
-
-    // If neither this layer nor any of its children were added, early out.
-    if (sortingStartIndex == descendants.size())
-        return;
-
     if (layer->masksToBounds() || useSurfaceForMasking) {
         IntRect drawableContentRect = layer->drawableContentRect();
         drawableContentRect.intersect(transformedLayerRect);
@@ -447,8 +431,22 @@
             replicaDrawTransform.translate3d(surfaceCenter.x() - anchorPoint.x() * bounds.width(), surfaceCenter.y() - anchorPoint.y() * bounds.height(), 0);
             renderSurface->setReplicaDrawTransform(replicaDrawTransform);
         }
+
+        // If a render surface has no layer list, then it and none of its
+        // children needed to get drawn. Therefore, it should be the last layer
+        // in the render surface list and we can trivially remove it.
+        if (!layer->renderSurface()->layerList().size()) {
+            ASSERT(renderSurfaceLayerList.last() == layer);
+            renderSurfaceLayerList.removeLast();
+            layer->clearRenderSurface();
+            return;
+        }
     }
 
+    // If neither this layer nor any of its children were added, early out.
+    if (sortingStartIndex == descendants.size())
+        return;
+
     // If preserves-3d then sort all the descendants in 3D so that they can be
     // drawn from back to front. If the preserves-3d property is also set on the parent then
     // skip the sorting as the parent will sort all the descendants anyway.

Modified: trunk/Source/WebKit/chromium/ChangeLog (101471 => 101472)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-11-30 10:56:23 UTC (rev 101471)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-11-30 11:00:06 UTC (rev 101472)
@@ -1,3 +1,13 @@
+2011-11-30  Daniel Sievers  <[email protected]>
+
+        [Chromium] Avoid ASSERT_NOT_REACHED() from creating FBO with content texture of size 0
+        https://bugs.webkit.org/show_bug.cgi?id=73266
+
+        Reviewed by James Robinson.
+
+        * tests/CCLayerTreeHostCommonTest.cpp:
+        (WebCore::TEST):
+
 2011-11-30  Pavel Feldman  <[email protected]>
 
         Web Inspector: do not report worker-related events unless inspector agent is enabled.

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp (101471 => 101472)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp	2011-11-30 10:56:23 UTC (rev 101471)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp	2011-11-30 11:00:06 UTC (rev 101472)
@@ -452,6 +452,35 @@
     EXPECT_FLOAT_EQ(5.0, grandChildOfRS2->screenSpaceTransform().m42());
 }
 
+TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceListForClipLayer)
+{
+    RefPtr<LayerChromium> parent = LayerChromium::create(0);
+    RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(0);
+    RefPtr<LayerChromiumWithForcedDrawsContent> child = adoptRef(new LayerChromiumWithForcedDrawsContent(0));
+    renderSurface1->setOpacity(0.9);
+
+    const TransformationMatrix identityMatrix;
+    setLayerPropertiesForTesting(renderSurface1.get(), identityMatrix, identityMatrix, FloatPoint::zero(), FloatPoint::zero(), IntSize(10, 10), false);
+    setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint::zero(), FloatPoint(30, 30), IntSize(10, 10), false);
+
+    parent->createRenderSurface();
+    parent->setClipRect(IntRect(0, 0, 10, 10));
+    parent->addChild(renderSurface1);
+    renderSurface1->createRenderSurface();
+    renderSurface1->addChild(child);
+
+    Vector<RefPtr<LayerChromium> > renderSurfaceLayerList;
+    Vector<RefPtr<LayerChromium> > dummyLayerList;
+    int dummyMaxTextureSize = 512;
+    CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize);
+
+    // The child layer's content is entirely outside the parent's clip rect, so the intermediate
+    // render surface should have been removed. Render surfaces without children or visible
+    // content are unexpected at draw time (e.g. we might try to create a content texture of size 0).
+    ASSERT_FALSE(renderSurface1->renderSurface());
+    EXPECT_EQ(renderSurfaceLayerList.size(), 0U);
+}
+
 // FIXME:
 // continue working on https://bugs.webkit.org/show_bug.cgi?id=68942
 //  - add a test to verify clipping that changes the "center point"
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to