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