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

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

Issue 2866733002: Remove owning_id from EffectNode and replace it by an opaque stable_id (Closed)
Patch Set: none Created 3 years, 7 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/property_tree.h ('k') | cc/trees/property_tree_builder.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 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 } 753 }
754 return &sticky_position_data_[node->sticky_position_constraint_id]; 754 return &sticky_position_data_[node->sticky_position_constraint_id];
755 } 755 }
756 756
757 EffectTree::EffectTree() { 757 EffectTree::EffectTree() {
758 render_surfaces_.push_back(nullptr); 758 render_surfaces_.push_back(nullptr);
759 } 759 }
760 760
761 EffectTree::~EffectTree() {} 761 EffectTree::~EffectTree() {}
762 762
763 #if DCHECK_IS_ON()
764 bool EffectTree::LookupByOnwningLayerIdAllowed() const {
765 return false;
766 }
767 #endif
768
763 int EffectTree::Insert(const EffectNode& tree_node, int parent_id) { 769 int EffectTree::Insert(const EffectNode& tree_node, int parent_id) {
764 int node_id = PropertyTree<EffectNode>::Insert(tree_node, parent_id); 770 int node_id = PropertyTree<EffectNode>::Insert(tree_node, parent_id);
765 DCHECK_EQ(node_id, static_cast<int>(render_surfaces_.size())); 771 DCHECK_EQ(node_id, static_cast<int>(render_surfaces_.size()));
766 772
767 render_surfaces_.push_back(nullptr); 773 render_surfaces_.push_back(nullptr);
768 return node_id; 774 return node_id;
769 } 775 }
770 776
771 void EffectTree::clear() { 777 void EffectTree::clear() {
772 PropertyTree<EffectNode>::clear(); 778 PropertyTree<EffectNode>::clear();
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 void EffectTree::UpdateRenderSurfaces(LayerTreeImpl* layer_tree_impl) { 1013 void EffectTree::UpdateRenderSurfaces(LayerTreeImpl* layer_tree_impl) {
1008 for (int id = kContentsRootNodeId; id < static_cast<int>(size()); ++id) { 1014 for (int id = kContentsRootNodeId; id < static_cast<int>(size()); ++id) {
1009 EffectNode* effect_node = Node(id); 1015 EffectNode* effect_node = Node(id);
1010 bool needs_render_surface = 1016 bool needs_render_surface =
1011 id == kContentsRootNodeId || effect_node->has_render_surface; 1017 id == kContentsRootNodeId || effect_node->has_render_surface;
1012 if (needs_render_surface == !!render_surfaces_[id]) 1018 if (needs_render_surface == !!render_surfaces_[id])
1013 continue; 1019 continue;
1014 1020
1015 if (needs_render_surface) { 1021 if (needs_render_surface) {
1016 render_surfaces_[id] = base::MakeUnique<RenderSurfaceImpl>( 1022 render_surfaces_[id] = base::MakeUnique<RenderSurfaceImpl>(
1017 layer_tree_impl, effect_node->owning_layer_id); 1023 layer_tree_impl, effect_node->stable_id);
1018 render_surfaces_[id]->set_effect_tree_index(id); 1024 render_surfaces_[id]->set_effect_tree_index(id);
1019 } else { 1025 } else {
1020 render_surfaces_[id].reset(); 1026 render_surfaces_[id].reset();
1021 } 1027 }
1022 } 1028 }
1023 } 1029 }
1024 1030
1025 bool EffectTree::ContributesToDrawnSurface(int id) { 1031 bool EffectTree::ContributesToDrawnSurface(int id) {
1026 // All drawn nodes contribute to drawn surface. 1032 // All drawn nodes contribute to drawn surface.
1027 // Exception : Nodes that are hidden and are drawn only for the sake of 1033 // Exception : Nodes that are hidden and are drawn only for the sake of
(...skipping 24 matching lines...) Expand all
1052 bool EffectTree::CreateOrReuseRenderSurfaces( 1058 bool EffectTree::CreateOrReuseRenderSurfaces(
1053 std::vector<std::unique_ptr<RenderSurfaceImpl>>* old_render_surfaces, 1059 std::vector<std::unique_ptr<RenderSurfaceImpl>>* old_render_surfaces,
1054 LayerTreeImpl* layer_tree_impl) { 1060 LayerTreeImpl* layer_tree_impl) {
1055 // Make a list of {stable id, node id} pairs for nodes that are supposed to 1061 // Make a list of {stable id, node id} pairs for nodes that are supposed to
1056 // have surfaces. 1062 // have surfaces.
1057 std::vector<std::pair<int, int>> stable_id_node_id_list; 1063 std::vector<std::pair<int, int>> stable_id_node_id_list;
1058 for (int id = kContentsRootNodeId; id < static_cast<int>(size()); ++id) { 1064 for (int id = kContentsRootNodeId; id < static_cast<int>(size()); ++id) {
1059 EffectNode* node = Node(id); 1065 EffectNode* node = Node(id);
1060 if (node->has_render_surface) { 1066 if (node->has_render_surface) {
1061 stable_id_node_id_list.push_back( 1067 stable_id_node_id_list.push_back(
1062 std::make_pair(node->owning_layer_id, node->id)); 1068 std::make_pair(node->stable_id, node->id));
1063 } 1069 }
1064 } 1070 }
1065 1071
1066 // Sort by stable id so that we can process the two lists cosequentially. 1072 // Sort by stable id so that we can process the two lists cosequentially.
1067 std::sort(stable_id_node_id_list.begin(), stable_id_node_id_list.end()); 1073 std::sort(stable_id_node_id_list.begin(), stable_id_node_id_list.end());
1068 std::sort(old_render_surfaces->begin(), old_render_surfaces->end(), 1074 std::sort(old_render_surfaces->begin(), old_render_surfaces->end(),
1069 [](const std::unique_ptr<RenderSurfaceImpl>& a, 1075 [](const std::unique_ptr<RenderSurfaceImpl>& a,
1070 const std::unique_ptr<RenderSurfaceImpl>& b) { 1076 const std::unique_ptr<RenderSurfaceImpl>& b) {
1071 return a->id() < b->id(); 1077 return a->id() < b->id();
1072 }); 1078 });
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 outer_viewport_container_bounds_delta_ = bounds_delta; 1717 outer_viewport_container_bounds_delta_ = bounds_delta;
1712 transform_tree.UpdateOuterViewportContainerBoundsDelta(); 1718 transform_tree.UpdateOuterViewportContainerBoundsDelta();
1713 } 1719 }
1714 1720
1715 void PropertyTrees::SetInnerViewportScrollBoundsDelta( 1721 void PropertyTrees::SetInnerViewportScrollBoundsDelta(
1716 gfx::Vector2dF bounds_delta) { 1722 gfx::Vector2dF bounds_delta) {
1717 inner_viewport_scroll_bounds_delta_ = bounds_delta; 1723 inner_viewport_scroll_bounds_delta_ = bounds_delta;
1718 } 1724 }
1719 1725
1720 void PropertyTrees::PushOpacityIfNeeded(PropertyTrees* target_tree) { 1726 void PropertyTrees::PushOpacityIfNeeded(PropertyTrees* target_tree) {
1721 for (int id : target_tree->always_use_active_tree_opacity_effect_ids) { 1727 for (const ElementId& element_id :
1728 target_tree->always_use_active_tree_opacity_effect_ids) {
1722 if (const EffectNode* source_effect_node = 1729 if (const EffectNode* source_effect_node =
1723 effect_tree.FindNodeFromOwningLayerId(id)) { 1730 effect_tree.FindNodeFromElementId(element_id)) {
1724 EffectNode* target_effect_node = 1731 EffectNode* target_effect_node =
1725 target_tree->effect_tree.UpdateNodeFromOwningLayerId(id); 1732 target_tree->effect_tree.FindNodeFromElementId(element_id);
1726 float source_opacity = source_effect_node->opacity; 1733 float source_opacity = source_effect_node->opacity;
1727 float target_opacity = target_effect_node->opacity; 1734 float target_opacity = target_effect_node->opacity;
1728 if (source_opacity == target_opacity) 1735 if (source_opacity == target_opacity)
1729 continue; 1736 continue;
1730 target_effect_node->opacity = source_opacity; 1737 target_effect_node->opacity = source_opacity;
1731 target_tree->effect_tree.set_needs_update(true); 1738 target_tree->effect_tree.set_needs_update(true);
1732 } 1739 }
1733 } 1740 }
1734 } 1741 }
1735 1742
1736 void PropertyTrees::RemoveIdFromIdToIndexMaps(int id) { 1743 void PropertyTrees::RemoveIdFromIdToIndexMaps(int id) {
1737 transform_tree.SetOwningLayerIdForNode(nullptr, id); 1744 transform_tree.SetOwningLayerIdForNode(nullptr, id);
1738 clip_tree.SetOwningLayerIdForNode(nullptr, id); 1745 clip_tree.SetOwningLayerIdForNode(nullptr, id);
1739 scroll_tree.SetOwningLayerIdForNode(nullptr, id); 1746 scroll_tree.SetOwningLayerIdForNode(nullptr, id);
1740 effect_tree.SetOwningLayerIdForNode(nullptr, id);
1741 } 1747 }
1742 1748
1743 void PropertyTrees::UpdateChangeTracking() { 1749 void PropertyTrees::UpdateChangeTracking() {
1744 for (int id = EffectTree::kContentsRootNodeId; 1750 for (int id = EffectTree::kContentsRootNodeId;
1745 id < static_cast<int>(effect_tree.size()); ++id) { 1751 id < static_cast<int>(effect_tree.size()); ++id) {
1746 EffectNode* node = effect_tree.Node(id); 1752 EffectNode* node = effect_tree.Node(id);
1747 EffectNode* parent_node = effect_tree.parent(node); 1753 EffectNode* parent_node = effect_tree.parent(node);
1748 effect_tree.UpdateEffectChanged(node, parent_node); 1754 effect_tree.UpdateEffectChanged(node, parent_node);
1749 } 1755 }
1750 for (int i = TransformTree::kContentsRootNodeId; 1756 for (int i = TransformTree::kContentsRootNodeId;
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 const EffectNode* effect_node = effect_tree.Node(effect_id); 2126 const EffectNode* effect_node = effect_tree.Node(effect_id);
2121 2127
2122 if (effect_node->surface_contents_scale.x() != 0.0 && 2128 if (effect_node->surface_contents_scale.x() != 0.0 &&
2123 effect_node->surface_contents_scale.y() != 0.0) 2129 effect_node->surface_contents_scale.y() != 0.0)
2124 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), 2130 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(),
2125 1.0 / effect_node->surface_contents_scale.y()); 2131 1.0 / effect_node->surface_contents_scale.y());
2126 return screen_space_transform; 2132 return screen_space_transform;
2127 } 2133 }
2128 2134
2129 } // namespace cc 2135 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698