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

Side by Side Diff: cc/layers/layer_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/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.
107 if (mask_layer_) 108 if (mask_layer_)
108 layer_tree_impl_->RemoveLayer(mask_layer_id_); 109 DCHECK(!layer_tree_impl_->RemoveLayer(mask_layer_id_));
109 if (replica_layer_) 110 if (replica_layer_)
110 layer_tree_impl_->RemoveLayer(replica_layer_id_); 111 DCHECK(!layer_tree_impl_->RemoveLayer(replica_layer_id_));
111 ClearChildList(); 112 children_.clear();
112 } 113 }
113 114
114 void LayerImpl::AddChild(std::unique_ptr<LayerImpl> child) { 115 void LayerImpl::AddChild(std::unique_ptr<LayerImpl> child) {
115 child->SetParent(this); 116 child->SetParent(this);
116 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); 117 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl());
117 children_.push_back(child.get()); 118 children_.push_back(child.get());
118 layer_tree_impl_->AddLayer(std::move(child)); 119 layer_tree_impl_->AddLayer(std::move(child));
119 } 120 }
120 121
121 std::unique_ptr<LayerImpl> LayerImpl::RemoveChildForTesting(LayerImpl* child) { 122 std::unique_ptr<LayerImpl> LayerImpl::RemoveChildForTesting(LayerImpl* child) {
122 auto it = std::find(children_.begin(), children_.end(), child); 123 auto it = std::find(children_.begin(), children_.end(), child);
123 if (it != children_.end()) 124 if (it != children_.end())
124 children_.erase(it); 125 children_.erase(it);
125 layer_tree_impl()->property_trees()->RemoveIdFromIdToIndexMaps(child->id()); 126 layer_tree_impl()->property_trees()->RemoveIdFromIdToIndexMaps(child->id());
126 return layer_tree_impl_->RemoveLayer(child->id()); 127 return layer_tree_impl_->RemoveLayer(child->id());
127 } 128 }
128 129
129 void LayerImpl::SetParent(LayerImpl* parent) { 130 void LayerImpl::SetParent(LayerImpl* parent) {
130 parent_ = parent; 131 parent_ = parent;
131 } 132 }
132 133
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
141 void LayerImpl::ClearLinksToOtherLayers() { 134 void LayerImpl::ClearLinksToOtherLayers() {
142 children_.clear(); 135 children_.clear();
143 mask_layer_ = nullptr; 136 mask_layer_ = nullptr;
144 replica_layer_ = nullptr; 137 replica_layer_ = nullptr;
145 } 138 }
146 139
147 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) { 140 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) {
148 if (has_will_change_transform_hint_ == has_will_change) 141 if (has_will_change_transform_hint_ == has_will_change)
149 return; 142 return;
150 has_will_change_transform_hint_ = has_will_change; 143 has_will_change_transform_hint_ = has_will_change;
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 834
842 if (replica_layer_) 835 if (replica_layer_)
843 layer_tree_impl_->RemoveLayer(replica_layer_->id()); 836 layer_tree_impl_->RemoveLayer(replica_layer_->id());
844 replica_layer_ = replica_layer.get(); 837 replica_layer_ = replica_layer.get();
845 if (replica_layer_) 838 if (replica_layer_)
846 layer_tree_impl_->AddLayer(std::move(replica_layer)); 839 layer_tree_impl_->AddLayer(std::move(replica_layer));
847 840
848 replica_layer_id_ = new_layer_id; 841 replica_layer_id_ = new_layer_id;
849 } 842 }
850 843
851 std::unique_ptr<LayerImpl> LayerImpl::TakeReplicaLayer() { 844 std::unique_ptr<LayerImpl> LayerImpl::TakeReplicaLayerForTesting() {
852 replica_layer_id_ = -1; 845 replica_layer_id_ = -1;
853 std::unique_ptr<LayerImpl> ret; 846 std::unique_ptr<LayerImpl> ret;
854 if (replica_layer_) 847 if (replica_layer_) {
848 if (replica_layer_->mask_layer())
849 replica_layer_->SetMaskLayer(nullptr);
855 ret = layer_tree_impl_->RemoveLayer(replica_layer_->id()); 850 ret = layer_tree_impl_->RemoveLayer(replica_layer_->id());
851 }
856 replica_layer_ = nullptr; 852 replica_layer_ = nullptr;
857 return ret; 853 return ret;
858 } 854 }
859 855
860 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() { 856 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() {
861 return nullptr; 857 return nullptr;
862 } 858 }
863 859
864 void LayerImpl::SetDrawsContent(bool draws_content) { 860 void LayerImpl::SetDrawsContent(bool draws_content) {
865 if (draws_content_ == draws_content) 861 if (draws_content_ == draws_content)
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 .layer_transforms_should_scale_layer_contents) { 1357 .layer_transforms_should_scale_layer_contents) {
1362 return default_scale; 1358 return default_scale;
1363 } 1359 }
1364 1360
1365 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1361 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1366 ScreenSpaceTransform(), default_scale); 1362 ScreenSpaceTransform(), default_scale);
1367 return std::max(transform_scales.x(), transform_scales.y()); 1363 return std::max(transform_scales.x(), transform_scales.y());
1368 } 1364 }
1369 1365
1370 } // namespace cc 1366 } // 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