Index: cc/layer_tree_host_common.cc |
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc |
index 662d5d82098e4a224d060daaa854c9b4ac3cf06b..60078ad73b21c8d71629e87e1661a59b374186f5 100644 |
--- a/cc/layer_tree_host_common.cc |
+++ b/cc/layer_tree_host_common.cc |
@@ -29,6 +29,15 @@ ScrollAndScaleSet::~ScrollAndScaleSet() |
{ |
} |
+bool LayerTreeHostCommon::canUseLCDText() |
+{ |
+#if OS(ANDROID) |
+ return false; |
+#else |
+ return true; |
+#endif |
+} |
+ |
gfx::Rect LayerTreeHostCommon::calculateVisibleRect(const gfx::Rect& targetSurfaceRect, const gfx::Rect& layerBoundRect, const WebTransformationMatrix& transform) |
{ |
// Is this layer fully contained within the target surface? |
@@ -388,7 +397,8 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform |
const WebTransformationMatrix& fullHierarchyMatrix, const WebTransformationMatrix& currentScrollCompensationMatrix, |
const gfx::Rect& clipRectFromAncestor, bool ancestorClipsSubtree, |
RenderSurfaceType* nearestAncestorThatMovesPixels, LayerList& renderSurfaceLayerList, LayerList& layerList, |
- LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, gfx::Rect& drawableContentRectOfSubtree) |
+ LayerSorter* layerSorter, int maxTextureSize, float deviceScaleFactor, float pageScaleFactor, bool canUseLCDText, |
+ gfx::Rect& drawableContentRectOfSubtree) |
{ |
// This function computes the new matrix transformations recursively for this |
// layer and all its descendants. It also computes the appropriate render surfaces. |
@@ -542,6 +552,11 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform |
animatingTransformToScreen |= layer->parent()->screenSpaceTransformIsAnimating(); |
} |
+ // Adjusting text AA method during animation may cause repaints, which in-turn jank. |
+ bool canAdjustTextAA = !drawOpacityIsAnimating && !animatingTransformToScreen; |
+ // To avoid color fringing, LCD text should only be used on opaque layers with just integral translation. |
+ bool layerCanUseLCDText = canAdjustTextAA ? canUseLCDText && (drawOpacity == 1.0) && drawTransform.isIntegerTranslation() : false; |
danakj
2012/11/07 18:15:00
This statement is weird to me. It is essentially:
alokp
2012/11/08 22:34:07
You are right. The logic to NOT mess with text AA
|
+ |
gfx::RectF contentRect(gfx::PointF(), layer->contentBounds()); |
// fullHierarchyMatrix is the matrix that transforms objects between screen space (except projection matrix) and the most recent RenderSurfaceImpl's space. |
@@ -627,6 +642,10 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform |
renderSurface->setNearestAncestorThatMovesPixels(nearestAncestorThatMovesPixels); |
+ // If the new render surface is drawn translucent or with a non-integral translation |
+ // then the subtree that gets drawn on this render surface cannot use LCD text. |
+ canUseLCDText = layerCanUseLCDText; |
+ |
renderSurfaceLayerList.push_back(layer); |
} else { |
DCHECK(layer->parent()); |
@@ -650,6 +669,9 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform |
layer->setRenderTarget(layer->parent()->renderTarget()); |
} |
+ if (canAdjustTextAA) |
+ layer->setCanUseLCDText(layerCanUseLCDText); |
+ |
gfx::Rect rectInTargetSpace = ToEnclosingRect(MathUtil::mapClippedRect(layer->drawTransform(), contentRect)); |
if (layerClipsSubtree(layer)) { |
@@ -686,7 +708,8 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform |
gfx::Rect drawableContentRectOfChildSubtree; |
calculateDrawTransformsInternal<LayerType, LayerList, RenderSurfaceType, LayerSorter>(child, sublayerMatrix, nextHierarchyMatrix, nextScrollCompensationMatrix, |
clipRectForSubtree, subtreeShouldBeClipped, nearestAncestorThatMovesPixels, |
- renderSurfaceLayerList, descendants, layerSorter, maxTextureSize, deviceScaleFactor, pageScaleFactor, drawableContentRectOfChildSubtree); |
+ renderSurfaceLayerList, descendants, layerSorter, maxTextureSize, deviceScaleFactor, pageScaleFactor, canUseLCDText, |
+ drawableContentRectOfChildSubtree); |
if (!drawableContentRectOfChildSubtree.IsEmpty()) { |
accumulatedDrawableContentRectOfChildren.Union(drawableContentRectOfChildSubtree); |
if (child->renderSurface()) |
@@ -824,7 +847,7 @@ void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const gfx::S |
rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, |
deviceViewportRect, subtreeShouldBeClipped, 0, renderSurfaceLayerList, |
dummyLayerList, 0, maxTextureSize, |
- deviceScaleFactor, pageScaleFactor, totalDrawableContentRect); |
+ deviceScaleFactor, pageScaleFactor, canUseLCDText(), totalDrawableContentRect); |
// The dummy layer list should not have been used. |
DCHECK(dummyLayerList.size() == 0); |
@@ -851,7 +874,7 @@ void LayerTreeHostCommon::calculateDrawTransforms(LayerImpl* rootLayer, const gf |
rootLayer, deviceScaleTransform, identityMatrix, identityMatrix, |
deviceViewportRect, subtreeShouldBeClipped, 0, renderSurfaceLayerList, |
dummyLayerList, layerSorter, maxTextureSize, |
- deviceScaleFactor, pageScaleFactor, totalDrawableContentRect); |
+ deviceScaleFactor, pageScaleFactor, canUseLCDText(), totalDrawableContentRect); |
// The dummy layer list should not have been used. |
DCHECK(dummyLayerList.size() == 0); |