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

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

Issue 1924933002: cc : Stop pushing properties not used by LayerImpl to LayerImpl (4) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 void SynchronizeTreesRecursive(OwnedLayerImplMap* old_layers, 120 void SynchronizeTreesRecursive(OwnedLayerImplMap* old_layers,
121 LayerImpl* old_root, 121 LayerImpl* old_root,
122 LayerTreeImpl* tree_impl) { 122 LayerTreeImpl* tree_impl) {
123 tree_impl->SetRootLayer( 123 tree_impl->SetRootLayer(
124 SynchronizeTreesRecursiveInternal(old_layers, old_root, tree_impl)); 124 SynchronizeTreesRecursiveInternal(old_layers, old_root, tree_impl));
125 } 125 }
126 126
127 #if DCHECK_IS_ON() 127 #if DCHECK_IS_ON()
128 static void CheckScrollAndClipPointersForLayer(Layer* layer, 128 static void CheckScrollAndClipPointersForLayer(Layer* layer) {
129 LayerImpl* layer_impl) {
130 DCHECK_EQ(!!layer, !!layer_impl);
131 if (!layer) 129 if (!layer)
132 return; 130 return;
133 131
134 // Having a scroll parent on the impl thread implies having one the main 132 if (layer->scroll_children()) {
135 // thread, too. The main thread may have a scroll parent that is not in the
136 // tree because it's been removed but not deleted. In this case, the layer
137 // impl will have no scroll parent. Same argument applies for clip parents and
138 // scroll/clip children.
139 DCHECK(!layer_impl->scroll_parent() || !!layer->scroll_parent());
140 DCHECK(!layer_impl->clip_parent() || !!layer->clip_parent());
141 DCHECK(!layer_impl->scroll_children() || !!layer->scroll_children());
142 DCHECK(!layer_impl->clip_children() || !!layer->clip_children());
143
144 if (layer_impl->scroll_parent())
145 DCHECK_EQ(layer->scroll_parent()->id(), layer_impl->scroll_parent()->id());
146
147 if (layer_impl->clip_parent())
148 DCHECK_EQ(layer->clip_parent()->id(), layer_impl->clip_parent()->id());
149
150 if (layer_impl->scroll_children()) {
151 for (std::set<Layer*>::iterator it = layer->scroll_children()->begin(); 133 for (std::set<Layer*>::iterator it = layer->scroll_children()->begin();
152 it != layer->scroll_children()->end(); ++it) { 134 it != layer->scroll_children()->end(); ++it) {
153 DCHECK_EQ((*it)->scroll_parent(), layer); 135 DCHECK_EQ((*it)->scroll_parent(), layer);
154 } 136 }
155 for (std::set<LayerImpl*>::iterator it =
156 layer_impl->scroll_children()->begin();
157 it != layer_impl->scroll_children()->end(); ++it) {
158 DCHECK_EQ((*it)->scroll_parent(), layer_impl);
159 }
160 } 137 }
161 138
162 if (layer_impl->clip_children()) { 139 if (layer->clip_children()) {
163 for (std::set<Layer*>::iterator it = layer->clip_children()->begin(); 140 for (std::set<Layer*>::iterator it = layer->clip_children()->begin();
164 it != layer->clip_children()->end(); ++it) { 141 it != layer->clip_children()->end(); ++it) {
165 DCHECK_EQ((*it)->clip_parent(), layer); 142 DCHECK_EQ((*it)->clip_parent(), layer);
166 } 143 }
167 for (std::set<LayerImpl*>::iterator it =
168 layer_impl->clip_children()->begin();
169 it != layer_impl->clip_children()->end(); ++it) {
170 DCHECK_EQ((*it)->clip_parent(), layer_impl);
171 }
172 } 144 }
173 } 145 }
174 146
175 static void CheckScrollAndClipPointers(LayerTreeHost* host, 147 static void CheckScrollAndClipPointers(LayerTreeHost* host) {
176 LayerTreeImpl* host_impl) { 148 for (auto* layer : *host)
177 for (auto* layer_impl : *host_impl) { 149 CheckScrollAndClipPointersForLayer(layer);
ajuma 2016/04/27 21:57:21 Since scroll and clip children aren't being pushed
jaydasika 2016/04/28 01:50:01 Acknowledged.
178 Layer* layer = host->LayerById(layer_impl->id());
179 CheckScrollAndClipPointersForLayer(layer, layer_impl);
180 }
181 } 150 }
182 #endif 151 #endif
183 152
184 template <typename LayerType> 153 template <typename LayerType>
185 static void PushLayerPropertiesInternal( 154 static void PushLayerPropertiesInternal(
186 std::unordered_set<LayerType*> layers_that_should_push_properties, 155 std::unordered_set<LayerType*> layers_that_should_push_properties,
187 LayerTreeImpl* impl_tree) { 156 LayerTreeImpl* impl_tree) {
188 for (auto layer : layers_that_should_push_properties) { 157 for (auto layer : layers_that_should_push_properties) {
189 LayerImpl* layer_impl = impl_tree->LayerById(layer->id()); 158 LayerImpl* layer_impl = impl_tree->LayerById(layer->id());
190 DCHECK(layer_impl); 159 DCHECK(layer_impl);
191 layer->PushPropertiesTo(layer_impl); 160 layer->PushPropertiesTo(layer_impl);
192 } 161 }
193 } 162 }
194 163
195 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree, 164 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree,
196 LayerTreeImpl* active_tree) { 165 LayerTreeImpl* active_tree) {
197 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(), 166 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(),
198 active_tree); 167 active_tree);
199 } 168 }
200 169
201 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, 170 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree,
202 LayerTreeImpl* impl_tree) { 171 LayerTreeImpl* impl_tree) {
203 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), 172 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(),
204 impl_tree); 173 impl_tree);
205 174
206 #if DCHECK_IS_ON() 175 #if DCHECK_IS_ON()
207 if (host_tree->root_layer() && impl_tree->root_layer()) 176 if (host_tree->root_layer())
208 CheckScrollAndClipPointers(host_tree, impl_tree); 177 CheckScrollAndClipPointers(host_tree);
209 #endif 178 #endif
210 } 179 }
211 180
212 } // namespace cc 181 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698