Index: cc/CCLayerTreeHostCommon.cpp |
diff --git a/cc/CCLayerTreeHostCommon.cpp b/cc/CCLayerTreeHostCommon.cpp |
index 141b3ffd172a8912bafe758e604579bd71c1ca02..f7cf3229e1b118989ab24ac83ead76cf0c91571e 100644 |
--- a/cc/CCLayerTreeHostCommon.cpp |
+++ b/cc/CCLayerTreeHostCommon.cpp |
@@ -333,6 +333,41 @@ 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) { |
+ WebTransformationMatrix flatTransform = combinedTransform; |
enne (OOO)
2012/10/02 19:13:18
Do you want the combinedTransform here or the scre
|
+ CCMathUtil::flattenTransformTo2d(flatTransform); |
+ |
+ bool clipped; |
+ FloatPoint origin = CCMathUtil::mapPoint(flatTransform, FloatPoint(0, 0), clipped); |
+ FloatPoint xScale = CCMathUtil::mapPoint(flatTransform, FloatPoint(1, 0), clipped); |
+ FloatPoint yScale = CCMathUtil::mapPoint(flatTransform, FloatPoint(0, 1), clipped); |
+ float combinedScale = fmaxf(CCMathUtil::distanceBetweenPoints(xScale, origin), CCMathUtil::distanceBetweenPoints(yScale, origin)); |
+ 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 +389,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) |
enne (OOO)
2012/10/02 19:13:18
How about an input struct to this function?
|
{ |
// This function computes the new matrix transformations recursively for this |
// layer and all its descendants. It also computes the appropriate render surfaces. |
@@ -487,6 +522,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; |
@@ -647,7 +686,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()) |
@@ -782,7 +821,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 +831,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 +845,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) |