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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { | 102 if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { |
103 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); | 103 AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); |
104 layer_animation_controller_ = | 104 layer_animation_controller_ = |
105 registrar->GetAnimationControllerForId(layer_id_); | 105 registrar->GetAnimationControllerForId(layer_id_); |
106 layer_animation_controller_->AddValueObserver(this); | 106 layer_animation_controller_->AddValueObserver(this); |
107 if (IsActive()) { | 107 if (IsActive()) { |
108 layer_animation_controller_->set_value_provider(this); | 108 layer_animation_controller_->set_value_provider(this); |
109 layer_animation_controller_->set_layer_animation_delegate(this); | 109 layer_animation_controller_->set_layer_animation_delegate(this); |
110 } | 110 } |
111 } | 111 } |
| 112 |
| 113 if (element_id_) |
| 114 layer_tree_impl_->AddToElementMap(this); |
| 115 |
112 SetNeedsPushProperties(); | 116 SetNeedsPushProperties(); |
113 } | 117 } |
114 | 118 |
115 LayerImpl::~LayerImpl() { | 119 LayerImpl::~LayerImpl() { |
116 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); | 120 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
117 | 121 |
118 if (layer_animation_controller_) { | 122 if (layer_animation_controller_) { |
119 layer_animation_controller_->RemoveValueObserver(this); | 123 layer_animation_controller_->RemoveValueObserver(this); |
120 layer_animation_controller_->remove_value_provider(this); | 124 layer_animation_controller_->remove_value_provider(this); |
121 layer_animation_controller_->remove_layer_animation_delegate(this); | 125 layer_animation_controller_->remove_layer_animation_delegate(this); |
122 } | 126 } |
123 | 127 |
124 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) | 128 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) |
125 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); | 129 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); |
126 layer_tree_impl_->UnregisterScrollLayer(this); | 130 layer_tree_impl_->UnregisterScrollLayer(this); |
127 layer_tree_impl_->UnregisterLayer(this); | 131 layer_tree_impl_->UnregisterLayer(this); |
128 | 132 |
| 133 if (element_id_) |
| 134 layer_tree_impl_->RemoveFromElementMap(this); |
| 135 |
129 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 136 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
130 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); | 137 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); |
131 } | 138 } |
132 | 139 |
133 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { | 140 void LayerImpl::AddChild(scoped_ptr<LayerImpl> child) { |
134 child->SetParent(this); | 141 child->SetParent(this); |
135 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); | 142 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); |
136 children_.push_back(std::move(child)); | 143 children_.push_back(std::move(child)); |
137 layer_tree_impl()->set_needs_update_draw_properties(); | 144 layer_tree_impl()->set_needs_update_draw_properties(); |
138 } | 145 } |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 return opacity_animation && opacity_animation->is_impl_only(); | 1235 return opacity_animation && opacity_animation->is_impl_only(); |
1229 } | 1236 } |
1230 | 1237 |
1231 void LayerImpl::SetElementId(uint64_t element_id) { | 1238 void LayerImpl::SetElementId(uint64_t element_id) { |
1232 if (element_id == element_id_) | 1239 if (element_id == element_id_) |
1233 return; | 1240 return; |
1234 | 1241 |
1235 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1242 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
1236 "LayerImpl::SetElementId", "id", element_id); | 1243 "LayerImpl::SetElementId", "id", element_id); |
1237 | 1244 |
| 1245 if (element_id_) |
| 1246 layer_tree_impl_->RemoveFromElementMap(this); |
1238 element_id_ = element_id; | 1247 element_id_ = element_id; |
| 1248 if (element_id_) |
| 1249 layer_tree_impl_->AddToElementMap(this); |
1239 SetNeedsPushProperties(); | 1250 SetNeedsPushProperties(); |
1240 } | 1251 } |
1241 | 1252 |
1242 void LayerImpl::SetMutableProperties(uint32_t properties) { | 1253 void LayerImpl::SetMutableProperties(uint32_t properties) { |
1243 if (mutable_properties_ == properties) | 1254 if (mutable_properties_ == properties) |
1244 return; | 1255 return; |
1245 | 1256 |
1246 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1257 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
1247 "LayerImpl::SetMutableProperties", "properties", properties); | 1258 "LayerImpl::SetMutableProperties", "properties", properties); |
1248 | 1259 |
1249 mutable_properties_ = properties; | 1260 mutable_properties_ = properties; |
| 1261 // If this layer is already in the element map, update its properties. |
| 1262 if (element_id_) |
| 1263 layer_tree_impl_->AddToElementMap(this); |
1250 SetNeedsPushProperties(); | 1264 SetNeedsPushProperties(); |
1251 } | 1265 } |
1252 | 1266 |
1253 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { | 1267 void LayerImpl::SetBlendMode(SkXfermode::Mode blend_mode) { |
1254 if (blend_mode_ == blend_mode) | 1268 if (blend_mode_ == blend_mode) |
1255 return; | 1269 return; |
1256 | 1270 |
1257 blend_mode_ = blend_mode; | 1271 blend_mode_ = blend_mode; |
1258 NoteLayerPropertyChangedForSubtree(); | 1272 NoteLayerPropertyChangedForSubtree(); |
1259 } | 1273 } |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 .layer_transforms_should_scale_layer_contents) { | 1899 .layer_transforms_should_scale_layer_contents) { |
1886 return default_scale; | 1900 return default_scale; |
1887 } | 1901 } |
1888 | 1902 |
1889 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1903 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1890 DrawTransform(), default_scale); | 1904 DrawTransform(), default_scale); |
1891 return std::max(transform_scales.x(), transform_scales.y()); | 1905 return std::max(transform_scales.x(), transform_scales.y()); |
1892 } | 1906 } |
1893 | 1907 |
1894 } // namespace cc | 1908 } // namespace cc |
OLD | NEW |