Title: [123685] trunk/Source
Revision
123685
Author
[email protected]
Date
2012-07-25 17:53:47 -0700 (Wed, 25 Jul 2012)

Log Message

[chromium] Make all compositor screen space transforms operate on content rects
https://bugs.webkit.org/show_bug.cgi?id=91807

Reviewed by Kenneth Russell.

Source/WebCore:

Previously, surface screen space transforms operated on surface
content space but layer screen space transforms operated on layer
space. For the purpose of consistency, unify these two so that they
both operate on content space.

No tests, because no change in behavior expected. Just a refactoring.

* platform/graphics/chromium/LayerChromium.h:
(LayerChromium):
* platform/graphics/chromium/cc/CCDebugRectHistory.cpp:
(WebCore::CCDebugRectHistory::savePaintRects):
(WebCore::CCDebugRectHistory::savePropertyChangedRects):
* platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
(WebCore::calculateDrawTransformsInternal):
(WebCore::CCLayerTreeHostCommon::findLayerThatIsHitByPoint):
* platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
(WebCore::::markOccludedBehindLayer):
(WebCore::::occluded):
(WebCore::::unoccludedContentRect):

Source/WebKit/chromium:

Update tests that deal with screen space transforms to reflect this change.

* tests/CCLayerTreeHostCommonTest.cpp:
* tests/TiledLayerChromiumTest.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (123684 => 123685)


--- trunk/Source/WebCore/ChangeLog	2012-07-26 00:30:35 UTC (rev 123684)
+++ trunk/Source/WebCore/ChangeLog	2012-07-26 00:53:47 UTC (rev 123685)
@@ -1,3 +1,30 @@
+2012-07-19  Adrienne Walker  <[email protected]>
+
+        [chromium] Make all compositor screen space transforms operate on content rects
+        https://bugs.webkit.org/show_bug.cgi?id=91807
+
+        Reviewed by Kenneth Russell.
+
+        Previously, surface screen space transforms operated on surface
+        content space but layer screen space transforms operated on layer
+        space. For the purpose of consistency, unify these two so that they
+        both operate on content space.
+
+        No tests, because no change in behavior expected. Just a refactoring.
+
+        * platform/graphics/chromium/LayerChromium.h:
+        (LayerChromium):
+        * platform/graphics/chromium/cc/CCDebugRectHistory.cpp:
+        (WebCore::CCDebugRectHistory::savePaintRects):
+        (WebCore::CCDebugRectHistory::savePropertyChangedRects):
+        * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
+        (WebCore::calculateDrawTransformsInternal):
+        (WebCore::CCLayerTreeHostCommon::findLayerThatIsHitByPoint):
+        * platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
+        (WebCore::::markOccludedBehindLayer):
+        (WebCore::::occluded):
+        (WebCore::::unoccludedContentRect):
+
 2012-07-25  Dan Bernstein  <[email protected]>
 
         Hit testing in one column or in the gap between cloumns along the block axis can return a result from the wrong column

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h (123684 => 123685)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2012-07-26 00:30:35 UTC (rev 123684)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h	2012-07-26 00:53:47 UTC (rev 123685)
@@ -247,7 +247,7 @@
     // root render surface, then this converts to physical pixels).
     const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; }
     void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_drawTransform = matrix; }
-    // This moves from layer space, with origin the top left to screen space with origin in the top left.
+    // This moves from content space, with origin the top left to screen space with origin in the top left.
     // It converts logical, non-page-scaled pixels to physical pixels.
     const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; }
     void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix) { m_screenSpaceTransform = matrix; }

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCDebugRectHistory.cpp (123684 => 123685)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCDebugRectHistory.cpp	2012-07-26 00:30:35 UTC (rev 123684)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCDebugRectHistory.cpp	2012-07-26 00:53:47 UTC (rev 123685)
@@ -67,8 +67,11 @@
     // regardless of whether this layer is skipped for actual drawing or not. Therefore
     // we traverse recursively over all layers, not just the render surface list.
 
-    if (!layer->updateRect().isEmpty() && layer->drawsContent())
-        m_debugRects.append(CCDebugRect(PaintRectType, CCMathUtil::mapClippedRect(layer->screenSpaceTransform(), layer->updateRect())));
+    if (!layer->updateRect().isEmpty() && layer->drawsContent()) {
+        FloatRect updateContentRect = layer->updateRect();
+        updateContentRect.scale(layer->contentBounds().width() / static_cast<float>(layer->bounds().width()), layer->contentBounds().height() / static_cast<float>(layer->bounds().height()));
+        m_debugRects.append(CCDebugRect(PaintRectType, CCMathUtil::mapClippedRect(layer->screenSpaceTransform(), updateContentRect)));
+    }
 
     for (unsigned i = 0; i < layer->children().size(); ++i)
         savePaintRects(layer->children()[i].get());
@@ -92,7 +95,7 @@
                 continue;
 
             if (layer->layerPropertyChanged() || layer->layerSurfacePropertyChanged())
-                m_debugRects.append(CCDebugRect(PropertyChangedRectType, CCMathUtil::mapClippedRect(layer->screenSpaceTransform(), FloatRect(FloatPoint::zero(), layer->bounds()))));
+                m_debugRects.append(CCDebugRect(PropertyChangedRectType, CCMathUtil::mapClippedRect(layer->screenSpaceTransform(), FloatRect(FloatPoint::zero(), layer->contentBounds()))));
         }
     }
 }

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


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp	2012-07-26 00:30:35 UTC (rev 123684)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp	2012-07-26 00:53:47 UTC (rev 123685)
@@ -464,8 +464,8 @@
     //        Interpreting the math left-to-right, this transforms from the layer's render surface to the origin of the layer in content space.
     //
     // The screen space transform is:
-    //        M[screenspace] = M[root] * Tr[origin] * compositeLayerTransform
-    //                       = M[root] * Tr[layer->position()] * M[layer] * Tr[origin2anchor].inverse()
+    //        M[screenspace] = M[root] * Tr[origin] * compositeLayerTransform * S[content2layer]
+    //                       = M[root] * Tr[layer->position()] * M[layer] * Tr[origin2anchor].inverse() * S[content2layer]
     //
     //        Interpreting the math left-to-right, this transforms from the root render surface's content space to the local layer's origin in layer space.
     //
@@ -554,15 +554,9 @@
                                       layer->bounds().height() / static_cast<double>(layer->contentBounds().height()));
     }
 
-    // layerScreenSpaceTransform represents the transform between root layer's "screen space" and local layer space.
+    // layerScreenSpaceTransform represents the transform between root layer's "screen space" and local content space.
     WebTransformationMatrix layerScreenSpaceTransform = fullHierarchyMatrix;
     layerScreenSpaceTransform.multiply(drawTransform);
-    // The draw transform operates on content space rects. This needs to be converted to transform layer space rects.
-    // FIXME: Make layer screen space transforms operate on content space rects.
-    if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) {
-        layerScreenSpaceTransform.scaleNonUniform(layer->contentBounds().width() / static_cast<double>(layer->bounds().width()),
-                                                  layer->contentBounds().height() / static_cast<double>(layer->bounds().height()));
-    }
     layer->setScreenSpaceTransform(layerScreenSpaceTransform);
 
     bool animatingTransformToTarget = layer->transformIsAnimating();
@@ -772,15 +766,8 @@
             renderSurface->clearLayerList();
 
         renderSurface->setContentRect(clippedContentRect);
+        renderSurface->setScreenSpaceTransform(layer->screenSpaceTransform());
 
-        WebTransformationMatrix screenSpaceTransform = layer->screenSpaceTransform();
-        // FIXME: These should be consistent.
-        // The layer's screen space transform operates on layer rects, but the surfaces
-        // screen space transform operates on surface rects, which are in physical pixels,
-        // so we have to 'undo' the scale here.
-        screenSpaceTransform.scale(1 / contentsScale);
-        renderSurface->setScreenSpaceTransform(screenSpaceTransform);
-
         if (layer->replicaLayer()) {
             WebTransformationMatrix surfaceOriginToReplicaOriginTransform;
             surfaceOriginToReplicaOriginTransform.scale(contentsScale);
@@ -958,8 +945,8 @@
 
         CCLayerImpl* currentLayer = (*it);
 
-        FloatRect layerRect(FloatPoint::zero(), currentLayer->bounds());
-        if (!pointHitsRect(viewportPoint, currentLayer->screenSpaceTransform(), layerRect))
+        FloatRect contentRect(FloatPoint::zero(), currentLayer->contentBounds());
+        if (!pointHitsRect(viewportPoint, currentLayer->screenSpaceTransform(), contentRect))
             continue;
 
         // At this point, we think the point does hit the layer, but we need to walk up

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp (123684 => 123685)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp	2012-07-26 00:30:35 UTC (rev 123684)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp	2012-07-26 00:53:47 UTC (rev 123685)
@@ -265,25 +265,6 @@
     }
 }
 
-template<typename LayerType>
-static inline WebTransformationMatrix contentToScreenSpaceTransform(const LayerType* layer)
-{
-    ASSERT(layerTransformsToScreenKnown(layer));
-    IntSize boundsInLayerSpace = layer->bounds();
-    IntSize boundsInContentSpace = layer->contentBounds();
-
-    WebTransformationMatrix transform = layer->screenSpaceTransform();
-
-    if (boundsInContentSpace.isEmpty())
-        return transform;
-
-    // Scale from content space to layer space
-    transform.scaleNonUniform(boundsInLayerSpace.width() / static_cast<double>(boundsInContentSpace.width()),
-                              boundsInLayerSpace.height() / static_cast<double>(boundsInContentSpace.height()));
-
-    return transform;
-}
-
 // FIXME: Remove usePaintTracking when paint tracking is on for paint culling.
 template<typename LayerType>
 static inline void addOcclusionBehindLayer(Region& region, const LayerType* layer, const WebTransformationMatrix& transform, const Region& opaqueContents, const IntRect& scissorRect, const IntSize& minimumTrackingSize, Vector<IntRect>* occludingScreenSpaceRects)
@@ -342,7 +323,7 @@
         if (clipped || !scissorInScreenQuad.isRectilinear())
             return;
         IntRect scissorInScreenRect = intersection(m_scissorRectInScreenSpace, enclosedIntRect(scissorInScreenQuad.boundingBox()));
-        addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInScreen, layer, contentToScreenSpaceTransform<LayerType>(layer), opaqueContents, scissorInScreenRect, m_minimumTrackingSize, m_occludingScreenSpaceRects);
+        addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInScreen, layer, layer->screenSpaceTransform(), opaqueContents, scissorInScreenRect, m_minimumTrackingSize, m_occludingScreenSpaceRects);
     }
 }
 
@@ -371,7 +352,7 @@
     if (layerTransformsToTargetKnown(layer) && testContentRectOccluded(contentRect, layer->drawTransform(), layerScissorRectInTargetSurface(layer), m_stack.last().occlusionInTarget))
         return true;
 
-    if (layerTransformsToScreenKnown(layer) && testContentRectOccluded(contentRect, contentToScreenSpaceTransform<LayerType>(layer), m_scissorRectInScreenSpace, m_stack.last().occlusionInScreen)) {
+    if (layerTransformsToScreenKnown(layer) && testContentRectOccluded(contentRect, layer->screenSpaceTransform(), m_scissorRectInScreenSpace, m_stack.last().occlusionInScreen)) {
         if (hasOcclusionFromOutsideTargetSurface)
             *hasOcclusionFromOutsideTargetSurface = true;
         return true;
@@ -418,7 +399,7 @@
 
     IntRect unoccludedInScreen = contentRect;
     if (layerTransformsToScreenKnown(layer))
-        unoccludedInScreen = computeUnoccludedContentRect(contentRect, contentToScreenSpaceTransform<LayerType>(layer), m_scissorRectInScreenSpace, m_stack.last().occlusionInScreen);
+        unoccludedInScreen = computeUnoccludedContentRect(contentRect, layer->screenSpaceTransform(), m_scissorRectInScreenSpace, m_stack.last().occlusionInScreen);
 
     IntRect unoccludedInTarget = contentRect;
     if (layerTransformsToTargetKnown(layer))

Modified: trunk/Source/WebKit/chromium/ChangeLog (123684 => 123685)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-07-26 00:30:35 UTC (rev 123684)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-07-26 00:53:47 UTC (rev 123685)
@@ -1,3 +1,15 @@
+2012-07-19  Adrienne Walker  <[email protected]>
+
+        [chromium] Make all compositor screen space transforms operate on content rects
+        https://bugs.webkit.org/show_bug.cgi?id=91807
+
+        Reviewed by Kenneth Russell.
+
+        Update tests that deal with screen space transforms to reflect this change.
+
+        * tests/CCLayerTreeHostCommonTest.cpp:
+        * tests/TiledLayerChromiumTest.cpp:
+
 2012-07-25  Andrew Wilson  <[email protected]>
 
         Unreviewed chromium change to disable failing WebViewTest.AutoResizeInBetweenSizes.

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp (123684 => 123685)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp	2012-07-26 00:30:35 UTC (rev 123684)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp	2012-07-26 00:53:47 UTC (rev 123685)
@@ -2806,8 +2806,7 @@
     // screenSpaceTransform converts from the layer's origin space to screen space. This
     // test makes sure that hit testing works correctly accounts for the contents scale.
     // A contentsScale that is not 1 effectively forces a non-identity transform between
-    // layer's content space and layer's origin space, which is not included in the
-    // screenSpaceTransform. The hit testing code must take this into account.
+    // layer's content space and layer's origin space. The hit testing code must take this into account.
     //
     // To test this, the layer is positioned at (25, 25), and is size (50, 50). If
     // contentsScale is ignored, then hit testing will mis-interpret the visibleContentRect
@@ -3304,19 +3303,15 @@
     EXPECT_EQ(1u, renderSurfaceLayerList.size());
 
     // Verify parent transforms
-    WebTransformationMatrix expectedParentScreenSpaceTransform;
-    expectedParentScreenSpaceTransform.setM11(deviceScaleFactor);
-    expectedParentScreenSpaceTransform.setM22(deviceScaleFactor);
-    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentScreenSpaceTransform, parent->screenSpaceTransform());
-    WebTransformationMatrix expectedParentDrawTransform;
-    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentDrawTransform, parent->drawTransform());
+    WebTransformationMatrix expectedParentTransform;
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpaceTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransform());
 
     // Verify results of transformed parent rects
-    IntRect parentBounds(IntPoint(), parent->bounds());
-    IntRect parentContentBounds(IntPoint(), parent->contentBounds());
+    FloatRect parentContentBounds(FloatPoint(), FloatSize(parent->contentBounds()));
 
-    FloatRect parentDrawRect = CCMathUtil::mapClippedRect(parent->drawTransform(), FloatRect(parentContentBounds));
-    FloatRect parentScreenSpaceRect = CCMathUtil::mapClippedRect(parent->screenSpaceTransform(), FloatRect(parentBounds));
+    FloatRect parentDrawRect = CCMathUtil::mapClippedRect(parent->drawTransform(), parentContentBounds);
+    FloatRect parentScreenSpaceRect = CCMathUtil::mapClippedRect(parent->screenSpaceTransform(), parentContentBounds);
 
     FloatRect expectedParentDrawRect(FloatPoint(), parent->bounds());
     expectedParentDrawRect.scale(deviceScaleFactor);
@@ -3324,22 +3319,16 @@
     EXPECT_FLOAT_RECT_EQ(expectedParentDrawRect, parentScreenSpaceRect);
 
     // Verify child transforms
-    WebTransformationMatrix expectedChildScreenSpaceTransform;
-    expectedChildScreenSpaceTransform.setM11(deviceScaleFactor);
-    expectedChildScreenSpaceTransform.setM22(deviceScaleFactor);
-    expectedChildScreenSpaceTransform.translate(child->position().x(), child->position().y());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->screenSpaceTransform());
+    WebTransformationMatrix expectedChildTransform;
+    expectedChildTransform.translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->screenSpaceTransform());
 
-    WebTransformationMatrix expectedChildDrawTransform;
-    expectedChildDrawTransform.translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildDrawTransform, child->drawTransform());
-
     // Verify results of transformed child rects
-    IntRect childBounds(IntPoint(), child->bounds());
-    IntRect childContentBounds(IntPoint(), child->contentBounds());
+    FloatRect childContentBounds(FloatPoint(), FloatSize(child->contentBounds()));
 
-    FloatRect childDrawRect = CCMathUtil::mapClippedRect(child->drawTransform(), FloatRect(childContentBounds));
-    FloatRect childScreenSpaceRect = CCMathUtil::mapClippedRect(child->screenSpaceTransform(), FloatRect(childBounds));
+    FloatRect childDrawRect = CCMathUtil::mapClippedRect(child->drawTransform(), childContentBounds);
+    FloatRect childScreenSpaceRect = CCMathUtil::mapClippedRect(child->screenSpaceTransform(), childContentBounds);
 
     FloatRect expectedChildDrawRect(FloatPoint(), child->bounds());
     expectedChildDrawRect.move(child->position().x(), child->position().y());
@@ -3349,11 +3338,11 @@
 
     // Verify childNoScale transforms
     WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform();
-    // drawTransform transforms on content rects. The child's content rect
+    // All transforms operate on content rects. The child's content rect
     // incorporates device scale, but the childNoScale does not; add it here.
     expectedChildNoScaleTransform.scale(deviceScaleFactor);
-    EXPECT_TRANSFORMATION_MATRIX_EQ(childNoScale->drawTransform(), expectedChildNoScaleTransform);
-    EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), childNoScale->screenSpaceTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildNoScaleTransform, childNoScale->screenSpaceTransform());
 }
 
 TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
@@ -3396,21 +3385,15 @@
     // render surface (it needs one because it has a replica layer).
     EXPECT_EQ(2u, renderSurfaceLayerList.size());
 
-    WebTransformationMatrix expectedParentScreenSpaceTransform;
-    expectedParentScreenSpaceTransform.setM11(deviceScaleFactor);
-    expectedParentScreenSpaceTransform.setM22(deviceScaleFactor);
-    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentScreenSpaceTransform, parent->screenSpaceTransform());
+    WebTransformationMatrix expectedParentTransform;
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->screenSpaceTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentTransform, parent->drawTransform());
 
-    WebTransformationMatrix expectedParentDrawTransform;
-    EXPECT_TRANSFORMATION_MATRIX_EQ(parent->drawTransform(), expectedParentDrawTransform);
-
     WebTransformationMatrix expectedDrawTransform;
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform());
 
     WebTransformationMatrix expectedScreenSpaceTransform;
-    expectedScreenSpaceTransform.setM11(deviceScaleFactor);
-    expectedScreenSpaceTransform.setM22(deviceScaleFactor);
-    expectedScreenSpaceTransform.translate(child->position().x(), child->position().y());
+    expectedScreenSpaceTransform.translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenSpaceTransform());
 
     WebTransformationMatrix expectedDuplicateChildDrawTransform = child->drawTransform();

Modified: trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp (123684 => 123685)


--- trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp	2012-07-26 00:30:35 UTC (rev 123684)
+++ trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp	2012-07-26 00:53:47 UTC (rev 123685)
@@ -1232,6 +1232,10 @@
     // pixels, which means none should be occluded.
     layer->setContentsScale(0.5);
     layer->setBounds(IntSize(600, 600));
+    WebTransformationMatrix drawTransform;
+    drawTransform.scale(1 / layer->contentsScale());
+    layer->setDrawTransform(drawTransform);
+    layer->setScreenSpaceTransform(drawTransform);
 
     occluded.setOcclusion(IntRect(200, 200, 300, 100));
     layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to