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

Unified Diff: cc/trees/property_tree.cc

Issue 2464103005: cc : Reland Move screen space scale factor to root transform node (Closed)
Patch Set: Reland patch Created 4 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
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/property_tree.cc
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc
index acc34795448ed974e952394e018b5092d051f8e9..9faa616a04889f1635f3282f3b3d7c71ade3cc1f 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -607,11 +607,9 @@ void TransformTree::UpdateTargetSpaceTransform(TransformNode* node,
// to the root of the transform tree in ComputeTransform.
int target_id = target_node->id;
ComputeTransform(node->id, target_id, &target_space_transform);
- if (target_id != kRootNodeId) {
- target_space_transform.matrix().postScale(
- target_node->surface_contents_scale.x(),
- target_node->surface_contents_scale.y(), 1.f);
- }
+ target_space_transform.matrix().postScale(
+ target_node->surface_contents_scale.x(),
+ target_node->surface_contents_scale.y(), 1.f);
}
gfx::Transform from_target;
@@ -705,30 +703,54 @@ 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;
- set_needs_update(true);
-}
-
-void TransformTree::SetDeviceTransformScaleFactor(
- const gfx::Transform& transform) {
+void TransformTree::SetRootTransformsAndScales(
+ float device_scale_factor,
+ float page_scale_factor_for_root,
+ const gfx::Transform& device_transform,
+ gfx::PointF root_position) {
gfx::Vector2dF device_transform_scale_components =
- MathUtil::ComputeTransform2dScaleComponents(transform, 1.f);
+ MathUtil::ComputeTransform2dScaleComponents(device_transform, 1.f);
// Not handling the rare case of different x and y device scale.
device_transform_scale_factor_ =
std::max(device_transform_scale_components.x(),
device_transform_scale_components.y());
+
+ // 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);
+ TransformNode* root_node = Node(kRootNodeId);
+ root_node->needs_surface_contents_scale = true;
+ root_node->surface_contents_scale = screen_space_scale;
+ 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::UpdateInnerViewportContainerBoundsDelta() {
@@ -1027,8 +1049,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;
}
@@ -1148,11 +1169,8 @@ void EffectTree::TakeCopyRequestsAndTransformToSurface(
gfx::Transform transform;
property_trees()->transform_tree.ComputeTransform(source_id, destination_id,
&transform);
- if (effect_node->id != kContentsRootNodeId) {
- transform.matrix().postScale(effect_node->surface_contents_scale.x(),
- effect_node->surface_contents_scale.y(),
- 1.f);
- }
+ transform.matrix().postScale(effect_node->surface_contents_scale.x(),
+ effect_node->surface_contents_scale.y(), 1.f);
it->set_area(MathUtil::MapEnclosingClippedRect(transform, it->area()));
}
}
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698