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

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

Issue 2166043002: cc: Compute target space transform dynamically (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve comments 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
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 PropertyTree(); 60 PropertyTree();
61 PropertyTree(const PropertyTree& other) = delete; 61 PropertyTree(const PropertyTree& other) = delete;
62 62
63 // These C++ special member functions cannot be implicit inline because 63 // These C++ special member functions cannot be implicit inline because
64 // they are exported by CC_EXPORT. They will be instantiated in every 64 // they are exported by CC_EXPORT. They will be instantiated in every
65 // compilation units that included this header, and compilation can fail 65 // compilation units that included this header, and compilation can fail
66 // because T may be incomplete. 66 // because T may be incomplete.
67 ~PropertyTree(); 67 ~PropertyTree();
68 PropertyTree<T>& operator=(const PropertyTree<T>&); 68 PropertyTree<T>& operator=(const PropertyTree<T>&);
69 69
70 // Property tree node starts from index 0.
71 static const int kInvalidNodeId = -1;
72 static const int kRootNodeId = 0;
73
70 bool operator==(const PropertyTree<T>& other) const; 74 bool operator==(const PropertyTree<T>& other) const;
71 75
72 int Insert(const T& tree_node, int parent_id); 76 int Insert(const T& tree_node, int parent_id);
73 77
74 T* Node(int i) { 78 T* Node(int i) {
75 // TODO(vollick): remove this. 79 // TODO(vollick): remove this.
76 CHECK(i < static_cast<int>(nodes_.size())); 80 CHECK(i < static_cast<int>(nodes_.size()));
77 return i > -1 ? &nodes_[i] : nullptr; 81 return i > -1 ? &nodes_[i] : nullptr;
78 } 82 }
79 const T* Node(int i) const { 83 const T* Node(int i) const {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 217
214 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() 218 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta()
215 const { 219 const {
216 return nodes_affected_by_inner_viewport_bounds_delta_; 220 return nodes_affected_by_inner_viewport_bounds_delta_;
217 } 221 }
218 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta() 222 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta()
219 const { 223 const {
220 return nodes_affected_by_outer_viewport_bounds_delta_; 224 return nodes_affected_by_outer_viewport_bounds_delta_;
221 } 225 }
222 226
223 const gfx::Transform& FromTarget(int node_id) const; 227 const gfx::Transform& FromTarget(int node_id, int effect) const;
224 void SetFromTarget(int node_id, const gfx::Transform& transform); 228 void SetFromTarget(int node_id, const gfx::Transform& transform);
225 229
226 const gfx::Transform& ToTarget(int node_id) const; 230 // TODO(sunxd): remove target space transforms in cached data when we
231 // completely implement computing draw transforms on demand
232 const gfx::Transform& ToTarget(int node_id, int effect_id) const;
227 void SetToTarget(int node_id, const gfx::Transform& transform); 233 void SetToTarget(int node_id, const gfx::Transform& transform);
228 234
229 const gfx::Transform& FromScreen(int node_id) const; 235 const gfx::Transform& FromScreen(int node_id) const;
230 void SetFromScreen(int node_id, const gfx::Transform& transform); 236 void SetFromScreen(int node_id, const gfx::Transform& transform);
231 237
232 const gfx::Transform& ToScreen(int node_id) const; 238 const gfx::Transform& ToScreen(int node_id) const;
233 void SetToScreen(int node_id, const gfx::Transform& transform); 239 void SetToScreen(int node_id, const gfx::Transform& transform);
234 240
235 int TargetId(int node_id) const; 241 int TargetId(int node_id) const;
236 void SetTargetId(int node_id, int target_id); 242 void SetTargetId(int node_id, int target_id);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 float starting_animation_scale; 473 float starting_animation_scale;
468 474
469 CombinedAnimationScale(float maximum, float starting) 475 CombinedAnimationScale(float maximum, float starting)
470 : maximum_animation_scale(maximum), starting_animation_scale(starting) {} 476 : maximum_animation_scale(maximum), starting_animation_scale(starting) {}
471 bool operator==(const CombinedAnimationScale& other) const { 477 bool operator==(const CombinedAnimationScale& other) const {
472 return maximum_animation_scale == other.maximum_animation_scale && 478 return maximum_animation_scale == other.maximum_animation_scale &&
473 starting_animation_scale == other.starting_animation_scale; 479 starting_animation_scale == other.starting_animation_scale;
474 } 480 }
475 }; 481 };
476 482
483 struct DrawTransforms {
484 gfx::Transform from_target;
485 gfx::Transform to_target;
486
487 DrawTransforms(gfx::Transform from, gfx::Transform to)
488 : from_target(from), to_target(to) {}
489 bool operator==(const DrawTransforms& other) const {
490 return from_target == other.from_target && to_target == other.to_target;
491 }
492 };
493
494 struct DrawTransformData {
495 int update_number;
496 DrawTransforms transforms;
497
498 // TODO(sunxd): move screen space transforms here if it can improve
499 // performance
500
501 DrawTransformData()
502 : update_number(-1), transforms(gfx::Transform(), gfx::Transform()) {}
503 };
504
477 struct PropertyTreesCachedData { 505 struct PropertyTreesCachedData {
478 int property_tree_update_number; 506 int property_tree_update_number;
479 std::vector<AnimationScaleData> animation_scales; 507 std::vector<AnimationScaleData> animation_scales;
508 mutable std::vector<std::unordered_map<int, DrawTransformData>>
509 draw_transforms;
480 510
481 PropertyTreesCachedData(); 511 PropertyTreesCachedData();
482 ~PropertyTreesCachedData(); 512 ~PropertyTreesCachedData();
483 }; 513 };
484 514
485 class CC_EXPORT PropertyTrees final { 515 class CC_EXPORT PropertyTrees final {
486 public: 516 public:
487 PropertyTrees(); 517 PropertyTrees();
488 PropertyTrees(const PropertyTrees& other) = delete; 518 PropertyTrees(const PropertyTrees& other) = delete;
489 ~PropertyTrees(); 519 ~PropertyTrees();
(...skipping 24 matching lines...) Expand all
514 bool changed; 544 bool changed;
515 // We cache a global bool for full tree damages to avoid walking the entire 545 // We cache a global bool for full tree damages to avoid walking the entire
516 // tree. 546 // tree.
517 // TODO(jaydasika): Changes to transform and effects that damage the entire 547 // TODO(jaydasika): Changes to transform and effects that damage the entire
518 // tree should be tracked by this bool. Currently, they are tracked by the 548 // tree should be tracked by this bool. Currently, they are tracked by the
519 // individual nodes. 549 // individual nodes.
520 bool full_tree_damaged; 550 bool full_tree_damaged;
521 int sequence_number; 551 int sequence_number;
522 bool is_main_thread; 552 bool is_main_thread;
523 bool is_active; 553 bool is_active;
554 bool verify_transform_tree_calculations;
524 555
525 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 556 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
526 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 557 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
527 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); 558 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta);
528 void PushOpacityIfNeeded(PropertyTrees* target_tree); 559 void PushOpacityIfNeeded(PropertyTrees* target_tree);
529 void RemoveIdFromIdToIndexMaps(int id); 560 void RemoveIdFromIdToIndexMaps(int id);
530 bool IsInIdToIndexMap(TreeType tree_type, int id); 561 bool IsInIdToIndexMap(TreeType tree_type, int id);
531 void UpdateChangeTracking(); 562 void UpdateChangeTracking();
532 void PushChangeTrackingTo(PropertyTrees* tree); 563 void PushChangeTrackingTo(PropertyTrees* tree);
533 void ResetAllChangeTracking(); 564 void ResetAllChangeTracking();
(...skipping 10 matching lines...) Expand all
544 return inner_viewport_scroll_bounds_delta_; 575 return inner_viewport_scroll_bounds_delta_;
545 } 576 }
546 577
547 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; 578 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const;
548 579
549 CombinedAnimationScale GetAnimationScales(int transform_node_id, 580 CombinedAnimationScale GetAnimationScales(int transform_node_id,
550 LayerTreeImpl* layer_tree_impl); 581 LayerTreeImpl* layer_tree_impl);
551 void SetAnimationScalesForTesting(int transform_id, 582 void SetAnimationScalesForTesting(int transform_id,
552 float maximum_animation_scale, 583 float maximum_animation_scale,
553 float starting_animation_scale); 584 float starting_animation_scale);
585
586 // GetDrawTransforms may change the value of cached_data_
587 const DrawTransforms& GetDrawTransforms(int transform_id,
588 int effect_id) const;
589
554 void ResetCachedData(); 590 void ResetCachedData();
555 void UpdateCachedNumber(); 591 void UpdateCachedNumber();
556 592
557 private: 593 private:
558 gfx::Vector2dF inner_viewport_container_bounds_delta_; 594 gfx::Vector2dF inner_viewport_container_bounds_delta_;
559 gfx::Vector2dF outer_viewport_container_bounds_delta_; 595 gfx::Vector2dF outer_viewport_container_bounds_delta_;
560 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; 596 gfx::Vector2dF inner_viewport_scroll_bounds_delta_;
561 597
562 PropertyTreesCachedData cached_data_; 598 PropertyTreesCachedData cached_data_;
563 }; 599 };
564 600
565 } // namespace cc 601 } // namespace cc
566 602
567 #endif // CC_TREES_PROPERTY_TREE_H_ 603 #endif // CC_TREES_PROPERTY_TREE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698