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

Unified Diff: cc/layer_tree_host_common.cc

Issue 11360093: Mark layers that can use LCD text based on layer transform and opacity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed unit tests Created 8 years, 1 month 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/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);

Powered by Google App Engine
This is Rietveld 408576698