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

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

Issue 2846653002: cc : Stop pushing layers from hidden subtrees at commit
Patch Set: don't add hidden layers to push propreties list 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
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/tree_synchronizer.h" 5 #include "cc/trees/tree_synchronizer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) { 87 static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) {
88 DCHECK(layer); 88 DCHECK(layer);
89 return layer->transform_tree_index() != TransformTree::kInvalidNodeId && 89 return layer->transform_tree_index() != TransformTree::kInvalidNodeId &&
90 layer->effect_tree_index() != EffectTree::kInvalidNodeId && 90 layer->effect_tree_index() != EffectTree::kInvalidNodeId &&
91 layer->clip_tree_index() != ClipTree::kInvalidNodeId && 91 layer->clip_tree_index() != ClipTree::kInvalidNodeId &&
92 layer->scroll_tree_index() != ScrollTree::kInvalidNodeId; 92 layer->scroll_tree_index() != ScrollTree::kInvalidNodeId;
93 } 93 }
94 #endif 94 #endif
95 95
96 static bool IsHidden(Layer* layer) {
97 return layer->is_hidden();
98 }
99
100 static bool IsHidden(LayerImpl* layer) {
101 return false;
102 }
103
104 static void RemoveLayerShouldPushProperties(LayerTreeHost* host, Layer* layer) {
105 host->RemoveLayerShouldPushProperties(layer);
106 }
107
108 static void RemoveLayerShouldPushProperties(LayerTreeImpl* host_impl,
109 LayerImpl* layer) {}
110
96 template <typename LayerTreeType> 111 template <typename LayerTreeType>
97 void PushLayerList(OwnedLayerImplMap* old_layers, 112 void PushLayerList(OwnedLayerImplMap* old_layers,
98 LayerTreeType* host, 113 LayerTreeType* host,
99 LayerTreeImpl* tree_impl) { 114 LayerTreeImpl* tree_impl) {
100 tree_impl->ClearLayerList(); 115 tree_impl->ClearLayerList();
101 for (auto* layer : *host) { 116 for (auto* layer : *host) {
102 std::unique_ptr<LayerImpl> layer_impl( 117 if (!IsHidden(layer)) {
103 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); 118 std::unique_ptr<LayerImpl> layer_impl(
119 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl));
104 120
105 #if DCHECK_IS_ON() 121 #if DCHECK_IS_ON()
106 // Every layer should have valid property tree indices 122 // Every layer should have valid property tree indices
107 AssertValidPropertyTreeIndices(layer); 123 AssertValidPropertyTreeIndices(layer);
108 // Every layer_impl should either have valid property tree indices already 124 // Every layer_impl should either have valid property tree indices already
109 // or the corresponding layer should push them onto layer_impl. 125 // or the corresponding layer should push them onto layer_impl.
110 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) || 126 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) ||
111 host->LayerNeedsPushPropertiesForTesting(layer)); 127 host->LayerNeedsPushPropertiesForTesting(layer));
112 #endif 128 #endif
113 129 tree_impl->AddToLayerList(layer_impl.get());
114 tree_impl->AddToLayerList(layer_impl.get()); 130 tree_impl->AddLayer(std::move(layer_impl));
115 tree_impl->AddLayer(std::move(layer_impl)); 131 } else {
132 RemoveLayerShouldPushProperties(host, layer);
133 }
116 } 134 }
117 tree_impl->OnCanDrawStateChangedForTree(); 135 tree_impl->OnCanDrawStateChangedForTree();
118 } 136 }
119 137
120 template <typename LayerType> 138 template <typename LayerType>
121 static void PushLayerPropertiesInternal( 139 static void PushLayerPropertiesInternal(
122 std::unordered_set<LayerType*> layers_that_should_push_properties, 140 std::unordered_set<LayerType*> layers_that_should_push_properties,
123 LayerTreeImpl* impl_tree) { 141 LayerTreeImpl* impl_tree) {
124 for (auto layer : layers_that_should_push_properties) { 142 for (auto layer : layers_that_should_push_properties) {
125 LayerImpl* layer_impl = impl_tree->LayerById(layer->id()); 143 LayerImpl* layer_impl = impl_tree->LayerById(layer->id());
126 DCHECK(layer_impl); 144 DCHECK(layer_impl);
127 layer->PushPropertiesTo(layer_impl); 145 layer->PushPropertiesTo(layer_impl);
128 } 146 }
129 } 147 }
130 148
131 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree, 149 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree,
132 LayerTreeImpl* active_tree) { 150 LayerTreeImpl* active_tree) {
133 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(), 151 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(),
134 active_tree); 152 active_tree);
135 } 153 }
136 154
137 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, 155 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree,
138 LayerTreeImpl* impl_tree) { 156 LayerTreeImpl* impl_tree) {
139 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), 157 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(),
140 impl_tree); 158 impl_tree);
141 } 159 }
142 160
143 } // namespace cc 161 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host.cc ('K') | « cc/trees/property_tree_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698