| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 num_unclipped_descendants(0), | 22 num_unclipped_descendants(0), |
| 23 opacity(1.f), | 23 opacity(1.f), |
| 24 scroll_parent(nullptr), | 24 scroll_parent(nullptr), |
| 25 clip_parent(nullptr), | 25 clip_parent(nullptr), |
| 26 mask_layer(nullptr), | 26 mask_layer(nullptr), |
| 27 replica_layer(nullptr), | 27 replica_layer(nullptr), |
| 28 parent(nullptr) {} | 28 parent(nullptr) {} |
| 29 | 29 |
| 30 LayerImplTestProperties::~LayerImplTestProperties() {} | 30 LayerImplTestProperties::~LayerImplTestProperties() {} |
| 31 | 31 |
| 32 void LayerImplTestProperties::AddChild(std::unique_ptr<LayerImpl> child) { |
| 33 child->test_properties()->parent = owning_layer; |
| 34 children.push_back(child.get()); |
| 35 owning_layer->layer_tree_impl()->AddLayer(std::move(child)); |
| 36 } |
| 37 |
| 38 std::unique_ptr<LayerImpl> LayerImplTestProperties::RemoveChild( |
| 39 LayerImpl* child) { |
| 40 auto it = std::find(children.begin(), children.end(), child); |
| 41 if (it != children.end()) |
| 42 children.erase(it); |
| 43 owning_layer->layer_tree_impl()->property_trees()->RemoveIdFromIdToIndexMaps( |
| 44 child->id()); |
| 45 return owning_layer->layer_tree_impl()->RemoveLayer(child->id()); |
| 46 } |
| 47 |
| 32 void LayerImplTestProperties::SetMaskLayer(std::unique_ptr<LayerImpl> mask) { | 48 void LayerImplTestProperties::SetMaskLayer(std::unique_ptr<LayerImpl> mask) { |
| 33 if (mask_layer) | 49 if (mask_layer) |
| 34 owning_layer->layer_tree_impl()->RemoveLayer(mask_layer->id()); | 50 owning_layer->layer_tree_impl()->RemoveLayer(mask_layer->id()); |
| 35 mask_layer = mask.get(); | 51 mask_layer = mask.get(); |
| 36 if (mask) | 52 if (mask) |
| 37 owning_layer->layer_tree_impl()->AddLayer(std::move(mask)); | 53 owning_layer->layer_tree_impl()->AddLayer(std::move(mask)); |
| 38 } | 54 } |
| 39 | 55 |
| 40 void LayerImplTestProperties::SetReplicaLayer( | 56 void LayerImplTestProperties::SetReplicaLayer( |
| 41 std::unique_ptr<LayerImpl> replica) { | 57 std::unique_ptr<LayerImpl> replica) { |
| 42 if (replica_layer) { | 58 if (replica_layer) { |
| 43 replica_layer->test_properties()->SetMaskLayer(nullptr); | 59 replica_layer->test_properties()->SetMaskLayer(nullptr); |
| 44 owning_layer->layer_tree_impl()->RemoveLayer(replica_layer->id()); | 60 owning_layer->layer_tree_impl()->RemoveLayer(replica_layer->id()); |
| 45 } | 61 } |
| 46 replica_layer = replica.get(); | 62 replica_layer = replica.get(); |
| 47 if (replica) { | 63 if (replica) { |
| 48 replica->test_properties()->parent = owning_layer; | 64 replica->test_properties()->parent = owning_layer; |
| 49 owning_layer->layer_tree_impl()->AddLayer(std::move(replica)); | 65 owning_layer->layer_tree_impl()->AddLayer(std::move(replica)); |
| 50 } | 66 } |
| 51 } | 67 } |
| 52 | 68 |
| 53 } // namespace cc | 69 } // namespace cc |
| OLD | NEW |