[chromium] Incorrect replica originTransform used in CCDamageTracker
authorshawnsingh@chromium.org <shawnsingh@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Mar 2012 06:51:34 +0000 (06:51 +0000)
committershawnsingh@chromium.org <shawnsingh@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Mar 2012 06:51:34 +0000 (06:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82118

Reviewed by Adrienne Walker.

Source/WebCore:

Unit test added to CCDamageTrackerTest.cpp

* platform/graphics/chromium/cc/CCDamageTracker.cpp:
(WebCore::CCDamageTracker::extendDamageForRenderSurface):

Source/WebKit/chromium:

* tests/CCDamageTrackerTest.cpp:
(WebKitTests::TEST_F):
(WebKitTests):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/cc/CCDamageTracker.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp

index 138d641d0acbc13ad5a88ce57f00283013594767..aa6ce604515c11f7264a4cb670e8d05cb478a2f7 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-23  Shawn Singh  <shawnsingh@chromium.org>
+
+        [chromium] Incorrect replica originTransform used in CCDamageTracker
+        https://bugs.webkit.org/show_bug.cgi?id=82118
+
+        Reviewed by Adrienne Walker.
+
+        Unit test added to CCDamageTrackerTest.cpp
+
+        * platform/graphics/chromium/cc/CCDamageTracker.cpp:
+        (WebCore::CCDamageTracker::extendDamageForRenderSurface):
+
 2012-03-23  Dana Jansens  <danakj@chromium.org>
 
         [chromium] When prepainting fails, tiles dirty rects may be cleared
index 1ff2ffc8b480fe54790aeba0caf0593f90e42972..d4b4cf916b12b13af7dfa62ade5326301ffb9c16 100644 (file)
@@ -297,11 +297,7 @@ void CCDamageTracker::extendDamageForRenderSurface(CCLayerImpl* layer, FloatRect
         removeRectFromCurrentFrame(replicaMaskLayer->id(), replicaIsNew);
 
         // Compute the replica's "originTransform" that maps from the replica's origin space to the target surface origin space.
-        TransformationMatrix replicaOriginTransform = layer->renderSurface()->originTransform();
-        replicaOriginTransform.translate(layer->replicaLayer()->position().x(), layer->replicaLayer()->position().y());
-        replicaOriginTransform.multiply(layer->replicaLayer()->transform());
-        replicaOriginTransform.translate(-layer->replicaLayer()->position().x(), -layer->replicaLayer()->position().y());
-
+        const TransformationMatrix& replicaOriginTransform = renderSurface->replicaOriginTransform();
         FloatRect replicaMaskLayerRect = replicaOriginTransform.mapRect(FloatRect(FloatPoint::zero(), FloatSize(replicaMaskLayer->bounds().width(), replicaMaskLayer->bounds().height())));
         saveRectForNextFrame(replicaMaskLayer->id(), replicaMaskLayerRect);
 
index 840c6acefefa8348404e5ca56936ee88613bbc7f..0c70d3ce906ebc315812b519731f5a7209dede31 100644 (file)
@@ -1,3 +1,14 @@
+2012-03-23  Shawn Singh  <shawnsingh@chromium.org>
+
+        [chromium] Incorrect replica originTransform used in CCDamageTracker
+        https://bugs.webkit.org/show_bug.cgi?id=82118
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCDamageTrackerTest.cpp:
+        (WebKitTests::TEST_F):
+        (WebKitTests):
+
 2012-03-23  Dana Jansens  <danakj@chromium.org>
 
         [chromium] When prepainting fails, tiles dirty rects may be cleared
index cdef13c0a03f4828b11766175e3a5557ea08c39e..26955985c291c713eb9fc1d181d163e485a14bb0 100644 (file)
@@ -797,6 +797,56 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask)
     EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect);
 }
 
+TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMaskWithAnchor)
+{
+    OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithTwoSurfaces();
+    CCLayerImpl* child1 = root->children()[0].get();
+    CCLayerImpl* grandChild1 = child1->children()[0].get();
+
+    // Verify that the correct replicaOriginTransform is used for the replicaMask; the
+    // incorrect old code did not actually correctly account for the anchor for the
+    // replica.
+    //
+    // Create a reflection about the left edge, but the anchor point is shifted all the
+    // way to the right. this case the reflection should be directly on top (but
+    // horizontally flipped) of grandChild1.
+
+    grandChild1->setAnchorPoint(FloatPoint(1.0, 0.0)); // This is the anchor being tested.
+
+    {
+        OwnPtr<CCLayerImpl> grandChild1Replica = CCLayerImpl::create(6);
+        grandChild1Replica->setPosition(FloatPoint::zero());
+        grandChild1Replica->setAnchorPoint(FloatPoint::zero()); // note, this is not the anchor being tested.
+        TransformationMatrix reflection;
+        reflection.scale3d(-1.0, 1.0, 1.0);
+        grandChild1Replica->setTransform(reflection);
+        grandChild1->setReplicaLayer(grandChild1Replica.release());
+    }
+    CCLayerImpl* grandChild1Replica = grandChild1->replicaLayer();
+
+    // Set up the mask layer on the replica layer
+    {
+        OwnPtr<CCLayerImpl> replicaMaskLayer = CCLayerImpl::create(7);
+        replicaMaskLayer->setPosition(FloatPoint::zero());
+        replicaMaskLayer->setAnchorPoint(FloatPoint::zero()); // note, this is not the anchor being tested.
+        replicaMaskLayer->setBounds(grandChild1->bounds());
+        grandChild1Replica->setMaskLayer(replicaMaskLayer.release());
+    }
+    CCLayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer();
+
+    emulateDrawingOneFrame(root.get());
+
+    // Sanity check that the appropriate render surfaces were created
+    ASSERT_TRUE(grandChild1->renderSurface());
+
+    // A property change on the replicaMask should damage the reflected region on the target surface.
+    replicaMaskLayer->setOpacity(0.6);
+    emulateDrawingOneFrame(root.get());
+
+    FloatRect childDamageRect = child1->renderSurface()->damageTracker()->currentDamageRect();
+    EXPECT_FLOAT_RECT_EQ(FloatRect(194, 200, 6, 8), childDamageRect);
+}
+
 TEST_F(CCDamageTrackerTest, verifyDamageWhenForcedFullDamage)
 {
     OwnPtr<CCLayerImpl> root = createAndSetUpTestTreeWithOneSurface();