| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_test_properties.h" | 5 #include "cc/layers/layer_impl_test_properties.h" |
| 6 | 6 |
| 7 #include "cc/layers/layer_impl.h" | 7 #include "cc/layers/layer_impl.h" |
| 8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
| 9 #include "cc/trees/layer_tree_impl.h" | 9 #include "cc/trees/layer_tree_impl.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 LayerImplTestProperties::LayerImplTestProperties(LayerImpl* owning_layer) | 13 LayerImplTestProperties::LayerImplTestProperties(LayerImpl* owning_layer) |
| 14 : owning_layer(owning_layer), | 14 : owning_layer(owning_layer), |
| 15 double_sided(true), | 15 double_sided(true), |
| 16 force_render_surface(false), | 16 force_render_surface(false), |
| 17 is_container_for_fixed_position_layers(false), | 17 is_container_for_fixed_position_layers(false), |
| 18 should_flatten_transform(true), | 18 should_flatten_transform(true), |
| 19 hide_layer_and_subtree(false), | 19 hide_layer_and_subtree(false), |
| 20 opacity_can_animate(false), | 20 opacity_can_animate(false), |
| 21 subtree_has_copy_request(false), | 21 subtree_has_copy_request(false), |
| 22 sorting_context_id(0), | 22 sorting_context_id(0), |
| 23 opacity(1.f), | 23 opacity(1.f), |
| 24 blend_mode(SkBlendMode::kSrcOver), | 24 blend_mode(SkBlendMode::kSrcOver), |
| 25 scroll_parent(nullptr), | 25 scroll_parent(nullptr), |
| 26 clip_parent(nullptr), | 26 clip_parent(nullptr), |
| 27 mask_layer(nullptr), | 27 mask_layer(nullptr), |
| 28 parent(nullptr) {} | 28 parent(nullptr), |
| 29 scroll_boundary_behavior(ScrollBoundaryBehavior()) {} |
| 29 | 30 |
| 30 LayerImplTestProperties::~LayerImplTestProperties() {} | 31 LayerImplTestProperties::~LayerImplTestProperties() {} |
| 31 | 32 |
| 32 void LayerImplTestProperties::AddChild(std::unique_ptr<LayerImpl> child) { | 33 void LayerImplTestProperties::AddChild(std::unique_ptr<LayerImpl> child) { |
| 33 child->test_properties()->parent = owning_layer; | 34 child->test_properties()->parent = owning_layer; |
| 34 children.push_back(child.get()); | 35 children.push_back(child.get()); |
| 35 owning_layer->layer_tree_impl()->AddLayer(std::move(child)); | 36 owning_layer->layer_tree_impl()->AddLayer(std::move(child)); |
| 36 owning_layer->layer_tree_impl()->BuildLayerListForTesting(); | 37 owning_layer->layer_tree_impl()->BuildLayerListForTesting(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 std::unique_ptr<LayerImpl> LayerImplTestProperties::RemoveChild( | 40 std::unique_ptr<LayerImpl> LayerImplTestProperties::RemoveChild( |
| 40 LayerImpl* child) { | 41 LayerImpl* child) { |
| 41 auto it = std::find(children.begin(), children.end(), child); | 42 auto it = std::find(children.begin(), children.end(), child); |
| 42 if (it != children.end()) | 43 if (it != children.end()) |
| 43 children.erase(it); | 44 children.erase(it); |
| 44 auto layer = owning_layer->layer_tree_impl()->RemoveLayer(child->id()); | 45 auto layer = owning_layer->layer_tree_impl()->RemoveLayer(child->id()); |
| 45 owning_layer->layer_tree_impl()->BuildLayerListForTesting(); | 46 owning_layer->layer_tree_impl()->BuildLayerListForTesting(); |
| 46 return layer; | 47 return layer; |
| 47 } | 48 } |
| 48 | 49 |
| 49 void LayerImplTestProperties::SetMaskLayer(std::unique_ptr<LayerImpl> mask) { | 50 void LayerImplTestProperties::SetMaskLayer(std::unique_ptr<LayerImpl> mask) { |
| 50 if (mask_layer) | 51 if (mask_layer) |
| 51 owning_layer->layer_tree_impl()->RemoveLayer(mask_layer->id()); | 52 owning_layer->layer_tree_impl()->RemoveLayer(mask_layer->id()); |
| 52 mask_layer = mask.get(); | 53 mask_layer = mask.get(); |
| 53 if (mask) | 54 if (mask) |
| 54 owning_layer->layer_tree_impl()->AddLayer(std::move(mask)); | 55 owning_layer->layer_tree_impl()->AddLayer(std::move(mask)); |
| 55 } | 56 } |
| 56 | 57 |
| 57 } // namespace cc | 58 } // namespace cc |
| OLD | NEW |