OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // Our parent should be holding a reference to us so there should be no | 83 // Our parent should be holding a reference to us so there should be no |
84 // way for us to be destroyed while we still have a parent. | 84 // way for us to be destroyed while we still have a parent. |
85 DCHECK(!parent()); | 85 DCHECK(!parent()); |
86 // Similarly we shouldn't have a layer tree host since it also keeps a | 86 // Similarly we shouldn't have a layer tree host since it also keeps a |
87 // reference to us. | 87 // reference to us. |
88 DCHECK(!layer_tree_host()); | 88 DCHECK(!layer_tree_host()); |
89 | 89 |
90 layer_animation_controller_->RemoveValueObserver(this); | 90 layer_animation_controller_->RemoveValueObserver(this); |
91 layer_animation_controller_->remove_value_provider(this); | 91 layer_animation_controller_->remove_value_provider(this); |
92 | 92 |
| 93 RemoveFromScrollTree(); |
| 94 RemoveFromClipTree(); |
| 95 |
93 // Remove the parent reference from all children and dependents. | 96 // Remove the parent reference from all children and dependents. |
94 RemoveAllChildren(); | 97 RemoveAllChildren(); |
95 if (mask_layer_.get()) { | 98 if (mask_layer_.get()) { |
96 DCHECK_EQ(this, mask_layer_->parent()); | 99 DCHECK_EQ(this, mask_layer_->parent()); |
97 mask_layer_->RemoveFromParent(); | 100 mask_layer_->RemoveFromParent(); |
98 } | 101 } |
99 if (replica_layer_.get()) { | 102 if (replica_layer_.get()) { |
100 DCHECK_EQ(this, replica_layer_->parent()); | 103 DCHECK_EQ(this, replica_layer_->parent()); |
101 replica_layer_->RemoveFromParent(); | 104 replica_layer_->RemoveFromParent(); |
102 } | 105 } |
103 | |
104 RemoveFromScrollTree(); | |
105 RemoveFromClipTree(); | |
106 } | 106 } |
107 | 107 |
108 void Layer::SetLayerTreeHost(LayerTreeHost* host) { | 108 void Layer::SetLayerTreeHost(LayerTreeHost* host) { |
109 if (layer_tree_host_ == host) | 109 if (layer_tree_host_ == host) |
110 return; | 110 return; |
111 | 111 |
112 layer_tree_host_ = host; | 112 layer_tree_host_ = host; |
113 | 113 |
114 // When changing hosts, the layer needs to commit its properties to the impl | 114 // When changing hosts, the layer needs to commit its properties to the impl |
115 // side for the new host. | 115 // side for the new host. |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 1192 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
1193 return layer_tree_host_->rendering_stats_instrumentation(); | 1193 return layer_tree_host_->rendering_stats_instrumentation(); |
1194 } | 1194 } |
1195 | 1195 |
1196 bool Layer::SupportsLCDText() const { | 1196 bool Layer::SupportsLCDText() const { |
1197 return false; | 1197 return false; |
1198 } | 1198 } |
1199 | 1199 |
1200 void Layer::RemoveFromScrollTree() { | 1200 void Layer::RemoveFromScrollTree() { |
1201 if (scroll_children_.get()) { | 1201 if (scroll_children_.get()) { |
1202 for (std::set<Layer*>::iterator it = scroll_children_->begin(); | 1202 std::set<Layer*> copy = *scroll_children_; |
1203 it != scroll_children_->end(); ++it) | 1203 for (std::set<Layer*>::iterator it = copy.begin(); it != copy.end(); ++it) |
1204 (*it)->scroll_parent_ = NULL; | 1204 (*it)->SetScrollParent(NULL); |
1205 } | 1205 } |
1206 | 1206 |
1207 if (scroll_parent_) | 1207 DCHECK(!scroll_children_); |
1208 scroll_parent_->RemoveScrollChild(this); | 1208 SetScrollParent(NULL); |
1209 | |
1210 scroll_parent_ = NULL; | |
1211 } | 1209 } |
1212 | 1210 |
1213 void Layer::RemoveFromClipTree() { | 1211 void Layer::RemoveFromClipTree() { |
1214 if (clip_children_.get()) { | 1212 if (clip_children_.get()) { |
1215 for (std::set<Layer*>::iterator it = clip_children_->begin(); | 1213 std::set<Layer*> copy = *clip_children_; |
1216 it != clip_children_->end(); ++it) | 1214 for (std::set<Layer*>::iterator it = copy.begin(); it != copy.end(); ++it) |
1217 (*it)->clip_parent_ = NULL; | 1215 (*it)->SetClipParent(NULL); |
1218 } | 1216 } |
1219 | 1217 |
1220 if (clip_parent_) | 1218 DCHECK(!clip_children_); |
1221 clip_parent_->RemoveClipChild(this); | 1219 SetClipParent(NULL); |
1222 | |
1223 clip_parent_ = NULL; | |
1224 } | 1220 } |
1225 | 1221 |
1226 void Layer::AddDrawableDescendants(int num) { | 1222 void Layer::AddDrawableDescendants(int num) { |
1227 DCHECK_GE(num_descendants_that_draw_content_, 0); | 1223 DCHECK_GE(num_descendants_that_draw_content_, 0); |
1228 DCHECK_GE(num_descendants_that_draw_content_ + num, 0); | 1224 DCHECK_GE(num_descendants_that_draw_content_ + num, 0); |
1229 if (num == 0) | 1225 if (num == 0) |
1230 return; | 1226 return; |
1231 num_descendants_that_draw_content_ += num; | 1227 num_descendants_that_draw_content_ += num; |
1232 SetNeedsCommit(); | 1228 SetNeedsCommit(); |
1233 if (parent()) | 1229 if (parent()) |
1234 parent()->AddDrawableDescendants(num); | 1230 parent()->AddDrawableDescendants(num); |
1235 } | 1231 } |
1236 | 1232 |
1237 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1233 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1238 benchmark->RunOnLayer(this); | 1234 benchmark->RunOnLayer(this); |
1239 } | 1235 } |
1240 | 1236 |
1241 bool Layer::HasDelegatedContent() const { | 1237 bool Layer::HasDelegatedContent() const { |
1242 return false; | 1238 return false; |
1243 } | 1239 } |
1244 | 1240 |
1245 } // namespace cc | 1241 } // namespace cc |
OLD | NEW |