Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Unified Diff: cc/CCLayerTreeHostCommon.cpp

Issue 10915313: cc: Apply the layer's initial CSS scale to the contentsScale to render text at the right resolution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove extra header Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/CCLayerTreeHostCommon.cpp
diff --git a/cc/CCLayerTreeHostCommon.cpp b/cc/CCLayerTreeHostCommon.cpp
index d60d43c0930631c4e7b40bcb53bf1ec85b11c05d..a644f39c5598da63a8644f37d3ea79541abe7b7b 100644
--- a/cc/CCLayerTreeHostCommon.cpp
+++ b/cc/CCLayerTreeHostCommon.cpp
@@ -325,6 +325,31 @@ WebTransformationMatrix computeScrollCompensationMatrixForChildren(CCLayerImpl*
return nextScrollCompensationMatrix;
}
+// There is no contentsScale on impl thread.
+static inline void updateLayerContentsScale(CCLayerImpl*, float, float) { }
+
+static inline void updateLayerContentsScale(LayerChromium* layer, float combinedScale, float pageScaleFactor)
+{
+ if (layer->transformIsAnimating())
+ return;
+
+ float contentsScale = combinedScale;
+
+ // FIXME: Remove this when pageScaleFactor is applied in the compositor and becomes part of the parentTransform during the tree walk.
+ 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)
@@ -346,7 +371,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.
@@ -479,6 +504,21 @@ 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.
+ float combinedScale = 1;
+ if (!layer->transformIsAnimating()) {
+ WebTransformationMatrix flatTransform = combinedTransform;
+ 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);
+ combinedScale = fmaxf(CCMathUtil::distanceBetweenPoints(xScale, origin), CCMathUtil::distanceBetweenPoints(yScale, origin));
+ }
+ updateLayerContentsScale(layer, combinedScale, 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;
@@ -639,7 +679,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())
@@ -773,7 +813,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;
@@ -783,11 +823,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;
@@ -797,8 +837,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)
« no previous file with comments | « cc/CCLayerTreeHostCommon.h ('k') | cc/CCLayerTreeHostCommonTest.cpp » ('j') | cc/CCMathUtil.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698