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

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

Issue 2266223002: cc: Compute draw transforms dynamically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix layout tests Created 4 years, 3 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
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 <map>
10 #include <memory> 11 #include <memory>
11 #include <unordered_map> 12 #include <unordered_map>
12 #include <vector> 13 #include <vector>
13 14
14 #include "cc/animation/element_id.h" 15 #include "cc/animation/element_id.h"
15 #include "cc/base/cc_export.h" 16 #include "cc/base/cc_export.h"
16 #include "cc/base/synced_property.h" 17 #include "cc/base/synced_property.h"
17 #include "cc/output/filter_operations.h" 18 #include "cc/output/filter_operations.h"
18 #include "ui/gfx/geometry/rect_f.h" 19 #include "ui/gfx/geometry/rect_f.h"
19 #include "ui/gfx/geometry/scroll_offset.h" 20 #include "ui/gfx/geometry/scroll_offset.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 TransformTree& operator=(const TransformTree&); 136 TransformTree& operator=(const TransformTree&);
136 137
137 bool operator==(const TransformTree& other) const; 138 bool operator==(const TransformTree& other) const;
138 139
139 static const int kContentsRootNodeId = 1; 140 static const int kContentsRootNodeId = 1;
140 141
141 int Insert(const TransformNode& tree_node, int parent_id); 142 int Insert(const TransformNode& tree_node, int parent_id);
142 143
143 void clear(); 144 void clear();
144 145
145 // Computes the change of basis transform from node |source_id| to |dest_id|.
146 // The function returns false iff the inverse of a singular transform was
147 // used (and the result should, therefore, not be trusted). Transforms may
148 // be computed between any pair of nodes that have an ancestor/descendant
149 // relationship. Transforms between other pairs of nodes may only be computed
150 // if the following condition holds: let id1 the larger id and let id2 be the
151 // other id; then the nearest ancestor of node id1 whose id is smaller than
152 // id2 is the lowest common ancestor of the pair of nodes, and the transform
153 // from this lowest common ancestor to node id2 is only a 2d translation.
154 bool ComputeTransform(int source_id,
155 int dest_id,
156 gfx::Transform* transform) const;
157
158 void OnTransformAnimated(const gfx::Transform& transform, 146 void OnTransformAnimated(const gfx::Transform& transform,
159 int id, 147 int id,
160 LayerTreeImpl* layer_tree_impl); 148 LayerTreeImpl* layer_tree_impl);
161 // Computes the change of basis transform from node |source_id| to |dest_id|. 149 // Computes the change of basis transform from node |source_id| to |dest_id|.
162 // This is used by scroll children to compute transform from their scroll 150 // This is used by scroll children to compute transform from their scroll
163 // parent space (source) to their parent space (destination) and it can atmost 151 // parent space (source) to their parent space (destination) and it can atmost
164 // be a translation. This function assumes that the path from source to 152 // be a translation. This function assumes that the path from source to
165 // destination has only translations. So, it should not be called when there 153 // destination has only translations. So, it should not be called when there
166 // can be intermediate 3d transforms but the end result is a translation. 154 // can be intermediate 3d transforms but the end result is a translation.
167 bool ComputeTranslation(int source_id, 155 bool ComputeTranslation(int source_id,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() 213 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta()
226 const { 214 const {
227 return nodes_affected_by_inner_viewport_bounds_delta_; 215 return nodes_affected_by_inner_viewport_bounds_delta_;
228 } 216 }
229 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta() 217 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta()
230 const { 218 const {
231 return nodes_affected_by_outer_viewport_bounds_delta_; 219 return nodes_affected_by_outer_viewport_bounds_delta_;
232 } 220 }
233 221
234 const gfx::Transform& FromTarget(int node_id, int effect) const; 222 const gfx::Transform& FromTarget(int node_id, int effect) const;
235 void SetFromTarget(int node_id, const gfx::Transform& transform);
236
237 // TODO(sunxd): Remove target space transforms in cached data when we
238 // completely implement computing draw transforms on demand.
239 const gfx::Transform& ToTarget(int node_id, int effect_id) const; 223 const gfx::Transform& ToTarget(int node_id, int effect_id) const;
240 void SetToTarget(int node_id, const gfx::Transform& transform);
241 224
242 const gfx::Transform& FromScreen(int node_id) const; 225 const gfx::Transform& FromScreen(int node_id) const;
243 void SetFromScreen(int node_id, const gfx::Transform& transform); 226 void SetFromScreen(int node_id, const gfx::Transform& transform);
244 227
245 const gfx::Transform& ToScreen(int node_id) const; 228 const gfx::Transform& ToScreen(int node_id) const;
246 void SetToScreen(int node_id, const gfx::Transform& transform); 229 void SetToScreen(int node_id, const gfx::Transform& transform);
247 230
248 int TargetId(int node_id) const; 231 int TargetId(int node_id) const;
249 void SetTargetId(int node_id, int target_id); 232 void SetTargetId(int node_id, int target_id);
250 233
251 int ContentTargetId(int node_id) const; 234 int ContentTargetId(int node_id) const;
252 void SetContentTargetId(int node_id, int content_target_id); 235 void SetContentTargetId(int node_id, int content_target_id);
253 236
254 const std::vector<TransformCachedNodeData>& cached_data() const { 237 const std::vector<TransformCachedNodeData>& cached_data() const {
255 return cached_data_; 238 return cached_data_;
256 } 239 }
257 240
258 void ToProtobuf(proto::PropertyTree* proto) const; 241 void ToProtobuf(proto::PropertyTree* proto) const;
259 void FromProtobuf(const proto::PropertyTree& proto, 242 void FromProtobuf(const proto::PropertyTree& proto,
260 std::unordered_map<int, int>* node_id_to_index_map); 243 std::unordered_map<int, int>* node_id_to_index_map);
261 244
262 // Computes the combined transform between |source_id| and |dest_id|. These
263 // two nodes must be on the same ancestor chain.
264 void CombineTransformsBetween(int source_id,
265 int dest_id,
266 gfx::Transform* transform) const;
267
268 // Computes the combined inverse transform between |source_id| and |dest_id|
269 // and returns false if the inverse of a singular transform was used. These
270 // two nodes must be on the same ancestor chain.
271 bool CombineInversesBetween(int source_id,
272 int dest_id,
273 gfx::Transform* transform) const;
274
275 private: 245 private:
276 // Returns true iff the node at |desc_id| is a descendant of the node at 246 // Returns true iff the node at |desc_id| is a descendant of the node at
277 // |anc_id|. 247 // |anc_id|.
278 bool IsDescendant(int desc_id, int anc_id) const; 248 bool IsDescendant(int desc_id, int anc_id) const;
279 249
280 void UpdateLocalTransform(TransformNode* node); 250 void UpdateLocalTransform(TransformNode* node);
281 void UpdateScreenSpaceTransform(TransformNode* node, 251 void UpdateScreenSpaceTransform(TransformNode* node,
282 TransformNode* parent_node, 252 TransformNode* parent_node,
283 TransformNode* target_node); 253 TransformNode* target_node);
284 void UpdateSurfaceContentsScale(TransformNode* node); 254 void UpdateSurfaceContentsScale(TransformNode* node);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 484
515 // TODO(sunxd): Move screen space transforms here if it can improve 485 // TODO(sunxd): Move screen space transforms here if it can improve
516 // performance. 486 // performance.
517 DrawTransformData() 487 DrawTransformData()
518 : update_number(-1), transforms(gfx::Transform(), gfx::Transform()) {} 488 : update_number(-1), transforms(gfx::Transform(), gfx::Transform()) {}
519 }; 489 };
520 490
521 struct PropertyTreesCachedData { 491 struct PropertyTreesCachedData {
522 int property_tree_update_number; 492 int property_tree_update_number;
523 std::vector<AnimationScaleData> animation_scales; 493 std::vector<AnimationScaleData> animation_scales;
524 mutable std::vector<std::unordered_map<int, DrawTransformData>> 494 mutable std::vector<std::map<int, DrawTransformData>> draw_transforms;
ajuma 2016/09/07 14:51:23 As discussed offline, please compare the performan
sunxd 2016/09/07 15:20:02 Acknowledged.
525 draw_transforms;
526 495
527 PropertyTreesCachedData(); 496 PropertyTreesCachedData();
528 ~PropertyTreesCachedData(); 497 ~PropertyTreesCachedData();
529 }; 498 };
530 499
531 class CC_EXPORT PropertyTrees final { 500 class CC_EXPORT PropertyTrees final {
532 public: 501 public:
533 PropertyTrees(); 502 PropertyTrees();
534 PropertyTrees(const PropertyTrees& other) = delete; 503 PropertyTrees(const PropertyTrees& other) = delete;
535 ~PropertyTrees(); 504 ~PropertyTrees();
(...skipping 24 matching lines...) Expand all
560 bool changed; 529 bool changed;
561 // We cache a global bool for full tree damages to avoid walking the entire 530 // We cache a global bool for full tree damages to avoid walking the entire
562 // tree. 531 // tree.
563 // TODO(jaydasika): Changes to transform and effects that damage the entire 532 // TODO(jaydasika): Changes to transform and effects that damage the entire
564 // tree should be tracked by this bool. Currently, they are tracked by the 533 // tree should be tracked by this bool. Currently, they are tracked by the
565 // individual nodes. 534 // individual nodes.
566 bool full_tree_damaged; 535 bool full_tree_damaged;
567 int sequence_number; 536 int sequence_number;
568 bool is_main_thread; 537 bool is_main_thread;
569 bool is_active; 538 bool is_active;
570 bool verify_transform_tree_calculations;
571 539
572 void clear(); 540 void clear();
573 541
574 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 542 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
575 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 543 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
576 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); 544 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta);
577 void PushOpacityIfNeeded(PropertyTrees* target_tree); 545 void PushOpacityIfNeeded(PropertyTrees* target_tree);
578 void RemoveIdFromIdToIndexMaps(int id); 546 void RemoveIdFromIdToIndexMaps(int id);
579 bool IsInIdToIndexMap(TreeType tree_type, int id); 547 bool IsInIdToIndexMap(TreeType tree_type, int id);
580 void UpdateChangeTracking(); 548 void UpdateChangeTracking();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 gfx::Vector2dF inner_viewport_container_bounds_delta_; 590 gfx::Vector2dF inner_viewport_container_bounds_delta_;
623 gfx::Vector2dF outer_viewport_container_bounds_delta_; 591 gfx::Vector2dF outer_viewport_container_bounds_delta_;
624 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; 592 gfx::Vector2dF inner_viewport_scroll_bounds_delta_;
625 593
626 PropertyTreesCachedData cached_data_; 594 PropertyTreesCachedData cached_data_;
627 }; 595 };
628 596
629 } // namespace cc 597 } // namespace cc
630 598
631 #endif // CC_TREES_PROPERTY_TREE_H_ 599 #endif // CC_TREES_PROPERTY_TREE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698