RESOLVED FIXED 83494
[chromium] Make culling work with clipped rects
https://bugs.webkit.org/show_bug.cgi?id=83494
Summary [chromium] Make culling work with clipped rects
Dana Jansens
Reported 2012-04-09 11:58:21 PDT
Reattmpting to land this with fixed unit tests. - CCQuadCuller tests were violating asserts by not setting the targetRenderSurface on all the layers. - CCOcclusionTracker tests were failing randomly due to uninitialied "clipped" value if you called CCMathUtil::mapQuad() with an identity or translation matrix.
Attachments
Patch (31.79 KB, patch)
2012-04-09 12:03 PDT, Dana Jansens
no flags
Dana Jansens
Comment 1 2012-04-09 12:00:12 PDT
here's the diff: diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCMathUtil.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCMathUtil.cpp index f26e7c3..aa90e47 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCMathUtil.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCMathUtil.cpp @@ -221,6 +221,7 @@ FloatQuad CCMathUtil::mapQuad(const TransformationMatrix& transform, const Float if (transform.isIdentityOrTranslation()) { FloatQuad mappedQuad(q); mappedQuad.move(static_cast<float>(transform.m41()), static_cast<float>(transform.m42())); + clipped = false; return mappedQuad; } diff --git a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp index 51cbc8b..aca196f 100644 --- a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp +++ b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp @@ -44,9 +44,6 @@ public: : CCOcclusionTrackerImpl(scissorRectInScreen, recordMetricsForFrame) , m_scissorRectInScreen(scissorRectInScreen) { - // Pretend we have visited the root render surface. - m_stack.append(StackObject()); - m_stack.last().surface = new CCRenderSurface(0); } protected: @@ -56,7 +53,7 @@ private: IntRect m_scissorRectInScreen; }; -static PassOwnPtr<CCTiledLayerImpl> makeLayer(const TransformationMatrix& drawTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect) +static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const TransformationMatrix& drawTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect) { OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(0); OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::NoBorderTexels); @@ -76,6 +73,12 @@ static PassOwnPtr<CCTiledLayerImpl> makeLayer(const TransformationMatrix& drawTr layer->pushTileProperties(i, j, static_cast<Platform3DObject>(textureId++), tileOpaqueRect); } + if (!parent) { + layer->createRenderSurface(); + layer->setTargetRenderSurface(layer->renderSurface()); + } else + layer->setTargetRenderSurface(parent->targetRenderSurface()); + return layer.release(); } @@ -102,9 +105,10 @@ TEST(CCQuadCullerTest, verifyNoCulling) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); appendQuads(quadList, sharedStateList, rootLayer.get(), occlusionTracker); @@ -118,9 +122,10 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpTopLeft) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -135,9 +140,10 @@ TEST(CCQuadCullerTest, verifyCullWhenChildOpacityNotOne) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 0.9, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 0.9, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -152,9 +158,10 @@ TEST(CCQuadCullerTest, verifyCullWhenChildOpaqueFlagFalse) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, false, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -171,9 +178,10 @@ TEST(CCQuadCullerTest, verifyCullCenterTileOnly) childTransform.translate(50, 50); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -214,9 +222,10 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize1) rootRect = childRect = IntRect(0, 0, 100, 100); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(rootTransform, rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -242,9 +251,10 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize2) rootRect = childRect = IntRect(0, 0, 100, 100); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(rootTransform, rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, rootTransform, rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -262,9 +272,10 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpBottomRight) childTransform.translate(100, 100); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -281,10 +292,11 @@ TEST(CCQuadCullerTest, verifyCullSubRegion) childTransform.translate(50, 50); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, false, childOpaqueRect); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, childOpaqueRect); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -301,10 +313,11 @@ TEST(CCQuadCullerTest, verifyCullSubRegion2) childTransform.translate(50, 10); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() * 3 / 4); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, false, childOpaqueRect); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, childOpaqueRect); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -321,10 +334,11 @@ TEST(CCQuadCullerTest, verifyCullSubRegionCheckOvercull) childTransform.translate(50, 49); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); IntRect childOpaqueRect(childRect.x() + childRect.width() / 4, childRect.y() + childRect.height() / 4, childRect.width() / 2, childRect.height() / 2); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, false, childOpaqueRect); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, false, childOpaqueRect); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -342,9 +356,10 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude) // Use a small rotation so as to not disturb the geometry significantly. childTransform.rotate(1); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(childTransform, childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), childTransform, childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -368,9 +383,10 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsSafelyCulled) TransformationMatrix parentTransform; parentTransform.rotate(1); - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(parentTransform, rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, parentTransform, rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(-100, -100, 1000, 1000)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -385,9 +401,10 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverTile) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(200, 100, 100, 100)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -402,9 +419,10 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverCulledTile) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(100, 100, 100, 100)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -419,9 +437,10 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverPartialTiles) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(50, 50, 200, 200)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -436,9 +455,10 @@ TEST(CCQuadCullerTest, verifyCullOutsideScissorOverNoTiles) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(500, 500, 100, 100)); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get()); @@ -453,9 +473,10 @@ TEST(CCQuadCullerTest, verifyWithoutMetrics) { DECLARE_AND_INITIALIZE_TEST_QUADS - OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(TransformationMatrix(), rootRect, 1.0, true, IntRect()); - OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(TransformationMatrix(), childRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> rootLayer = makeLayer(0, TransformationMatrix(), rootRect, 1.0, true, IntRect()); + OwnPtr<CCTiledLayerImpl> childLayer = makeLayer(rootLayer.get(), TransformationMatrix(), childRect, 1.0, true, IntRect()); TestCCOcclusionTrackerImpl occlusionTracker(IntRect(50, 50, 200, 200), false); + occlusionTracker.enterTargetRenderSurface(rootLayer->renderSurface()); appendQuads(quadList, sharedStateList, childLayer.get(), occlusionTracker); occlusionTracker.markOccludedBehindLayer(childLayer.get());
Dana Jansens
Comment 2 2012-04-09 12:03:36 PDT
Build Bot
Comment 3 2012-04-09 12:27:58 PDT
Dana Jansens
Comment 4 2012-04-09 12:31:22 PDT
Comment on attachment 136280 [details] Patch The mac bot segfaulted in make make: *** [DOMCSSValueList.h] Segmentation fault: 11 I can reupload if you like?
Adrienne Walker
Comment 5 2012-04-09 12:40:45 PDT
Comment on attachment 136280 [details] Patch R=me. Thanks for the diff. I like that this makes the tests a little bit more real, too. No need to reupload, the CQ will yell, and there aren't changes that affect mac here.
WebKit Review Bot
Comment 6 2012-04-09 15:52:44 PDT
Comment on attachment 136280 [details] Patch Clearing flags on attachment: 136280 Committed r113637: <http://trac.webkit.org/changeset/113637>
WebKit Review Bot
Comment 7 2012-04-09 15:52:49 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.