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

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: rebase with TOT, addressed comments 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 52b72009b84649f2fb7f25a015616b9053315873..e2ff0848aa3fe7a6504f8df1775a872d53e2224f 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -390,7 +390,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.
@@ -485,10 +486,14 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
bool subtreeShouldBeClipped = false;
float drawOpacity = layer->opacity();
- bool drawOpacityIsAnimating = layer->opacityIsAnimating();
- if (layer->parent() && layer->parent()->preserves3D()) {
- drawOpacity *= layer->parent()->drawOpacity();
- drawOpacityIsAnimating |= layer->parent()->drawOpacityIsAnimating();
+ bool animatingOpacityToTarget = layer->opacityIsAnimating();
+ bool animatingOpacityToScreen = animatingOpacityToTarget;
+ if (layer->parent()) {
+ if (layer->parent()->preserves3D()) {
+ drawOpacity *= layer->parent()->drawOpacity();
+ animatingOpacityToTarget |= layer->parent()->drawOpacityIsAnimating();
+ }
+ animatingOpacityToScreen |= layer->parent()->screenSpaceOpacityIsAnimating();
}
bool animatingTransformToTarget = layer->transformIsAnimating();
@@ -544,6 +549,11 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
layerScreenSpaceTransform.multiply(drawTransform);
layer->setScreenSpaceTransform(layerScreenSpaceTransform);
+ // Adjusting text AA method during animation may cause repaints, which in-turn jank.
enne (OOO) 2012/11/14 17:42:15 Grammar. "which in turn causes jank." maybe?
alokp 2012/11/16 04:41:11 Done.
+ bool adjustTextAA = !animatingOpacityToScreen && !animatingTransformToScreen;
+ // To avoid color fringing, LCD text should only be used on opaque layers with just integral translation.
enne (OOO) 2012/11/14 17:42:15 If this is true, where is the check for opaque()?
alokp 2012/11/16 04:41:11 We check for draw-opacity here. Check for content-
enne (OOO) 2012/11/16 17:36:38 Can you point me at where this check is currently
alokp 2012/11/16 21:33:52 http://trac.webkit.org/browser/trunk/Source/WebCor
+ bool layerCanUseLCDText = adjustTextAA && canUseLCDText && (drawOpacity == 1.0) && drawTransform.isIntegerTranslation();
enne (OOO) 2012/11/14 17:42:15 Can you rename canUseLCDText to something more lik
alokp 2012/11/16 04:41:11 Done.
+
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.
@@ -586,9 +596,11 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
// The opacity value is moved from the layer to its surface, so that the entire subtree properly inherits opacity.
renderSurface->setDrawOpacity(drawOpacity);
- renderSurface->setDrawOpacityIsAnimating(drawOpacityIsAnimating);
+ renderSurface->setDrawOpacityIsAnimating(animatingOpacityToTarget);
+ animatingOpacityToTarget = false;
layer->setDrawOpacity(1);
- layer->setDrawOpacityIsAnimating(false);
+ layer->setDrawOpacityIsAnimating(animatingOpacityToTarget);
+ layer->setScreenSpaceOpacityIsAnimating(animatingOpacityToScreen);
renderSurface->setTargetSurfaceTransformsAreAnimating(animatingTransformToTarget);
renderSurface->setScreenSpaceTransformsAreAnimating(animatingTransformToScreen);
@@ -629,6 +641,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());
@@ -639,7 +655,8 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
sublayerMatrix = combinedTransform;
layer->setDrawOpacity(drawOpacity);
- layer->setDrawOpacityIsAnimating(drawOpacityIsAnimating);
+ layer->setDrawOpacityIsAnimating(animatingOpacityToTarget);
+ layer->setScreenSpaceOpacityIsAnimating(animatingOpacityToScreen);
layer->clearRenderSurface();
@@ -652,6 +669,9 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
layer->setRenderTarget(layer->parent()->renderTarget());
}
+ if (adjustTextAA)
+ layer->setCanUseLCDText(layerCanUseLCDText);
+
gfx::Rect rectInTargetSpace = ToEnclosingRect(MathUtil::mapClippedRect(layer->drawTransform(), contentRect));
if (layerClipsSubtree(layer)) {
@@ -688,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())
@@ -807,7 +828,7 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform
layer->renderTarget()->renderSurface()->addContributingDelegatedRenderPassLayer(layer);
}
-void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerList)
+void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, int maxTextureSize, bool canUseLCDText, std::vector<scoped_refptr<Layer> >& renderSurfaceLayerList)
{
gfx::Rect totalDrawableContentRect;
WebTransformationMatrix identityMatrix;
@@ -826,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);
@@ -834,7 +855,7 @@ void LayerTreeHostCommon::calculateDrawTransforms(Layer* rootLayer, const gfx::S
DCHECK(rootLayer->renderSurface());
}
-void LayerTreeHostCommon::calculateDrawTransforms(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, LayerSorter* layerSorter, int maxTextureSize, std::vector<LayerImpl*>& renderSurfaceLayerList)
+void LayerTreeHostCommon::calculateDrawTransforms(LayerImpl* rootLayer, const gfx::Size& deviceViewportSize, float deviceScaleFactor, float pageScaleFactor, LayerSorter* layerSorter, int maxTextureSize, bool canUseLCDText, std::vector<LayerImpl*>& renderSurfaceLayerList)
{
gfx::Rect totalDrawableContentRect;
WebTransformationMatrix identityMatrix;
@@ -853,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