diff options
author | ajuma <ajuma@chromium.org> | 2015-06-29 12:54:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-29 19:55:37 +0000 |
commit | 5bcff153554728c6e893b59b00aa55a95468931e (patch) | |
tree | 0e6df80880d8856e9e554b5f4e04957ab2acb389 /cc | |
parent | 4a7c13aeeef9a4453ec268f6aba9883837370455 (diff) | |
download | chromium_src-5bcff153554728c6e893b59b00aa55a95468931e.zip chromium_src-5bcff153554728c6e893b59b00aa55a95468931e.tar.gz chromium_src-5bcff153554728c6e893b59b00aa55a95468931e.tar.bz2 |
cc: Store lists of nodes affected by bounds_delta in the transform tree
This adds lists of nodes affected by inner viewport or outer viewport
bounds delta to the transform tree, and uses these lists to determine
which nodes need to have their local transform updated because of a
bounds delta change (rather than always updating the local transform
of every node affected by bounds delta).
BUG=497806
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1215753002
Cr-Commit-Position: refs/heads/master@{#336620}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/layer_impl.cc | 11 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.cc | 20 | ||||
-rw-r--r-- | cc/trees/property_tree.cc | 45 | ||||
-rw-r--r-- | cc/trees/property_tree.h | 13 | ||||
-rw-r--r-- | cc/trees/property_tree_builder.cc | 10 |
5 files changed, 62 insertions, 37 deletions
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index cde5339..c11e915 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -865,13 +865,10 @@ void LayerImpl::SetBoundsDelta(const gfx::Vector2dF& bounds_delta) { TransformTree& transform_tree = layer_tree_impl()->property_trees()->transform_tree; - if (this == layer_tree_impl()->InnerViewportContainerLayer()) { - transform_tree.set_inner_viewport_bounds_delta(bounds_delta); - transform_tree.set_needs_update(true); - } else if (this == layer_tree_impl()->OuterViewportContainerLayer()) { - transform_tree.set_outer_viewport_bounds_delta(bounds_delta); - transform_tree.set_needs_update(true); - } + if (this == layer_tree_impl()->InnerViewportContainerLayer()) + transform_tree.SetInnerViewportBoundsDelta(bounds_delta); + else if (this == layer_tree_impl()->OuterViewportContainerLayer()) + transform_tree.SetOuterViewportBoundsDelta(bounds_delta); ScrollbarParametersDidChange(true); diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 0a9d5cd..60aed70 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -217,22 +217,10 @@ void LayerTreeImpl::UpdatePropertyTreesForBoundsDelta() { &property_trees_.clip_tree); TransformTree& transform_tree = property_trees_.transform_tree; - if (inner_container) { - if (inner_container->bounds_delta() != - transform_tree.inner_viewport_bounds_delta()) { - transform_tree.set_inner_viewport_bounds_delta( - inner_container->bounds_delta()); - transform_tree.set_needs_update(true); - } - } - if (outer_container) { - if (outer_container->bounds_delta() != - transform_tree.outer_viewport_bounds_delta()) { - transform_tree.set_outer_viewport_bounds_delta( - outer_container->bounds_delta()); - transform_tree.set_needs_update(true); - } - } + if (inner_container) + transform_tree.SetInnerViewportBoundsDelta(inner_container->bounds_delta()); + if (outer_container) + transform_tree.SetOuterViewportBoundsDelta(outer_container->bounds_delta()); } void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc index 20e446b..f00563b 100644 --- a/cc/trees/property_tree.cc +++ b/cc/trees/property_tree.cc @@ -156,19 +156,12 @@ bool TransformTree::NeedsSourceToParentUpdate(TransformNode* node) { node->parent_id != node->data.source_node_id); } -static bool AffectedByBoundsDelta(TransformNode* node) { - return node->data.affected_by_inner_viewport_bounds_delta_x || - node->data.affected_by_inner_viewport_bounds_delta_y || - node->data.affected_by_outer_viewport_bounds_delta_x || - node->data.affected_by_outer_viewport_bounds_delta_y; -} - void TransformTree::UpdateTransforms(int id) { TransformNode* node = Node(id); TransformNode* parent_node = parent(node); TransformNode* target_node = Node(node->data.target_id); if (node->data.needs_local_transform_update || - NeedsSourceToParentUpdate(node) || AffectedByBoundsDelta(node)) + NeedsSourceToParentUpdate(node)) UpdateLocalTransform(node); UpdateScreenSpaceTransform(node, parent_node, target_node); UpdateSublayerScale(node); @@ -426,6 +419,42 @@ void TransformTree::UpdateSnapping(TransformNode* node) { node->data.scroll_snap = translation; } +void TransformTree::SetInnerViewportBoundsDelta(gfx::Vector2dF bounds_delta) { + if (inner_viewport_bounds_delta_ == bounds_delta) + return; + + inner_viewport_bounds_delta_ = bounds_delta; + + if (nodes_affected_by_inner_viewport_bounds_delta_.empty()) + return; + + set_needs_update(true); + for (int i : nodes_affected_by_inner_viewport_bounds_delta_) + Node(i)->data.needs_local_transform_update = true; +} + +void TransformTree::SetOuterViewportBoundsDelta(gfx::Vector2dF bounds_delta) { + if (outer_viewport_bounds_delta_ == bounds_delta) + return; + + outer_viewport_bounds_delta_ = bounds_delta; + + if (nodes_affected_by_outer_viewport_bounds_delta_.empty()) + return; + + set_needs_update(true); + for (int i : nodes_affected_by_outer_viewport_bounds_delta_) + Node(i)->data.needs_local_transform_update = true; +} + +void TransformTree::AddNodeAffectedByInnerViewportBoundsDelta(int node_id) { + nodes_affected_by_inner_viewport_bounds_delta_.push_back(node_id); +} + +void TransformTree::AddNodeAffectedByOuterViewportBoundsDelta(int node_id) { + nodes_affected_by_outer_viewport_bounds_delta_.push_back(node_id); +} + void OpacityTree::UpdateOpacities(int id) { OpacityNode* node = Node(id); node->data.screen_space_opacity = node->data.opacity; diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h index ac0089a..a47fee4 100644 --- a/cc/trees/property_tree.h +++ b/cc/trees/property_tree.h @@ -249,20 +249,19 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { return source_to_parent_updates_allowed_; } - void set_inner_viewport_bounds_delta(gfx::Vector2dF bounds_delta) { - inner_viewport_bounds_delta_ = bounds_delta; - } + void SetInnerViewportBoundsDelta(gfx::Vector2dF bounds_delta); gfx::Vector2dF inner_viewport_bounds_delta() const { return inner_viewport_bounds_delta_; } - void set_outer_viewport_bounds_delta(gfx::Vector2dF bounds_delta) { - outer_viewport_bounds_delta_ = bounds_delta; - } + void SetOuterViewportBoundsDelta(gfx::Vector2dF bounds_delta); gfx::Vector2dF outer_viewport_bounds_delta() const { return outer_viewport_bounds_delta_; } + void AddNodeAffectedByInnerViewportBoundsDelta(int node_id); + void AddNodeAffectedByOuterViewportBoundsDelta(int node_id); + private: // Returns true iff the node at |desc_id| is a descendant of the node at // |anc_id|. @@ -299,6 +298,8 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { bool source_to_parent_updates_allowed_; gfx::Vector2dF inner_viewport_bounds_delta_; gfx::Vector2dF outer_viewport_bounds_delta_; + std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; + std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; }; class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {}; diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc index 0091975..36d1a57 100644 --- a/cc/trees/property_tree_builder.cc +++ b/cc/trees/property_tree_builder.cc @@ -308,11 +308,21 @@ bool AddTransformNodeIfNeeded( layer->position_constraint().is_fixed_to_right_edge(); node->data.affected_by_inner_viewport_bounds_delta_y = layer->position_constraint().is_fixed_to_bottom_edge(); + if (node->data.affected_by_inner_viewport_bounds_delta_x || + node->data.affected_by_inner_viewport_bounds_delta_y) { + data_for_children->transform_tree + ->AddNodeAffectedByInnerViewportBoundsDelta(node->id); + } } else if (data_from_ancestor.affected_by_outer_viewport_bounds_delta) { node->data.affected_by_outer_viewport_bounds_delta_x = layer->position_constraint().is_fixed_to_right_edge(); node->data.affected_by_outer_viewport_bounds_delta_y = layer->position_constraint().is_fixed_to_bottom_edge(); + if (node->data.affected_by_outer_viewport_bounds_delta_x || + node->data.affected_by_outer_viewport_bounds_delta_y) { + data_for_children->transform_tree + ->AddNodeAffectedByOuterViewportBoundsDelta(node->id); + } } } |