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

Unified Diff: cc/trees/property_tree.cc

Issue 2408243002: cc : Move screen space scale factor to root transform node (Closed)
Patch Set: test Created 4 years, 2 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
Index: cc/trees/property_tree.cc
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc
index acc34795448ed974e952394e018b5092d051f8e9..dddba3637390bb3f6c6a22b9cc5768d4935666ad 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;
@@ -707,15 +705,18 @@ void TransformTree::UpdateNodeAndAncestorsAreAnimatedOrInvertible(
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)
+ gfx::Vector2dF device_transform_scale_components =
+ MathUtil::ComputeTransform2dScaleComponents(transform, 1.f);
+ gfx::Transform post_local = transform;
+ post_local.matrix().postScale(1.f / device_transform_scale_components.x(),
+ 1.f / device_transform_scale_components.y(),
+ 1.f);
+ post_local.Translate(root_position.x(), root_position.y());
+
+ TransformNode* node = Node(kContentsRootNodeId);
+ if (node->post_local == post_local)
return;
-
- node->post_local = root_post_local;
+ node->post_local = post_local;
node->needs_local_transform_update = true;
set_needs_update(true);
}
@@ -731,6 +732,32 @@ void TransformTree::SetDeviceTransformScaleFactor(
device_transform_scale_components.y());
}
+void TransformTree::SetScreenSpaceScale(float device_scale_factor,
+ float page_scale_factor_for_root,
+ gfx::Transform device_transform) {
+ gfx::Vector2dF device_transform_scale_components =
+ MathUtil::ComputeTransform2dScaleComponents(device_transform, 1.f);
+ gfx::Vector2dF screen_space_scale_components(
+ device_transform_scale_components.x() * device_scale_factor *
+ page_scale_factor_for_root,
+ device_transform_scale_components.y() * device_scale_factor *
+ page_scale_factor_for_root);
+ TransformNode* node = Node(kRootNodeId);
+ if (node->surface_contents_scale == screen_space_scale_components)
+ return;
+ node->needs_surface_contents_scale = true;
+ node->surface_contents_scale = screen_space_scale_components;
+ gfx::Transform to_screen;
+ to_screen.Scale(node->surface_contents_scale.x(),
+ node->surface_contents_scale.y());
+ SetToScreen(node->id, to_screen);
+ gfx::Transform from_screen;
+ if (!ToScreen(node->id).GetInverse(&from_screen))
+ node->ancestors_are_invertible = false;
+ SetFromScreen(node->id, from_screen);
+ set_needs_update(true);
+}
+
void TransformTree::UpdateInnerViewportContainerBoundsDelta() {
if (nodes_affected_by_inner_viewport_bounds_delta_.empty())
return;
@@ -1027,8 +1054,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 +1174,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()));
}
}

Powered by Google App Engine
This is Rietveld 408576698