| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "cc/trees/proxy.h" | 37 #include "cc/trees/proxy.h" |
| 38 #include "ui/gfx/geometry/box_f.h" | 38 #include "ui/gfx/geometry/box_f.h" |
| 39 #include "ui/gfx/geometry/point_conversions.h" | 39 #include "ui/gfx/geometry/point_conversions.h" |
| 40 #include "ui/gfx/geometry/quad_f.h" | 40 #include "ui/gfx/geometry/quad_f.h" |
| 41 #include "ui/gfx/geometry/rect_conversions.h" | 41 #include "ui/gfx/geometry/rect_conversions.h" |
| 42 #include "ui/gfx/geometry/size_conversions.h" | 42 #include "ui/gfx/geometry/size_conversions.h" |
| 43 #include "ui/gfx/geometry/vector2d_conversions.h" | 43 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 44 | 44 |
| 45 namespace cc { | 45 namespace cc { |
| 46 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) | 46 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) |
| 47 : parent_(nullptr), | 47 : mask_layer_id_(-1), |
| 48 mask_layer_id_(-1), | |
| 49 mask_layer_(nullptr), | 48 mask_layer_(nullptr), |
| 50 replica_layer_id_(-1), | 49 replica_layer_id_(-1), |
| 51 replica_layer_(nullptr), | 50 replica_layer_(nullptr), |
| 52 layer_id_(id), | 51 layer_id_(id), |
| 53 layer_tree_impl_(tree_impl), | 52 layer_tree_impl_(tree_impl), |
| 54 test_properties_(nullptr), | 53 test_properties_(nullptr), |
| 55 scroll_clip_layer_id_(Layer::INVALID_ID), | 54 scroll_clip_layer_id_(Layer::INVALID_ID), |
| 56 main_thread_scrolling_reasons_( | 55 main_thread_scrolling_reasons_( |
| 57 MainThreadScrollingReason::kNotScrollingOnMain), | 56 MainThreadScrollingReason::kNotScrollingOnMain), |
| 58 user_scrollable_horizontal_(true), | 57 user_scrollable_horizontal_(true), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); | 104 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); |
| 106 | 105 |
| 107 // The mask and replica layers should have been removed already. | 106 // The mask and replica layers should have been removed already. |
| 108 if (mask_layer_) | 107 if (mask_layer_) |
| 109 DCHECK(!layer_tree_impl_->RemoveLayer(mask_layer_id_)); | 108 DCHECK(!layer_tree_impl_->RemoveLayer(mask_layer_id_)); |
| 110 if (replica_layer_) | 109 if (replica_layer_) |
| 111 DCHECK(!layer_tree_impl_->RemoveLayer(replica_layer_id_)); | 110 DCHECK(!layer_tree_impl_->RemoveLayer(replica_layer_id_)); |
| 112 } | 111 } |
| 113 | 112 |
| 114 void LayerImpl::AddChild(std::unique_ptr<LayerImpl> child) { | 113 void LayerImpl::AddChild(std::unique_ptr<LayerImpl> child) { |
| 115 child->SetParent(this); | 114 child->test_properties()->parent = this; |
| 116 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); | 115 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); |
| 117 test_properties()->children.push_back(child.get()); | 116 test_properties()->children.push_back(child.get()); |
| 118 layer_tree_impl_->AddLayer(std::move(child)); | 117 layer_tree_impl_->AddLayer(std::move(child)); |
| 119 } | 118 } |
| 120 | 119 |
| 121 std::unique_ptr<LayerImpl> LayerImpl::RemoveChildForTesting(LayerImpl* child) { | 120 std::unique_ptr<LayerImpl> LayerImpl::RemoveChildForTesting(LayerImpl* child) { |
| 122 auto it = std::find(test_properties()->children.begin(), | 121 auto it = std::find(test_properties()->children.begin(), |
| 123 test_properties()->children.end(), child); | 122 test_properties()->children.end(), child); |
| 124 if (it != test_properties()->children.end()) | 123 if (it != test_properties()->children.end()) |
| 125 test_properties()->children.erase(it); | 124 test_properties()->children.erase(it); |
| 126 layer_tree_impl()->property_trees()->RemoveIdFromIdToIndexMaps(child->id()); | 125 layer_tree_impl()->property_trees()->RemoveIdFromIdToIndexMaps(child->id()); |
| 127 return layer_tree_impl_->RemoveLayer(child->id()); | 126 return layer_tree_impl_->RemoveLayer(child->id()); |
| 128 } | 127 } |
| 129 | 128 |
| 130 void LayerImpl::SetParent(LayerImpl* parent) { | |
| 131 parent_ = parent; | |
| 132 } | |
| 133 | |
| 134 void LayerImpl::ClearLinksToOtherLayers() { | 129 void LayerImpl::ClearLinksToOtherLayers() { |
| 135 mask_layer_ = nullptr; | 130 mask_layer_ = nullptr; |
| 136 replica_layer_ = nullptr; | 131 replica_layer_ = nullptr; |
| 137 } | 132 } |
| 138 | 133 |
| 139 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) { | 134 void LayerImpl::SetHasWillChangeTransformHint(bool has_will_change) { |
| 140 if (has_will_change_transform_hint_ == has_will_change) | 135 if (has_will_change_transform_hint_ == has_will_change) |
| 141 return; | 136 return; |
| 142 has_will_change_transform_hint_ = has_will_change; | 137 has_will_change_transform_hint_ = has_will_change; |
| 143 SetNeedsPushProperties(); | 138 SetNeedsPushProperties(); |
| (...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 .layer_transforms_should_scale_layer_contents) { | 1351 .layer_transforms_should_scale_layer_contents) { |
| 1357 return default_scale; | 1352 return default_scale; |
| 1358 } | 1353 } |
| 1359 | 1354 |
| 1360 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1355 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1361 ScreenSpaceTransform(), default_scale); | 1356 ScreenSpaceTransform(), default_scale); |
| 1362 return std::max(transform_scales.x(), transform_scales.y()); | 1357 return std::max(transform_scales.x(), transform_scales.y()); |
| 1363 } | 1358 } |
| 1364 | 1359 |
| 1365 } // namespace cc | 1360 } // namespace cc |
| OLD | NEW |