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

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

Powered by Google App Engine
This is Rietveld 408576698