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

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

Issue 2048863003: Reland 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 if (root_layer_) 99 DetachLayers();
100 RemoveLayer(root_layer_->id()); 100 DCHECK(!root_layer_);
101 root_layer_ = nullptr;
102 } 101 }
103 102
104 void LayerTreeImpl::ReleaseResources() { 103 void LayerTreeImpl::ReleaseResources() {
105 if (root_layer_) { 104 if (root_layer_) {
106 LayerTreeHostCommon::CallFunctionForEveryLayer( 105 LayerTreeHostCommon::CallFunctionForEveryLayer(
107 this, [](LayerImpl* layer) { layer->ReleaseResources(); }); 106 this, [](LayerImpl* layer) { layer->ReleaseResources(); });
108 } 107 }
109 } 108 }
110 109
111 void LayerTreeImpl::RecreateResources() { 110 void LayerTreeImpl::RecreateResources() {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 309
311 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { 310 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() {
312 root_layer_ = nullptr; 311 root_layer_ = nullptr;
313 render_surface_layer_list_.clear(); 312 render_surface_layer_list_.clear();
314 set_needs_update_draw_properties(); 313 set_needs_update_draw_properties();
315 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_); 314 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_);
316 layers_.reset(new OwnedLayerImplList); 315 layers_.reset(new OwnedLayerImplList);
317 return ret; 316 return ret;
318 } 317 }
319 318
320 void LayerTreeImpl::ClearLayers() {
321 SetRootLayer(nullptr);
322 DCHECK(layers_->empty());
323 }
324
325 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer, 319 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer,
326 ClipTree* clip_tree) { 320 ClipTree* clip_tree) {
327 if (layer && layer->masks_to_bounds()) { 321 if (layer && layer->masks_to_bounds()) {
328 ClipNode* clip_node = clip_tree->Node(layer->clip_tree_index()); 322 ClipNode* clip_node = clip_tree->Node(layer->clip_tree_index());
329 if (clip_node) { 323 if (clip_node) {
330 DCHECK_EQ(layer->id(), clip_node->owner_id); 324 DCHECK_EQ(layer->id(), clip_node->owner_id);
331 gfx::SizeF bounds = gfx::SizeF(layer->bounds()); 325 gfx::SizeF bounds = gfx::SizeF(layer->bounds());
332 if (clip_node->data.clip.size() != bounds) { 326 if (clip_node->data.clip.size() != bounds) {
333 clip_node->data.clip.set_size(bounds); 327 clip_node->data.clip.set_size(bounds);
334 clip_tree->set_needs_update(true); 328 clip_tree->set_needs_update(true);
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 } 2063 }
2070 2064
2071 void LayerTreeImpl::ResetAllChangeTracking() { 2065 void LayerTreeImpl::ResetAllChangeTracking() {
2072 layers_that_should_push_properties_.clear(); 2066 layers_that_should_push_properties_.clear();
2073 for (auto* layer : *this) 2067 for (auto* layer : *this)
2074 layer->ResetChangeTracking(); 2068 layer->ResetChangeTracking();
2075 property_trees_.ResetAllChangeTracking(); 2069 property_trees_.ResetAllChangeTracking();
2076 } 2070 }
2077 2071
2078 } // namespace cc 2072 } // 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