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

Unified Diff: cc/trees/property_tree.cc

Issue 2448403002: cc: Clean up transform tree (Closed)
Patch Set: PAC 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
« 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 795e337aa18b94cce584e717df8ef09f5449290f..00a0025a3a2f29b145520de41f0eb6910fc56faa 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -24,6 +24,7 @@
#include "cc/trees/scroll_node.h"
#include "cc/trees/transform_node.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
+
namespace cc {
template <typename T>
@@ -180,9 +181,10 @@ void TransformTree::set_needs_update(bool needs_update) {
needs_update_ = needs_update;
}
-bool TransformTree::ComputeTransform(int source_id,
- int dest_id,
- gfx::Transform* transform) const {
+bool TransformTree::ComputeTransformForTesting(
+ int source_id,
+ int dest_id,
+ gfx::Transform* transform) const {
transform->MakeIdentity();
if (source_id == dest_id)
@@ -278,7 +280,6 @@ void TransformTree::UpdateTransforms(int id) {
UndoSnapping(node);
}
UpdateScreenSpaceTransform(node, parent_node, target_node);
- UpdateSurfaceContentsScale(node);
UpdateAnimationProperties(node, parent_node);
UpdateSnapping(node);
UpdateNodeAndAncestorsHaveIntegerTranslations(node, parent_node);
@@ -332,22 +333,11 @@ void TransformTree::CombineTransformsBetween(int source_id,
std::vector<int> source_to_destination;
source_to_destination.push_back(current->id);
current = parent(current);
- bool destination_has_non_zero_surface_contents_scale =
- dest->surface_contents_scale.x() != 0.f &&
- dest->surface_contents_scale.y() != 0.f;
- DCHECK(destination_has_non_zero_surface_contents_scale ||
- !dest->ancestors_are_invertible);
for (; current && current->id > dest_id; current = parent(current))
source_to_destination.push_back(current->id);
gfx::Transform combined_transform;
- if (current->id > dest_id) {
- // The stored target space transform has surface contents scale baked in,
- // but we need the unscaled transform.
- combined_transform.matrix().postScale(
- 1.0f / dest->surface_contents_scale.x(),
- 1.0f / dest->surface_contents_scale.y(), 1.0f);
- } else if (current->id < dest_id) {
+ if (current->id < dest_id) {
// We have reached the lowest common ancestor of the source and destination
// nodes. This case can occur when we are transforming between a node
// corresponding to a fixed-position layer (or its descendant) and the node
@@ -583,46 +573,6 @@ void TransformTree::UpdateScreenSpaceTransform(TransformNode* node,
SetFromScreen(node->id, from_screen);
}
-void TransformTree::UpdateSurfaceContentsScale(TransformNode* node) {
- // The surface contents scale depends on the screen space transform, so update
- // it too.
- if (!node->needs_surface_contents_scale) {
- node->surface_contents_scale = gfx::Vector2dF(1.0f, 1.0f);
- return;
- }
-
- float layer_scale_factor =
- device_scale_factor_ * device_transform_scale_factor_;
- if (node->in_subtree_of_page_scale_layer)
- layer_scale_factor *= page_scale_factor_;
- node->surface_contents_scale = MathUtil::ComputeTransform2dScaleComponents(
- ToScreen(node->id), layer_scale_factor);
-}
-
-void TransformTree::UpdateTargetSpaceTransform(TransformNode* node,
- TransformNode* target_node) {
- gfx::Transform target_space_transform;
- if (node->needs_surface_contents_scale) {
- target_space_transform.MakeIdentity();
- target_space_transform.Scale(node->surface_contents_scale.x(),
- node->surface_contents_scale.y());
- } else {
- // In order to include the root transform for the root surface, we walk up
- // to the root of the transform tree in ComputeTransform.
- int target_id = target_node->id;
- ComputeTransform(node->id, target_id, &target_space_transform);
- target_space_transform.matrix().postScale(
- target_node->surface_contents_scale.x(),
- target_node->surface_contents_scale.y(), 1.f);
- }
-
- gfx::Transform from_target;
- if (!target_space_transform.GetInverse(&from_target))
- node->ancestors_are_invertible = false;
- SetToTarget(node->id, target_space_transform);
- SetFromTarget(node->id, from_target);
-}
-
void TransformTree::UpdateAnimationProperties(TransformNode* node,
TransformNode* parent_node) {
bool ancestor_is_animating = false;
@@ -728,13 +678,11 @@ void TransformTree::SetContentsRootPostLocalTransform(
void TransformTree::SetScreenSpaceScaleOnRootNode(
gfx::Vector2dF screen_space_scale_components) {
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());
+ to_screen.Scale(screen_space_scale_components.x(),
+ screen_space_scale_components.y());
+ if (ToScreen(node->id) == to_screen)
+ return;
SetToScreen(node->id, to_screen);
gfx::Transform from_screen;
if (!ToScreen(node->id).GetInverse(&from_screen))
@@ -804,29 +752,6 @@ bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const {
return !nodes_affected_by_outer_viewport_bounds_delta_.empty();
}
-gfx::Transform TransformTree::FromTarget(int node_id, int effect_id) const {
- gfx::Transform from_target;
- property_trees()->GetFromTarget(node_id, effect_id, &from_target);
- return from_target;
-}
-
-void TransformTree::SetFromTarget(int node_id,
- const gfx::Transform& transform) {
- DCHECK(static_cast<int>(cached_data_.size()) > node_id);
- cached_data_[node_id].from_target = transform;
-}
-
-gfx::Transform TransformTree::ToTarget(int node_id, int effect_id) const {
- gfx::Transform to_target;
- property_trees()->GetToTarget(node_id, effect_id, &to_target);
- return to_target;
-}
-
-void TransformTree::SetToTarget(int node_id, const gfx::Transform& transform) {
- DCHECK(static_cast<int>(cached_data_.size()) > node_id);
- cached_data_[node_id].to_target = transform;
-}
-
const gfx::Transform& TransformTree::FromScreen(int node_id) const {
DCHECK(static_cast<int>(cached_data_.size()) > node_id);
return cached_data_[node_id].from_screen;
@@ -1035,8 +960,8 @@ void EffectTree::UpdateBackfaceVisibility(EffectNode* node,
parent_transform_node->sorting_context_id ==
transform_node->sorting_context_id) {
gfx::Transform surface_draw_transform;
- property_trees()->ComputeTransformToTarget(
- transform_node->id, node->target_id, &surface_draw_transform);
+ property_trees()->GetToTarget(transform_node->id, node->target_id,
+ &surface_draw_transform);
node->hidden_by_backface_visibility =
surface_draw_transform.IsBackFaceVisible();
} else {
@@ -1169,10 +1094,7 @@ void EffectTree::TakeCopyRequestsAndTransformToSurface(
source_id = TransformTree::kContentsRootNodeId;
}
gfx::Transform transform;
- property_trees()->transform_tree.ComputeTransform(source_id, destination_id,
- &transform);
- transform.matrix().postScale(effect_node->surface_contents_scale.x(),
- effect_node->surface_contents_scale.y(), 1.f);
+ property_trees()->GetToTarget(source_id, node_id, &transform);
it->set_area(MathUtil::MapEnclosingClippedRect(transform, it->area()));
}
}
@@ -2339,25 +2261,6 @@ gfx::Transform PropertyTrees::ToScreenSpaceTransformWithoutSurfaceContentsScale(
return screen_space_transform;
}
-bool PropertyTrees::ComputeTransformToTarget(int transform_id,
- int effect_id,
- gfx::Transform* transform) const {
- transform->MakeIdentity();
- if (transform_id == TransformTree::kInvalidNodeId)
- return true;
-
- const EffectNode* effect_node = effect_tree.Node(effect_id);
-
- bool success = true;
- success = GetToTarget(transform_id, effect_id, transform);
- if (effect_node->surface_contents_scale.x() != 0.f &&
- effect_node->surface_contents_scale.y() != 0.f)
- transform->matrix().postScale(
- 1.0f / effect_node->surface_contents_scale.x(),
- 1.0f / effect_node->surface_contents_scale.y(), 1.0f);
- return success;
-}
-
bool PropertyTrees::ComputeTransformFromTarget(
int transform_id,
int effect_id,
« 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