| 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.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Serialize |src| to protobuf and read the first entry in the | 136 // Serialize |src| to protobuf and read the first entry in the |
| 137 // LayerUpdate. There are no descendants, so the serialization | 137 // LayerUpdate. There are no descendants, so the serialization |
| 138 // of |src| is the only entry. | 138 // of |src| is the only entry. |
| 139 proto::LayerUpdate layer_update; | 139 proto::LayerUpdate layer_update; |
| 140 src->ToLayerPropertiesProto(&layer_update); | 140 src->ToLayerPropertiesProto(&layer_update); |
| 141 ASSERT_EQ(1, layer_update.layers_size()); | 141 ASSERT_EQ(1, layer_update.layers_size()); |
| 142 proto::LayerProperties props = layer_update.layers(0); | 142 proto::LayerProperties props = layer_update.layers(0); |
| 143 | 143 |
| 144 // The |dest| layer needs to be able to lookup the scroll and clip parents. | 144 // The |dest| layer needs to be able to lookup the scroll and clip parents. |
| 145 if (src->inputs_.scroll_parent) | 145 if (src->inputs_.scroll_parent) |
| 146 layer_tree_host_->RegisterLayer(src->inputs_.scroll_parent); | 146 layer_tree_host_->GetLayerTree()->RegisterLayer( |
| 147 src->inputs_.scroll_parent); |
| 147 if (src->scroll_children_) { | 148 if (src->scroll_children_) { |
| 148 for (auto* child : *(src->scroll_children_)) | 149 for (auto* child : *(src->scroll_children_)) |
| 149 layer_tree_host_->RegisterLayer(child); | 150 layer_tree_host_->GetLayerTree()->RegisterLayer(child); |
| 150 } | 151 } |
| 151 if (src->inputs_.clip_parent) | 152 if (src->inputs_.clip_parent) |
| 152 layer_tree_host_->RegisterLayer(src->inputs_.clip_parent); | 153 layer_tree_host_->GetLayerTree()->RegisterLayer(src->inputs_.clip_parent); |
| 153 if (src->clip_children_) { | 154 if (src->clip_children_) { |
| 154 for (auto* child : *(src->clip_children_)) | 155 for (auto* child : *(src->clip_children_)) |
| 155 layer_tree_host_->RegisterLayer(child); | 156 layer_tree_host_->GetLayerTree()->RegisterLayer(child); |
| 156 } | 157 } |
| 157 // Reset the LayerTreeHost registration for the |src| layer so | 158 // Reset the LayerTreeHost registration for the |src| layer so |
| 158 // it can be re-used for the |dest| layer. | 159 // it can be re-used for the |dest| layer. |
| 159 src->SetLayerTreeHost(nullptr); | 160 src->SetLayerTreeHost(nullptr); |
| 160 | 161 |
| 161 scoped_refptr<Layer> dest = Layer::Create(); | 162 scoped_refptr<Layer> dest = Layer::Create(); |
| 162 dest->inputs_.layer_id = src->inputs_.layer_id; | 163 dest->inputs_.layer_id = src->inputs_.layer_id; |
| 163 dest->SetLayerTreeHost(layer_tree_host_.get()); | 164 dest->SetLayerTreeHost(layer_tree_host_.get()); |
| 164 dest->FromLayerPropertiesProto(props); | 165 dest->FromLayerPropertiesProto(props); |
| 165 | 166 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 244 } |
| 244 | 245 |
| 245 // The following member should have been reset during serialization. | 246 // The following member should have been reset during serialization. |
| 246 EXPECT_EQ(gfx::Rect(), src->inputs_.update_rect); | 247 EXPECT_EQ(gfx::Rect(), src->inputs_.update_rect); |
| 247 | 248 |
| 248 // Before deleting |dest|, the LayerTreeHost must be unset. | 249 // Before deleting |dest|, the LayerTreeHost must be unset. |
| 249 dest->SetLayerTreeHost(nullptr); | 250 dest->SetLayerTreeHost(nullptr); |
| 250 | 251 |
| 251 // Cleanup scroll tree. | 252 // Cleanup scroll tree. |
| 252 if (src->inputs_.scroll_parent) | 253 if (src->inputs_.scroll_parent) |
| 253 layer_tree_host_->UnregisterLayer(src->inputs_.scroll_parent); | 254 layer_tree_host_->GetLayerTree()->UnregisterLayer( |
| 255 src->inputs_.scroll_parent); |
| 254 src->inputs_.scroll_parent = nullptr; | 256 src->inputs_.scroll_parent = nullptr; |
| 255 dest->inputs_.scroll_parent = nullptr; | 257 dest->inputs_.scroll_parent = nullptr; |
| 256 if (src->scroll_children_) { | 258 if (src->scroll_children_) { |
| 257 for (auto* child : *(src->scroll_children_)) | 259 for (auto* child : *(src->scroll_children_)) |
| 258 layer_tree_host_->UnregisterLayer(child); | 260 layer_tree_host_->GetLayerTree()->UnregisterLayer(child); |
| 259 src->scroll_children_.reset(); | 261 src->scroll_children_.reset(); |
| 260 dest->scroll_children_.reset(); | 262 dest->scroll_children_.reset(); |
| 261 } | 263 } |
| 262 | 264 |
| 263 // Cleanup clip tree. | 265 // Cleanup clip tree. |
| 264 if (src->inputs_.clip_parent) | 266 if (src->inputs_.clip_parent) |
| 265 layer_tree_host_->UnregisterLayer(src->inputs_.clip_parent); | 267 layer_tree_host_->GetLayerTree()->UnregisterLayer( |
| 268 src->inputs_.clip_parent); |
| 266 src->inputs_.clip_parent = nullptr; | 269 src->inputs_.clip_parent = nullptr; |
| 267 dest->inputs_.clip_parent = nullptr; | 270 dest->inputs_.clip_parent = nullptr; |
| 268 if (src->clip_children_) { | 271 if (src->clip_children_) { |
| 269 for (auto* child : *(src->clip_children_)) | 272 for (auto* child : *(src->clip_children_)) |
| 270 layer_tree_host_->UnregisterLayer(child); | 273 layer_tree_host_->GetLayerTree()->UnregisterLayer(child); |
| 271 src->clip_children_.reset(); | 274 src->clip_children_.reset(); |
| 272 dest->clip_children_.reset(); | 275 dest->clip_children_.reset(); |
| 273 } | 276 } |
| 274 } | 277 } |
| 275 | 278 |
| 276 void RunNoMembersChangedTest() { | 279 void RunNoMembersChangedTest() { |
| 277 scoped_refptr<Layer> layer = Layer::Create(); | 280 scoped_refptr<Layer> layer = Layer::Create(); |
| 278 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); | 281 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); |
| 279 } | 282 } |
| 280 | 283 |
| (...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2534 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2537 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 2535 | 2538 |
| 2536 test_layer->PushPropertiesTo(impl_layer.get()); | 2539 test_layer->PushPropertiesTo(impl_layer.get()); |
| 2537 | 2540 |
| 2538 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); | 2541 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); |
| 2539 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2542 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 2540 } | 2543 } |
| 2541 | 2544 |
| 2542 } // namespace | 2545 } // namespace |
| 2543 } // namespace cc | 2546 } // namespace cc |
| OLD | NEW |