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

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: Revert ancestors_are_invertible change 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 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 208
205 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() 209 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta()
206 const { 210 const {
207 return nodes_affected_by_inner_viewport_bounds_delta_; 211 return nodes_affected_by_inner_viewport_bounds_delta_;
208 } 212 }
209 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta() 213 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta()
210 const { 214 const {
211 return nodes_affected_by_outer_viewport_bounds_delta_; 215 return nodes_affected_by_outer_viewport_bounds_delta_;
212 } 216 }
213 217
214 const gfx::Transform& FromTarget(int node_id) const; 218 const gfx::Transform& FromTarget(int node_id, int effect) const;
215 void SetFromTarget(int node_id, const gfx::Transform& transform); 219 void SetFromTarget(int node_id, const gfx::Transform& transform);
216 220
217 const gfx::Transform& ToTarget(int node_id) const; 221 // TODO(sunxd): Remove target space transforms in cached data when we
222 // completely implement computing draw transforms on demand.
223 const gfx::Transform& ToTarget(int node_id, int effect_id) const;
218 void SetToTarget(int node_id, const gfx::Transform& transform); 224 void SetToTarget(int node_id, const gfx::Transform& transform);
219 225
220 const gfx::Transform& FromScreen(int node_id) const; 226 const gfx::Transform& FromScreen(int node_id) const;
221 void SetFromScreen(int node_id, const gfx::Transform& transform); 227 void SetFromScreen(int node_id, const gfx::Transform& transform);
222 228
223 const gfx::Transform& ToScreen(int node_id) const; 229 const gfx::Transform& ToScreen(int node_id) const;
224 void SetToScreen(int node_id, const gfx::Transform& transform); 230 void SetToScreen(int node_id, const gfx::Transform& transform);
225 231
226 int TargetId(int node_id) const; 232 int TargetId(int node_id) const;
227 void SetTargetId(int node_id, int target_id); 233 void SetTargetId(int node_id, int target_id);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 float starting_animation_scale; 461 float starting_animation_scale;
456 462
457 CombinedAnimationScale(float maximum, float starting) 463 CombinedAnimationScale(float maximum, float starting)
458 : maximum_animation_scale(maximum), starting_animation_scale(starting) {} 464 : maximum_animation_scale(maximum), starting_animation_scale(starting) {}
459 bool operator==(const CombinedAnimationScale& other) const { 465 bool operator==(const CombinedAnimationScale& other) const {
460 return maximum_animation_scale == other.maximum_animation_scale && 466 return maximum_animation_scale == other.maximum_animation_scale &&
461 starting_animation_scale == other.starting_animation_scale; 467 starting_animation_scale == other.starting_animation_scale;
462 } 468 }
463 }; 469 };
464 470
471 struct DrawTransforms {
472 bool invertible;
473 gfx::Transform from_target;
474 gfx::Transform to_target;
475
476 DrawTransforms(gfx::Transform from, gfx::Transform to)
477 : invertible(true), from_target(from), to_target(to) {}
478 bool operator==(const DrawTransforms& other) const {
479 return invertible == other.invertible && from_target == other.from_target &&
480 to_target == other.to_target;
481 }
482 };
483
484 struct DrawTransformData {
485 int update_number;
486 DrawTransforms transforms;
487
488 // TODO(sunxd): Move screen space transforms here if it can improve
489 // performance.
490 DrawTransformData()
491 : update_number(-1), transforms(gfx::Transform(), gfx::Transform()) {}
492 };
493
465 struct PropertyTreesCachedData { 494 struct PropertyTreesCachedData {
466 int property_tree_update_number; 495 int property_tree_update_number;
467 std::vector<AnimationScaleData> animation_scales; 496 std::vector<AnimationScaleData> animation_scales;
497 mutable std::vector<std::unordered_map<int, DrawTransformData>>
498 draw_transforms;
468 499
469 PropertyTreesCachedData(); 500 PropertyTreesCachedData();
470 ~PropertyTreesCachedData(); 501 ~PropertyTreesCachedData();
471 }; 502 };
472 503
473 class CC_EXPORT PropertyTrees final { 504 class CC_EXPORT PropertyTrees final {
474 public: 505 public:
475 PropertyTrees(); 506 PropertyTrees();
476 PropertyTrees(const PropertyTrees& other) = delete; 507 PropertyTrees(const PropertyTrees& other) = delete;
477 ~PropertyTrees(); 508 ~PropertyTrees();
(...skipping 24 matching lines...) Expand all
502 bool changed; 533 bool changed;
503 // We cache a global bool for full tree damages to avoid walking the entire 534 // We cache a global bool for full tree damages to avoid walking the entire
504 // tree. 535 // tree.
505 // TODO(jaydasika): Changes to transform and effects that damage the entire 536 // TODO(jaydasika): Changes to transform and effects that damage the entire
506 // tree should be tracked by this bool. Currently, they are tracked by the 537 // tree should be tracked by this bool. Currently, they are tracked by the
507 // individual nodes. 538 // individual nodes.
508 bool full_tree_damaged; 539 bool full_tree_damaged;
509 int sequence_number; 540 int sequence_number;
510 bool is_main_thread; 541 bool is_main_thread;
511 bool is_active; 542 bool is_active;
543 bool verify_transform_tree_calculations;
512 544
513 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 545 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
514 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 546 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
515 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); 547 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta);
516 void PushOpacityIfNeeded(PropertyTrees* target_tree); 548 void PushOpacityIfNeeded(PropertyTrees* target_tree);
517 void RemoveIdFromIdToIndexMaps(int id); 549 void RemoveIdFromIdToIndexMaps(int id);
518 bool IsInIdToIndexMap(TreeType tree_type, int id); 550 bool IsInIdToIndexMap(TreeType tree_type, int id);
519 void UpdateChangeTracking(); 551 void UpdateChangeTracking();
520 void PushChangeTrackingTo(PropertyTrees* tree); 552 void PushChangeTrackingTo(PropertyTrees* tree);
521 void ResetAllChangeTracking(); 553 void ResetAllChangeTracking();
(...skipping 10 matching lines...) Expand all
532 return inner_viewport_scroll_bounds_delta_; 564 return inner_viewport_scroll_bounds_delta_;
533 } 565 }
534 566
535 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; 567 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const;
536 568
537 CombinedAnimationScale GetAnimationScales(int transform_node_id, 569 CombinedAnimationScale GetAnimationScales(int transform_node_id,
538 LayerTreeImpl* layer_tree_impl); 570 LayerTreeImpl* layer_tree_impl);
539 void SetAnimationScalesForTesting(int transform_id, 571 void SetAnimationScalesForTesting(int transform_id,
540 float maximum_animation_scale, 572 float maximum_animation_scale,
541 float starting_animation_scale); 573 float starting_animation_scale);
574
575 // GetDrawTransforms may change the value of cached_data_.
576 const DrawTransforms& GetDrawTransforms(int transform_id,
577 int effect_id) const;
578
542 void ResetCachedData(); 579 void ResetCachedData();
543 void UpdateCachedNumber(); 580 void UpdateCachedNumber();
544 gfx::Transform ToScreenSpaceTransformWithoutSurfaceContentsScale( 581 gfx::Transform ToScreenSpaceTransformWithoutSurfaceContentsScale(
545 int transform_id, 582 int transform_id,
546 int effect_id) const; 583 int effect_id) const;
547 584
548 private: 585 private:
549 gfx::Vector2dF inner_viewport_container_bounds_delta_; 586 gfx::Vector2dF inner_viewport_container_bounds_delta_;
550 gfx::Vector2dF outer_viewport_container_bounds_delta_; 587 gfx::Vector2dF outer_viewport_container_bounds_delta_;
551 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; 588 gfx::Vector2dF inner_viewport_scroll_bounds_delta_;
552 589
553 PropertyTreesCachedData cached_data_; 590 PropertyTreesCachedData cached_data_;
554 }; 591 };
555 592
556 } // namespace cc 593 } // namespace cc
557 594
558 #endif // CC_TREES_PROPERTY_TREE_H_ 595 #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