| OLD | NEW |
| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 property_trees_ = property_trees; | 97 property_trees_ = property_trees; |
| 98 } | 98 } |
| 99 PropertyTrees* property_trees() const { return property_trees_; } | 99 PropertyTrees* property_trees() const { return property_trees_; } |
| 100 | 100 |
| 101 void AsValueInto(base::trace_event::TracedValue* value) const; | 101 void AsValueInto(base::trace_event::TracedValue* value) const; |
| 102 | 102 |
| 103 const T* FindNodeFromOwningLayerId(int id) const { | 103 const T* FindNodeFromOwningLayerId(int id) const { |
| 104 return Node(FindNodeIndexFromOwningLayerId(id)); | 104 return Node(FindNodeIndexFromOwningLayerId(id)); |
| 105 } | 105 } |
| 106 T* UpdateNodeFromOwningLayerId(int id) { | 106 T* UpdateNodeFromOwningLayerId(int id) { |
| 107 #if DCHECK_IS_ON() |
| 108 DCHECK(LookupByOnwningLayerIdAllowed()); |
| 109 #endif |
| 107 int index = FindNodeIndexFromOwningLayerId(id); | 110 int index = FindNodeIndexFromOwningLayerId(id); |
| 108 if (index == kInvalidNodeId) { | 111 if (index == kInvalidNodeId) { |
| 109 DCHECK(property_trees()->is_main_thread); | 112 DCHECK(property_trees()->is_main_thread); |
| 110 property_trees()->needs_rebuild = true; | 113 property_trees()->needs_rebuild = true; |
| 111 } | 114 } |
| 112 | 115 |
| 113 return Node(index); | 116 return Node(index); |
| 114 } | 117 } |
| 115 | 118 |
| 116 int FindNodeIndexFromOwningLayerId(int id) const { | 119 int FindNodeIndexFromOwningLayerId(int id) const { |
| 120 #if DCHECK_IS_ON() |
| 121 DCHECK(LookupByOnwningLayerIdAllowed()); |
| 122 #endif |
| 117 auto iter = owning_layer_id_to_node_index_.find(id); | 123 auto iter = owning_layer_id_to_node_index_.find(id); |
| 118 if (iter == owning_layer_id_to_node_index_.end()) | 124 if (iter == owning_layer_id_to_node_index_.end()) |
| 119 return kInvalidNodeId; | 125 return kInvalidNodeId; |
| 120 else | 126 else |
| 121 return iter->second; | 127 return iter->second; |
| 122 } | 128 } |
| 123 | 129 |
| 124 void SetOwningLayerIdForNode(const T* node, int id) { | 130 void SetOwningLayerIdForNode(const T* node, int id) { |
| 131 #if DCHECK_IS_ON() |
| 132 DCHECK(LookupByOnwningLayerIdAllowed()); |
| 133 #endif |
| 125 if (!node) { | 134 if (!node) { |
| 126 owning_layer_id_to_node_index_[id] = kInvalidNodeId; | 135 owning_layer_id_to_node_index_[id] = kInvalidNodeId; |
| 127 return; | 136 return; |
| 128 } | 137 } |
| 129 | 138 |
| 130 DCHECK(node == Node(node->id)); | 139 DCHECK(node == Node(node->id)); |
| 131 owning_layer_id_to_node_index_[id] = node->id; | 140 owning_layer_id_to_node_index_[id] = node->id; |
| 132 } | 141 } |
| 133 | 142 |
| 143 protected: |
| 144 #if DCHECK_IS_ON() |
| 145 virtual bool LookupByOnwningLayerIdAllowed() const { return true; } |
| 146 #endif |
| 147 |
| 134 private: | 148 private: |
| 135 std::vector<T> nodes_; | 149 std::vector<T> nodes_; |
| 136 | 150 |
| 137 // Maps from layer id to the property tree node index. This container is | 151 // Maps from layer id to the property tree node index. This container is |
| 138 // typically very small and the memory overhead of unordered_map will | 152 // typically very small and the memory overhead of unordered_map will |
| 139 // dominate so use a flat_map. See http://crbug.com/709243 | 153 // dominate so use a flat_map. See http://crbug.com/709243 |
| 140 base::flat_map<int, int> owning_layer_id_to_node_index_; | 154 base::flat_map<int, int> owning_layer_id_to_node_index_; |
| 141 | 155 |
| 142 bool needs_update_; | 156 bool needs_update_; |
| 143 PropertyTrees* property_trees_; | 157 PropertyTrees* property_trees_; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 416 |
| 403 void TakeRenderSurfaces( | 417 void TakeRenderSurfaces( |
| 404 std::vector<std::unique_ptr<RenderSurfaceImpl>>* render_surfaces); | 418 std::vector<std::unique_ptr<RenderSurfaceImpl>>* render_surfaces); |
| 405 | 419 |
| 406 // Returns true if render surfaces changed (that is, if any render surfaces | 420 // Returns true if render surfaces changed (that is, if any render surfaces |
| 407 // were created or destroyed). | 421 // were created or destroyed). |
| 408 bool CreateOrReuseRenderSurfaces( | 422 bool CreateOrReuseRenderSurfaces( |
| 409 std::vector<std::unique_ptr<RenderSurfaceImpl>>* old_render_surfaces, | 423 std::vector<std::unique_ptr<RenderSurfaceImpl>>* old_render_surfaces, |
| 410 LayerTreeImpl* layer_tree_impl); | 424 LayerTreeImpl* layer_tree_impl); |
| 411 | 425 |
| 426 protected: |
| 427 #if DCHECK_IS_ON() |
| 428 bool LookupByOnwningLayerIdAllowed() const override; |
| 429 #endif |
| 430 |
| 412 private: | 431 private: |
| 413 void UpdateOpacities(EffectNode* node, EffectNode* parent_node); | 432 void UpdateOpacities(EffectNode* node, EffectNode* parent_node); |
| 414 void UpdateIsDrawn(EffectNode* node, EffectNode* parent_node); | 433 void UpdateIsDrawn(EffectNode* node, EffectNode* parent_node); |
| 415 void UpdateBackfaceVisibility(EffectNode* node, EffectNode* parent_node); | 434 void UpdateBackfaceVisibility(EffectNode* node, EffectNode* parent_node); |
| 416 | 435 |
| 417 // Stores copy requests, keyed by node id. | 436 // Stores copy requests, keyed by node id. |
| 418 std::unordered_multimap<int, std::unique_ptr<CopyOutputRequest>> | 437 std::unordered_multimap<int, std::unique_ptr<CopyOutputRequest>> |
| 419 copy_requests_; | 438 copy_requests_; |
| 420 | 439 |
| 421 // Unsorted list of all mask layer ids that effect nodes refer to. | 440 // Unsorted list of all mask layer ids that effect nodes refer to. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 // These maps allow mapping directly from a compositor element id to the | 659 // These maps allow mapping directly from a compositor element id to the |
| 641 // respective property node. This will eventually allow simplifying logic in | 660 // respective property node. This will eventually allow simplifying logic in |
| 642 // various places that today has to map from element id to layer id, and then | 661 // various places that today has to map from element id to layer id, and then |
| 643 // from layer id to the respective property node. Completing that work is | 662 // from layer id to the respective property node. Completing that work is |
| 644 // pending the launch of Slimming Paint v2 and reworking UI compositor logic | 663 // pending the launch of Slimming Paint v2 and reworking UI compositor logic |
| 645 // to produce cc property trees and these maps. | 664 // to produce cc property trees and these maps. |
| 646 base::flat_map<ElementId, int> element_id_to_effect_node_index; | 665 base::flat_map<ElementId, int> element_id_to_effect_node_index; |
| 647 base::flat_map<ElementId, int> element_id_to_scroll_node_index; | 666 base::flat_map<ElementId, int> element_id_to_scroll_node_index; |
| 648 base::flat_map<ElementId, int> element_id_to_transform_node_index; | 667 base::flat_map<ElementId, int> element_id_to_transform_node_index; |
| 649 | 668 |
| 650 std::vector<int> always_use_active_tree_opacity_effect_ids; | 669 std::vector<ElementId> always_use_active_tree_opacity_effect_ids; |
| 651 TransformTree transform_tree; | 670 TransformTree transform_tree; |
| 652 EffectTree effect_tree; | 671 EffectTree effect_tree; |
| 653 ClipTree clip_tree; | 672 ClipTree clip_tree; |
| 654 ScrollTree scroll_tree; | 673 ScrollTree scroll_tree; |
| 655 bool needs_rebuild; | 674 bool needs_rebuild; |
| 656 bool can_adjust_raster_scales; | 675 bool can_adjust_raster_scales; |
| 657 // Change tracking done on property trees needs to be preserved across commits | 676 // Change tracking done on property trees needs to be preserved across commits |
| 658 // (when they are not rebuild). We cache a global bool which stores whether | 677 // (when they are not rebuild). We cache a global bool which stores whether |
| 659 // we did any change tracking so that we can skip copying the change status | 678 // we did any change tracking so that we can skip copying the change status |
| 660 // between property trees when this bool is false. | 679 // between property trees when this bool is false. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 DrawTransforms& GetDrawTransforms(int transform_id, int effect_id) const; | 743 DrawTransforms& GetDrawTransforms(int transform_id, int effect_id) const; |
| 725 DrawTransformData& FetchDrawTransformsDataFromCache(int transform_id, | 744 DrawTransformData& FetchDrawTransformsDataFromCache(int transform_id, |
| 726 int effect_id) const; | 745 int effect_id) const; |
| 727 | 746 |
| 728 PropertyTreesCachedData cached_data_; | 747 PropertyTreesCachedData cached_data_; |
| 729 }; | 748 }; |
| 730 | 749 |
| 731 } // namespace cc | 750 } // namespace cc |
| 732 | 751 |
| 733 #endif // CC_TREES_PROPERTY_TREE_H_ | 752 #endif // CC_TREES_PROPERTY_TREE_H_ |
| OLD | NEW |