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

Side by Side Diff: cc/trees/property_tree.h

Issue 2105673003: cc: Compute animation scale on demand (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit changes Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_TREES_PROPERTY_TREE_H_ 5 #ifndef CC_TREES_PROPERTY_TREE_H_
6 #define CC_TREES_PROPERTY_TREE_H_ 6 #define CC_TREES_PROPERTY_TREE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 bool node_and_ancestors_are_animated_or_invertible : 1; 114 bool node_and_ancestors_are_animated_or_invertible : 1;
115 115
116 bool is_invertible : 1; 116 bool is_invertible : 1;
117 bool ancestors_are_invertible : 1; 117 bool ancestors_are_invertible : 1;
118 118
119 bool has_potential_animation : 1; 119 bool has_potential_animation : 1;
120 bool is_currently_animating : 1; 120 bool is_currently_animating : 1;
121 bool to_screen_is_potentially_animated : 1; 121 bool to_screen_is_potentially_animated : 1;
122 bool has_only_translation_animations : 1; 122 bool has_only_translation_animations : 1;
123 bool to_screen_has_scale_animation : 1;
124 123
125 // Flattening, when needed, is only applied to a node's inherited transform, 124 // Flattening, when needed, is only applied to a node's inherited transform,
126 // never to its local transform. 125 // never to its local transform.
127 bool flattens_inherited_transform : 1; 126 bool flattens_inherited_transform : 1;
128 127
129 // This is true if the to_parent transform at every node on the path to the 128 // This is true if the to_parent transform at every node on the path to the
130 // root is flat. 129 // root is flat.
131 bool node_and_ancestors_are_flat : 1; 130 bool node_and_ancestors_are_flat : 1;
132 131
133 // This is needed to know if a layer can use lcd text. 132 // This is needed to know if a layer can use lcd text.
(...skipping 15 matching lines...) Expand all
149 // space transform. For layers in the subtree of the page scale layer, the 148 // space transform. For layers in the subtree of the page scale layer, the
150 // layer scale factor should include the page scale factor. 149 // layer scale factor should include the page scale factor.
151 bool in_subtree_of_page_scale_layer : 1; 150 bool in_subtree_of_page_scale_layer : 1;
152 151
153 // We need to track changes to to_screen transform to compute the damage rect. 152 // We need to track changes to to_screen transform to compute the damage rect.
154 bool transform_changed : 1; 153 bool transform_changed : 1;
155 154
156 // TODO(vollick): will be moved when accelerated effects are implemented. 155 // TODO(vollick): will be moved when accelerated effects are implemented.
157 float post_local_scale_factor; 156 float post_local_scale_factor;
158 157
159 // The maximum scale that that node's |local| transform will have during
160 // current animations, considering only scales at keyframes not including the
161 // starting keyframe of each animation.
162 float local_maximum_animation_target_scale;
163
164 // The maximum scale that this node's |local| transform will have during
165 // current animatons, considering only the starting scale of each animation.
166 float local_starting_animation_scale;
167
168 // The maximum scale that this node's |to_target| transform will have during
169 // current animations, considering only scales at keyframes not incuding the
170 // starting keyframe of each animation.
171 float combined_maximum_animation_target_scale;
172
173 // The maximum scale that this node's |to_target| transform will have during
174 // current animations, considering only the starting scale of each animation.
175 float combined_starting_animation_scale;
176
177 gfx::Vector2dF sublayer_scale; 158 gfx::Vector2dF sublayer_scale;
178 159
179 // TODO(vollick): will be moved when accelerated effects are implemented. 160 // TODO(vollick): will be moved when accelerated effects are implemented.
180 gfx::ScrollOffset scroll_offset; 161 gfx::ScrollOffset scroll_offset;
181 162
182 // We scroll snap where possible, but this means fixed-pos elements must be 163 // We scroll snap where possible, but this means fixed-pos elements must be
183 // adjusted. This value stores the snapped amount for this purpose. 164 // adjusted. This value stores the snapped amount for this purpose.
184 gfx::Vector2dF scroll_snap; 165 gfx::Vector2dF scroll_snap;
185 166
186 // TODO(vollick): will be moved when accelerated effects are implemented. 167 // TODO(vollick): will be moved when accelerated effects are implemented.
(...skipping 11 matching lines...) Expand all
198 179
199 void update_post_local_transform(const gfx::PointF& position, 180 void update_post_local_transform(const gfx::PointF& position,
200 const gfx::Point3F& transform_origin); 181 const gfx::Point3F& transform_origin);
201 182
202 void ToProtobuf(proto::TreeNode* proto) const; 183 void ToProtobuf(proto::TreeNode* proto) const;
203 void FromProtobuf(const proto::TreeNode& proto); 184 void FromProtobuf(const proto::TreeNode& proto);
204 185
205 void AsValueInto(base::trace_event::TracedValue* value) const; 186 void AsValueInto(base::trace_event::TracedValue* value) const;
206 }; 187 };
207 188
189 // TODO(sunxd): move this into PropertyTrees::cached_data_.
208 struct CC_EXPORT TransformCachedNodeData { 190 struct CC_EXPORT TransformCachedNodeData {
209 TransformCachedNodeData(); 191 TransformCachedNodeData();
210 TransformCachedNodeData(const TransformCachedNodeData& other); 192 TransformCachedNodeData(const TransformCachedNodeData& other);
211 ~TransformCachedNodeData(); 193 ~TransformCachedNodeData();
212 194
213 gfx::Transform from_target; 195 gfx::Transform from_target;
214 gfx::Transform to_target; 196 gfx::Transform to_target;
215 gfx::Transform from_screen; 197 gfx::Transform from_screen;
216 gfx::Transform to_screen; 198 gfx::Transform to_screen;
217 int target_id; 199 int target_id;
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 ScrollOffsetMap layer_id_to_scroll_offset_map_; 702 ScrollOffsetMap layer_id_to_scroll_offset_map_;
721 703
722 SyncedScrollOffset* synced_scroll_offset(int layer_id); 704 SyncedScrollOffset* synced_scroll_offset(int layer_id);
723 const SyncedScrollOffset* synced_scroll_offset(int layer_id) const; 705 const SyncedScrollOffset* synced_scroll_offset(int layer_id) const;
724 gfx::ScrollOffset PullDeltaForMainThread(SyncedScrollOffset* scroll_offset); 706 gfx::ScrollOffset PullDeltaForMainThread(SyncedScrollOffset* scroll_offset);
725 void UpdateScrollOffsetMapEntry(int key, 707 void UpdateScrollOffsetMapEntry(int key,
726 ScrollOffsetMap* new_scroll_offset_map, 708 ScrollOffsetMap* new_scroll_offset_map,
727 LayerTreeImpl* layer_tree_impl); 709 LayerTreeImpl* layer_tree_impl);
728 }; 710 };
729 711
712 struct AnimationScaleData {
713 // Variable used to invalidate cached animation scale data when transform tree
714 // updates.
715 int update_number;
716
717 // Current animations, considering only scales at keyframes not including the
718 // starting keyframe of each animation.
719 float local_maximum_animation_target_scale;
720
721 // The maximum scale that this node's |local| transform will have during
722 // current animatons, considering only the starting scale of each animation.
723 float local_starting_animation_scale;
724
725 // The maximum scale that this node's |to_target| transform will have during
726 // current animations, considering only scales at keyframes not incuding the
727 // starting keyframe of each animation.
728 float combined_maximum_animation_target_scale;
729
730 // The maximum scale that this node's |to_target| transform will have during
731 // current animations, considering only the starting scale of each animation.
732 float combined_starting_animation_scale;
733
734 bool to_screen_has_scale_animation;
735
736 AnimationScaleData() {
737 update_number = -1;
738 local_maximum_animation_target_scale = 0.f;
739 local_starting_animation_scale = 0.f;
740 combined_maximum_animation_target_scale = 0.f;
741 combined_starting_animation_scale = 0.f;
742 to_screen_has_scale_animation = false;
743 }
744 };
745
746 struct CombinedAnimationScale {
747 float maximum_animation_scale;
748 float starting_animation_scale;
749
750 CombinedAnimationScale(float maximum, float starting)
751 : maximum_animation_scale(maximum), starting_animation_scale(starting) {}
752 bool operator==(const CombinedAnimationScale& other) const {
753 return maximum_animation_scale == other.maximum_animation_scale &&
754 starting_animation_scale == other.starting_animation_scale;
755 }
756 };
757
758 struct PropertyTreesCachedData {
759 int property_tree_update_number;
760 std::vector<AnimationScaleData> animation_scales;
761
762 PropertyTreesCachedData();
763 ~PropertyTreesCachedData();
764 };
765
730 class CC_EXPORT PropertyTrees final { 766 class CC_EXPORT PropertyTrees final {
731 public: 767 public:
732 PropertyTrees(); 768 PropertyTrees();
733 PropertyTrees(const PropertyTrees& other) = delete; 769 PropertyTrees(const PropertyTrees& other) = delete;
734 ~PropertyTrees(); 770 ~PropertyTrees();
735 771
736 bool operator==(const PropertyTrees& other) const; 772 bool operator==(const PropertyTrees& other) const;
737 PropertyTrees& operator=(const PropertyTrees& from); 773 PropertyTrees& operator=(const PropertyTrees& from);
738 774
739 void ToProtobuf(proto::PropertyTrees* proto) const; 775 void ToProtobuf(proto::PropertyTrees* proto) const;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 gfx::Vector2dF outer_viewport_container_bounds_delta() const { 820 gfx::Vector2dF outer_viewport_container_bounds_delta() const {
785 return outer_viewport_container_bounds_delta_; 821 return outer_viewport_container_bounds_delta_;
786 } 822 }
787 823
788 gfx::Vector2dF inner_viewport_scroll_bounds_delta() const { 824 gfx::Vector2dF inner_viewport_scroll_bounds_delta() const {
789 return inner_viewport_scroll_bounds_delta_; 825 return inner_viewport_scroll_bounds_delta_;
790 } 826 }
791 827
792 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; 828 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const;
793 829
830 CombinedAnimationScale GetAnimationScales(int transform_node_id,
831 LayerTreeImpl* layer_tree_impl);
832 void SetAnimationScalesForTesting(int transform_id,
833 float maximum_animation_scale,
834 float starting_animation_scale);
835 void ResetCachedData();
836 void UpdateCachedNumber();
837
794 private: 838 private:
795 gfx::Vector2dF inner_viewport_container_bounds_delta_; 839 gfx::Vector2dF inner_viewport_container_bounds_delta_;
796 gfx::Vector2dF outer_viewport_container_bounds_delta_; 840 gfx::Vector2dF outer_viewport_container_bounds_delta_;
797 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; 841 gfx::Vector2dF inner_viewport_scroll_bounds_delta_;
842
843 PropertyTreesCachedData cached_data_;
798 }; 844 };
799 845
800 } // namespace cc 846 } // namespace cc
801 847
802 #endif // CC_TREES_PROPERTY_TREE_H_ 848 #endif // CC_TREES_PROPERTY_TREE_H_
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698