Chromium Code Reviews| Index: cc/trees/property_tree.cc |
| diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc |
| index d3a0dc8d8df6edce828ba7c2693cf760348172c3..3cf044bb8b2f093b16622edb616e0326f03ac81b 100644 |
| --- a/cc/trees/property_tree.cc |
| +++ b/cc/trees/property_tree.cc |
| @@ -668,19 +668,43 @@ void TransformTree::UpdateNodeAndAncestorsAreAnimatedOrInvertible( |
| node->has_potential_animation || is_invertible; |
| } |
| -void TransformTree::SetDeviceTransform(const gfx::Transform& transform, |
| - gfx::PointF root_position) { |
| - gfx::Transform root_post_local = transform; |
| - TransformNode* node = Node(1); |
| - root_post_local.Scale(node->post_local_scale_factor, |
| - node->post_local_scale_factor); |
| - root_post_local.Translate(root_position.x(), root_position.y()); |
| - if (node->post_local == root_post_local) |
| - return; |
| - |
| - node->post_local = root_post_local; |
| - node->needs_local_transform_update = true; |
| +void TransformTree::SetRootTransformsAndScales( |
| + float device_scale_factor, |
| + float page_scale_factor_for_root, |
| + const gfx::Transform& device_transform, |
| + gfx::PointF root_position) { |
| + // If DT is the device transform, DSF is the matrix scaled by (device scale |
| + // factor * page scale factor for root), RP is the matrix translated by root's |
| + // position, |
| + // Let Screen Space Scale(SSS) = scale component of DT*DSF*RP, |
| + // then the screen space transform of the root transform node is set to SSS |
| + // and the post local transform of the contents root node is set to |
| + // SSS^-1*DT*DSF*RP. |
| + gfx::Transform transform = device_transform; |
| + transform.Scale(device_scale_factor * page_scale_factor_for_root, |
| + device_scale_factor * page_scale_factor_for_root); |
| + transform.Translate(root_position.x(), root_position.y()); |
| + float fallback_value = device_scale_factor * page_scale_factor_for_root; |
| + gfx::Vector2dF screen_space_scale = |
| + MathUtil::ComputeTransform2dScaleComponents(transform, fallback_value); |
| + DCHECK_NE(screen_space_scale.x(), 0.f); |
| + DCHECK_NE(screen_space_scale.y(), 0.f); |
| + |
| + gfx::Transform root_to_screen; |
| + root_to_screen.Scale(screen_space_scale.x(), screen_space_scale.y()); |
| + gfx::Transform root_from_screen; |
| + bool invertible = root_to_screen.GetInverse(&root_from_screen); |
| + DCHECK(invertible); |
| + SetToScreen(kRootNodeId, root_to_screen); |
| + SetFromScreen(kRootNodeId, root_from_screen); |
| set_needs_update(true); |
| + |
| + transform.ConcatTransform(root_from_screen); |
| + TransformNode* contents_root_node = Node(kContentsRootNodeId); |
| + if (contents_root_node->post_local != transform) { |
| + contents_root_node->post_local = transform; |
| + contents_root_node->needs_local_transform_update = true; |
| + } |
| } |
| void TransformTree::SetDeviceTransformScaleFactor( |
|
weiliangc
2016/11/02 15:38:21
Could this function be folded into above function?
jaydasika
2016/11/02 17:36:55
Done.
|
| @@ -952,8 +976,7 @@ void EffectTree::UpdateBackfaceVisibility(EffectNode* node, |
| } |
| void EffectTree::UpdateSurfaceContentsScale(EffectNode* effect_node) { |
| - if (!effect_node->has_render_surface || |
| - effect_node->transform_id == kRootNodeId) { |
| + if (!effect_node->has_render_surface) { |
| effect_node->surface_contents_scale = gfx::Vector2dF(1.0f, 1.0f); |
| return; |
| } |
| @@ -2178,10 +2201,9 @@ DrawTransforms& PropertyTrees::GetDrawTransforms(int transform_id, |
| } else if (transform_id > dest_id) { |
| transform_tree.CombineTransformsBetween(transform_id, dest_id, |
| &target_space_transform); |
| - if (dest_id != TransformTree::kRootNodeId) |
| - target_space_transform.matrix().postScale( |
| - effect_node->surface_contents_scale.x(), |
| - effect_node->surface_contents_scale.y(), 1.f); |
| + target_space_transform.matrix().postScale( |
| + effect_node->surface_contents_scale.x(), |
| + effect_node->surface_contents_scale.y(), 1.f); |
| data.transforms.to_valid = true; |
| data.transforms.from_valid = false; |
| data.transforms.might_be_invertible = true; |