| 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 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 return opacity_animation && opacity_animation->is_impl_only(); | 1240 return opacity_animation && opacity_animation->is_impl_only(); |
| 1236 } | 1241 } |
| 1237 | 1242 |
| 1238 void LayerImpl::SetElementId(uint64_t element_id) { | 1243 void LayerImpl::SetElementId(uint64_t element_id) { |
| 1239 if (element_id == element_id_) | 1244 if (element_id == element_id_) |
| 1240 return; | 1245 return; |
| 1241 | 1246 |
| 1242 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1247 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1243 "LayerImpl::SetElementId", "id", element_id); | 1248 "LayerImpl::SetElementId", "id", element_id); |
| 1244 | 1249 |
| 1250 layer_tree_impl_->RemoveFromElementMap(this); |
| 1245 element_id_ = element_id; | 1251 element_id_ = element_id; |
| 1252 layer_tree_impl_->AddToElementMap(this); |
| 1246 SetNeedsPushProperties(); | 1253 SetNeedsPushProperties(); |
| 1247 } | 1254 } |
| 1248 | 1255 |
| 1249 void LayerImpl::SetMutableProperties(uint32_t properties) { | 1256 void LayerImpl::SetMutableProperties(uint32_t properties) { |
| 1250 if (mutable_properties_ == properties) | 1257 if (mutable_properties_ == properties) |
| 1251 return; | 1258 return; |
| 1252 | 1259 |
| 1253 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1260 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1254 "LayerImpl::SetMutableProperties", "properties", properties); | 1261 "LayerImpl::SetMutableProperties", "properties", properties); |
| 1255 | 1262 |
| 1256 mutable_properties_ = properties; | 1263 mutable_properties_ = properties; |
| 1264 // If this layer is already in the element map, update its properties. |
| 1265 layer_tree_impl_->AddToElementMap(this); |
| 1257 SetNeedsPushProperties(); | 1266 SetNeedsPushProperties(); |
| 1258 } | 1267 } |
| 1259 | 1268 |
| 1260 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { | 1269 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { |
| 1261 if (blend_mode_ == blend_mode) | 1270 if (blend_mode_ == blend_mode) |
| 1262 return; | 1271 return; |
| 1263 | 1272 |
| 1264 blend_mode_ = blend_mode; | 1273 blend_mode_ = blend_mode; |
| 1265 NoteLayerPropertyChangedForSubtree(); | 1274 NoteLayerPropertyChangedForSubtree(); |
| 1266 } | 1275 } |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 .layer_transforms_should_scale_layer_contents) { | 1909 .layer_transforms_should_scale_layer_contents) { |
| 1901 return default_scale; | 1910 return default_scale; |
| 1902 } | 1911 } |
| 1903 | 1912 |
| 1904 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1913 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1905 DrawTransform(), default_scale); | 1914 DrawTransform(), default_scale); |
| 1906 return std::max(transform_scales.x(), transform_scales.y()); | 1915 return std::max(transform_scales.x(), transform_scales.y()); |
| 1907 } | 1916 } |
| 1908 | 1917 |
| 1909 } // namespace cc | 1918 } // namespace cc |
| OLD | NEW |