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

Unified Diff: cc/layer_tree_host_common.cc

Issue 12224113: [cc] Apply sublayer transform about anchor instead of about layer center. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows build error Created 7 years, 10 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
« no previous file with comments | « no previous file | cc/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_tree_host_common.cc
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index e316c370fad9a7c6f3423e0b97c60f7764cd2398..4d3377a919de45164bb5a33f7b0663b8d4397fcd 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -169,6 +169,7 @@ static inline bool transformToParentIsKnown(LayerImpl*)
static inline bool transformToParentIsKnown(Layer* layer)
{
+
return !layer->transformIsAnimating();
}
@@ -570,15 +571,12 @@ static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo
// Tr[origin2anchor] is the translation from the layer's origin to its anchor point
// Tr[origin2center] is the translation from the layer's origin to its center
// M[layer] is the layer's matrix (applied at the anchor point)
- // M[sublayer] is the layer's sublayer transform (applied at the layer's center)
+ // M[sublayer] is the layer's sublayer transform (also applied at the layer's anchor point)
// S[layer2content] is the ratio of a layer's contentBounds() to its bounds().
//
// Some composite transforms can help in understanding the sequence of transforms:
// compositeLayerTransform = Tr[origin2anchor] * M[layer] * Tr[origin2anchor].inverse()
- // compositeSublayerTransform = Tr[origin2center] * M[sublayer] * Tr[origin2center].inverse()
- //
- // In words, the layer transform is applied about the anchor point, and the sublayer transform is
- // applied about the center of the layer.
+ // compositeSublayerTransform = Tr[origin2anchor] * M[sublayer] * Tr[origin2anchor].inverse()
//
// 4. When a layer (or render surface) is drawn, it is drawn into a "target render surface". Therefore the draw
// transform does not necessarily transform from screen space to local layer space. Instead, the draw transform
@@ -754,7 +752,7 @@ static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo
layerDrawProperties.target_space_transform.Scale(renderSurfaceSublayerScale.x() / layer->contentsScaleX(), renderSurfaceSublayerScale.y() / layer->contentsScaleY());
// Inside the surface's subtree, we scale everything to the owning layer's scale.
- // The sublayer matrix transforms centered layer rects into target
+ // The sublayer matrix transforms layer rects into target
// surface content space.
DCHECK(sublayerMatrix.IsIdentity());
sublayerMatrix.Scale(renderSurfaceSublayerScale.x(), renderSurfaceSublayerScale.y());
@@ -867,11 +865,11 @@ static void calculateDrawPropertiesInternal(LayerType* layer, const gfx::Transfo
if (!layer->preserves3D())
sublayerMatrix.FlattenTo2d();
- // Apply the sublayer transform at the center of the layer.
+ // Apply the sublayer transform at the anchor point of the layer.
if (!layer->sublayerTransform().IsIdentity()) {
- sublayerMatrix.Translate(0.5 * bounds.width(), 0.5 * bounds.height());
+ sublayerMatrix.Translate(layer->anchorPoint().x() * bounds.width(), layer->anchorPoint().y() * bounds.height());
sublayerMatrix.PreconcatTransform(layer->sublayerTransform());
- sublayerMatrix.Translate(-0.5 * bounds.width(), -0.5 * bounds.height());
+ sublayerMatrix.Translate(-layer->anchorPoint().x() * bounds.width(), -layer->anchorPoint().y() * bounds.height());
}
LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->layerList() : layerList);
« no previous file with comments | « no previous file | cc/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698