Chromium Code Reviews| Index: cc/layer_tree_host_common.cc |
| diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc |
| index e64a339aa8c2f3d7afc0848bdd401e50336f015c..b432b03ce59e3c23b2f4e92956388da31dec5d00 100644 |
| --- a/cc/layer_tree_host_common.cc |
| +++ b/cc/layer_tree_host_common.cc |
| @@ -388,7 +388,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. |
| @@ -483,10 +484,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(); |
| @@ -542,6 +547,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. |
| + bool adjustTextAA = !animatingOpacityToScreen && !animatingTransformToScreen; |
| + // To avoid color fringing, LCD text should only be used on opaque layers with just integral translation. |
| + bool layerCanUseLCDText = adjustTextAA && canUseLCDText && (drawOpacity == 1.0) && drawTransform.isIntegerTranslation(); |
|
danakj
2012/11/10 01:12:35
I still don't understand why adjustTextAA is part
alokp
2012/11/12 01:04:45
Sorry for the confusion. adjustTextAA and canUseLC
danakj
2012/11/12 01:25:47
Ya, I think having the layerCanUseLCDText variable
alokp
2012/11/12 03:58:42
It is essentially that. adjustTextAA is part of th
danakj
2012/11/12 05:55:03
Ohh okay, I see.
Can you please add a comment ex
alokp
2012/11/12 16:50:10
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. |
| @@ -584,14 +594,14 @@ 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); |
| layer->setDrawOpacity(1); |
| layer->setDrawOpacityIsAnimating(false); |
| + layer->setScreenSpaceOpacityIsAnimating(animatingOpacityToScreen); |
| renderSurface->setTargetSurfaceTransformsAreAnimating(animatingTransformToTarget); |
| renderSurface->setScreenSpaceTransformsAreAnimating(animatingTransformToScreen); |
| - animatingTransformToTarget = false; |
| - layer->setDrawTransformIsAnimating(animatingTransformToTarget); |
| + layer->setDrawTransformIsAnimating(false); |
|
danakj
2012/11/10 01:12:35
Can you undo this unrelated change?
alokp
2012/11/12 01:04:45
It is not entirely unrelated. It makes transform h
danakj
2012/11/12 01:25:47
If any code later in the method wants to check ani
alokp
2012/11/12 03:58:42
reverted.
|
| layer->setScreenSpaceTransformIsAnimating(animatingTransformToScreen); |
| // Update the aggregate hierarchy matrix to include the transform of the |
| @@ -627,6 +637,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()); |
| @@ -637,7 +651,8 @@ static void calculateDrawTransformsInternal(LayerType* layer, const WebTransform |
| sublayerMatrix = combinedTransform; |
| layer->setDrawOpacity(drawOpacity); |
| - layer->setDrawOpacityIsAnimating(drawOpacityIsAnimating); |
| + layer->setDrawOpacityIsAnimating(animatingOpacityToTarget); |
| + layer->setScreenSpaceOpacityIsAnimating(animatingOpacityToScreen); |
| layer->clearRenderSurface(); |
| @@ -650,6 +665,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)) { |
| @@ -686,7 +704,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()) |
| @@ -805,7 +824,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; |
| @@ -824,7 +843,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); |
| @@ -832,7 +851,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; |
| @@ -851,7 +870,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); |