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/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 void LayerTreeImpl::SetViewportLayersFromIds( | 1008 void LayerTreeImpl::SetViewportLayersFromIds( |
1009 int overscroll_elasticity_layer_id, | 1009 int overscroll_elasticity_layer_id, |
1010 int page_scale_layer_id, | 1010 int page_scale_layer_id, |
1011 int inner_viewport_scroll_layer_id, | 1011 int inner_viewport_scroll_layer_id, |
1012 int outer_viewport_scroll_layer_id) { | 1012 int outer_viewport_scroll_layer_id) { |
1013 overscroll_elasticity_layer_id_ = overscroll_elasticity_layer_id; | 1013 overscroll_elasticity_layer_id_ = overscroll_elasticity_layer_id; |
1014 page_scale_layer_id_ = page_scale_layer_id; | 1014 page_scale_layer_id_ = page_scale_layer_id; |
1015 inner_viewport_scroll_layer_id_ = inner_viewport_scroll_layer_id; | 1015 inner_viewport_scroll_layer_id_ = inner_viewport_scroll_layer_id; |
1016 outer_viewport_scroll_layer_id_ = outer_viewport_scroll_layer_id; | 1016 outer_viewport_scroll_layer_id_ = outer_viewport_scroll_layer_id; |
1017 | 1017 |
1018 UpdateViewportLayerTypes(); | |
1019 } | |
1020 | |
1021 void LayerTreeImpl::ClearViewportLayers() { | |
1022 SetViewportLayersFromIds(Layer::INVALID_ID, Layer::INVALID_ID, | |
1023 Layer::INVALID_ID, Layer::INVALID_ID); | |
1024 } | |
1025 | |
1026 void LayerTreeImpl::UpdateViewportLayerTypes() { | |
1027 // The scroll_clip_layer Layer properties should be up-to-date. | 1018 // The scroll_clip_layer Layer properties should be up-to-date. |
1028 // TODO(pdr): Enable this DCHECK by not calling this function unnecessarily | 1019 DCHECK(lifecycle().AllowsLayerPropertyAccess()); |
1029 // from LayerImpl::SetScrollClipLayer. | |
1030 // DCHECK(lifecycle().AllowsLayerPropertyAccess()); | |
1031 | |
1032 if (auto* inner_scroll = LayerById(inner_viewport_scroll_layer_id_)) { | 1020 if (auto* inner_scroll = LayerById(inner_viewport_scroll_layer_id_)) { |
1033 inner_scroll->SetViewportLayerType(INNER_VIEWPORT_SCROLL); | 1021 inner_scroll->SetViewportLayerType(INNER_VIEWPORT_SCROLL); |
1034 if (auto* inner_container = inner_scroll->scroll_clip_layer()) | 1022 if (auto* inner_container = inner_scroll->scroll_clip_layer()) |
1035 inner_container->SetViewportLayerType(INNER_VIEWPORT_CONTAINER); | 1023 inner_container->SetViewportLayerType(INNER_VIEWPORT_CONTAINER); |
1036 } | 1024 } |
1037 if (auto* outer_scroll = LayerById(outer_viewport_scroll_layer_id_)) { | 1025 if (auto* outer_scroll = LayerById(outer_viewport_scroll_layer_id_)) { |
1038 outer_scroll->SetViewportLayerType(OUTER_VIEWPORT_SCROLL); | 1026 outer_scroll->SetViewportLayerType(OUTER_VIEWPORT_SCROLL); |
1039 if (auto* outer_container = outer_scroll->scroll_clip_layer()) | 1027 if (auto* outer_container = outer_scroll->scroll_clip_layer()) |
1040 outer_container->SetViewportLayerType(OUTER_VIEWPORT_CONTAINER); | 1028 outer_container->SetViewportLayerType(OUTER_VIEWPORT_CONTAINER); |
1041 } | 1029 } |
1042 } | 1030 } |
1043 | 1031 |
| 1032 void LayerTreeImpl::ClearViewportLayers() { |
| 1033 SetViewportLayersFromIds(Layer::INVALID_ID, Layer::INVALID_ID, |
| 1034 Layer::INVALID_ID, Layer::INVALID_ID); |
| 1035 } |
| 1036 |
1044 // For unit tests, we use the layer's id as its element id. | 1037 // For unit tests, we use the layer's id as its element id. |
1045 static void SetElementIdForTesting(LayerImpl* layer) { | 1038 static void SetElementIdForTesting(LayerImpl* layer) { |
1046 layer->SetElementId(LayerIdToElementIdForTesting(layer->id())); | 1039 layer->SetElementId(LayerIdToElementIdForTesting(layer->id())); |
1047 } | 1040 } |
1048 | 1041 |
1049 void LayerTreeImpl::SetElementIdsForTesting() { | 1042 void LayerTreeImpl::SetElementIdsForTesting() { |
1050 LayerListIterator<LayerImpl> it(root_layer_for_testing_); | 1043 LayerListIterator<LayerImpl> it(root_layer_for_testing_); |
1051 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) { | 1044 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) { |
1052 if (!it->element_id()) | 1045 if (!it->element_id()) |
1053 SetElementIdForTesting(*it); | 1046 SetElementIdForTesting(*it); |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2145 | 2138 |
2146 void LayerTreeImpl::ResetAllChangeTracking() { | 2139 void LayerTreeImpl::ResetAllChangeTracking() { |
2147 layers_that_should_push_properties_.clear(); | 2140 layers_that_should_push_properties_.clear(); |
2148 // Iterate over all layers, including masks. | 2141 // Iterate over all layers, including masks. |
2149 for (auto& layer : *layers_) | 2142 for (auto& layer : *layers_) |
2150 layer->ResetChangeTracking(); | 2143 layer->ResetChangeTracking(); |
2151 property_trees_.ResetAllChangeTracking(); | 2144 property_trees_.ResetAllChangeTracking(); |
2152 } | 2145 } |
2153 | 2146 |
2154 } // namespace cc | 2147 } // namespace cc |
OLD | NEW |