Index: cc/CCLayerTreeHostCommon.cpp |
diff --git a/cc/CCLayerTreeHostCommon.cpp b/cc/CCLayerTreeHostCommon.cpp |
index 141b3ffd172a8912bafe758e604579bd71c1ca02..6d637e21016218d0f334bded1bed9ce7c55ee378 100644 |
--- a/cc/CCLayerTreeHostCommon.cpp |
+++ b/cc/CCLayerTreeHostCommon.cpp |
@@ -333,6 +333,35 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(CCLayerImpl* |
return nextScrollCompensationMatrix; |
} |
+// There is no contentsScale on impl thread. |
+static inline void updateLayerContentsScale(CCLayerImpl*, const WebTransformationMatrix&, float, float) { } |
+ |
+static inline void updateLayerContentsScale(LayerChromium* layer, const WebTransformationMatrix& combinedTransform, float deviceScaleFactor, float pageScaleFactor) |
+{ |
+ float cssScale = layer->initialCssScale(); |
+ if (!cssScale) { |
+ FloatPoint transformScale = CCMathUtil::computeTransform2dScaleComponents(combinedTransform); |
+ float combinedScale = fmaxf(transformScale.x(), transformScale.y()); |
+ cssScale = combinedScale / deviceScaleFactor; |
+ if (!layer->boundsContainPageScale()) |
+ cssScale /= pageScaleFactor; |
+ layer->setInitialCssScale(cssScale); |
+ } |
+ |
+ float contentsScale = cssScale * deviceScaleFactor; |
+ if (!layer->boundsContainPageScale()) |
+ contentsScale *= pageScaleFactor; |
+ layer->setContentsScale(contentsScale); |
+ |
+ LayerChromium* maskLayer = layer->maskLayer(); |
+ if (maskLayer) |
+ maskLayer->setContentsScale(contentsScale); |
+ |
+ LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->maskLayer() : 0; |
+ if (replicaMaskLayer) |
+ replicaMaskLayer->setContentsScale(contentsScale); |
+} |
+ |
// Should be called just before the recursive calculateDrawTransformsInternal(). |
template<typename LayerType, typename LayerList> |
void setupRootLayerAndSurfaceForRecursion(LayerType* rootLayer, LayerList& renderSurfaceLayerList, const IntSize& deviceViewportSize) |
@@ -354,7 +383,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay |
const WebTransformationMatrix& fullHierarchyMatrix, const WebTransformationMatrix& currentScrollCompensationMatrix, |
const IntRect& clipRectFromAncestor, bool ancestorClipsSubtree, |
RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceLayerList, LayerList& layerList, |
- LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, IntRect& drawableContentRectOfSubtree) |
+ LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, IntRect& drawableContentRectOfSubtree) |
{ |
// This function computes the new matrix transformations recursively for this |
// layer and all its descendants. It also computes the appropriate render surfaces. |
@@ -487,6 +516,10 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay |
combinedTransform = currentScrollCompensationMatrix * combinedTransform; |
} |
+ // The layer's contentsSize is determined from the combinedTransform, which then informs the |
+ // layer's drawTransform. |
+ updateLayerContentsScale(layer, combinedTransform, deviceScaleFactor, pageScaleFactor); |
+ |
// 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; |
@@ -530,20 +563,20 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay |
RenderSurfaceType* renderSurface = layer->renderSurface(); |
renderSurface->clearLayerLists(); |
- // The origin of the new surface is the upper left corner of the layer. |
+ // The origin of the new surface is the upper left corner of the layer. The contents of the |
+ // the render surface match the scale of the owning layer. |
renderSurface->setDrawTransform(drawTransform); |
WebTransformationMatrix layerDrawTransform; |
- layerDrawTransform.scale(deviceScaleFactor); |
enne (OOO)
2012/10/03 19:52:38
This block of code is highly intentional.
The "co
|
- 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); |
+ // Inside the surface's subtree, we scale everything to the owning layer's scale. |
// The sublayer matrix transforms centered layer rects into target |
// surface content space. |
sublayerMatrix.makeIdentity(); |
- sublayerMatrix.scale(deviceScaleFactor); |
+ if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
+ sublayerMatrix.scaleNonUniform(layer->contentBounds().width() / static_cast<double>(layer->bounds().width()), |
+ layer->contentBounds().height() / static_cast<double>(layer->bounds().height())); |
+ } |
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. |
@@ -647,7 +680,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay |
IntRect drawableContentRectOfChildSubtree; |
calculateDrawTransformsInternal<LayerType, LayerList, RenderSurfaceType, LayerSorter>(child, rootLayer, sublayerMatrix, nextHierarchyMatrix, nextScrollCompensationMatrix, |
clipRectForSubtree, subtreeShouldBeClipped, nearestAncestorThatMovesPixels, |
- renderSurfaceLayerList, descendants, layerSorter, maxTextureSize, deviceScaleFactor, drawableContentRectOfChildSubtree); |
+ renderSurfaceLayerList, descendants, layerSorter, maxTextureSize, deviceScaleFactor, pageScaleFactor, drawableContentRectOfChildSubtree); |
if (!drawableContentRectOfChildSubtree.isEmpty()) { |
accumulatedDrawableContentRectOfChildren.unite(drawableContentRectOfChildSubtree); |
if (child->renderSurface()) |
@@ -704,12 +737,20 @@ static void calculateDrawTransformsInternal(LayerType* layer, LayerType* rootLay |
if (layer->replicaLayer()) { |
WebTransformationMatrix surfaceOriginToReplicaOriginTransform; |
- surfaceOriginToReplicaOriginTransform.scale(deviceScaleFactor); |
+ if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
+ surfaceOriginToReplicaOriginTransform.scaleNonUniform(layer->contentBounds().width() / static_cast<double>(layer->bounds().width()), |
+ layer->contentBounds().height() / static_cast<double>(layer->bounds().height())); |
+ } |
+ |
surfaceOriginToReplicaOriginTransform.translate(layer->replicaLayer()->position().x() + layer->replicaLayer()->anchorPoint().x() * bounds.width(), |
layer->replicaLayer()->position().y() + layer->replicaLayer()->anchorPoint().y() * bounds.height()); |
surfaceOriginToReplicaOriginTransform.multiply(layer->replicaLayer()->transform()); |
surfaceOriginToReplicaOriginTransform.translate(-layer->replicaLayer()->anchorPoint().x() * bounds.width(), -layer->replicaLayer()->anchorPoint().y() * bounds.height()); |
- surfaceOriginToReplicaOriginTransform.scale(1 / deviceScaleFactor); |
+ |
+ if (!layer->contentBounds().isEmpty() && !layer->bounds().isEmpty()) { |
+ surfaceOriginToReplicaOriginTransform.scaleNonUniform(layer->bounds().width() / static_cast<double>(layer->contentBounds().width()), |
+ layer->bounds().height() / static_cast<double>(layer->contentBounds().height())); |
+ } |
// Compute the replica's "originTransform" that maps from the replica's origin space to the target surface origin space. |
WebTransformationMatrix replicaOriginTransform = layer->renderSurface()->drawTransform() * surfaceOriginToReplicaOriginTransform; |
@@ -782,7 +823,7 @@ static void calculateVisibleRectsInternal(const LayerList& renderSurfaceLayerLis |
} |
} |
-void CCLayerTreeHostCommon::calculateDrawTransforms(LayerChromium* rootLayer, const IntSize& deviceViewportSize, float deviceScaleFactor, int maxTextureSize, Vector<RefPtr<LayerChromium> >& renderSurfaceLayerList) |
+void CCLayerTreeHostCommon::calculateDrawTransforms(LayerChromium* rootLayer, const IntSize& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, Vector<RefPtr<LayerChromium> >& renderSurfaceLayerList) |
{ |
IntRect totalDrawableContentRect; |
WebTransformationMatrix identityMatrix; |
@@ -792,11 +833,11 @@ void CCLayerTreeHostCommon::calculateDrawTransforms(LayerChromium* rootLayer, co |
setupRootLayerAndSurfaceForRecursion<LayerChromium, Vector<RefPtr<LayerChromium> > >(rootLayer, renderSurfaceLayerList, deviceViewportSize); |
cc::calculateDrawTransformsInternal<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, void>(rootLayer, rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, |
- rootLayer->renderSurface()->contentRect(), true, 0, renderSurfaceLayerList, |
- rootLayer->renderSurface()->layerList(), 0, maxTextureSize, deviceScaleFactor, totalDrawableContentRect); |
+ rootLayer->renderSurface()->contentRect(), true, 0, renderSurfaceLayerList, |
+ rootLayer->renderSurface()->layerList(), 0, maxTextureSize, deviceScaleFactor, pageScaleFactor, totalDrawableContentRect); |
} |
-void CCLayerTreeHostCommon::calculateDrawTransforms(CCLayerImpl* rootLayer, const IntSize& deviceViewportSize, float deviceScaleFactor, CCLayerSorter* layerSorter, int maxTextureSize, Vector<CCLayerImpl*>& renderSurfaceLayerList) |
+void CCLayerTreeHostCommon::calculateDrawTransforms(CCLayerImpl* rootLayer, const IntSize& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, CCLayerSorter* layerSorter, int maxTextureSize, Vector<CCLayerImpl*>& renderSurfaceLayerList) |
{ |
IntRect totalDrawableContentRect; |
WebTransformationMatrix identityMatrix; |
@@ -806,8 +847,8 @@ void CCLayerTreeHostCommon::calculateDrawTransforms(CCLayerImpl* rootLayer, cons |
setupRootLayerAndSurfaceForRecursion<CCLayerImpl, Vector<CCLayerImpl*> >(rootLayer, renderSurfaceLayerList, deviceViewportSize); |
cc::calculateDrawTransformsInternal<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerSorter>(rootLayer, rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, |
- rootLayer->renderSurface()->contentRect(), true, 0, renderSurfaceLayerList, |
- rootLayer->renderSurface()->layerList(), layerSorter, maxTextureSize, deviceScaleFactor, totalDrawableContentRect); |
+ rootLayer->renderSurface()->contentRect(), true, 0, renderSurfaceLayerList, |
+ rootLayer->renderSurface()->layerList(), layerSorter, maxTextureSize, deviceScaleFactor, pageScaleFactor, totalDrawableContentRect); |
} |
void CCLayerTreeHostCommon::calculateVisibleRects(Vector<RefPtr<LayerChromium> >& renderSurfaceLayerList) |