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

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

Issue 2051013002: cc : Push layer lists instead of layer tree at commit and activation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/layer_tree_impl.h ('k') | cc/trees/tree_synchronizer.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 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/layer_tree_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 void LayerTreeImpl::SetRootLayer(std::unique_ptr<LayerImpl> layer) { 255 void LayerTreeImpl::SetRootLayer(std::unique_ptr<LayerImpl> layer) {
256 if (root_layer_ && layer.get() != root_layer_) 256 if (root_layer_ && layer.get() != root_layer_)
257 RemoveLayer(root_layer_->id()); 257 RemoveLayer(root_layer_->id());
258 root_layer_ = layer.get(); 258 root_layer_ = layer.get();
259 if (layer) 259 if (layer)
260 AddLayer(std::move(layer)); 260 AddLayer(std::move(layer));
261 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); 261 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
262 } 262 }
263 263
264 void LayerTreeImpl::SetRootLayerFromLayerList() {
265 root_layer_ = layer_list_.empty() ? nullptr : layer_list_[0];
266 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
267 }
268
269 void LayerTreeImpl::AddToLayerList(LayerImpl* layer) {
270 layer_list_.push_back(layer);
271 }
272
273 void LayerTreeImpl::ClearLayerList() {
274 layer_list_.clear();
275 }
276
264 void LayerTreeImpl::BuildLayerListForTesting() { 277 void LayerTreeImpl::BuildLayerListForTesting() {
265 layer_list_.clear(); 278 ClearLayerList();
266 LayerListIterator<LayerImpl> it(root_layer_); 279 LayerListIterator<LayerImpl> it(root_layer_);
267 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) { 280 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) {
268 layer_list_.push_back(*it); 281 AddToLayerList(*it);
269 } 282 }
270 } 283 }
271 284
272 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const { 285 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const {
273 return root_layer_ == layer; 286 return root_layer_ == layer;
274 } 287 }
275 288
276 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { 289 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const {
277 return LayerById(inner_viewport_scroll_layer_id_); 290 return LayerById(inner_viewport_scroll_layer_id_);
278 } 291 }
(...skipping 21 matching lines...) Expand all
300 offset += InnerViewportScrollLayer()->MaxScrollOffset(); 313 offset += InnerViewportScrollLayer()->MaxScrollOffset();
301 314
302 if (OuterViewportScrollLayer()) 315 if (OuterViewportScrollLayer())
303 offset += OuterViewportScrollLayer()->MaxScrollOffset(); 316 offset += OuterViewportScrollLayer()->MaxScrollOffset();
304 317
305 return offset; 318 return offset;
306 } 319 }
307 320
308 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { 321 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() {
309 root_layer_ = nullptr; 322 root_layer_ = nullptr;
323 layer_list_.clear();
310 render_surface_layer_list_.clear(); 324 render_surface_layer_list_.clear();
311 set_needs_update_draw_properties(); 325 set_needs_update_draw_properties();
312 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_); 326 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_);
313 layers_.reset(new OwnedLayerImplList); 327 layers_.reset(new OwnedLayerImplList);
314 return ret; 328 return ret;
315 } 329 }
316 330
317 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, 331 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer,
318 ClipTree* clip_tree) { 332 ClipTree* clip_tree) {
319 if (layer && layer->masks_to_bounds()) { 333 if (layer && layer->masks_to_bounds()) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 void LayerTreeImpl::MoveChangeTrackingToLayers() { 451 void LayerTreeImpl::MoveChangeTrackingToLayers() {
438 // We need to update the change tracking on property trees before we move it 452 // We need to update the change tracking on property trees before we move it
439 // onto the layers. 453 // onto the layers.
440 property_trees_.UpdateChangeTracking(); 454 property_trees_.UpdateChangeTracking();
441 for (auto* layer : *this) { 455 for (auto* layer : *this) {
442 if (layer->LayerPropertyChanged()) 456 if (layer->LayerPropertyChanged())
443 layer->NoteLayerPropertyChanged(); 457 layer->NoteLayerPropertyChanged();
444 } 458 }
445 } 459 }
446 460
447 LayerListIterator<LayerImpl> LayerTreeImpl::begin() const { 461 LayerImplList::const_iterator LayerTreeImpl::begin() const {
448 return LayerListIterator<LayerImpl>(root_layer_); 462 return layer_list_.cbegin();
449 } 463 }
450 464
451 LayerListIterator<LayerImpl> LayerTreeImpl::end() const { 465 LayerImplList::const_iterator LayerTreeImpl::end() const {
452 return LayerListIterator<LayerImpl>(nullptr); 466 return layer_list_.cend();
453 } 467 }
454 468
455 LayerListReverseIterator<LayerImpl> LayerTreeImpl::rbegin() { 469 LayerImplList::reverse_iterator LayerTreeImpl::rbegin() {
456 return LayerListReverseIterator<LayerImpl>(root_layer_); 470 return layer_list_.rbegin();
457 } 471 }
458 472
459 LayerListReverseIterator<LayerImpl> LayerTreeImpl::rend() { 473 LayerImplList::reverse_iterator LayerTreeImpl::rend() {
460 return LayerListReverseIterator<LayerImpl>(nullptr); 474 return layer_list_.rend();
461 } 475 }
462 476
463 void LayerTreeImpl::AddToElementMap(LayerImpl* layer) { 477 void LayerTreeImpl::AddToElementMap(LayerImpl* layer) {
464 if (!layer->element_id() || !layer->mutable_properties()) 478 if (!layer->element_id() || !layer->mutable_properties())
465 return; 479 return;
466 480
467 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), 481 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
468 "LayerTreeImpl::AddToElementMap", "element_id", 482 "LayerTreeImpl::AddToElementMap", "element_id",
469 layer->element_id(), "layer_id", layer->id()); 483 layer->element_id(), "layer_id", layer->id());
470 484
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 clip_scroll_map_.erase(layer->scroll_clip_layer_id()); 1514 clip_scroll_map_.erase(layer->scroll_clip_layer_id());
1501 } 1515 }
1502 1516
1503 void LayerTreeImpl::AddSurfaceLayer(LayerImpl* layer) { 1517 void LayerTreeImpl::AddSurfaceLayer(LayerImpl* layer) {
1504 DCHECK(std::find(surface_layers_.begin(), surface_layers_.end(), layer) == 1518 DCHECK(std::find(surface_layers_.begin(), surface_layers_.end(), layer) ==
1505 surface_layers_.end()); 1519 surface_layers_.end());
1506 surface_layers_.push_back(layer); 1520 surface_layers_.push_back(layer);
1507 } 1521 }
1508 1522
1509 void LayerTreeImpl::RemoveSurfaceLayer(LayerImpl* layer) { 1523 void LayerTreeImpl::RemoveSurfaceLayer(LayerImpl* layer) {
1510 std::vector<LayerImpl*>::iterator it = 1524 LayerImplList::iterator it =
1511 std::find(surface_layers_.begin(), surface_layers_.end(), layer); 1525 std::find(surface_layers_.begin(), surface_layers_.end(), layer);
1512 DCHECK(it != surface_layers_.end()); 1526 DCHECK(it != surface_layers_.end());
1513 surface_layers_.erase(it); 1527 surface_layers_.erase(it);
1514 } 1528 }
1515 1529
1516 template <typename LayerType> 1530 template <typename LayerType>
1517 static inline bool LayerClipsSubtree(LayerType* layer) { 1531 static inline bool LayerClipsSubtree(LayerType* layer) {
1518 return layer->masks_to_bounds() || layer->mask_layer(); 1532 return layer->masks_to_bounds() || layer->mask_layer();
1519 } 1533 }
1520 1534
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 } 2075 }
2062 2076
2063 void LayerTreeImpl::ResetAllChangeTracking() { 2077 void LayerTreeImpl::ResetAllChangeTracking() {
2064 layers_that_should_push_properties_.clear(); 2078 layers_that_should_push_properties_.clear();
2065 for (auto* layer : *this) 2079 for (auto* layer : *this)
2066 layer->ResetChangeTracking(); 2080 layer->ResetChangeTracking();
2067 property_trees_.ResetAllChangeTracking(); 2081 property_trees_.ResetAllChangeTracking();
2068 } 2082 }
2069 2083
2070 } // namespace cc 2084 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/tree_synchronizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698