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

Unified Diff: cc/trees/property_tree.cc

Issue 2032213002: cc: Put to_target and to_screen behind an accessor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Put target_id behind accessor Created 4 years, 6 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 894b2d5da469a38121fc404424b943c810b494e4..519aae485fd04a869622ac69a83539059e1fb275 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -771,7 +771,7 @@ void TransformTree::ResetChangeTracking() {
void TransformTree::UpdateTransforms(int id) {
TransformNode* node = Node(id);
TransformNode* parent_node = parent(node);
- TransformNode* target_node = Node(node->data.target_id);
+ TransformNode* target_node = Node(TargetId(id));
TransformNode* source_node = Node(node->data.source_node_id);
if (node->data.needs_local_transform_update ||
NeedsSourceToParentUpdate(node))
@@ -815,7 +815,7 @@ bool TransformTree::CombineTransformsBetween(int source_id,
// A's from_screen will not produce the correct result.
if (!dest || (dest->data.ancestors_are_invertible &&
dest->data.node_and_ancestors_are_flat)) {
- transform->ConcatTransform(current->data.to_screen);
+ transform->ConcatTransform(ToScreen(current->id));
if (dest)
transform->ConcatTransform(dest->data.from_screen);
return true;
@@ -840,15 +840,15 @@ bool TransformTree::CombineTransformsBetween(int source_id,
!dest->data.ancestors_are_invertible);
for (; current && current->id > dest_id; current = parent(current)) {
if (destination_has_non_zero_sublayer_scale &&
- current->data.target_id == dest_id &&
- current->data.content_target_id == dest_id)
+ TargetId(current->id) == dest_id &&
+ ContentTargetId(current->id) == dest_id)
break;
source_to_destination.push_back(current->id);
}
gfx::Transform combined_transform;
if (current->id > dest_id) {
- combined_transform = current->data.to_target;
+ combined_transform = ToTarget(current->id);
// The stored target space transform has sublayer scale baked in, but we
// need the unscaled transform.
combined_transform.matrix().postScale(1.0f / dest->data.sublayer_scale.x(),
@@ -904,7 +904,7 @@ bool TransformTree::CombineInversesBetween(int source_id,
current->data.node_and_ancestors_are_flat) {
transform->PreconcatTransform(current->data.from_screen);
if (dest)
- transform->PreconcatTransform(dest->data.to_screen);
+ transform->PreconcatTransform(ToScreen(dest->id));
return true;
}
@@ -959,23 +959,24 @@ void TransformTree::UpdateScreenSpaceTransform(TransformNode* node,
TransformNode* parent_node,
TransformNode* target_node) {
if (!parent_node) {
- node->data.to_screen = node->data.to_parent;
+ SetToScreen(node->id, node->data.to_parent);
node->data.ancestors_are_invertible = true;
node->data.to_screen_is_potentially_animated = false;
node->data.node_and_ancestors_are_flat = node->data.to_parent.IsFlat();
} else {
- node->data.to_screen = parent_node->data.to_screen;
+ gfx::Transform to_screen_space_transform = parent_node->data.to_screen;
if (node->data.flattens_inherited_transform)
- node->data.to_screen.FlattenTo2d();
- node->data.to_screen.PreconcatTransform(node->data.to_parent);
+ to_screen_space_transform.FlattenTo2d();
+ to_screen_space_transform.PreconcatTransform(node->data.to_parent);
node->data.ancestors_are_invertible =
parent_node->data.ancestors_are_invertible;
node->data.node_and_ancestors_are_flat =
parent_node->data.node_and_ancestors_are_flat &&
node->data.to_parent.IsFlat();
+ SetToScreen(node->id, to_screen_space_transform);
}
- if (!node->data.to_screen.GetInverse(&node->data.from_screen))
+ if (!ToScreen(node->id).GetInverse(&node->data.from_screen))
node->data.ancestors_are_invertible = false;
}
@@ -991,25 +992,27 @@ void TransformTree::UpdateSublayerScale(TransformNode* node) {
if (node->data.in_subtree_of_page_scale_layer)
layer_scale_factor *= page_scale_factor_;
node->data.sublayer_scale = MathUtil::ComputeTransform2dScaleComponents(
- node->data.to_screen, layer_scale_factor);
+ ToScreen(node->id), layer_scale_factor);
}
void TransformTree::UpdateTargetSpaceTransform(TransformNode* node,
TransformNode* target_node) {
+ gfx::Transform target_space_transform;
if (node->data.needs_sublayer_scale) {
- node->data.to_target.MakeIdentity();
- node->data.to_target.Scale(node->data.sublayer_scale.x(),
- node->data.sublayer_scale.y());
+ target_space_transform.MakeIdentity();
+ target_space_transform.Scale(node->data.sublayer_scale.x(),
+ node->data.sublayer_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;
ComputeTransformWithDestinationSublayerScale(node->id, target_id,
- &node->data.to_target);
+ &target_space_transform);
}
- if (!node->data.to_target.GetInverse(&node->data.from_target))
+ if (!target_space_transform.GetInverse(&node->data.from_target))
node->data.ancestors_are_invertible = false;
+ SetToTarget(node->id, target_space_transform);
}
void TransformTree::UpdateAnimationProperties(TransformNode* node,
@@ -1041,7 +1044,7 @@ void TransformTree::UpdateAnimationProperties(TransformNode* node,
// Computing maximum animated scale in the presence of non-scale/translation
// transforms isn't supported.
bool failed_for_non_scale_or_translation =
- !node->data.to_target.IsScaleOrTranslation();
+ !ToTarget(node->id).IsScaleOrTranslation();
// We don't attempt to accumulate animation scale from multiple nodes with
// scale animations, because of the risk of significant overestimation. For
@@ -1092,7 +1095,7 @@ void TransformTree::UpdateAnimationProperties(TransformNode* node,
gfx::Vector2dF ancestor_scales =
parent_node ? MathUtil::ComputeTransform2dScaleComponents(
- parent_node->data.to_target, 0.f)
+ ToTarget(parent_node->id), 0.f)
: gfx::Vector2dF(1.f, 1.f);
float max_ancestor_scale = std::max(ancestor_scales.x(), ancestor_scales.y());
node->data.combined_maximum_animation_target_scale =
@@ -1111,7 +1114,7 @@ void TransformTree::UndoSnapping(TransformNode* node) {
void TransformTree::UpdateSnapping(TransformNode* node) {
if (!node->data.scrolls || node->data.to_screen_is_potentially_animated ||
- !node->data.to_screen.IsScaleOrTranslation() ||
+ !ToScreen(node->id).IsScaleOrTranslation() ||
!node->data.ancestors_are_invertible) {
return;
}
@@ -1122,7 +1125,7 @@ void TransformTree::UpdateSnapping(TransformNode* node) {
// rounded, then what we're after is the scroll delta X, where ST * X = ST'.
// I.e., we want a transform that will realize our scroll snap. It follows
// that X = ST^-1 * ST'. We cache ST and ST^-1 to make this more efficient.
- gfx::Transform rounded = node->data.to_screen;
+ gfx::Transform rounded = ToScreen(node->id);
rounded.RoundTranslationComponents();
gfx::Transform delta = node->data.from_screen;
delta *= rounded;
@@ -1134,11 +1137,13 @@ void TransformTree::UpdateSnapping(TransformNode* node) {
// Now that we have our scroll delta, we must apply it to each of our
// combined, to/from matrices.
- node->data.to_screen = rounded;
+ SetToScreen(node->id, rounded);
node->data.to_parent.Translate(translation.x(), translation.y());
node->data.from_screen.matrix().postTranslate(-translation.x(),
-translation.y(), 0);
- node->data.to_target.Translate(translation.x(), translation.y());
+ gfx::Transform to_target = ToTarget(node->id);
+ to_target.Translate(translation.x(), translation.y());
+ SetToTarget(node->id, to_target);
node->data.from_target.matrix().postTranslate(-translation.x(),
-translation.y(), 0);
@@ -1241,6 +1246,38 @@ bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const {
return !nodes_affected_by_outer_viewport_bounds_delta_.empty();
}
+gfx::Transform TransformTree::ToTarget(int id) const {
+ return Node(id)->data.to_target;
+}
+
+void TransformTree::SetToTarget(int id, const gfx::Transform& transform) {
+ Node(id)->data.to_target = transform;
+}
+
+gfx::Transform TransformTree::ToScreen(int id) const {
+ return Node(id)->data.to_screen;
+}
+
+void TransformTree::SetToScreen(int id, const gfx::Transform& transform) {
+ Node(id)->data.to_screen = transform;
+}
+
+int TransformTree::TargetId(int id) const {
+ return Node(id)->data.target_id;
+}
+
+void TransformTree::SetTargetId(int id, int target_id) {
+ Node(id)->data.target_id = target_id;
+}
+
+int TransformTree::ContentTargetId(int id) const {
+ return Node(id)->data.content_target_id;
+}
+
+void TransformTree::SetContentTargetId(int id, int content_target_id) {
+ Node(id)->data.content_target_id = content_target_id;
+}
+
gfx::Transform TransformTree::ToScreenSpaceTransformWithoutSublayerScale(
int id) const {
DCHECK_GT(id, 0);
@@ -1248,7 +1285,7 @@ gfx::Transform TransformTree::ToScreenSpaceTransformWithoutSublayerScale(
return gfx::Transform();
}
const TransformNode* node = Node(id);
- gfx::Transform screen_space_transform = node->data.to_screen;
+ gfx::Transform screen_space_transform = ToScreen(id);
if (node->data.sublayer_scale.x() != 0.0 &&
node->data.sublayer_scale.y() != 0.0)
screen_space_transform.Scale(1.0 / node->data.sublayer_scale.x(),
@@ -1385,9 +1422,9 @@ void EffectTree::UpdateBackfaceVisibility(EffectNode* node,
parent_transform_node->data.sorting_context_id ==
transform_node->data.sorting_context_id) {
gfx::Transform surface_draw_transform;
- transform_tree.ComputeTransform(transform_node->id,
- transform_node->data.target_id,
- &surface_draw_transform);
+ transform_tree.ComputeTransform(
+ transform_node->id, transform_tree.TargetId(transform_node->id),
+ &surface_draw_transform);
node->data.hidden_by_backface_visibility =
surface_draw_transform.IsBackFaceVisible();
} else {
@@ -1751,12 +1788,14 @@ void ScrollTree::set_currently_scrolling_node(int scroll_node_id) {
gfx::Transform ScrollTree::ScreenSpaceTransform(int scroll_node_id) const {
const ScrollNode* scroll_node = Node(scroll_node_id);
+ const TransformTree& transform_tree = property_trees()->transform_tree;
const TransformNode* transform_node =
- property_trees()->transform_tree.Node(scroll_node->data.transform_id);
+ transform_tree.Node(scroll_node->data.transform_id);
gfx::Transform screen_space_transform(
1, 0, 0, 1, scroll_node->data.offset_to_transform_parent.x(),
scroll_node->data.offset_to_transform_parent.y());
- screen_space_transform.ConcatTransform(transform_node->data.to_screen);
+ screen_space_transform.ConcatTransform(
+ transform_tree.ToScreen(transform_node->id));
if (scroll_node->data.should_flatten)
screen_space_transform.FlattenTo2d();
return screen_space_transform;

Powered by Google App Engine
This is Rietveld 408576698