| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 src->SetLayerTreeHost(layer_tree_host_.get()); | 110 src->SetLayerTreeHost(layer_tree_host_.get()); |
| 111 | 111 |
| 112 // The following member is reset during serialization, so store the original | 112 // The following member is reset during serialization, so store the original |
| 113 // values. | 113 // values. |
| 114 gfx::Rect update_rect = src->inputs_.update_rect; | 114 gfx::Rect update_rect = src->inputs_.update_rect; |
| 115 | 115 |
| 116 // Serialize |src| to protobuf and read the first entry in the | 116 // Serialize |src| to protobuf and read the first entry in the |
| 117 // LayerUpdate. There are no descendants, so the serialization | 117 // LayerUpdate. There are no descendants, so the serialization |
| 118 // of |src| is the only entry. | 118 // of |src| is the only entry. |
| 119 proto::LayerUpdate layer_update; | 119 proto::LayerUpdate layer_update; |
| 120 src->ToLayerPropertiesProto(&layer_update); | 120 src->ToLayerPropertiesProto(&layer_update, false); |
| 121 ASSERT_EQ(1, layer_update.layers_size()); | 121 ASSERT_EQ(1, layer_update.layers_size()); |
| 122 proto::LayerProperties props = layer_update.layers(0); | 122 proto::LayerProperties props = layer_update.layers(0); |
| 123 | 123 |
| 124 // The |dest| layer needs to be able to lookup the scroll and clip parents. | 124 // The |dest| layer needs to be able to lookup the scroll and clip parents. |
| 125 LayerTree* layer_tree = layer_tree_host_->GetLayerTree(); | 125 LayerTree* layer_tree = layer_tree_host_->GetLayerTree(); |
| 126 if (src->inputs_.scroll_parent) | 126 if (src->inputs_.scroll_parent) |
| 127 layer_tree->RegisterLayer(src->inputs_.scroll_parent); | 127 layer_tree->RegisterLayer(src->inputs_.scroll_parent); |
| 128 if (src->scroll_children_) { | 128 if (src->scroll_children_) { |
| 129 for (auto* child : *(src->scroll_children_)) | 129 for (auto* child : *(src->scroll_children_)) |
| 130 layer_tree->RegisterLayer(child); | 130 layer_tree->RegisterLayer(child); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 !layer->inputs_.user_scrollable_vertical; | 354 !layer->inputs_.user_scrollable_vertical; |
| 355 layer->inputs_.scroll_offset = gfx::ScrollOffset(3, 14); | 355 layer->inputs_.scroll_offset = gfx::ScrollOffset(3, 14); |
| 356 layer->inputs_.update_rect = gfx::Rect(14, 15); | 356 layer->inputs_.update_rect = gfx::Rect(14, 15); |
| 357 | 357 |
| 358 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); | 358 VerifyBaseLayerPropertiesSerializationAndDeserialization(layer.get()); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization( | 361 void VerifySolidColorScrollbarLayerAfterSerializationAndDeserialization( |
| 362 scoped_refptr<SolidColorScrollbarLayer> source_scrollbar) { | 362 scoped_refptr<SolidColorScrollbarLayer> source_scrollbar) { |
| 363 proto::LayerProperties serialized_scrollbar; | 363 proto::LayerProperties serialized_scrollbar; |
| 364 source_scrollbar->LayerSpecificPropertiesToProto(&serialized_scrollbar); | 364 source_scrollbar->LayerSpecificPropertiesToProto(&serialized_scrollbar, |
| 365 false); |
| 365 | 366 |
| 366 scoped_refptr<SolidColorScrollbarLayer> deserialized_scrollbar = | 367 scoped_refptr<SolidColorScrollbarLayer> deserialized_scrollbar = |
| 367 SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL, -1, | 368 SolidColorScrollbarLayer::Create(ScrollbarOrientation::HORIZONTAL, -1, |
| 368 -1, false, Layer::INVALID_ID); | 369 -1, false, Layer::INVALID_ID); |
| 369 deserialized_scrollbar->inputs_.layer_id = | 370 deserialized_scrollbar->inputs_.layer_id = |
| 370 source_scrollbar->inputs_.layer_id; | 371 source_scrollbar->inputs_.layer_id; |
| 371 | 372 |
| 372 // FromLayerSpecificPropertiesProto expects a non-null LayerTreeHost to be | 373 // FromLayerSpecificPropertiesProto expects a non-null LayerTreeHost to be |
| 373 // set. | 374 // set. |
| 374 deserialized_scrollbar->SetLayerTreeHost(layer_tree_host_.get()); | 375 deserialized_scrollbar->SetLayerTreeHost(layer_tree_host_.get()); |
| (...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2474 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2475 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 2475 | 2476 |
| 2476 test_layer->PushPropertiesTo(impl_layer.get()); | 2477 test_layer->PushPropertiesTo(impl_layer.get()); |
| 2477 | 2478 |
| 2478 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); | 2479 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); |
| 2479 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2480 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 2480 } | 2481 } |
| 2481 | 2482 |
| 2482 } // namespace | 2483 } // namespace |
| 2483 } // namespace cc | 2484 } // namespace cc |
| OLD | NEW |