[chromium] Unify compositor quadTransform/drawTransform/originTransform
authorenne@google.com <enne@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jul 2012 17:07:29 +0000 (17:07 +0000)
committerenne@google.com <enne@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Jul 2012 17:07:29 +0000 (17:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91417

Reviewed by Kenneth Russell.

Source/WebCore:

drawTransform used to operate on centered layer rects. To unify quad
transforms, draw transforms, and origin transforms, make draw
transforms operate on content rects with the origin in the top left.

This essentially eliminates the need for surface origin transforms,
which will be eliminated in a future patch.

Also, remove the unused CCLayerImpl::getDrawRect function.

No-op refactoring. Tested by existing tests.

* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::drawRenderPassQuad):
* platform/graphics/chromium/RenderSurfaceChromium.cpp:
(WebCore::RenderSurfaceChromium::drawableContentRect):
* platform/graphics/chromium/cc/CCDamageTracker.cpp:
(WebCore::CCDamageTracker::extendDamageForLayer):
* platform/graphics/chromium/cc/CCLayerImpl.cpp:
(WebCore::CCLayerImpl::createSharedQuadState):
* platform/graphics/chromium/cc/CCLayerImpl.h:
(CCLayerImpl):
* platform/graphics/chromium/cc/CCLayerSorter.cpp:
(WebCore::CCLayerSorter::LayerShape::LayerShape):
(WebCore::CCLayerSorter::createGraphNodes):
* platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
(WebCore::calculateVisibleContentRect):
(WebCore::calculateDrawTransformsInternal):
* platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
(WebCore::::markOccludedBehindLayer):
(WebCore::::occluded):
(WebCore::::unoccludedContentRect):
* platform/graphics/chromium/cc/CCRenderPass.cpp:
(WebCore::CCRenderPass::appendQuadsToFillScreen):
* platform/graphics/chromium/cc/CCRenderSurface.cpp:
(WebCore::CCRenderSurface::drawableContentRect):

Source/WebKit/chromium:

Clean up tests to refer to the new draw transform semantics.

* tests/CCDamageTrackerTest.cpp:
(WebKitTests::createTestTreeWithOneSurface):
(WebKitTests::createTestTreeWithTwoSurfaces):
(WebKitTests::TEST_F):
* tests/CCLayerSorterTest.cpp:
* tests/CCLayerTreeHostCommonTest.cpp:
* tests/CCLayerTreeHostImplTest.cpp:
* tests/CCLayerTreeHostTest.cpp:
(WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::commitCompleteOnCCThread):
* tests/CCQuadCullerTest.cpp:
* tests/TiledLayerChromiumTest.cpp:

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

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp
Source/WebCore/platform/graphics/chromium/cc/CCDamageTracker.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerSorter.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp
Source/WebCore/platform/graphics/chromium/cc/CCOcclusionTracker.cpp
Source/WebCore/platform/graphics/chromium/cc/CCRenderPass.cpp
Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp
Source/WebKit/chromium/tests/CCLayerSorterTest.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
Source/WebKit/chromium/tests/CCQuadCullerTest.cpp
Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp

index 27e0dae..a053b5a 100644 (file)
@@ -1,3 +1,46 @@
+2012-07-25  Adrienne Walker  <enne@google.com>
+
+        [chromium] Unify compositor quadTransform/drawTransform/originTransform
+        https://bugs.webkit.org/show_bug.cgi?id=91417
+
+        Reviewed by Kenneth Russell.
+
+        drawTransform used to operate on centered layer rects. To unify quad
+        transforms, draw transforms, and origin transforms, make draw
+        transforms operate on content rects with the origin in the top left.
+
+        This essentially eliminates the need for surface origin transforms,
+        which will be eliminated in a future patch.
+
+        Also, remove the unused CCLayerImpl::getDrawRect function.
+
+        No-op refactoring. Tested by existing tests.
+
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::drawRenderPassQuad):
+        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
+        (WebCore::RenderSurfaceChromium::drawableContentRect):
+        * platform/graphics/chromium/cc/CCDamageTracker.cpp:
+        (WebCore::CCDamageTracker::extendDamageForLayer):
+        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
+        (WebCore::CCLayerImpl::createSharedQuadState):
+        * platform/graphics/chromium/cc/CCLayerImpl.h:
+        (CCLayerImpl):
+        * platform/graphics/chromium/cc/CCLayerSorter.cpp:
+        (WebCore::CCLayerSorter::LayerShape::LayerShape):
+        (WebCore::CCLayerSorter::createGraphNodes):
+        * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
+        (WebCore::calculateVisibleContentRect):
+        (WebCore::calculateDrawTransformsInternal):
+        * platform/graphics/chromium/cc/CCOcclusionTracker.cpp:
+        (WebCore::::markOccludedBehindLayer):
+        (WebCore::::occluded):
+        (WebCore::::unoccludedContentRect):
+        * platform/graphics/chromium/cc/CCRenderPass.cpp:
+        (WebCore::CCRenderPass::appendQuadsToFillScreen):
+        * platform/graphics/chromium/cc/CCRenderSurface.cpp:
+        (WebCore::CCRenderSurface::drawableContentRect):
+
 2012-07-25  Tommy Widenflycht  <tommyw@google.com>
 
         MediaStream API: Update MediaStreamTrack to match the specification
index e5637a0..96b50a4 100644 (file)
@@ -634,10 +634,11 @@ void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad)
     if (!contentsTexture || !contentsTexture->id())
         return;
 
-    WebTransformationMatrix renderTransform = quad->drawTransform();
-    // Apply a scaling factor to size the quad from 1x1 to its intended size.
-    renderTransform.scale3d(quad->quadRect().width(), quad->quadRect().height(), 1);
-    WebTransformationMatrix contentsDeviceTransform = WebTransformationMatrix(windowMatrix() * projectionMatrix() * renderTransform).to2dTransform();
+    WebTransformationMatrix renderMatrix = quad->quadTransform();
+    renderMatrix.translate(0.5 * quad->quadRect().width() + quad->quadRect().x(), 0.5 * quad->quadRect().height() + quad->quadRect().y());
+    WebTransformationMatrix deviceMatrix = renderMatrix;
+    deviceMatrix.scaleNonUniform(quad->quadRect().width(), quad->quadRect().height());
+    WebTransformationMatrix contentsDeviceTransform = WebTransformationMatrix(windowMatrix() * projectionMatrix() * deviceMatrix).to2dTransform();
 
     // Can only draw surface if device matrix is invertible.
     if (!contentsDeviceTransform.isInvertible())
@@ -662,7 +663,7 @@ void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad)
     if (backgroundTexture) {
         ASSERT(backgroundTexture->size() == quad->quadRect().size());
         CCScopedLockResourceForRead lock(m_resourceProvider, backgroundTexture->id());
-        copyTextureToFramebuffer(lock.textureId(), quad->quadRect().size(), quad->drawTransform());
+        copyTextureToFramebuffer(lock.textureId(), quad->quadRect().size(), renderMatrix);
     }
 
     bool clipped = false;
@@ -749,7 +750,7 @@ void LayerRendererChromium::drawRenderPassQuad(const CCRenderPassDrawQuad* quad)
     FloatQuad surfaceQuad = CCMathUtil::mapQuad(contentsDeviceTransform.inverse(), deviceLayerEdges.floatQuad(), clipped);
     ASSERT(!clipped);
 
-    drawTexturedQuad(quad->drawTransform(), quad->quadRect().width(), quad->quadRect().height(), quad->opacity(), surfaceQuad,
+    drawTexturedQuad(renderMatrix, quad->quadRect().width(), quad->quadRect().height(), quad->opacity(), surfaceQuad,
                      shaderMatrixLocation, shaderAlphaLocation, shaderQuadLocation);
 }
 
index f7aebee..7c280a0 100644 (file)
@@ -54,12 +54,9 @@ RenderSurfaceChromium::~RenderSurfaceChromium()
 
 FloatRect RenderSurfaceChromium::drawableContentRect() const
 {
-    FloatRect localContentRect(-0.5 * m_contentRect.width(), -0.5 * m_contentRect.height(),
-                               m_contentRect.width(), m_contentRect.height());
-    FloatRect drawableContentRect = CCMathUtil::mapClippedRect(m_drawTransform, localContentRect);
-    if (m_owningLayer->replicaLayer())
-        drawableContentRect.unite(CCMathUtil::mapClippedRect(m_replicaDrawTransform, localContentRect));
-
+    FloatRect drawableContentRect = CCMathUtil::mapClippedRect(m_drawTransform, m_contentRect);
+    if (m_owningLayer->hasReplica())
+        drawableContentRect.unite(CCMathUtil::mapClippedRect(m_replicaDrawTransform, m_contentRect));
     return drawableContentRect;
 }
 
index da99426..97c99da 100644 (file)
@@ -270,27 +270,28 @@ void CCDamageTracker::extendDamageForLayer(CCLayerImpl* layer, FloatRect& target
     // To consider how a layer's targetSurface contributes to the ancestorSurface,
     // extendDamageForRenderSurface() must be called instead.
 
-    // Compute the layer's "originTransform" by translating the drawTransform.
-    WebTransformationMatrix originTransform = layer->drawTransform();
-    originTransform.translate(-0.5 * layer->bounds().width(), -0.5 * layer->bounds().height());
-
     bool layerIsNew = false;
-    FloatRect oldLayerRect = removeRectFromCurrentFrame(layer->id(), layerIsNew);
+    FloatRect oldRectInTargetSpace = removeRectFromCurrentFrame(layer->id(), layerIsNew);
 
-    FloatRect layerRectInTargetSpace = CCMathUtil::mapClippedRect(originTransform, FloatRect(FloatPoint::zero(), layer->bounds()));
-    saveRectForNextFrame(layer->id(), layerRectInTargetSpace);
+    FloatRect rectInTargetSpace = CCMathUtil::mapClippedRect(layer->drawTransform(), FloatRect(FloatPoint::zero(), layer->contentBounds()));
+    saveRectForNextFrame(layer->id(), rectInTargetSpace);
 
     if (layerIsNew || layerNeedsToRedrawOntoItsTargetSurface(layer)) {
         // If a layer is new or has changed, then its entire layer rect affects the target surface.
-        targetDamageRect.uniteIfNonZero(layerRectInTargetSpace);
+        targetDamageRect.uniteIfNonZero(rectInTargetSpace);
 
         // The layer's old region is now exposed on the target surface, too.
-        // Note oldLayerRect is already in target space.
-        targetDamageRect.uniteIfNonZero(oldLayerRect);
+        // Note oldRectInTargetSpace is already in target space.
+        targetDamageRect.uniteIfNonZero(oldRectInTargetSpace);
     } else if (!layer->updateRect().isEmpty()) {
         // If the layer properties havent changed, then the the target surface is only
         // affected by the layer's update area, which could be empty.
-        FloatRect updateRectInTargetSpace = CCMathUtil::mapClippedRect(originTransform, layer->updateRect());
+        FloatRect updateContentRect = layer->updateRect();
+        float widthScale = layer->contentBounds().width() / static_cast<float>(layer->bounds().width());
+        float heightScale = layer->contentBounds().height() / static_cast<float>(layer->bounds().height());
+        updateContentRect.scale(widthScale, heightScale);
+
+        FloatRect updateRectInTargetSpace = CCMathUtil::mapClippedRect(layer->drawTransform(), updateContentRect);
         targetDamageRect.uniteIfNonZero(updateRectInTargetSpace);
     }
 }
index 8a05a88..23a38a2 100644 (file)
@@ -146,14 +146,7 @@ bool CCLayerImpl::descendantDrawsContent()
 
 PassOwnPtr<CCSharedQuadState> CCLayerImpl::createSharedQuadState(int id) const
 {
-    WebTransformationMatrix quadTransformation = drawTransform();
-    if (!contentBounds().isEmpty() && !bounds().isEmpty()) {
-        quadTransformation.scaleNonUniform(bounds().width() / static_cast<double>(contentBounds().width()),
-                                           bounds().height() / static_cast<double>(contentBounds().height()));
-        quadTransformation.translate(-contentBounds().width() / 2.0, -contentBounds().height() / 2.0);
-    }
-
-    return CCSharedQuadState::create(id, quadTransformation, m_visibleContentRect, m_scissorRect, m_drawOpacity, m_opaque);
+    return CCSharedQuadState::create(id, m_drawTransform, m_visibleContentRect, m_scissorRect, m_drawOpacity, m_opaque);
 }
 
 void CCLayerImpl::willDraw(CCResourceProvider*)
@@ -232,15 +225,6 @@ CCInputHandlerClient::ScrollStatus CCLayerImpl::tryScroll(const IntPoint& viewpo
     return CCInputHandlerClient::ScrollStarted;
 }
 
-const IntRect CCLayerImpl::getDrawRect() const
-{
-    // Form the matrix used by the shader to map the corners of the layer's
-    // bounds into the view space.
-    FloatRect layerRect(-0.5 * bounds().width(), -0.5 * bounds().height(), bounds().width(), bounds().height());
-    IntRect mappedRect = enclosingIntRect(CCMathUtil::mapClippedRect(drawTransform(), layerRect));
-    return mappedRect;
-}
-
 void CCLayerImpl::writeIndent(TextStream& ts, int indent)
 {
     for (int i = 0; i != indent; ++i)
index 25bedc2..a2622ea 100644 (file)
@@ -230,9 +230,6 @@ public:
     bool doubleSided() const { return m_doubleSided; }
     void setDoubleSided(bool);
 
-    // Returns the rect containtaining this layer in the current view's coordinate system.
-    const IntRect getDrawRect() const;
-
     void setTransform(const WebKit::WebTransformationMatrix&);
     bool transformIsAnimating() const;
 
index fdf3c7b..48802d6 100644 (file)
@@ -154,10 +154,7 @@ CCLayerSorter::ABCompareResult CCLayerSorter::checkOverlap(LayerShape* a, LayerS
 
 CCLayerSorter::LayerShape::LayerShape(float width, float height, const WebTransformationMatrix& drawTransform)
 {
-    FloatQuad layerQuad(FloatPoint(-width * 0.5, height * 0.5),
-                        FloatPoint(width * 0.5, height * 0.5),
-                        FloatPoint(width * 0.5, -height * 0.5),
-                        FloatPoint(-width * 0.5, -height * 0.5));
+    FloatQuad layerQuad(FloatRect(0, 0, width, height));
 
     // Compute the projection of the layer quad onto the z = 0 plane.
 
@@ -245,8 +242,8 @@ void CCLayerSorter::createGraphNodes(LayerList::iterator first, LayerList::itera
             layerHeight = renderSurface->contentRect().height();
         } else {
             drawTransform = node.layer->drawTransform();
-            layerWidth = node.layer->bounds().width();
-            layerHeight = node.layer->bounds().height();
+            layerWidth = node.layer->contentBounds().width();
+            layerHeight = node.layer->contentBounds().height();
         }
 
         node.shape = LayerShape(layerWidth, layerHeight, drawTransform);
index 343766a..9cb91f1 100644 (file)
@@ -177,18 +177,8 @@ static IntRect calculateVisibleContentRect(LayerType* layer)
     if (targetSurfaceRect.isEmpty() || layer->contentBounds().isEmpty())
         return IntRect();
 
-    // Note carefully these are aliases
-    const IntSize& bounds = layer->bounds();
-    const IntSize& contentBounds = layer->contentBounds();
-
-    const IntRect layerBoundRect = IntRect(IntPoint(), contentBounds);
-    WebTransformationMatrix transform = layer->drawTransform();
-
-    transform.scaleNonUniform(bounds.width() / static_cast<double>(contentBounds.width()),
-                              bounds.height() / static_cast<double>(contentBounds.height()));
-    transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0);
-
-    IntRect visibleContentRect = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, layerBoundRect, transform);
+    const IntRect contentRect = IntRect(IntPoint(), layer->contentBounds());
+    IntRect visibleContentRect = CCLayerTreeHostCommon::calculateVisibleRect(targetSurfaceRect, contentRect, layer->drawTransform());
     return visibleContentRect;
 }
 
@@ -433,6 +423,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
     //        M[layer] is the layer's matrix (applied at the anchor point)
     //        M[sublayer] is the layer's sublayer transform (applied at the layer's center)
     //        Tr[anchor2center] is the translation offset from the anchor point and the center of the layer
+    //        S[content2layer] is the ratio of a layer's contentBounds() to its bounds().
     //
     //    Some shortcuts and substitutions are used in the code to reduce matrix multiplications:
     //        Tr[anchor2center] = Tr[origin2anchor].inverse() * Tr[origin2center]
@@ -453,16 +444,16 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
     // Using these definitions, then:
     //
     // The draw transform for the layer is:
-    //        M[draw] = M[parent] * Tr[origin] * compositeLayerTransform * Tr[origin2center]
-    //                = M[parent] * Tr[layer->position()] * M[layer] * Tr[anchor2center]
+    //        M[draw] = M[parent] * Tr[origin] * compositeLayerTransform * S[content2layer]
+    //                = M[parent] * Tr[layer->position()] * M[layer] * Tr[anchor2origin] * S[content2layer]
     //
-    //        Interpreting the math left-to-right, this transforms from the layer's render surface to the center of the layer.
+    //        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()
     //
-    //        Interpreting the math left-to-right, this transforms from the root layer space to the local layer's origin.
+    //        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.
     //
     // The transform hierarchy that is passed on to children (i.e. the child's parentMatrix) is:
     //        M[parent]_for_child = M[parent] * Tr[origin] * compositeLayerTransform * compositeSublayerTransform
@@ -481,18 +472,14 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
     //
     // We will denote a scale by contents scale S[contentsScale]
     //
-    // The render surface origin transform to its target surface origin is:
-    //        M[surfaceOrigin] = M[owningLayer->Draw] * S[contentsScale].inverse() * Tr[origin2centerInScreenSpace].inverse()
+    // The render surface origin/draw transform to its target surface origin is:
+    //        M[surfaceOrigin] = M[owningLayer->Draw]
     //
     // The render surface origin transform to its the root (screen space) origin is:
     //        M[surface2root] =  M[owningLayer->screenspace] * S[contentsScale].inverse()
     //
-    // The replica draw transform is:
-    //        M[replicaDraw] = M[surfaceOrigin] * S[contentsScale] * Tr[replica->position() + replica->anchor()] * Tr[replica] * Tr[anchor2center] * S[contentsScale].inverse()
-    //                       = M[owningLayer->draw] * Tr[origin2center].inverse() * S[contentsScale] * Tr[replica->position() + replica->anchor()] * Tr[replica] * Tr[anchor2clippedCenter] * S[contentsScale].inverse()
-    //
-    // The replica origin transform to its target surface origin is:
-    //        M[replicaOrigin] = S[contentsScale] * M[surfaceOrigin] * Tr[replica->position() + replica->anchor()] * Tr[replica] * Tr[origin2anchor].inverse() * S[contentsScale].invers()
+    // The replica origin/draw transform to its target surface origin is:
+    //        M[replicaOrigin] = S[contentsScale] * M[surfaceOrigin] * Tr[replica->position() + replica->anchor()] * Tr[replica] * Tr[origin2anchor].inverse() * S[contentsScale].inverse()
     //
     // The replica origin transform to the root (screen space) origin is:
     //        M[replica2root] = M[surface2root] * Tr[replica->position()] * Tr[replica] * Tr[origin2anchor].inverse()
@@ -532,8 +519,6 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
     // LT = S[pageScaleDelta] * Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2center]
     layerLocalTransform.translate3d(centerOffsetX, centerOffsetY, -layer->anchorPointZ());
 
-    // The combinedTransform that gets computed below is effectively the layer's drawTransform, unless
-    // the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms.
     WebTransformationMatrix combinedTransform = parentMatrix;
     combinedTransform.multiply(layerLocalTransform);
 
@@ -544,6 +529,28 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
         combinedTransform = currentScrollCompensationMatrix * combinedTransform;
     }
 
+    // The drawTransform that gets computed below is effectively the layer's drawTransform, unless
+    // the layer itself creates a renderSurface. In that case, the renderSurface re-parents the transforms.
+    WebTransformationMatrix drawTransform = combinedTransform;
+    if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) {
+        // M[draw] = M[parent] * LT * Tr[anchor2center] * Tr[center2anchor]
+        drawTransform.translate(-layer->bounds().width() / 2.0, -layer->bounds().height() / 2.0);
+        // M[draw] = M[parent] * LT * Tr[anchor2origin] * S[content2layer]
+        drawTransform.scaleNonUniform(layer->bounds().width() / static_cast<double>(layer->contentBounds().width()),
+                                      layer->bounds().height() / static_cast<double>(layer->contentBounds().height()));
+    }
+
+    // layerScreenSpaceTransform represents the transform between root layer's "screen space" and local layer 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();
     bool animatingTransformToScreen = animatingTransformToTarget;
     if (layer->parent()) {
@@ -552,13 +559,12 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
     }
 
     float contentsScale = layer->contentsScale();
-
-    FloatRect layerRect(-0.5 * layer->bounds().width(), -0.5 * layer->bounds().height(), layer->bounds().width(), layer->bounds().height());
-    IntRect transformedLayerRect;
+    FloatRect contentRect(FloatPoint(), layer->contentBounds());
 
     // fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurface's space.
     // nextHierarchyMatrix will only change if this layer uses a new RenderSurface, otherwise remains the same.
     WebTransformationMatrix nextHierarchyMatrix = fullHierarchyMatrix;
+    WebTransformationMatrix sublayerMatrix;
 
     if (subtreeShouldRenderToSeparateSurface(layer, isScaleOrTranslation(combinedTransform))) {
         // Check back-face visibility before continuing with this surface and its subtree
@@ -572,12 +578,21 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
         renderSurface->clearLayerList();
 
         // The origin of the new surface is the upper left corner of the layer.
-        WebTransformationMatrix drawTransform;
-        drawTransform.scale(contentsScale);
-        drawTransform.translate3d(0.5 * bounds.width(), 0.5 * bounds.height(), 0);
-        layer->setDrawTransform(drawTransform);
+        renderSurface->setOriginTransform(drawTransform);
+        renderSurface->setDrawTransform(drawTransform);
+        WebTransformationMatrix layerDrawTransform;
+        layerDrawTransform.scale(contentsScale);
+        if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) {
+            layerDrawTransform.scaleNonUniform(layer->bounds().width() / static_cast<double>(layer->contentBounds().width()),
+                                               layer->bounds().height() / static_cast<double>(layer->contentBounds().height()));
+        }
+        layer->setDrawTransform(layerDrawTransform);
 
-        transformedLayerRect = IntRect(0, 0, contentsScale * bounds.width(), contentsScale * bounds.height());
+        // The sublayer matrix transforms centered layer rects into target
+        // surface content space.
+        sublayerMatrix.makeIdentity();
+        sublayerMatrix.scale(contentsScale);
+        sublayerMatrix.translate(0.5 * bounds.width(), 0.5 * bounds.height());
 
         // The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity.
         renderSurface->setDrawOpacity(drawOpacity);
@@ -585,27 +600,15 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
         layer->setDrawOpacity(1);
         layer->setDrawOpacityIsAnimating(false);
 
-        WebTransformationMatrix surfaceOriginTransform = combinedTransform;
-        // The surfaceOriginTransform transforms points in the surface's content space
-        // to its parent's content space. Distances in these spaces are both in physical
-        // pixels, so we need to 'undo' the scale by contentsScale. Ultimately, the
-        // transform should map (0, 0) to contentsScale * position, and preserve distances.
-        // Note, the following two lines are not equivalent to translating by (bounds.width(),
-        // bounds.height). The effect on m41 and m42 would be identical, but the scale
-        // affects the entire matrix. We need to scale these other entries to avoid
-        // double scaling; we must remain in physical pixels.
-        surfaceOriginTransform.scale(1 / contentsScale);
-        surfaceOriginTransform.translate3d(-0.5 * transformedLayerRect.width(), -0.5 * transformedLayerRect.height(), 0);
-        renderSurface->setOriginTransform(surfaceOriginTransform);
-
         renderSurface->setTargetSurfaceTransformsAreAnimating(animatingTransformToTarget);
         renderSurface->setScreenSpaceTransformsAreAnimating(animatingTransformToScreen);
         animatingTransformToTarget = false;
         layer->setDrawTransformIsAnimating(animatingTransformToTarget);
         layer->setScreenSpaceTransformIsAnimating(animatingTransformToScreen);
 
-        // Update the aggregate hierarchy matrix to include the transform of the newly created RenderSurface.
-        nextHierarchyMatrix.multiply(surfaceOriginTransform);
+        // Update the aggregate hierarchy matrix to include the transform of the
+        // newly created RenderSurface.
+        nextHierarchyMatrix.multiply(renderSurface->originTransform());
 
         // The new renderSurface here will correctly clip the entire subtree. So, we do
         // not need to continue propagating the clipping state further down the tree. This
@@ -626,10 +629,10 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
 
         renderSurfaceLayerList.append(layer);
     } else {
-        layer->setDrawTransform(combinedTransform);
+        layer->setDrawTransform(drawTransform);
         layer->setDrawTransformIsAnimating(animatingTransformToTarget);
         layer->setScreenSpaceTransformIsAnimating(animatingTransformToScreen);
-        transformedLayerRect = enclosingIntRect(CCMathUtil::mapClippedRect(layer->drawTransform(), layerRect));
+        sublayerMatrix = combinedTransform;
 
         layer->setDrawOpacity(drawOpacity);
         layer->setDrawOpacityIsAnimating(drawOpacityIsAnimating);
@@ -642,7 +645,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
             subtreeShouldBeClipped = ancestorClipsSubtree;
             if (ancestorClipsSubtree)
                 clipRectForSubtree = clipRectFromAncestor;
-            
+
             // Layers that are not their own renderTarget will render into the target of their nearest ancestor.
             layer->setRenderTarget(layer->parent()->renderTarget());
         } else {
@@ -658,24 +661,17 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
         }
     }
 
+    IntRect rectInTargetSpace = enclosingIntRect(CCMathUtil::mapClippedRect(layer->drawTransform(), contentRect));
+
     if (layerClipsSubtree(layer)) {
         subtreeShouldBeClipped = true;
         if (ancestorClipsSubtree && !layer->renderSurface()) {
             clipRectForSubtree = clipRectFromAncestor;
-            clipRectForSubtree.intersect(transformedLayerRect);
+            clipRectForSubtree.intersect(rectInTargetSpace);
         } else
-            clipRectForSubtree = transformedLayerRect;
+            clipRectForSubtree = rectInTargetSpace;
     }
 
-    // Note that at this point, layer->drawTransform() is not necessarily the same as local variable drawTransform.
-    // layerScreenSpaceTransform represents the transform between root layer's "screen space" and local layer space.
-    WebTransformationMatrix layerScreenSpaceTransform = nextHierarchyMatrix;
-    layerScreenSpaceTransform.multiply(layer->drawTransform());
-    layerScreenSpaceTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0);
-    layer->setScreenSpaceTransform(layerScreenSpaceTransform);
-
-    WebTransformationMatrix sublayerMatrix = layer->drawTransform();
-
     // Flatten to 2D if the layer doesn't preserve 3D.
     if (!layer->preserves3D()) {
         sublayerMatrix.setM13(0);
@@ -720,12 +716,12 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
     // Compute the total drawableContentRect for this subtree (the rect is in targetSurface space)
     IntRect localDrawableContentRectOfSubtree = accumulatedDrawableContentRectOfChildren;
     if (layer->drawsContent())
-        localDrawableContentRectOfSubtree.unite(transformedLayerRect);
+        localDrawableContentRectOfSubtree.unite(rectInTargetSpace);
     if (subtreeShouldBeClipped)
         localDrawableContentRectOfSubtree.intersect(clipRectForSubtree);
 
     // Compute the layer's drawable content rect (the rect is in targetSurface space)
-    IntRect drawableContentRectOfLayer = transformedLayerRect;
+    IntRect drawableContentRectOfLayer = rectInTargetSpace;
     if (subtreeShouldBeClipped)
         drawableContentRectOfLayer.intersect(clipRectForSubtree);
     layer->setDrawableContentRect(drawableContentRectOfLayer);
@@ -742,9 +738,6 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
         else
             renderSurface->setClipRect(IntRect());
 
-        // Restrict the RenderSurface size to the portion that's visible.
-        FloatSize centerOffsetDueToClipping;
-
         // Don't clip if the layer is reflected as the reflection shouldn't be
         // clipped. If the layer is animating, then the surface's transform to
         // its target is not known on the main thread, and we should not use it
@@ -755,8 +748,6 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
                 IntRect surfaceClipRect = CCLayerTreeHostCommon::calculateVisibleRect(renderSurface->clipRect(), clippedContentRect, renderSurface->originTransform());
                 clippedContentRect.intersect(surfaceClipRect);
             }
-            FloatPoint clippedSurfaceCenter = FloatRect(clippedContentRect).center();
-            centerOffsetDueToClipping = clippedSurfaceCenter - surfaceCenter;
         }
 
         // The RenderSurface backing texture cannot exceed the maximum supported
@@ -769,12 +760,8 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
 
         renderSurface->setContentRect(clippedContentRect);
 
-        // Adjust the origin of the transform to be the center of the render surface.
-        WebTransformationMatrix drawTransform = renderSurface->originTransform();
-        drawTransform.translate3d(surfaceCenter.x() + centerOffsetDueToClipping.width(), surfaceCenter.y() + centerOffsetDueToClipping.height(), 0);
-        renderSurface->setDrawTransform(drawTransform);
-
         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.
@@ -782,20 +769,6 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
         renderSurface->setScreenSpaceTransform(screenSpaceTransform);
 
         if (layer->replicaLayer()) {
-            // Compute the transformation matrix used to draw the surface's replica to the target surface.
-            WebTransformationMatrix replicaDrawTransform = renderSurface->originTransform();
-
-            replicaDrawTransform.scale(contentsScale);
-            replicaDrawTransform.translate(layer->replicaLayer()->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(),
-                                           layer->replicaLayer()->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height());
-            replicaDrawTransform.multiply(layer->replicaLayer()->transform());
-            FloatPoint layerSpaceSurfaceCenter = surfaceCenter;
-            layerSpaceSurfaceCenter.scale(1 / contentsScale, 1 / contentsScale);
-            replicaDrawTransform.translate(layerSpaceSurfaceCenter.x() - layer->replicaLayer()->anchorPoint().x() * bounds.width(), layerSpaceSurfaceCenter.y() - layer->replicaLayer()->anchorPoint().y() * bounds.height());
-            replicaDrawTransform.scale(1 / contentsScale);
-
-            renderSurface->setReplicaDrawTransform(replicaDrawTransform);
-
             WebTransformationMatrix surfaceOriginToReplicaOriginTransform;
             surfaceOriginToReplicaOriginTransform.scale(contentsScale);
             surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer()->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(),
@@ -807,6 +780,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay
             // Compute the replica's "originTransform" that maps from the replica's origin space to the target surface origin space.
             WebTransformationMatrix replicaOriginTransform = layer->renderSurface()->originTransform() * surfaceOriginToReplicaOriginTransform;
             renderSurface->setReplicaOriginTransform(replicaOriginTransform);
+            renderSurface->setReplicaDrawTransform(replicaOriginTransform);
 
             // Compute the replica's "screenSpaceTransform" that maps from the replica's origin space to the screen's origin space.
             WebTransformationMatrix replicaScreenSpaceTransform = layer->renderSurface()->screenSpaceTransform() * surfaceOriginToReplicaOriginTransform;
index 3946157..c1a38ca 100644 (file)
@@ -284,28 +284,6 @@ static inline WebTransformationMatrix contentToScreenSpaceTransform(const LayerT
     return transform;
 }
 
-template<typename LayerType>
-static inline WebTransformationMatrix contentToTargetSurfaceTransform(const LayerType* layer)
-{
-    ASSERT(layerTransformsToTargetKnown(layer));
-    IntSize boundsInLayerSpace = layer->bounds();
-    IntSize boundsInContentSpace = layer->contentBounds();
-
-    WebTransformationMatrix transform = layer->drawTransform();
-
-    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()));
-
-    // The draw transform expects the origin to be in the middle of the layer.
-    transform.translate(-boundsInContentSpace.width() / 2.0, -boundsInContentSpace.height() / 2.0);
-
-    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)
@@ -351,7 +329,7 @@ void CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::markOccludedBehindLay
 
     IntRect scissorInTarget = layerScissorRectInTargetSurface(layer);
     if (layerTransformsToTargetKnown(layer))
-        addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInTarget, layer, contentToTargetSurfaceTransform<LayerType>(layer), opaqueContents, scissorInTarget, m_minimumTrackingSize, 0);
+        addOcclusionBehindLayer<LayerType>(m_stack.last().occlusionInTarget, layer, layer->drawTransform(), opaqueContents, scissorInTarget, m_minimumTrackingSize, 0);
 
     // We must clip the occlusion within the layer's scissorInTarget within screen space as well. If the scissor rect can't be moved to screen space and
     // remain rectilinear, then we don't add any occlusion in screen space.
@@ -390,7 +368,7 @@ bool CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::occluded(const LayerT
 
     ASSERT(layer->renderTarget() == m_stack.last().target);
 
-    if (layerTransformsToTargetKnown(layer) && testContentRectOccluded(contentRect, contentToTargetSurfaceTransform<LayerType>(layer), layerScissorRectInTargetSurface(layer), m_stack.last().occlusionInTarget))
+    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)) {
@@ -444,7 +422,7 @@ IntRect CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::unoccludedContentR
 
     IntRect unoccludedInTarget = contentRect;
     if (layerTransformsToTargetKnown(layer))
-        unoccludedInTarget = computeUnoccludedContentRect(contentRect, contentToTargetSurfaceTransform<LayerType>(layer), layerScissorRectInTargetSurface(layer), m_stack.last().occlusionInTarget);
+        unoccludedInTarget = computeUnoccludedContentRect(contentRect, layer->drawTransform(), layerScissorRectInTargetSurface(layer), m_stack.last().occlusionInTarget);
 
     if (hasOcclusionFromOutsideTargetSurface)
         *hasOcclusionFromOutsideTargetSurface = (intersection(unoccludedInScreen, unoccludedInTarget) != unoccludedInTarget);
index 75b4e2d..c1af9d1 100644 (file)
@@ -107,6 +107,7 @@ void CCRenderPass::appendQuadsToFillScreen(CCLayerImpl* rootLayer, SkColor scree
     // Manually create the quad state for the gutter quads, as the root layer
     // doesn't have any bounds and so can't generate this itself.
     OwnPtr<CCSharedQuadState> sharedQuadState = rootLayer->createSharedQuadState(m_sharedQuadStateList.size());
+    ASSERT(rootLayer->screenSpaceTransform().isInvertible());
     WebTransformationMatrix transformToLayerSpace = rootLayer->screenSpaceTransform().inverse();
     Vector<IntRect> fillRects = fillRegion.rects();
     for (size_t i = 0; i < fillRects.size(); ++i) {
index 22434c2..95ef0b9 100644 (file)
@@ -75,11 +75,9 @@ CCRenderSurface::~CCRenderSurface()
 
 FloatRect CCRenderSurface::drawableContentRect() const
 {
-    FloatRect localContentRect(-0.5 * m_contentRect.width(), -0.5 * m_contentRect.height(),
-                               m_contentRect.width(), m_contentRect.height());
-    FloatRect drawableContentRect = CCMathUtil::mapClippedRect(m_drawTransform, localContentRect);
+    FloatRect drawableContentRect = CCMathUtil::mapClippedRect(m_drawTransform, m_contentRect);
     if (m_owningLayer->hasReplica())
-        drawableContentRect.unite(CCMathUtil::mapClippedRect(m_replicaDrawTransform, localContentRect));
+        drawableContentRect.unite(CCMathUtil::mapClippedRect(m_replicaDrawTransform, m_contentRect));
 
     return drawableContentRect;
 }
index 7c3c759..f1b43fe 100644 (file)
@@ -1,3 +1,24 @@
+2012-07-25  Adrienne Walker  <enne@google.com>
+
+        [chromium] Unify compositor quadTransform/drawTransform/originTransform
+        https://bugs.webkit.org/show_bug.cgi?id=91417
+
+        Reviewed by Kenneth Russell.
+
+        Clean up tests to refer to the new draw transform semantics.
+
+        * tests/CCDamageTrackerTest.cpp:
+        (WebKitTests::createTestTreeWithOneSurface):
+        (WebKitTests::createTestTreeWithTwoSurfaces):
+        (WebKitTests::TEST_F):
+        * tests/CCLayerSorterTest.cpp:
+        * tests/CCLayerTreeHostCommonTest.cpp:
+        * tests/CCLayerTreeHostImplTest.cpp:
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::commitCompleteOnCCThread):
+        * tests/CCQuadCullerTest.cpp:
+        * tests/TiledLayerChromiumTest.cpp:
+
 2012-07-25  Kevin Ellis  <kevers@chromium.org>
 
         [chromium] Calendar picker popup displays at wrong scale when deviceScaleFactor != 1.
index 9aa4120..14e83a0 100644 (file)
@@ -99,6 +99,7 @@ PassOwnPtr<CCLayerImpl> createTestTreeWithOneSurface()
     root->setPosition(FloatPoint::zero());
     root->setAnchorPoint(FloatPoint::zero());
     root->setBounds(IntSize(500, 500));
+    root->setContentBounds(IntSize(500, 500));
     root->setDrawsContent(true);
     root->createRenderSurface();
     root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(500, 500)));
@@ -106,6 +107,7 @@ PassOwnPtr<CCLayerImpl> createTestTreeWithOneSurface()
     child->setPosition(FloatPoint(100, 100));
     child->setAnchorPoint(FloatPoint::zero());
     child->setBounds(IntSize(30, 30));
+    child->setContentBounds(IntSize(30, 30));
     child->setDrawsContent(true);
     root->addChild(child.release());
 
@@ -127,6 +129,7 @@ PassOwnPtr<CCLayerImpl> createTestTreeWithTwoSurfaces()
     root->setPosition(FloatPoint::zero());
     root->setAnchorPoint(FloatPoint::zero());
     root->setBounds(IntSize(500, 500));
+    root->setContentBounds(IntSize(500, 500));
     root->setDrawsContent(true);
     root->createRenderSurface();
     root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(500, 500)));
@@ -134,22 +137,26 @@ PassOwnPtr<CCLayerImpl> createTestTreeWithTwoSurfaces()
     child1->setPosition(FloatPoint(100, 100));
     child1->setAnchorPoint(FloatPoint::zero());
     child1->setBounds(IntSize(30, 30));
+    child1->setContentBounds(IntSize(30, 30));
     child1->setOpacity(0.5); // with a child that drawsContent, this will cause the layer to create its own renderSurface.
     child1->setDrawsContent(false); // this layer does not draw, but is intended to create its own renderSurface.
 
     child2->setPosition(FloatPoint(11, 11));
     child2->setAnchorPoint(FloatPoint::zero());
     child2->setBounds(IntSize(18, 18));
+    child2->setContentBounds(IntSize(18, 18));
     child2->setDrawsContent(true);
 
     grandChild1->setPosition(FloatPoint(200, 200));
     grandChild1->setAnchorPoint(FloatPoint::zero());
     grandChild1->setBounds(IntSize(6, 8));
+    grandChild1->setContentBounds(IntSize(6, 8));
     grandChild1->setDrawsContent(true);
 
     grandChild2->setPosition(FloatPoint(190, 190));
     grandChild2->setAnchorPoint(FloatPoint::zero());
     grandChild2->setBounds(IntSize(6, 8));
+    grandChild2->setContentBounds(IntSize(6, 8));
     grandChild2->setDrawsContent(true);
 
     child1->addChild(grandChild1.release());
@@ -360,6 +367,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForPerspectiveClippedLayer)
     // Set up the child
     child->setPosition(FloatPoint(0, 0));
     child->setBounds(IntSize(100, 100));
+    child->setContentBounds(IntSize(100, 100));
     child->setTransform(transform);
     emulateDrawingOneFrame(root.get());
 
@@ -526,6 +534,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForAddingAndRemovingLayer)
         child2->setPosition(FloatPoint(400, 380));
         child2->setAnchorPoint(FloatPoint::zero());
         child2->setBounds(IntSize(6, 8));
+        child2->setContentBounds(IntSize(6, 8));
         child2->setDrawsContent(true);
         root->addChild(child2.release());
     }
@@ -565,6 +574,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForNewUnchangedLayer)
         child2->setPosition(FloatPoint(400, 380));
         child2->setAnchorPoint(FloatPoint::zero());
         child2->setBounds(IntSize(6, 8));
+        child2->setContentBounds(IntSize(6, 8));
         child2->setDrawsContent(true);
         child2->resetAllChangeTrackingForSubtree();
         // Sanity check the initial conditions of the test, if these asserts trigger, it
@@ -594,6 +604,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMultipleLayers)
         child2->setPosition(FloatPoint(400, 380));
         child2->setAnchorPoint(FloatPoint::zero());
         child2->setBounds(IntSize(6, 8));
+        child2->setContentBounds(IntSize(6, 8));
         child2->setDrawsContent(true);
         root->addChild(child2.release());
     }
@@ -812,6 +823,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplica)
         grandChild3->setPosition(FloatPoint(240, 240));
         grandChild3->setAnchorPoint(FloatPoint::zero());
         grandChild3->setBounds(IntSize(10, 10));
+        grandChild3->setContentBounds(IntSize(10, 10));
         grandChild3->setDrawsContent(true);
         child1->addChild(grandChild3.release());
     }
@@ -894,6 +906,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMask)
         maskLayer->setPosition(child->position());
         maskLayer->setAnchorPoint(FloatPoint::zero());
         maskLayer->setBounds(child->bounds());
+        maskLayer->setContentBounds(child->bounds());
         child->setMaskLayer(maskLayer.release());
     }
     CCLayerImpl* maskLayer = child->maskLayer();
@@ -905,6 +918,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForMask)
         grandChild->setPosition(FloatPoint(2, 2));
         grandChild->setAnchorPoint(FloatPoint::zero());
         grandChild->setBounds(IntSize(2, 2));
+        grandChild->setContentBounds(IntSize(2, 2));
         grandChild->setDrawsContent(true);
         child->addChild(grandChild.release());
     }
@@ -989,6 +1003,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMask)
         replicaMaskLayer->setPosition(FloatPoint::zero());
         replicaMaskLayer->setAnchorPoint(FloatPoint::zero());
         replicaMaskLayer->setBounds(grandChild1->bounds());
+        replicaMaskLayer->setContentBounds(grandChild1->bounds());
         grandChild1Replica->setMaskLayer(replicaMaskLayer.release());
     }
     CCLayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer();
@@ -1050,6 +1065,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForReplicaMaskWithAnchor)
         replicaMaskLayer->setPosition(FloatPoint::zero());
         replicaMaskLayer->setAnchorPoint(FloatPoint::zero()); // note, this is not the anchor being tested.
         replicaMaskLayer->setBounds(grandChild1->bounds());
+        replicaMaskLayer->setContentBounds(grandChild1->bounds());
         grandChild1Replica->setMaskLayer(replicaMaskLayer.release());
     }
     CCLayerImpl* replicaMaskLayer = grandChild1Replica->maskLayer();
index d231e12..8ffcea2 100644 (file)
@@ -89,9 +89,11 @@ TEST(CCLayerSorterTest, RightAngleOverlap)
     WebTransformationMatrix leftFaceMatrix;
     leftFaceMatrix.rotate3d(0, 1, 0, -90);
     leftFaceMatrix.translateRight3d(-1, 0, -5);
+    leftFaceMatrix.translate(-1, -1);
     CCLayerSorter::LayerShape leftFace(2, 2, perspectiveMatrix * leftFaceMatrix);
     WebTransformationMatrix frontFaceMatrix;
     frontFaceMatrix.translate3d(0, 0, -4);
+    frontFaceMatrix.translate(-1, -1);
     CCLayerSorter::LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
 
     overlapResult = CCLayerSorter::checkOverlap(&frontFace, &leftFace, zThreshold, weight);
@@ -111,11 +113,13 @@ TEST(CCLayerSorterTest, IntersectingLayerOverlap)
     // values at the overlapping features but the weight returned should be zero.
     WebTransformationMatrix frontFaceMatrix;
     frontFaceMatrix.translate3d(0, 0, -4);
+    frontFaceMatrix.translate(-1, -1);
     CCLayerSorter::LayerShape frontFace(2, 2, perspectiveMatrix * frontFaceMatrix);
 
     WebTransformationMatrix throughMatrix;
     throughMatrix.rotate3d(0, 1, 0, 45);
     throughMatrix.translateRight3d(0, 0, -4);
+    throughMatrix.translate(-1, -1);
     CCLayerSorter::LayerShape rotatedFace(2, 2, perspectiveMatrix * throughMatrix);
     overlapResult = CCLayerSorter::checkOverlap(&frontFace, &rotatedFace, zThreshold, weight);
     EXPECT_NE(CCLayerSorter::None, overlapResult);
@@ -142,14 +146,17 @@ TEST(CCLayerSorterTest, LayersAtAngleOverlap)
 
     WebTransformationMatrix transformA;
     transformA.translate3d(-6, 0, 1);
+    transformA.translate(-4, -10);
     CCLayerSorter::LayerShape layerA(8, 20, transformA);
 
     WebTransformationMatrix transformB;
     transformB.translate3d(6, 0, -1);
+    transformB.translate(-4, -10);
     CCLayerSorter::LayerShape layerB(8, 20, transformB);
 
     WebTransformationMatrix transformC;
     transformC.rotate3d(0, 1, 0, 40);
+    transformC.translate(-4, -10);
     CCLayerSorter::LayerShape layerC(8, 20, transformC);
 
     overlapResult = CCLayerSorter::checkOverlap(&layerA, &layerC, zThreshold, weight);
@@ -176,6 +183,7 @@ TEST(CCLayerSorterTest, LayersUnderPathologicalPerspectiveTransform)
 
     WebTransformationMatrix transformA;
     transformA.translate3d(-15, 0, -2);
+    transformA.translate(-5, -5);
     CCLayerSorter::LayerShape layerA(10, 10, perspectiveMatrix * transformA);
 
     // With this sequence of transforms, when layer B is correctly clipped, it will be
@@ -185,6 +193,7 @@ TEST(CCLayerSorterTest, LayersUnderPathologicalPerspectiveTransform)
     WebTransformationMatrix transformB;
     transformB.translate3d(0, 0, 0.7);
     transformB.rotate3d(0, 45, 0);
+    transformB.translate(-5, -5);
     CCLayerSorter::LayerShape layerB(10, 10, perspectiveMatrix * transformB);
 
     // Sanity check that the test case actually covers the intended scenario, where part
@@ -226,22 +235,27 @@ TEST(CCLayerSorterTest, verifyExistingOrderingPreservedWhenNoZDiff)
     FrontMatrix.translate3d(0, 0, 1);
 
     layer1->setBounds(IntSize(10, 10));
+    layer1->setContentBounds(IntSize(10, 10));
     layer1->setDrawTransform(BehindMatrix);
     layer1->setDrawsContent(true);
 
     layer2->setBounds(IntSize(20, 20));
+    layer2->setContentBounds(IntSize(20, 20));
     layer2->setDrawTransform(BehindMatrix);
     layer2->setDrawsContent(true);
 
     layer3->setBounds(IntSize(30, 30));
+    layer3->setContentBounds(IntSize(30, 30));
     layer3->setDrawTransform(FrontMatrix);
     layer3->setDrawsContent(true);
 
     layer4->setBounds(IntSize(40, 40));
+    layer4->setContentBounds(IntSize(40, 40));
     layer4->setDrawTransform(FrontMatrix);
     layer4->setDrawsContent(true);
 
     layer5->setBounds(IntSize(50, 50));
+    layer5->setContentBounds(IntSize(50, 50));
     layer5->setDrawTransform(BehindMatrix);
     layer5->setDrawsContent(true);
 
index 86af40a..e40a1c2 100644 (file)
@@ -184,23 +184,21 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
     setLayerPropertiesForTesting(layer.get(), identityMatrix, arbitraryTranslation, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false);
     executeCalculateDrawTransformsAndVisibility(layer.get());
     WebTransformationMatrix expectedDrawTransform = identityMatrix;
-    expectedDrawTransform.translate(50, 50);
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, layer->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform());
 
-    // Case 2: setting the bounds of the layer should result in a draw transform that translates to half the width and height.
-    //         The screen-space transform should remain as the identity, because it does not deal with transforming to/from the center of the layer.
+    // Case 2: Setting the bounds of the layer should not affect either the draw transform or the screenspace transform.
     WebTransformationMatrix translationToCenter;
     translationToCenter.translate(5, 6);
     setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 12), false);
     executeCalculateDrawTransformsAndVisibility(layer.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(translationToCenter, layer->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform());
 
     // Case 3: The anchor point by itself (without a layer transform) should have no effect on the transforms.
     setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false);
     executeCalculateDrawTransformsAndVisibility(layer.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(translationToCenter, layer->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, layer->screenSpaceTransform());
 
     // Case 4: A change in actual position affects both the draw transform and screen space transform.
@@ -208,7 +206,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
     positionTransform.translate(0, 1.2);
     setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 1.2), IntSize(10, 12), false);
     executeCalculateDrawTransformsAndVisibility(layer.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform * translationToCenter, layer->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(positionTransform, layer->screenSpaceTransform());
 
     // Case 5: In the correct sequence of transforms, the layer transform should pre-multiply the translationToCenter. This is easily tested by
@@ -217,7 +215,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
     layerTransform.scale3d(2, 2, 1);
     setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(10, 12), false);
     executeCalculateDrawTransformsAndVisibility(layer.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform * translationToCenter, layer->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(layerTransform, layer->screenSpaceTransform());
 
     // Case 6: The layer transform should occur with respect to the anchor point.
@@ -226,7 +224,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
     WebTransformationMatrix expectedResult = translationToAnchor * layerTransform * translationToAnchor.inverse();
     setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0.5, 0), FloatPoint(0, 0), IntSize(10, 12), false);
     executeCalculateDrawTransformsAndVisibility(layer.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult * translationToCenter, layer->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform());
 
     // Case 7: Verify that position pre-multiplies the layer transform.
@@ -235,7 +233,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleLayer)
     expectedResult = positionTransform * translationToAnchor * layerTransform * translationToAnchor.inverse();
     setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0.5, 0), FloatPoint(0, 1.2), IntSize(10, 12), false);
     executeCalculateDrawTransformsAndVisibility(layer.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult * translationToCenter, layer->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedResult, layer->screenSpaceTransform());
 }
 
@@ -250,16 +248,13 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
     child->addChild(grandChild);
 
     // Case 1: parent's anchorPoint should not affect child or grandChild.
-    WebTransformationMatrix childTranslationToCenter, grandChildTranslationToCenter;
-    childTranslationToCenter.translate(8, 9);
-    grandChildTranslationToCenter.translate(38, 39);
     setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0.25, 0.25), FloatPoint(0, 0), IntSize(10, 12), false);
     setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false);
     setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false);
     executeCalculateDrawTransformsAndVisibility(parent.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(childTranslationToCenter, child->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->screenSpaceTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(grandChildTranslationToCenter, grandChild->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->screenSpaceTransform());
 
     // Case 2: parent's position affects child and grandChild.
@@ -269,9 +264,9 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
     setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false);
     setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false);
     executeCalculateDrawTransformsAndVisibility(parent.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform * childTranslationToCenter, child->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, child->screenSpaceTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform * grandChildTranslationToCenter, grandChild->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentPositionTransform, grandChild->screenSpaceTransform());
 
     // Case 3: parent's local transform affects child and grandchild
@@ -284,9 +279,9 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
     setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false);
     setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false);
     executeCalculateDrawTransformsAndVisibility(parent.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform * childTranslationToCenter, child->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpaceTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform * grandChildTranslationToCenter, grandChild->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screenSpaceTransform());
 
     // Case 4: parent's sublayerMatrix affects child and grandchild
@@ -305,9 +300,9 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
     setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), false);
     setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false);
     executeCalculateDrawTransformsAndVisibility(parent.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform * childTranslationToCenter, child->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpaceTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform * grandChildTranslationToCenter, grandChild->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(flattenedCompositeTransform, grandChild->screenSpaceTransform());
 
     // Case 5: same as Case 4, except that child does preserve 3D, so the grandChild should receive the non-flattened composite transform.
@@ -316,9 +311,9 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSimpleHierarchy)
     setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(16, 18), true);
     setLayerPropertiesForTesting(grandChild.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(76, 78), false);
     executeCalculateDrawTransformsAndVisibility(parent.get());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform * childTranslationToCenter, child->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpaceTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform * grandChildTranslationToCenter, grandChild->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, grandChild->screenSpaceTransform());
 }
 
@@ -346,11 +341,6 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface)
     WebTransformationMatrix parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * parentTranslationToAnchor.inverse()
             * parentTranslationToCenter * parentSublayerMatrix * parentTranslationToCenter.inverse();
 
-    WebTransformationMatrix childTranslationToCenter;
-    childTranslationToCenter.translate(8, 9);
-    WebTransformationMatrix grandChildTranslationToCenter;
-    grandChildTranslationToCenter.translate(4, 5);
-
     // Child's render surface should not exist yet.
     ASSERT_FALSE(child->renderSurface());
 
@@ -363,16 +353,15 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface)
     ASSERT_TRUE(child->renderSurface());
     ASSERT_EQ(child, child->renderTarget());
 
-    // The child layer's draw transform should refer to its new render surface; they only differ by a translation to center.
+    // The child layer's draw transform should refer to its new render surface.
     // The screen-space transform, however, should still refer to the root.
-    EXPECT_TRANSFORMATION_MATRIX_EQ(childTranslationToCenter, child->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpaceTransform());
 
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarget()->renderSurface()->originTransform());
 
     // Because the grandChild is the only drawable content, the child's renderSurface will tighten its bounds to the grandChild.
-    // Therefore, the draw transform will have a translation of half-width, half-height of the grandChild's bounds.
-    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform * grandChildTranslationToCenter, child->renderTarget()->renderSurface()->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarget()->renderSurface()->drawTransform());
 
     // The screen space is the same as the target since the child surface draws into the root.
     EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarget()->renderSurface()->screenSpaceTransform());
@@ -412,6 +401,7 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClip)
     root->setAnchorPoint(FloatPoint(0, 0));
     root->setPosition(FloatPoint(rootRect.x(), rootRect.y()));
     root->setBounds(IntSize(rootRect.width(), rootRect.height()));
+    root->setContentBounds(root->bounds());
     root->setDrawsContent(true);
     root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.width(), rootRect.height())));
 
@@ -419,11 +409,13 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClip)
     child->setPosition(FloatPoint(childRect.x(), childRect.y()));
     child->setOpacity(0.5);
     child->setBounds(IntSize(childRect.width(), childRect.height()));
+    child->setContentBounds(child->bounds());
     child->setDrawsContent(true);
 
     grandChild->setAnchorPoint(FloatPoint(0, 0));
     grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y()));
     grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height()));
+    grandChild->setContentBounds(grandChild->bounds());
     grandChild->setDrawsContent(true);
 
     CCLayerImpl* childPtr = child.get();
@@ -579,6 +571,7 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClipAndSpaceTransform)
     root->setAnchorPoint(FloatPoint(0, 0));
     root->setPosition(FloatPoint(rootRect.x(), rootRect.y()));
     root->setBounds(IntSize(rootRect.width(), rootRect.height()));
+    root->setContentBounds(root->bounds());
     root->setDrawsContent(true);
     root->renderSurface()->setContentRect(IntRect(IntPoint(), IntSize(rootRect.width(), rootRect.height())));
 
@@ -586,18 +579,21 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClipAndSpaceTransform)
     child->setPosition(FloatPoint(childRect.x(), childRect.y()));
     child->setOpacity(0.5);
     child->setBounds(IntSize(childRect.width(), childRect.height()));
+    child->setContentBounds(child->bounds());
     child->setDrawsContent(true);
 
     grandChild->setAnchorPoint(FloatPoint(0, 0));
     grandChild->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y()));
     grandChild->setOpacity(0.5);
     grandChild->setBounds(IntSize(grandChildRect.width(), grandChildRect.height()));
+    grandChild->setContentBounds(grandChild->bounds());
     grandChild->setDrawsContent(true);
 
     grandChild2->setAnchorPoint(FloatPoint(0, 0));
     grandChild2->setPosition(IntPoint(grandChildRect.x(), grandChildRect.y()));
     grandChild2->setOpacity(0.5);
     grandChild2->setBounds(IntSize(grandChildRect.width(), grandChildRect.height()));
+    grandChild2->setContentBounds(grandChild2->bounds());
     grandChild2->setDrawsContent(true);
 
     CCLayerImpl* childPtr = child.get();
@@ -828,6 +824,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy)
     WebTransformationMatrix A = translationToAnchor * layerTransform * translationToAnchor.inverse();
     WebTransformationMatrix B = translationToCenter * sublayerTransform * translationToCenter.inverse();
     WebTransformationMatrix R = A * translationToAnchor * replicaLayerTransform * translationToAnchor.inverse();
+    WebTransformationMatrix identityMatrix;
 
     setLayerPropertiesForTesting(parent.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false);
     setLayerPropertiesForTesting(renderSurface1.get(), layerTransform, sublayerTransform, FloatPoint(0.25, 0), FloatPoint(0, 0), IntSize(10, 10), false);
@@ -875,17 +872,17 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy)
     //  note that draw transforms are described with respect to the nearest ancestor render surface
     //  but screen space transforms are described with respect to the root.
     //
-    EXPECT_TRANSFORMATION_MATRIX_EQ(A * translationToCenter, parent->drawTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * translationToCenter, childOfRoot->drawTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A * translationToCenter, grandChildOfRoot->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(A, parent->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A, childOfRoot->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(A * B * A * B * A, grandChildOfRoot->drawTransform());
 
-    EXPECT_TRANSFORMATION_MATRIX_EQ(translationToCenter, renderSurface1->drawTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(B * A * translationToCenter, childOfRS1->drawTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(B * A * B * A * translationToCenter, grandChildOfRS1->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, renderSurface1->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(B * A, childOfRS1->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(B * A * B * A, grandChildOfRS1->drawTransform());
 
-    EXPECT_TRANSFORMATION_MATRIX_EQ(translationToCenter, renderSurface2->drawTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(B * A * translationToCenter, childOfRS2->drawTransform());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(B * A * B * A * translationToCenter, grandChildOfRS2->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, renderSurface2->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(B * A, childOfRS2->drawTransform());
+    EXPECT_TRANSFORMATION_MATRIX_EQ(B * A * B * A, grandChildOfRS2->drawTransform());
 
     // Verify layer screen-space transforms
     //
@@ -1042,10 +1039,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     child->setScrollDelta(IntSize(0, 0));
     executeCalculateDrawTransformsAndVisibility(root.get());
 
-    // The expected drawTransforms without any scroll should still include a translation to the center of the layer (i.e. translation by 50, 50).
     WebTransformationMatrix expectedChildTransform;
-    expectedChildTransform.translate(50, 50);
-
     WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform;
 
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
@@ -1057,7 +1051,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
 
     // Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected.
     expectedChildTransform.makeIdentity();
-    expectedChildTransform.translate(40, 40);
+    expectedChildTransform.translate(-10, -10);
 
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -1091,10 +1085,8 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     child->setScrollDelta(IntSize(0, 0));
     executeCalculateDrawTransformsAndVisibility(root.get());
 
-    // The expected drawTransforms without any scroll should still include a translation to the center of the layer (i.e. translation by 50, 50).
     WebTransformationMatrix expectedChildTransform;
     expectedChildTransform.multiply(nonUniformScale);
-    expectedChildTransform.translate(50, 50);
 
     WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform;
 
@@ -1109,7 +1101,6 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     expectedChildTransform.makeIdentity();
     expectedChildTransform.translate(-10, -20); // scrollDelta
     expectedChildTransform.multiply(nonUniformScale);
-    expectedChildTransform.translate(50, 50);
 
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -1135,10 +1126,8 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     executeCalculateDrawTransformsAndVisibility(root.get());
 
     WebTransformationMatrix expectedChildTransform;
-    expectedChildTransform.translate(50, 50);
-
     WebTransformationMatrix expectedGrandChildTransform;
-    expectedGrandChildTransform.translate(58, 56);
+    expectedGrandChildTransform.translate(8, 6);
 
     WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChildTransform;
 
@@ -1152,9 +1141,9 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
 
     // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
     expectedChildTransform.makeIdentity();
-    expectedChildTransform.translate(40, 40);
+    expectedChildTransform.translate(-10, -10);
     expectedGrandChildTransform.makeIdentity();
-    expectedGrandChildTransform.translate(48, 46);
+    expectedGrandChildTransform.translate(-2, -4);
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrandChild->drawTransform());
@@ -1174,7 +1163,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
 
     WebTransformationMatrix rotationAboutZ;
     rotationAboutZ.rotate3d(0, 0, 90);
-    
+
     child->setIsContainerForFixedPositionLayers(true);
     child->setTransform(rotationAboutZ);
     grandChild->setPosition(FloatPoint(8, 6));
@@ -1187,13 +1176,11 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
 
     WebTransformationMatrix expectedChildTransform;
     expectedChildTransform.multiply(rotationAboutZ);
-    expectedChildTransform.translate(50, 50);
 
     WebTransformationMatrix expectedGrandChildTransform;
     expectedGrandChildTransform.multiply(rotationAboutZ); // child's local transform is inherited
     expectedGrandChildTransform.translate(8, 6); // translation because of position occurs before layer's local transform.
     expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
-    expectedGrandChildTransform.translate(50, 50); // translation because of half-width half-height occurs after layer's local transform
 
     WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChildTransform;
 
@@ -1209,14 +1196,12 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     expectedChildTransform.makeIdentity();
     expectedChildTransform.translate(-10, -20); // scrollDelta
     expectedChildTransform.multiply(rotationAboutZ);
-    expectedChildTransform.translate(50, 50);
 
     expectedGrandChildTransform.makeIdentity();
     expectedGrandChildTransform.translate(-10, -20); // child's scrollDelta is inherited
     expectedGrandChildTransform.multiply(rotationAboutZ); // child's local transform is inherited
     expectedGrandChildTransform.translate(8, 6); // translation because of position occurs before layer's local transform.
     expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
-    expectedGrandChildTransform.translate(50, 50); // translation because of half-width half-height occurs after layer's local transform
 
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -1240,7 +1225,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
 
     WebTransformationMatrix rotationAboutZ;
     rotationAboutZ.rotate3d(0, 0, 90);
-    
+
     child->setIsContainerForFixedPositionLayers(true);
     child->setTransform(rotationAboutZ);
     grandChild->setPosition(FloatPoint(8, 6));
@@ -1253,13 +1238,11 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
 
     WebTransformationMatrix expectedChildTransform;
     expectedChildTransform.multiply(rotationAboutZ);
-    expectedChildTransform.translate(50, 50);
 
     WebTransformationMatrix expectedGrandChildTransform;
     expectedGrandChildTransform.multiply(rotationAboutZ); // child's local transform is inherited
     expectedGrandChildTransform.translate(8, 6); // translation because of position occurs before layer's local transform.
     expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
-    expectedGrandChildTransform.translate(50, 50); // translation because of half-width half-height occurs after layer's local transform
 
     WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChildTransform;
 
@@ -1276,7 +1259,6 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     expectedChildTransform.makeIdentity();
     expectedChildTransform.translate(-10, 0); // scrollDelta
     expectedChildTransform.multiply(rotationAboutZ);
-    expectedChildTransform.translate(50, 50);
 
     expectedGrandChildTransform.makeIdentity();
     expectedGrandChildTransform.translate(-10, 0); // child's scrollDelta is inherited
@@ -1284,7 +1266,6 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     expectedGrandChildTransform.translate(-5, 0); // grandChild's scrollDelta
     expectedGrandChildTransform.translate(8, 6); // translation because of position occurs before layer's local transform.
     expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
-    expectedGrandChildTransform.translate(50, 50); // translation because of half-width half-height occurs after layer's local transform
 
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -1313,20 +1294,17 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     WebTransformationMatrix rotationAboutZ;
     rotationAboutZ.rotate3d(0, 0, 90);
     grandChild->setTransform(rotationAboutZ);
-    
+
     // Case 1: scrollDelta of 0, 0
     child->setScrollDelta(IntSize(0, 0));
     executeCalculateDrawTransformsAndVisibility(root.get());
-        
+
     WebTransformationMatrix expectedChildTransform;
-    expectedChildTransform.translate(50, 50);
     WebTransformationMatrix expectedSurfaceOriginTransform;
     expectedSurfaceOriginTransform.translate(8, 6);
     expectedSurfaceOriginTransform.multiply(rotationAboutZ);
     WebTransformationMatrix expectedGrandChildTransform;
-    expectedGrandChildTransform.translate(50, 50);
     WebTransformationMatrix expectedGreatGrandChildTransform;
-    expectedGreatGrandChildTransform.translate(50, 50);
     ASSERT_TRUE(grandChild->renderSurface());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceOriginTransform, grandChild->renderSurface()->originTransform());
@@ -1336,7 +1314,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     // Case 2: scrollDelta of 10, 30
     child->setScrollDelta(IntSize(10, 30));
     executeCalculateDrawTransformsAndVisibility(root.get());
-        
+
     // Here the grandChild remains unchanged, because it scrolls along with the
     // renderSurface, and the translation is actually in the renderSurface. But, the fixed
     // position greatGrandChild is more awkward: its actually being drawn with respect to
@@ -1346,7 +1324,6 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     // transform explicitly contains the translation that cancels out the scroll.
     expectedChildTransform.makeIdentity();
     expectedChildTransform.translate(-10, -30); // scrollDelta
-    expectedChildTransform.translate(50, 50);
 
     expectedSurfaceOriginTransform.makeIdentity();
     expectedSurfaceOriginTransform.translate(-10, -30); // scrollDelta
@@ -1360,7 +1337,6 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     expectedGreatGrandChildTransform.multiply(rotationAboutZ.inverse());
     expectedGreatGrandChildTransform.translate(10, 30); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface.
     expectedGreatGrandChildTransform.multiply(rotationAboutZ);
-    expectedGreatGrandChildTransform.translate(50, 50);
 
     ASSERT_TRUE(grandChild->renderSurface());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
@@ -1416,24 +1392,20 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     executeCalculateDrawTransformsAndVisibility(root.get());
 
     WebTransformationMatrix expectedChildTransform;
-    expectedChildTransform.translate(50, 50);
 
     WebTransformationMatrix expectedGrandChildSurfaceOriginTransform;
     expectedGrandChildSurfaceOriginTransform.translate(8, 6);
     expectedGrandChildSurfaceOriginTransform.multiply(rotationAboutZ);
 
     WebTransformationMatrix expectedGrandChildTransform;
-    expectedGrandChildTransform.translate(50, 50);
 
     WebTransformationMatrix expectedGreatGrandChildSurfaceOriginTransform;
     expectedGreatGrandChildSurfaceOriginTransform.translate(40, 60);
     expectedGreatGrandChildSurfaceOriginTransform.multiply(rotationAboutZ);
 
     WebTransformationMatrix expectedGreatGrandChildTransform;
-    expectedGreatGrandChildTransform.translate(50, 50);
 
     WebTransformationMatrix expectedFixedPositionChildTransform;
-    expectedFixedPositionChildTransform.translate(50, 50);
 
     ASSERT_TRUE(grandChild->renderSurface());
     ASSERT_TRUE(greatGrandChild->renderSurface());
@@ -1450,7 +1422,6 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
 
     expectedChildTransform.makeIdentity();
     expectedChildTransform.translate(-10, -30); // scrollDelta
-    expectedChildTransform.translate(50, 50);
 
     expectedGrandChildSurfaceOriginTransform.makeIdentity();
     expectedGrandChildSurfaceOriginTransform.translate(-10, -30); // scrollDelta
@@ -1474,7 +1445,6 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     expectedFixedPositionChildTransform.multiply(compoundOriginTransform.inverse());
     expectedFixedPositionChildTransform.translate(10, 30); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface.
     expectedFixedPositionChildTransform.multiply(compoundOriginTransform);
-    expectedFixedPositionChildTransform.translate(50, 50);
 
     ASSERT_TRUE(grandChild->renderSurface());
     ASSERT_TRUE(greatGrandChild->renderSurface());
@@ -1507,13 +1477,10 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     child->setScrollDelta(IntSize(0, 0));
     executeCalculateDrawTransformsAndVisibility(root.get());
 
-    // The expected draw transforms without any scroll should still include a translation to the center of the layer (i.e. translation by 50, 50).
     WebTransformationMatrix expectedSurfaceOriginTransform;
     expectedSurfaceOriginTransform.translate(0, 0);
     WebTransformationMatrix expectedChildTransform;
-    expectedChildTransform.translate(50, 50);
     WebTransformationMatrix expectedGrandChildTransform;
-    expectedGrandChildTransform.translate(50, 50);
     ASSERT_TRUE(child->renderSurface());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceOriginTransform, child->renderSurface()->originTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
@@ -1529,7 +1496,8 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit
     expectedSurfaceOriginTransform.makeIdentity();
     expectedSurfaceOriginTransform.translate(-10, -10);
     expectedGrandChildTransform.makeIdentity();
-    expectedGrandChildTransform.translate(60, 60);
+    expectedGrandChildTransform.translate(10, 10);
+
     ASSERT_TRUE(child->renderSurface());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceOriginTransform, child->renderSurface()->originTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
@@ -1557,11 +1525,8 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
     child->setScrollDelta(IntSize(0, 0));
     executeCalculateDrawTransformsAndVisibility(root.get());
 
-    // The expected draw transforms without any scroll should still include a translation to the center of the layer (i.e. translation by 50, 50).
     WebTransformationMatrix expectedChildTransform;
-    expectedChildTransform.translate(50, 50);
     WebTransformationMatrix expectedGrandChildTransform;
-    expectedGrandChildTransform.translate(50, 50);
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
 
@@ -1571,7 +1536,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
 
     // Here the child is affected by scrollDelta, but the fixed position grandChild should not be affected.
     expectedChildTransform.makeIdentity();
-    expectedChildTransform.translate(40, 40);
+    expectedChildTransform.translate(-10, -10);
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
 }
@@ -1597,14 +1562,11 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
     root->setScrollDelta(IntSize(0, 0));
     executeCalculateDrawTransformsAndVisibility(root.get());
 
-    // The expected draw transforms without any scroll should still include a translation to the center of the layer (i.e. translation by 50, 50).
     WebTransformationMatrix expectedChildTransform;
     expectedChildTransform.multiply(rotationByZ);
-    expectedChildTransform.translate(50, 50);
 
     WebTransformationMatrix expectedGrandChildTransform;
     expectedGrandChildTransform.multiply(rotationByZ);
-    expectedGrandChildTransform.translate(50, 50);
 
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -1617,7 +1579,6 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerTha
     expectedChildTransform.makeIdentity();
     expectedChildTransform.translate(-10, -10); // the scrollDelta
     expectedChildTransform.multiply(rotationByZ);
-    expectedChildTransform.translate(50, 50);
 
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->drawTransform());
@@ -3457,17 +3418,14 @@ TEST(CCLayerTreeHostCommonTest, verifyLayerTransformsInHighDPI)
     expectedParentScreenSpaceTransform.setM11(deviceScaleFactor);
     expectedParentScreenSpaceTransform.setM22(deviceScaleFactor);
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentScreenSpaceTransform, parent->screenSpaceTransform());
-
-    WebTransformationMatrix expectedParentDrawTransform = expectedParentScreenSpaceTransform;
-    expectedParentDrawTransform.translate(0.5 * parent->bounds().width(), 0.5 * parent->bounds().height());
+    WebTransformationMatrix expectedParentDrawTransform;
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentDrawTransform, parent->drawTransform());
 
     // Verify results of transformed parent rects
     IntRect parentBounds(IntPoint(), parent->bounds());
-    IntRect centeredParentBounds = parentBounds;
-    centeredParentBounds.move(-parentBounds.width() * 0.5, -parentBounds.height() * 0.5);
+    IntRect parentContentBounds(IntPoint(), parent->contentBounds());
 
-    FloatRect parentDrawRect = CCMathUtil::mapClippedRect(parent->drawTransform(), FloatRect(centeredParentBounds));
+    FloatRect parentDrawRect = CCMathUtil::mapClippedRect(parent->drawTransform(), FloatRect(parentContentBounds));
     FloatRect parentScreenSpaceRect = CCMathUtil::mapClippedRect(parent->screenSpaceTransform(), FloatRect(parentBounds));
 
     FloatRect expectedParentDrawRect(FloatPoint(), parent->bounds());
@@ -3482,16 +3440,15 @@ TEST(CCLayerTreeHostCommonTest, verifyLayerTransformsInHighDPI)
     expectedChildScreenSpaceTransform.translate(child->position().x(), child->position().y());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildScreenSpaceTransform, child->screenSpaceTransform());
 
-    WebTransformationMatrix expectedChildDrawTransform = expectedChildScreenSpaceTransform;
-    expectedChildDrawTransform.translate(0.5 * child->bounds().width(), 0.5 * child->bounds().height());
+    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 centeredChildBounds = childBounds;
-    centeredChildBounds.move(-childBounds.width() * 0.5, -childBounds.height() * 0.5);
+    IntRect childContentBounds(IntPoint(), child->contentBounds());
 
-    FloatRect childDrawRect = CCMathUtil::mapClippedRect(child->drawTransform(), FloatRect(centeredChildBounds));
+    FloatRect childDrawRect = CCMathUtil::mapClippedRect(child->drawTransform(), FloatRect(childContentBounds));
     FloatRect childScreenSpaceRect = CCMathUtil::mapClippedRect(child->screenSpaceTransform(), FloatRect(childBounds));
 
     FloatRect expectedChildDrawRect(FloatPoint(), child->bounds());
@@ -3501,7 +3458,11 @@ TEST(CCLayerTreeHostCommonTest, verifyLayerTransformsInHighDPI)
     EXPECT_FLOAT_RECT_EQ(expectedChildDrawRect, childScreenSpaceRect);
 
     // Verify childNoScale transforms
-    EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), childNoScale->drawTransform());
+    WebTransformationMatrix expectedChildNoScaleTransform = child->drawTransform();
+    // drawTransform transforms 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());
 }
 
@@ -3555,16 +3516,12 @@ TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
     WebTransformationMatrix expectedParentScreenSpaceTransform;
     expectedParentScreenSpaceTransform.setM11(deviceScaleFactor);
     expectedParentScreenSpaceTransform.setM22(deviceScaleFactor);
-    WebTransformationMatrix expectedParentDrawTransform = expectedParentScreenSpaceTransform;
-    expectedParentDrawTransform.translate(0.5 * parent->bounds().width(), 0.5 * parent->bounds().height());
-    EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentDrawTransform, parent->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedParentScreenSpaceTransform, parent->screenSpaceTransform());
 
+    WebTransformationMatrix expectedParentDrawTransform;
+    EXPECT_TRANSFORMATION_MATRIX_EQ(parent->drawTransform(), expectedParentDrawTransform);
+
     WebTransformationMatrix expectedDrawTransform;
-    expectedDrawTransform.setM11(deviceScaleFactor);
-    expectedDrawTransform.setM22(deviceScaleFactor);
-    expectedDrawTransform.setM41(0.5 * deviceScaleFactor * child->bounds().width());
-    expectedDrawTransform.setM42(0.5 * deviceScaleFactor * child->bounds().height());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedDrawTransform, child->drawTransform());
 
     WebTransformationMatrix expectedScreenSpaceTransform;
@@ -3573,13 +3530,14 @@ TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
     expectedScreenSpaceTransform.translate(child->position().x(), child->position().y());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedScreenSpaceTransform, child->screenSpaceTransform());
 
+    WebTransformationMatrix expectedDuplicateChildDrawTransform = child->drawTransform();
     EXPECT_TRANSFORMATION_MATRIX_EQ(child->drawTransform(), duplicateChildNonOwner->drawTransform());
     EXPECT_TRANSFORMATION_MATRIX_EQ(child->screenSpaceTransform(), duplicateChildNonOwner->screenSpaceTransform());
     EXPECT_INT_RECT_EQ(child->drawableContentRect(), duplicateChildNonOwner->drawableContentRect());
     EXPECT_EQ(child->contentBounds(), duplicateChildNonOwner->contentBounds());
 
     WebTransformationMatrix expectedRenderSurfaceDrawTransform;
-    expectedRenderSurfaceDrawTransform.translate(deviceScaleFactor * (child->position().x() + 0.5 * child->bounds().width()), deviceScaleFactor * (child->position().y() + 0.5 * child->bounds().height()));
+    expectedRenderSurfaceDrawTransform.translate(deviceScaleFactor * child->position().x(), deviceScaleFactor * child->position().y());
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedRenderSurfaceDrawTransform, child->renderSurface()->drawTransform());
 
     WebTransformationMatrix expectedOriginTransform;
@@ -3592,8 +3550,8 @@ TEST(CCLayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
 
     WebTransformationMatrix expectedReplicaDrawTransform;
     expectedReplicaDrawTransform.setM22(-1);
-    expectedReplicaDrawTransform.setM41(13.5);
-    expectedReplicaDrawTransform.setM42(-1.5);
+    expectedReplicaDrawTransform.setM41(6);
+    expectedReplicaDrawTransform.setM42(6);
     EXPECT_TRANSFORMATION_MATRIX_EQ(expectedReplicaDrawTransform, child->renderSurface()->replicaDrawTransform());
 
     WebTransformationMatrix expectedReplicaOriginTransform = expectedReplicaDrawTransform;
index 1419164..e64156b 100644 (file)
@@ -1038,12 +1038,12 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
     m_hostImpl->drawLayers(frame);
     m_hostImpl->didDrawAllLayers(frame);
 
-    WebTransformationMatrix pageScaleTransform;
-    pageScaleTransform.scale(newPageScale);
-    pageScaleTransform.translate(0.5 * surfaceSize.width(), 0.5 * surfaceSize.height());
-    EXPECT_EQ(root->drawTransform(), pageScaleTransform);
-    EXPECT_EQ(child->drawTransform(), pageScaleTransform);
-    EXPECT_EQ(grandChild->drawTransform(), pageScaleTransform);
+    EXPECT_EQ(root->drawTransform().m11(), newPageScale);
+    EXPECT_EQ(root->drawTransform().m22(), newPageScale);
+    EXPECT_EQ(child->drawTransform().m11(), newPageScale);
+    EXPECT_EQ(child->drawTransform().m22(), newPageScale);
+    EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale);
+    EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale);
 }
 
 TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
@@ -1635,9 +1635,11 @@ TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect)
     child->setPosition(FloatPoint(12, 13));
     child->setAnchorPoint(FloatPoint(0, 0));
     child->setBounds(IntSize(14, 15));
+    child->setContentBounds(IntSize(14, 15));
     child->setDrawsContent(true);
     root->setAnchorPoint(FloatPoint(0, 0));
     root->setBounds(IntSize(500, 500));
+    root->setContentBounds(IntSize(500, 500));
     root->setDrawsContent(true);
     root->addChild(adoptPtr(child));
     layerTreeHostImpl->setRootLayer(adoptPtr(root));
@@ -1695,9 +1697,11 @@ TEST_F(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface)
     CCLayerImpl* child = new FakeDrawableCCLayerImpl(2);
     child->setAnchorPoint(FloatPoint(0, 0));
     child->setBounds(IntSize(10, 10));
+    child->setContentBounds(IntSize(10, 10));
     child->setDrawsContent(true);
     root->setAnchorPoint(FloatPoint(0, 0));
     root->setBounds(IntSize(10, 10));
+    root->setContentBounds(IntSize(10, 10));
     root->setDrawsContent(true);
     root->setOpacity(0.7f);
     root->addChild(adoptPtr(child));
@@ -1709,6 +1713,7 @@ TEST_F(CCLayerTreeHostImplTest, rootLayerDoesntCreateExtraSurface)
     EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
     EXPECT_EQ(1u, frame.renderSurfaceLayerList->size());
     EXPECT_EQ(1u, frame.renderPasses.size());
+    m_hostImpl->didDrawAllLayers(frame);
 }
 
 } // namespace
index 62b1e45..ea7678b 100644 (file)
@@ -1301,7 +1301,6 @@ public:
         // The root layer is scaled by 2x.
         WebTransformationMatrix rootScreenSpaceTransform = scaleTransform;
         WebTransformationMatrix rootDrawTransform = scaleTransform;
-        rootDrawTransform.translate(root->bounds().width() * 0.5, root->bounds().height() * 0.5);
 
         EXPECT_EQ(rootDrawTransform, root->drawTransform());
         EXPECT_EQ(rootScreenSpaceTransform, root->screenSpaceTransform());
@@ -1311,7 +1310,6 @@ public:
         childScreenSpaceTransform.translate(2, 2);
         WebTransformationMatrix childDrawTransform = scaleTransform;
         childDrawTransform.translate(2, 2);
-        childDrawTransform.translate(child->bounds().width() * 0.5, child->bounds().height() * 0.5);
 
         EXPECT_EQ(childDrawTransform, child->drawTransform());
         EXPECT_EQ(childScreenSpaceTransform, child->screenSpaceTransform());
index 526ab4e..9eff157 100644 (file)
@@ -58,17 +58,15 @@ private:
 
 typedef CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
 
-static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const WebTransformationMatrix& originTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect, Vector<CCLayerImpl*>& surfaceLayerList)
+static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const WebTransformationMatrix& drawTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect, Vector<CCLayerImpl*>& surfaceLayerList)
 {
     OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(1);
     OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::NoBorderTexels);
     tiler->setBounds(layerRect.size());
     layer->setTilingData(*tiler);
     layer->setSkipsDraw(false);
-    WebTransformationMatrix drawTransform = originTransform;
-    drawTransform.translate(0.5 * layerRect.width(), 0.5 * layerRect.height());
     layer->setDrawTransform(drawTransform);
-    layer->setScreenSpaceTransform(originTransform);
+    layer->setScreenSpaceTransform(drawTransform);
     layer->setVisibleContentRect(layerRect);
     layer->setDrawOpacity(opacity);
     layer->setOpaque(opaque);
index fc0215b..c2796b9 100644 (file)
@@ -149,7 +149,6 @@ TEST_F(TiledLayerChromiumTest, pushOccludedDirtyTiles)
 
     // The tile size is 100x100, so this invalidates and then paints two tiles.
     layer->setBounds(IntSize(100, 200));
-    layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
     layer->setVisibleContentRect(IntRect(0, 0, 100, 200));
     layer->invalidateContentRect(IntRect(0, 0, 100, 200));
 
@@ -383,7 +382,6 @@ TEST_F(TiledLayerChromiumTest, pushIdlePaintedOccludedTiles)
     occluded.setOcclusion(IntRect(0, 0, 100, 100));
 
     layer->setBounds(IntSize(100, 100));
-    layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
     layer->setVisibleContentRect(IntRect(0, 0, 100, 100));
     layer->invalidateContentRect(IntRect(0, 0, 100, 100));
 
@@ -1062,10 +1060,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusion)
     // The tile size is 100x100.
 
     layer->setBounds(IntSize(600, 600));
-    layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
 
     occluded.setOcclusion(IntRect(200, 200, 300, 100));
-    layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds()));
+    layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
 
     layer->setTexturePriorities(m_priorityCalculator);
@@ -1109,7 +1106,6 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
     // The tile size is 100x100.
 
     layer->setBounds(IntSize(600, 600));
-    layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
 
     // The partially occluded tiles (by the 150 occlusion height) are visible beyond the occlusion, so not culled.
     occluded.setOcclusion(IntRect(200, 200, 300, 150));
@@ -1166,7 +1162,6 @@ TEST_F(TiledLayerChromiumTest, tilesNotPaintedWithoutInvalidation)
     // The tile size is 100x100.
 
     layer->setBounds(IntSize(600, 600));
-    layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
 
     occluded.setOcclusion(IntRect(200, 200, 300, 100));
     layer->setVisibleContentRect(IntRect(0, 0, 600, 600));
@@ -1209,10 +1204,10 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndTransforms)
     WebTransformationMatrix screenTransform;
     screenTransform.scale(0.5);
     layer->setScreenSpaceTransform(screenTransform);
-    layer->setDrawTransform(screenTransform * WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+    layer->setDrawTransform(screenTransform);
 
     occluded.setOcclusion(IntRect(100, 100, 150, 50));
-    layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds()));
+    layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
     textureManager->prioritizeTextures();
@@ -1237,10 +1232,9 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
     // pixels, which means none should be occluded.
     layer->setContentsScale(0.5);
     layer->setBounds(IntSize(600, 600));
-    layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
 
     occluded.setOcclusion(IntRect(200, 200, 300, 100));
-    layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds()));
+    layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
     textureManager->prioritizeTextures();
@@ -1260,7 +1254,7 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
     // a different layer space. In this case the occluded region catches the
     // blown up tiles.
     occluded.setOcclusion(IntRect(200, 200, 300, 200));
-    layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds()));
+    layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
     textureManager->prioritizeTextures();
@@ -1277,10 +1271,10 @@ TEST_F(TiledLayerChromiumTest, tilesPaintedWithOcclusionAndScaling)
     WebTransformationMatrix screenTransform;
     screenTransform.scale(0.5);
     layer->setScreenSpaceTransform(screenTransform);
-    layer->setDrawTransform(screenTransform * WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
+    layer->setDrawTransform(screenTransform);
 
     occluded.setOcclusion(IntRect(100, 100, 150, 100));
-    layer->setVisibleContentRect(IntRect(IntPoint(), layer->bounds()));
+    layer->setVisibleContentRect(IntRect(IntPoint(), layer->contentBounds()));
     layer->invalidateContentRect(IntRect(0, 0, 600, 600));
     layer->setTexturePriorities(m_priorityCalculator);
     textureManager->prioritizeTextures();
@@ -1308,7 +1302,6 @@ TEST_F(TiledLayerChromiumTest, visibleContentOpaqueRegion)
     IntRect visibleBounds = IntRect(0, 0, 100, 150);
 
     layer->setBounds(contentBounds.size());
-    layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
     layer->setVisibleContentRect(visibleBounds);
     layer->setDrawOpacity(1);
 
@@ -1402,7 +1395,6 @@ TEST_F(TiledLayerChromiumTest, pixelsPaintedMetrics)
     IntRect visibleBounds = IntRect(0, 0, 100, 300);
 
     layer->setBounds(contentBounds.size());
-    layer->setDrawTransform(WebTransformationMatrix(1, 0, 0, 1, layer->bounds().width() / 2.0, layer->bounds().height() / 2.0));
     layer->setVisibleContentRect(visibleBounds);
     layer->setDrawOpacity(1);