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/location.h" | 10 #include "base/location.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 namespace cc { | 33 namespace cc { |
34 | 34 |
35 base::StaticAtomicSequenceNumber g_next_layer_id; | 35 base::StaticAtomicSequenceNumber g_next_layer_id; |
36 | 36 |
37 scoped_refptr<Layer> Layer::Create(const LayerSettings& settings) { | 37 scoped_refptr<Layer> Layer::Create(const LayerSettings& settings) { |
38 return make_scoped_refptr(new Layer(settings)); | 38 return make_scoped_refptr(new Layer(settings)); |
39 } | 39 } |
40 | 40 |
41 Layer::Layer(const LayerSettings& settings) | 41 Layer::Layer(const LayerSettings& settings) |
42 : needs_push_properties_(false), | 42 : needs_push_properties_(false), |
43 num_dependents_need_push_properties_(false), | 43 num_dependents_need_push_properties_(0u), |
44 stacking_order_changed_(false), | 44 stacking_order_changed_(false), |
45 // Layer IDs start from 1. | 45 // Layer IDs start from 1. |
46 layer_id_(g_next_layer_id.GetNext() + 1), | 46 layer_id_(g_next_layer_id.GetNext() + 1), |
47 ignore_set_needs_commit_(false), | 47 ignore_set_needs_commit_(false), |
48 sorting_context_id_(0), | 48 sorting_context_id_(0), |
49 parent_(nullptr), | 49 parent_(nullptr), |
50 layer_tree_host_(nullptr), | 50 layer_tree_host_(nullptr), |
51 scroll_clip_layer_id_(INVALID_ID), | 51 scroll_clip_layer_id_(INVALID_ID), |
52 num_descendants_that_draw_content_(0), | 52 num_descendants_that_draw_content_(0), |
53 transform_tree_index_(-1), | 53 transform_tree_index_(-1), |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 202 |
203 void Layer::SetNeedsPushProperties() { | 203 void Layer::SetNeedsPushProperties() { |
204 if (needs_push_properties_) | 204 if (needs_push_properties_) |
205 return; | 205 return; |
206 if (!parent_should_know_need_push_properties() && parent_) | 206 if (!parent_should_know_need_push_properties() && parent_) |
207 parent_->AddDependentNeedsPushProperties(); | 207 parent_->AddDependentNeedsPushProperties(); |
208 needs_push_properties_ = true; | 208 needs_push_properties_ = true; |
209 } | 209 } |
210 | 210 |
211 void Layer::AddDependentNeedsPushProperties() { | 211 void Layer::AddDependentNeedsPushProperties() { |
212 DCHECK_GE(num_dependents_need_push_properties_, 0); | |
213 | |
214 if (!parent_should_know_need_push_properties() && parent_) | 212 if (!parent_should_know_need_push_properties() && parent_) |
215 parent_->AddDependentNeedsPushProperties(); | 213 parent_->AddDependentNeedsPushProperties(); |
216 | 214 |
217 num_dependents_need_push_properties_++; | 215 num_dependents_need_push_properties_++; |
218 } | 216 } |
219 | 217 |
220 void Layer::RemoveDependentNeedsPushProperties() { | 218 void Layer::RemoveDependentNeedsPushProperties() { |
| 219 DCHECK_GT(num_dependents_need_push_properties_, 0u); |
221 num_dependents_need_push_properties_--; | 220 num_dependents_need_push_properties_--; |
222 DCHECK_GE(num_dependents_need_push_properties_, 0); | |
223 | 221 |
224 if (!parent_should_know_need_push_properties() && parent_) | 222 if (!parent_should_know_need_push_properties() && parent_) |
225 parent_->RemoveDependentNeedsPushProperties(); | 223 parent_->RemoveDependentNeedsPushProperties(); |
226 } | 224 } |
227 | 225 |
228 bool Layer::IsPropertyChangeAllowed() const { | 226 bool Layer::IsPropertyChangeAllowed() const { |
229 if (!layer_tree_host_) | 227 if (!layer_tree_host_) |
230 return true; | 228 return true; |
231 | 229 |
232 if (!layer_tree_host_->settings().strict_layer_property_change_checking) | 230 if (!layer_tree_host_->settings().strict_layer_property_change_checking) |
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 ? layer_tree_host()->meta_information_sequence_number() | 1645 ? layer_tree_host()->meta_information_sequence_number() |
1648 : 0; | 1646 : 0; |
1649 } | 1647 } |
1650 | 1648 |
1651 bool Layer::sorted_for_recursion() { | 1649 bool Layer::sorted_for_recursion() { |
1652 return sorted_for_recursion_tracker_ == | 1650 return sorted_for_recursion_tracker_ == |
1653 layer_tree_host()->meta_information_sequence_number(); | 1651 layer_tree_host()->meta_information_sequence_number(); |
1654 } | 1652 } |
1655 | 1653 |
1656 } // namespace cc | 1654 } // namespace cc |
OLD | NEW |