OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
10 #include "cc/animation/scrollbar_animation_controller.h" | 10 #include "cc/animation/scrollbar_animation_controller.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 contents_opaque_(false), | 48 contents_opaque_(false), |
49 opacity_(1.0), | 49 opacity_(1.0), |
50 preserves_3d_(false), | 50 preserves_3d_(false), |
51 use_parent_backface_visibility_(false), | 51 use_parent_backface_visibility_(false), |
52 draw_checkerboard_for_missing_tiles_(false), | 52 draw_checkerboard_for_missing_tiles_(false), |
53 draws_content_(false), | 53 draws_content_(false), |
54 force_render_surface_(false), | 54 force_render_surface_(false), |
55 is_container_for_fixed_position_layers_(false), | 55 is_container_for_fixed_position_layers_(false), |
56 draw_depth_(0.f), | 56 draw_depth_(0.f), |
57 compositing_reasons_(kCompositingReasonUnknown), | 57 compositing_reasons_(kCompositingReasonUnknown), |
58 #ifndef NDEBUG | 58 current_draw_mode_(DRAW_MODE_NONE), |
59 between_will_draw_and_did_draw_(false), | |
60 #endif | |
61 horizontal_scrollbar_layer_(NULL), | 59 horizontal_scrollbar_layer_(NULL), |
62 vertical_scrollbar_layer_(NULL) { | 60 vertical_scrollbar_layer_(NULL) { |
63 DCHECK_GT(layer_id_, 0); | 61 DCHECK_GT(layer_id_, 0); |
64 DCHECK(layer_tree_impl_); | 62 DCHECK(layer_tree_impl_); |
65 layer_tree_impl_->RegisterLayer(this); | 63 layer_tree_impl_->RegisterLayer(this); |
66 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); | 64 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); |
67 layer_animation_controller_ = | 65 layer_animation_controller_ = |
68 registrar->GetAnimationControllerForId(layer_id_); | 66 registrar->GetAnimationControllerForId(layer_id_); |
69 layer_animation_controller_->AddValueObserver(this); | 67 layer_animation_controller_->AddValueObserver(this); |
70 } | 68 } |
71 | 69 |
72 LayerImpl::~LayerImpl() { | 70 LayerImpl::~LayerImpl() { |
73 #ifndef NDEBUG | 71 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
74 DCHECK(!between_will_draw_and_did_draw_); | |
75 #endif | |
76 | 72 |
77 layer_tree_impl_->UnregisterLayer(this); | 73 layer_tree_impl_->UnregisterLayer(this); |
78 layer_animation_controller_->RemoveValueObserver(this); | 74 layer_animation_controller_->RemoveValueObserver(this); |
79 } | 75 } |
80 | 76 |
81 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { | 77 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { |
82 child->set_parent(this); | 78 child->set_parent(this); |
83 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); | 79 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); |
84 children_.push_back(child.Pass()); | 80 children_.push_back(child.Pass()); |
85 layer_tree_impl()->set_needs_update_draw_properties(); | 81 layer_tree_impl()->set_needs_update_draw_properties(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); | 136 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); |
141 state->SetAll(draw_properties_.target_space_transform, | 137 state->SetAll(draw_properties_.target_space_transform, |
142 draw_properties_.content_bounds, | 138 draw_properties_.content_bounds, |
143 draw_properties_.visible_content_rect, | 139 draw_properties_.visible_content_rect, |
144 draw_properties_.clip_rect, | 140 draw_properties_.clip_rect, |
145 draw_properties_.is_clipped, | 141 draw_properties_.is_clipped, |
146 draw_properties_.opacity); | 142 draw_properties_.opacity); |
147 return state.Pass(); | 143 return state.Pass(); |
148 } | 144 } |
149 | 145 |
150 void LayerImpl::WillDraw(ResourceProvider* resource_provider) { | 146 bool LayerImpl::WillDraw(DrawMode draw_mode, |
151 #ifndef NDEBUG | 147 ResourceProvider* resource_provider) { |
152 // WillDraw/DidDraw must be matched. | 148 // WillDraw/DidDraw must be matched. |
153 DCHECK(!between_will_draw_and_did_draw_); | 149 DCHECK_NE(DRAW_MODE_NONE, draw_mode); |
154 between_will_draw_and_did_draw_ = true; | 150 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
155 #endif | 151 current_draw_mode_ = draw_mode; |
| 152 return true; |
156 } | 153 } |
157 | 154 |
158 void LayerImpl::DidDraw(ResourceProvider* resource_provider) { | 155 void LayerImpl::DidDraw(ResourceProvider* resource_provider) { |
159 #ifndef NDEBUG | 156 DCHECK_NE(DRAW_MODE_NONE, current_draw_mode_); |
160 DCHECK(between_will_draw_and_did_draw_); | 157 current_draw_mode_ = DRAW_MODE_NONE; |
161 between_will_draw_and_did_draw_ = false; | |
162 #endif | |
163 } | 158 } |
164 | 159 |
165 bool LayerImpl::ShowDebugBorders() const { | 160 bool LayerImpl::ShowDebugBorders() const { |
166 return layer_tree_impl()->debug_state().show_debug_borders; | 161 return layer_tree_impl()->debug_state().show_debug_borders; |
167 } | 162 } |
168 | 163 |
169 void LayerImpl::GetDebugBorderProperties(SkColor* color, float* width) const { | 164 void LayerImpl::GetDebugBorderProperties(SkColor* color, float* width) const { |
170 if (draws_content_) { | 165 if (draws_content_) { |
171 *color = DebugColors::ContentLayerBorderColor(); | 166 *color = DebugColors::ContentLayerBorderColor(); |
172 *width = DebugColors::ContentLayerBorderWidth(layer_tree_impl()); | 167 *width = DebugColors::ContentLayerBorderWidth(layer_tree_impl()); |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 | 1147 |
1153 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1148 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
1154 | 1149 |
1155 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1150 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
1156 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1151 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1157 AsValueInto(state.get()); | 1152 AsValueInto(state.get()); |
1158 return state.PassAs<base::Value>(); | 1153 return state.PassAs<base::Value>(); |
1159 } | 1154 } |
1160 | 1155 |
1161 } // namespace cc | 1156 } // namespace cc |
OLD | NEW |