| 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 "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { | 99 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { |
| 100 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); | 100 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); |
| 101 layer_animation_controller_ = | 101 layer_animation_controller_ = |
| 102 registrar->GetAnimationControllerForId(layer_id_); | 102 registrar->GetAnimationControllerForId(layer_id_); |
| 103 layer_animation_controller_->AddValueObserver(this); | 103 layer_animation_controller_->AddValueObserver(this); |
| 104 if (IsActive()) { | 104 if (IsActive()) { |
| 105 layer_animation_controller_->set_value_provider(this); | 105 layer_animation_controller_->set_value_provider(this); |
| 106 layer_animation_controller_->set_layer_animation_delegate(this); | 106 layer_animation_controller_->set_layer_animation_delegate(this); |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 |
| 110 if (element_id_) |
| 111 layer_tree_impl_->AddToElementMap(this); |
| 112 |
| 109 SetNeedsPushProperties(); | 113 SetNeedsPushProperties(); |
| 110 } | 114 } |
| 111 | 115 |
| 112 LayerImpl::~LayerImpl() { | 116 LayerImpl::~LayerImpl() { |
| 113 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); | 117 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
| 114 | 118 |
| 115 if (layer_animation_controller_) { | 119 if (layer_animation_controller_) { |
| 116 layer_animation_controller_->RemoveValueObserver(this); | 120 layer_animation_controller_->RemoveValueObserver(this); |
| 117 layer_animation_controller_->remove_value_provider(this); | 121 layer_animation_controller_->remove_value_provider(this); |
| 118 layer_animation_controller_->remove_layer_animation_delegate(this); | 122 layer_animation_controller_->remove_layer_animation_delegate(this); |
| 119 } | 123 } |
| 120 | 124 |
| 121 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) | 125 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) |
| 122 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); | 126 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); |
| 123 layer_tree_impl_->UnregisterScrollLayer(this); | 127 layer_tree_impl_->UnregisterScrollLayer(this); |
| 124 layer_tree_impl_->UnregisterLayer(this); | 128 layer_tree_impl_->UnregisterLayer(this); |
| 125 | 129 |
| 130 if (element_id_) |
| 131 layer_tree_impl_->RemoveFromElementMap(this); |
| 132 |
| 126 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 133 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 127 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); | 134 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); |
| 128 } | 135 } |
| 129 | 136 |
| 130 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { | 137 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { |
| 131 child->SetParent(this); | 138 child->SetParent(this); |
| 132 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); | 139 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); |
| 133 children_.push_back(child.Pass()); | 140 children_.push_back(child.Pass()); |
| 134 layer_tree_impl()->set_needs_update_draw_properties(); | 141 layer_tree_impl()->set_needs_update_draw_properties(); |
| 135 } | 142 } |
| (...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 return opacity_animation && opacity_animation->is_impl_only(); | 1219 return opacity_animation && opacity_animation->is_impl_only(); |
| 1213 } | 1220 } |
| 1214 | 1221 |
| 1215 void LayerImpl::SetElementId(uint64_t element_id) { | 1222 void LayerImpl::SetElementId(uint64_t element_id) { |
| 1216 if (element_id == element_id_) | 1223 if (element_id == element_id_) |
| 1217 return; | 1224 return; |
| 1218 | 1225 |
| 1219 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1226 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1220 "LayerImpl::SetElementId", "id", element_id); | 1227 "LayerImpl::SetElementId", "id", element_id); |
| 1221 | 1228 |
| 1229 if (element_id_) |
| 1230 layer_tree_impl_->RemoveFromElementMap(this); |
| 1222 element_id_ = element_id; | 1231 element_id_ = element_id; |
| 1232 if (element_id_) |
| 1233 layer_tree_impl_->AddToElementMap(this); |
| 1223 SetNeedsPushProperties(); | 1234 SetNeedsPushProperties(); |
| 1224 } | 1235 } |
| 1225 | 1236 |
| 1226 void LayerImpl::SetMutableProperties(uint32_t properties) { | 1237 void LayerImpl::SetMutableProperties(uint32_t properties) { |
| 1227 if (mutable_properties_ == properties) | 1238 if (mutable_properties_ == properties) |
| 1228 return; | 1239 return; |
| 1229 | 1240 |
| 1230 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1241 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1231 "LayerImpl::SetMutableProperties", "properties", properties); | 1242 "LayerImpl::SetMutableProperties", "properties", properties); |
| 1232 | 1243 |
| 1233 mutable_properties_ = properties; | 1244 mutable_properties_ = properties; |
| 1245 // If this layer is already in the element map, we will add it again in order |
| 1246 // to update the layer assignments per these new properties. |
| 1247 if (element_id_) |
| 1248 layer_tree_impl_->AddToElementMap(this); |
| 1234 SetNeedsPushProperties(); | 1249 SetNeedsPushProperties(); |
| 1235 } | 1250 } |
| 1236 | 1251 |
| 1237 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { | 1252 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { |
| 1238 if (blend_mode_ == blend_mode) | 1253 if (blend_mode_ == blend_mode) |
| 1239 return; | 1254 return; |
| 1240 | 1255 |
| 1241 blend_mode_ = blend_mode; | 1256 blend_mode_ = blend_mode; |
| 1242 NoteLayerPropertyChangedForSubtree(); | 1257 NoteLayerPropertyChangedForSubtree(); |
| 1243 } | 1258 } |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1830 } | 1845 } |
| 1831 | 1846 |
| 1832 // TODO(enne): the transform needs to come from property trees instead of | 1847 // TODO(enne): the transform needs to come from property trees instead of |
| 1833 // draw properties. | 1848 // draw properties. |
| 1834 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1849 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1835 draw_properties().target_space_transform, default_scale); | 1850 draw_properties().target_space_transform, default_scale); |
| 1836 return std::max(transform_scales.x(), transform_scales.y()); | 1851 return std::max(transform_scales.x(), transform_scales.y()); |
| 1837 } | 1852 } |
| 1838 | 1853 |
| 1839 } // namespace cc | 1854 } // namespace cc |
| OLD | NEW |