OLD | NEW |
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 <utility> | 10 #include <utility> |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { | 108 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { |
109 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); | 109 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); |
110 layer_animation_controller_ = | 110 layer_animation_controller_ = |
111 registrar->GetAnimationControllerForId(layer_id_); | 111 registrar->GetAnimationControllerForId(layer_id_); |
112 layer_animation_controller_->AddValueObserver(this); | 112 layer_animation_controller_->AddValueObserver(this); |
113 if (IsActive()) { | 113 if (IsActive()) { |
114 layer_animation_controller_->set_value_provider(this); | 114 layer_animation_controller_->set_value_provider(this); |
115 layer_animation_controller_->set_layer_animation_delegate(this); | 115 layer_animation_controller_->set_layer_animation_delegate(this); |
116 } | 116 } |
117 } | 117 } |
| 118 |
| 119 layer_tree_impl_->AddToElementMap(this); |
| 120 |
118 SetNeedsPushProperties(); | 121 SetNeedsPushProperties(); |
119 } | 122 } |
120 | 123 |
121 LayerImpl::~LayerImpl() { | 124 LayerImpl::~LayerImpl() { |
122 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); | 125 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
123 | 126 |
124 if (layer_animation_controller_) { | 127 if (layer_animation_controller_) { |
125 layer_animation_controller_->RemoveValueObserver(this); | 128 layer_animation_controller_->RemoveValueObserver(this); |
126 layer_animation_controller_->remove_value_provider(this); | 129 layer_animation_controller_->remove_value_provider(this); |
127 layer_animation_controller_->remove_layer_animation_delegate(this); | 130 layer_animation_controller_->remove_layer_animation_delegate(this); |
128 } | 131 } |
129 | 132 |
130 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) | 133 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) |
131 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); | 134 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); |
132 layer_tree_impl_->UnregisterScrollLayer(this); | 135 layer_tree_impl_->UnregisterScrollLayer(this); |
133 layer_tree_impl_->UnregisterLayer(this); | 136 layer_tree_impl_->UnregisterLayer(this); |
134 | 137 |
| 138 layer_tree_impl_->RemoveFromElementMap(this); |
| 139 |
135 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 140 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
136 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); | 141 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); |
137 } | 142 } |
138 | 143 |
139 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { | 144 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { |
140 child->SetParent(this); | 145 child->SetParent(this); |
141 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); | 146 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); |
142 children_.push_back(std::move(child)); | 147 children_.push_back(std::move(child)); |
143 layer_tree_impl()->set_needs_update_draw_properties(); | 148 layer_tree_impl()->set_needs_update_draw_properties(); |
144 } | 149 } |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 return opacity_animation && opacity_animation->is_impl_only(); | 1247 return opacity_animation && opacity_animation->is_impl_only(); |
1243 } | 1248 } |
1244 | 1249 |
1245 void LayerImpl::SetElementId(uint64_t element_id) { | 1250 void LayerImpl::SetElementId(uint64_t element_id) { |
1246 if (element_id == element_id_) | 1251 if (element_id == element_id_) |
1247 return; | 1252 return; |
1248 | 1253 |
1249 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1254 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
1250 "LayerImpl::SetElementId", "id", element_id); | 1255 "LayerImpl::SetElementId", "id", element_id); |
1251 | 1256 |
| 1257 layer_tree_impl_->RemoveFromElementMap(this); |
1252 element_id_ = element_id; | 1258 element_id_ = element_id; |
| 1259 layer_tree_impl_->AddToElementMap(this); |
1253 SetNeedsPushProperties(); | 1260 SetNeedsPushProperties(); |
1254 } | 1261 } |
1255 | 1262 |
1256 void LayerImpl::SetMutableProperties(uint32_t properties) { | 1263 void LayerImpl::SetMutableProperties(uint32_t properties) { |
1257 if (mutable_properties_ == properties) | 1264 if (mutable_properties_ == properties) |
1258 return; | 1265 return; |
1259 | 1266 |
1260 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1267 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
1261 "LayerImpl::SetMutableProperties", "properties", properties); | 1268 "LayerImpl::SetMutableProperties", "properties", properties); |
1262 | 1269 |
1263 mutable_properties_ = properties; | 1270 mutable_properties_ = properties; |
| 1271 // If this layer is already in the element map, update its properties. |
| 1272 layer_tree_impl_->AddToElementMap(this); |
1264 SetNeedsPushProperties(); | 1273 SetNeedsPushProperties(); |
1265 } | 1274 } |
1266 | 1275 |
1267 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { | 1276 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { |
1268 if (blend_mode_ == blend_mode) | 1277 if (blend_mode_ == blend_mode) |
1269 return; | 1278 return; |
1270 | 1279 |
1271 blend_mode_ = blend_mode; | 1280 blend_mode_ = blend_mode; |
1272 NoteLayerPropertyChangedForSubtree(); | 1281 NoteLayerPropertyChangedForSubtree(); |
1273 } | 1282 } |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 .layer_transforms_should_scale_layer_contents) { | 1913 .layer_transforms_should_scale_layer_contents) { |
1905 return default_scale; | 1914 return default_scale; |
1906 } | 1915 } |
1907 | 1916 |
1908 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1917 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1909 DrawTransform(), default_scale); | 1918 DrawTransform(), default_scale); |
1910 return std::max(transform_scales.x(), transform_scales.y()); | 1919 return std::max(transform_scales.x(), transform_scales.y()); |
1911 } | 1920 } |
1912 | 1921 |
1913 } // namespace cc | 1922 } // namespace cc |
OLD | NEW |