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

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

Issue 2054483002: Revert of cc : Make LayerImpl destruction independent of tree hierarchy (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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 LayerTreeImpl::~LayerTreeImpl() { 89 LayerTreeImpl::~LayerTreeImpl() {
90 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS 90 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS
91 : SwapPromise::ACTIVATION_FAILS); 91 : SwapPromise::ACTIVATION_FAILS);
92 92
93 // Need to explicitly clear the tree prior to destroying this so that 93 // Need to explicitly clear the tree prior to destroying this so that
94 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. 94 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor.
95 DCHECK(!root_layer_); 95 DCHECK(!root_layer_);
96 } 96 }
97 97
98 void LayerTreeImpl::Shutdown() { 98 void LayerTreeImpl::Shutdown() {
99 DetachLayers(); 99 if (root_layer_)
100 DCHECK(!root_layer_); 100 RemoveLayer(root_layer_->id());
101 root_layer_ = nullptr;
101 } 102 }
102 103
103 void LayerTreeImpl::ReleaseResources() { 104 void LayerTreeImpl::ReleaseResources() {
104 if (root_layer_) { 105 if (root_layer_) {
105 LayerTreeHostCommon::CallFunctionForEveryLayer( 106 LayerTreeHostCommon::CallFunctionForEveryLayer(
106 this, [](LayerImpl* layer) { layer->ReleaseResources(); }); 107 this, [](LayerImpl* layer) { layer->ReleaseResources(); });
107 } 108 }
108 } 109 }
109 110
110 void LayerTreeImpl::RecreateResources() { 111 void LayerTreeImpl::RecreateResources() {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 310
310 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { 311 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() {
311 root_layer_ = nullptr; 312 root_layer_ = nullptr;
312 render_surface_layer_list_.clear(); 313 render_surface_layer_list_.clear();
313 set_needs_update_draw_properties(); 314 set_needs_update_draw_properties();
314 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_); 315 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_);
315 layers_.reset(new OwnedLayerImplList); 316 layers_.reset(new OwnedLayerImplList);
316 return ret; 317 return ret;
317 } 318 }
318 319
320 void LayerTreeImpl::ClearLayers() {
321 SetRootLayer(nullptr);
322 DCHECK(layers_->empty());
323 }
324
319 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, 325 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer,
320 ClipTree* clip_tree) { 326 ClipTree* clip_tree) {
321 if (layer && layer->masks_to_bounds()) { 327 if (layer && layer->masks_to_bounds()) {
322 ClipNode* clip_node = clip_tree->Node(layer->clip_tree_index()); 328 ClipNode* clip_node = clip_tree->Node(layer->clip_tree_index());
323 if (clip_node) { 329 if (clip_node) {
324 DCHECK_EQ(layer->id(), clip_node->owner_id); 330 DCHECK_EQ(layer->id(), clip_node->owner_id);
325 gfx::SizeF bounds = gfx::SizeF(layer->bounds()); 331 gfx::SizeF bounds = gfx::SizeF(layer->bounds());
326 if (clip_node->data.clip.size() != bounds) { 332 if (clip_node->data.clip.size() != bounds) {
327 clip_node->data.clip.set_size(bounds); 333 clip_node->data.clip.set_size(bounds);
328 clip_tree->set_needs_update(true); 334 clip_tree->set_needs_update(true);
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 } 2069 }
2064 2070
2065 void LayerTreeImpl::ResetAllChangeTracking() { 2071 void LayerTreeImpl::ResetAllChangeTracking() {
2066 layers_that_should_push_properties_.clear(); 2072 layers_that_should_push_properties_.clear();
2067 for (auto* layer : *this) 2073 for (auto* layer : *this)
2068 layer->ResetChangeTracking(); 2074 layer->ResetChangeTracking();
2069 property_trees_.ResetAllChangeTracking(); 2075 property_trees_.ResetAllChangeTracking();
2070 } 2076 }
2071 2077
2072 } // namespace cc 2078 } // 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