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

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

Issue 2846653002: cc : Stop pushing layers from hidden subtrees at commit
Patch Set: . 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
96 template <typename LayerTreeType> 104 template <typename LayerTreeType>
97 void PushLayerList(OwnedLayerImplMap* old_layers, 105 void PushLayerList(OwnedLayerImplMap* old_layers,
98 LayerTreeType* host, 106 LayerTreeType* host,
99 LayerTreeImpl* tree_impl) { 107 LayerTreeImpl* tree_impl) {
100 tree_impl->ClearLayerList(); 108 tree_impl->ClearLayerList();
101 for (auto* layer : *host) { 109 for (auto* layer : *host) {
102 std::unique_ptr<LayerImpl> layer_impl( 110 if (!IsHidden(layer)) {
103 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); 111 std::unique_ptr<LayerImpl> layer_impl(
112 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl));
104 113
105 #if DCHECK_IS_ON() 114 #if DCHECK_IS_ON()
106 // Every layer should have valid property tree indices 115 // Every layer should have valid property tree indices
107 AssertValidPropertyTreeIndices(layer); 116 AssertValidPropertyTreeIndices(layer);
108 // Every layer_impl should either have valid property tree indices already 117 // Every layer_impl should either have valid property tree indices already
109 // or the corresponding layer should push them onto layer_impl. 118 // or the corresponding layer should push them onto layer_impl.
110 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) || 119 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) ||
111 host->LayerNeedsPushPropertiesForTesting(layer)); 120 host->LayerNeedsPushPropertiesForTesting(layer));
112 #endif 121 #endif
113 122 tree_impl->AddToLayerList(layer_impl.get());
114 tree_impl->AddToLayerList(layer_impl.get()); 123 tree_impl->AddLayer(std::move(layer_impl));
115 tree_impl->AddLayer(std::move(layer_impl)); 124 }
116 } 125 }
117 tree_impl->OnCanDrawStateChangedForTree(); 126 tree_impl->OnCanDrawStateChangedForTree();
118 } 127 }
119 128
120 template <typename LayerType> 129 template <typename LayerType>
121 static void PushLayerPropertiesInternal( 130 static void PushLayerPropertiesInternal(
122 std::unordered_set<LayerType*> layers_that_should_push_properties, 131 std::unordered_set<LayerType*> layers_that_should_push_properties,
123 LayerTreeImpl* impl_tree) { 132 LayerTreeImpl* impl_tree) {
124 for (auto layer : layers_that_should_push_properties) { 133 for (auto layer : layers_that_should_push_properties) {
125 LayerImpl* layer_impl = impl_tree->LayerById(layer->id()); 134 if (!IsHidden(layer)) {
126 DCHECK(layer_impl); 135 LayerImpl* layer_impl = impl_tree->LayerById(layer->id());
127 layer->PushPropertiesTo(layer_impl); 136 DCHECK(layer_impl);
137 layer->PushPropertiesTo(layer_impl);
138 }
128 } 139 }
129 } 140 }
130 141
131 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree, 142 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree,
132 LayerTreeImpl* active_tree) { 143 LayerTreeImpl* active_tree) {
133 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(), 144 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(),
134 active_tree); 145 active_tree);
146 active_tree->ClearSurfaceLayerIds();
147 active_tree->SetSurfaceLayerIds(pending_tree->SurfaceLayerIds());
148 // Reset for next update.
149 pending_tree->ClearSurfaceLayerIds();
135 } 150 }
136 151
137 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, 152 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree,
138 LayerTreeImpl* impl_tree) { 153 LayerTreeImpl* impl_tree) {
139 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), 154 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(),
140 impl_tree); 155 impl_tree);
156 impl_tree->ClearSurfaceLayerIds();
157 impl_tree->SetSurfaceLayerIds(host_tree->SurfaceLayerIds());
158 // Reset for next update.
159 host_tree->ClearSurfaceLayerIds();
141 } 160 }
142 161
143 } // namespace cc 162 } // 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