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

Side by Side Diff: cc/layers/layer_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/layers/layer_impl.h ('k') | cc/layers/picture_layer_impl_perftest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/layer_impl.h" 5 #include "cc/layers/layer_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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 layer_tree_impl_->UnregisterScrollLayer(this); 98 layer_tree_impl_->UnregisterScrollLayer(this);
99 layer_tree_impl_->UnregisterLayer(this); 99 layer_tree_impl_->UnregisterLayer(this);
100 layer_tree_impl_->RemoveLayerShouldPushProperties(this); 100 layer_tree_impl_->RemoveLayerShouldPushProperties(this);
101 101
102 layer_tree_impl_->RemoveFromElementMap(this); 102 layer_tree_impl_->RemoveFromElementMap(this);
103 103
104 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 104 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
105 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); 105 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this);
106 106
107 // The mask and replica layers should have been removed already.
108 if (mask_layer_) 107 if (mask_layer_)
109 DCHECK(!layer_tree_impl_->RemoveLayer(mask_layer_id_)); 108 layer_tree_impl_->RemoveLayer(mask_layer_id_);
110 if (replica_layer_) 109 if (replica_layer_)
111 DCHECK(!layer_tree_impl_->RemoveLayer(replica_layer_id_)); 110 layer_tree_impl_->RemoveLayer(replica_layer_id_);
112 children_.clear(); 111 ClearChildList();
113 } 112 }
114 113
115 void LayerImpl::AddChild(std::unique_ptr<LayerImpl> child) { 114 void LayerImpl::AddChild(std::unique_ptr<LayerImpl> child) {
116 child->SetParent(this); 115 child->SetParent(this);
117 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); 116 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl());
118 children_.push_back(child.get()); 117 children_.push_back(child.get());
119 layer_tree_impl_->AddLayer(std::move(child)); 118 layer_tree_impl_->AddLayer(std::move(child));
120 } 119 }
121 120
122 std::unique_ptr<LayerImpl> LayerImpl::RemoveChildForTesting(LayerImpl* child) { 121 std::unique_ptr<LayerImpl> LayerImpl::RemoveChildForTesting(LayerImpl* child) {
123 auto it = std::find(children_.begin(), children_.end(), child); 122 auto it = std::find(children_.begin(), children_.end(), child);
124 if (it != children_.end()) 123 if (it != children_.end())
125 children_.erase(it); 124 children_.erase(it);
126 layer_tree_impl()->property_trees()->RemoveIdFromIdToIndexMaps(child->id()); 125 layer_tree_impl()->property_trees()->RemoveIdFromIdToIndexMaps(child->id());
127 return layer_tree_impl_->RemoveLayer(child->id()); 126 return layer_tree_impl_->RemoveLayer(child->id());
128 } 127 }
129 128
130 void LayerImpl::SetParent(LayerImpl* parent) { 129 void LayerImpl::SetParent(LayerImpl* parent) {
131 parent_ = parent; 130 parent_ = parent;
132 } 131 }
133 132
133 void LayerImpl::ClearChildList() {
134 if (children_.empty())
135 return;
136 for (auto* child : children_)
137 layer_tree_impl_->RemoveLayer(child->id());
138 children_.clear();
139 }
140
134 void LayerImpl::ClearLinksToOtherLayers() { 141 void LayerImpl::ClearLinksToOtherLayers() {
135 children_.clear(); 142 children_.clear();
136 mask_layer_ = nullptr; 143 mask_layer_ = nullptr;
137 replica_layer_ = nullptr; 144 replica_layer_ = nullptr;
138 } 145 }
139 146
140 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) { 147 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) {
141 if (has_will_change_transform_hint_ == has_will_change) 148 if (has_will_change_transform_hint_ == has_will_change)
142 return; 149 return;
143 has_will_change_transform_hint_ = has_will_change; 150 has_will_change_transform_hint_ = has_will_change;
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 841
835 if (replica_layer_) 842 if (replica_layer_)
836 layer_tree_impl_->RemoveLayer(replica_layer_->id()); 843 layer_tree_impl_->RemoveLayer(replica_layer_->id());
837 replica_layer_ = replica_layer.get(); 844 replica_layer_ = replica_layer.get();
838 if (replica_layer_) 845 if (replica_layer_)
839 layer_tree_impl_->AddLayer(std::move(replica_layer)); 846 layer_tree_impl_->AddLayer(std::move(replica_layer));
840 847
841 replica_layer_id_ = new_layer_id; 848 replica_layer_id_ = new_layer_id;
842 } 849 }
843 850
844 std::unique_ptr<LayerImpl> LayerImpl::TakeReplicaLayerForTesting() { 851 std::unique_ptr<LayerImpl> LayerImpl::TakeReplicaLayer() {
845 replica_layer_id_ = -1; 852 replica_layer_id_ = -1;
846 std::unique_ptr<LayerImpl> ret; 853 std::unique_ptr<LayerImpl> ret;
847 if (replica_layer_) { 854 if (replica_layer_)
848 if (replica_layer_->mask_layer())
849 replica_layer_->SetMaskLayer(nullptr);
850 ret = layer_tree_impl_->RemoveLayer(replica_layer_->id()); 855 ret = layer_tree_impl_->RemoveLayer(replica_layer_->id());
851 }
852 replica_layer_ = nullptr; 856 replica_layer_ = nullptr;
853 return ret; 857 return ret;
854 } 858 }
855 859
856 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() { 860 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() {
857 return nullptr; 861 return nullptr;
858 } 862 }
859 863
860 void LayerImpl::SetDrawsContent(bool draws_content) { 864 void LayerImpl::SetDrawsContent(bool draws_content) {
861 if (draws_content_ == draws_content) 865 if (draws_content_ == draws_content)
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 .layer_transforms_should_scale_layer_contents) { 1361 .layer_transforms_should_scale_layer_contents) {
1358 return default_scale; 1362 return default_scale;
1359 } 1363 }
1360 1364
1361 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1365 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1362 ScreenSpaceTransform(), default_scale); 1366 ScreenSpaceTransform(), default_scale);
1363 return std::max(transform_scales.x(), transform_scales.y()); 1367 return std::max(transform_scales.x(), transform_scales.y());
1364 } 1368 }
1365 1369
1366 } // namespace cc 1370 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/picture_layer_impl_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698