Chromium Code Reviews| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 DCHECK(OuterViewportContainerLayer()->viewport_layer_type() == | 155 DCHECK(OuterViewportContainerLayer()->viewport_layer_type() == |
| 156 OUTER_VIEWPORT_CONTAINER); | 156 OUTER_VIEWPORT_CONTAINER); |
| 157 #endif | 157 #endif |
| 158 if (auto* layer = LayerById(id)) | 158 if (auto* layer = LayerById(id)) |
| 159 return layer->viewport_layer_type() != NOT_VIEWPORT_LAYER; | 159 return layer->viewport_layer_type() != NOT_VIEWPORT_LAYER; |
| 160 return false; | 160 return false; |
| 161 } | 161 } |
| 162 | 162 |
| 163 void LayerTreeImpl::DidUpdateScrollOffset(int layer_id) { | 163 void LayerTreeImpl::DidUpdateScrollOffset(int layer_id) { |
| 164 DidUpdateScrollState(layer_id); | 164 DidUpdateScrollState(layer_id); |
| 165 | |
| 166 DCHECK(PropertyTreeSyncComplete()); | |
| 165 TransformTree& transform_tree = property_trees()->transform_tree; | 167 TransformTree& transform_tree = property_trees()->transform_tree; |
| 166 ScrollTree& scroll_tree = property_trees()->scroll_tree; | 168 ScrollTree& scroll_tree = property_trees()->scroll_tree; |
| 167 int transform_id = TransformTree::kInvalidNodeId; | 169 int transform_id = TransformTree::kInvalidNodeId; |
| 168 | 170 |
| 169 // If pending tree topology changed and we still want to notify the pending | 171 // If pending tree topology changed and we still want to notify the pending |
| 170 // tree about scroll offset in the active tree, we may not find the | 172 // tree about scroll offset in the active tree, we may not find the |
| 171 // corresponding pending layer. | 173 // corresponding pending layer. |
| 172 if (LayerById(layer_id)) { | 174 if (LayerById(layer_id)) { |
| 173 // TODO(sunxd): when we have a layer_id to property_tree index map in | 175 // TODO(sunxd): when we have a layer_id to property_tree index map in |
| 174 // property trees, use the transform_id parameter instead of looking for | 176 // property trees, use the transform_id parameter instead of looking for |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 192 } | 194 } |
| 193 | 195 |
| 194 if (IsActiveTree() && layer_tree_host_impl_->pending_tree()) | 196 if (IsActiveTree() && layer_tree_host_impl_->pending_tree()) |
| 195 layer_tree_host_impl_->pending_tree()->DidUpdateScrollOffset(layer_id); | 197 layer_tree_host_impl_->pending_tree()->DidUpdateScrollOffset(layer_id); |
| 196 } | 198 } |
| 197 | 199 |
| 198 void LayerTreeImpl::DidUpdateScrollState(int layer_id) { | 200 void LayerTreeImpl::DidUpdateScrollState(int layer_id) { |
| 199 if (!IsActiveTree()) | 201 if (!IsActiveTree()) |
| 200 return; | 202 return; |
| 201 | 203 |
| 204 // If we are syncing, the scroll_clip_layer properties should be up-to-date. | |
| 205 // TODO(pdr): This DCHECK fails on existing tests but should be enabled. | |
| 206 // DCHECK(layer_tree_host_impl_->SyncStateComplete(SYNCED_LAYER_PROPERTIES)); | |
|
jaydasika
2017/05/12 18:19:16
Something related I just noticed : LayerImpl::SetB
pdr.
2017/05/15 18:30:24
+1, this bug is all over :(
| |
| 207 | |
| 202 if (layer_id == Layer::INVALID_ID) | 208 if (layer_id == Layer::INVALID_ID) |
| 203 return; | 209 return; |
| 204 | 210 |
| 205 int scroll_layer_id, clip_layer_id; | 211 int scroll_layer_id, clip_layer_id; |
| 206 if (IsViewportLayerId(layer_id)) { | 212 if (IsViewportLayerId(layer_id)) { |
| 207 if (!InnerViewportContainerLayer()) | 213 if (!InnerViewportContainerLayer()) |
| 208 return; | 214 return; |
| 209 | 215 |
| 210 // For scrollbar purposes, a change to any of the four viewport layers | 216 // For scrollbar purposes, a change to any of the four viewport layers |
| 211 // should affect the scrollbars tied to the outermost layers, which express | 217 // should affect the scrollbars tied to the outermost layers, which express |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 property_trees_.effect_tree.CreateOrReuseRenderSurfaces( | 381 property_trees_.effect_tree.CreateOrReuseRenderSurfaces( |
| 376 &old_render_surfaces, this); | 382 &old_render_surfaces, this); |
| 377 if (render_surfaces_changed) | 383 if (render_surfaces_changed) |
| 378 set_needs_update_draw_properties(); | 384 set_needs_update_draw_properties(); |
| 379 property_trees->effect_tree.PushCopyRequestsTo(&property_trees_.effect_tree); | 385 property_trees->effect_tree.PushCopyRequestsTo(&property_trees_.effect_tree); |
| 380 property_trees_.is_main_thread = false; | 386 property_trees_.is_main_thread = false; |
| 381 property_trees_.is_active = IsActiveTree(); | 387 property_trees_.is_active = IsActiveTree(); |
| 382 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false); | 388 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false); |
| 383 } | 389 } |
| 384 | 390 |
| 385 void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { | 391 void LayerTreeImpl::PushPropertyTreesTo(LayerTreeImpl* target_tree) { |
| 386 // The request queue should have been processed and does not require a push. | |
| 387 DCHECK_EQ(ui_resource_request_queue_.size(), 0u); | |
| 388 | |
| 389 // To maintain the current scrolling node we need to use element ids which | 392 // To maintain the current scrolling node we need to use element ids which |
| 390 // are stable across the property tree update in SetPropertyTrees. | 393 // are stable across the property tree update in SetPropertyTrees. |
| 391 ElementId scrolling_element_id; | 394 ElementId scrolling_element_id; |
| 392 if (ScrollNode* scrolling_node = target_tree->CurrentlyScrollingNode()) | 395 if (ScrollNode* scrolling_node = target_tree->CurrentlyScrollingNode()) |
| 393 scrolling_element_id = scrolling_node->element_id; | 396 scrolling_element_id = scrolling_node->element_id; |
| 394 | 397 |
| 395 target_tree->SetPropertyTrees(&property_trees_); | 398 target_tree->SetPropertyTrees(&property_trees_); |
| 396 | 399 |
| 397 ScrollNode* scrolling_node = nullptr; | 400 ScrollNode* scrolling_node = nullptr; |
| 398 if (scrolling_element_id) { | 401 if (scrolling_element_id) { |
| 399 auto& scroll_tree = target_tree->property_trees()->scroll_tree; | 402 auto& scroll_tree = target_tree->property_trees()->scroll_tree; |
| 400 scrolling_node = scroll_tree.FindNodeFromElementId(scrolling_element_id); | 403 scrolling_node = scroll_tree.FindNodeFromElementId(scrolling_element_id); |
| 401 } | 404 } |
| 402 target_tree->SetCurrentlyScrollingNode(scrolling_node); | 405 target_tree->SetCurrentlyScrollingNode(scrolling_node); |
|
chrishtr
2017/05/12 23:13:29
"just noting" --wkorman
It seems perhaps this fie
| |
| 406 } | |
| 407 | |
| 408 void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { | |
| 409 // The request queue should have been processed and does not require a push. | |
| 410 DCHECK_EQ(ui_resource_request_queue_.size(), 0u); | |
| 403 | 411 |
| 404 target_tree->property_trees()->scroll_tree.PushScrollUpdatesFromPendingTree( | 412 target_tree->property_trees()->scroll_tree.PushScrollUpdatesFromPendingTree( |
| 405 &property_trees_, target_tree); | 413 &property_trees_, target_tree); |
| 406 | 414 |
| 407 if (next_activation_forces_redraw_) { | 415 if (next_activation_forces_redraw_) { |
| 408 target_tree->ForceRedrawNextActivation(); | 416 target_tree->ForceRedrawNextActivation(); |
| 409 next_activation_forces_redraw_ = false; | 417 next_activation_forces_redraw_ = false; |
| 410 } | 418 } |
| 411 | 419 |
| 412 target_tree->PassSwapPromises(std::move(swap_promise_list_)); | 420 target_tree->PassSwapPromises(std::move(swap_promise_list_)); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 ++element_id_to_transform; | 769 ++element_id_to_transform; |
| 762 } | 770 } |
| 763 | 771 |
| 764 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { | 772 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { |
| 765 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); | 773 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); |
| 766 }); | 774 }); |
| 767 } | 775 } |
| 768 | 776 |
| 769 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { | 777 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { |
| 770 DCHECK(IsActiveTree()); | 778 DCHECK(IsActiveTree()); |
| 779 DCHECK(PropertyTreeSyncComplete()); | |
| 771 if (page_scale_factor()->SetCurrent( | 780 if (page_scale_factor()->SetCurrent( |
| 772 ClampPageScaleFactorToLimits(active_page_scale))) { | 781 ClampPageScaleFactorToLimits(active_page_scale))) { |
| 773 DidUpdatePageScale(); | 782 DidUpdatePageScale(); |
| 774 if (PageScaleLayer()) { | 783 if (PageScaleLayer()) { |
| 775 draw_property_utils::UpdatePageScaleFactor( | 784 draw_property_utils::UpdatePageScaleFactor( |
| 776 property_trees(), PageScaleLayer(), current_page_scale_factor(), | 785 property_trees(), PageScaleLayer(), current_page_scale_factor(), |
| 777 device_scale_factor(), layer_tree_host_impl_->DrawTransform()); | 786 device_scale_factor(), layer_tree_host_impl_->DrawTransform()); |
| 778 } else { | 787 } else { |
| 779 DCHECK(layer_list_.empty() || active_page_scale == 1); | 788 DCHECK(layer_list_.empty() || active_page_scale == 1); |
| 780 } | 789 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 811 // TODO(enne): Pushing from pending to active should never require | 820 // TODO(enne): Pushing from pending to active should never require |
| 812 // DidUpdatePageScale. The values should already be set by the fully | 821 // DidUpdatePageScale. The values should already be set by the fully |
| 813 // computed property trees being synced from one tree to another. Remove | 822 // computed property trees being synced from one tree to another. Remove |
| 814 // this once CDP goes away. | 823 // this once CDP goes away. |
| 815 changed_page_scale |= page_scale_factor_->PushPendingToActive(); | 824 changed_page_scale |= page_scale_factor_->PushPendingToActive(); |
| 816 } | 825 } |
| 817 | 826 |
| 818 if (changed_page_scale) | 827 if (changed_page_scale) |
| 819 DidUpdatePageScale(); | 828 DidUpdatePageScale(); |
| 820 | 829 |
| 830 DCHECK(PropertyTreeSyncComplete()); | |
| 821 if (page_scale_factor) { | 831 if (page_scale_factor) { |
| 822 if (PageScaleLayer()) { | 832 if (PageScaleLayer()) { |
| 823 draw_property_utils::UpdatePageScaleFactor( | 833 draw_property_utils::UpdatePageScaleFactor( |
| 824 property_trees(), PageScaleLayer(), current_page_scale_factor(), | 834 property_trees(), PageScaleLayer(), current_page_scale_factor(), |
| 825 device_scale_factor(), layer_tree_host_impl_->DrawTransform()); | 835 device_scale_factor(), layer_tree_host_impl_->DrawTransform()); |
| 826 } else { | 836 } else { |
| 827 DCHECK(layer_list_.empty() || *page_scale_factor == 1); | 837 DCHECK(layer_list_.empty() || *page_scale_factor == 1); |
| 828 } | 838 } |
| 829 } | 839 } |
| 830 } | 840 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 | 997 |
| 988 UpdateViewportLayerTypes(); | 998 UpdateViewportLayerTypes(); |
| 989 } | 999 } |
| 990 | 1000 |
| 991 void LayerTreeImpl::ClearViewportLayers() { | 1001 void LayerTreeImpl::ClearViewportLayers() { |
| 992 SetViewportLayersFromIds(Layer::INVALID_ID, Layer::INVALID_ID, | 1002 SetViewportLayersFromIds(Layer::INVALID_ID, Layer::INVALID_ID, |
| 993 Layer::INVALID_ID, Layer::INVALID_ID); | 1003 Layer::INVALID_ID, Layer::INVALID_ID); |
| 994 } | 1004 } |
| 995 | 1005 |
| 996 void LayerTreeImpl::UpdateViewportLayerTypes() { | 1006 void LayerTreeImpl::UpdateViewportLayerTypes() { |
| 1007 // If we are syncing, the scroll_clip_layer properties should be up-to-date. | |
| 1008 // TODO(pdr): This DCHECK fails on existing tests but should be enabled. | |
|
enne (OOO)
2017/05/12 17:25:06
This is a pre-existing data inconsistency, I guess
pdr.
2017/05/15 18:30:24
This is due to how https://codereview.chromium.org
pdr.
2017/05/15 18:56:42
I've reverted this change and will do it in a foll
| |
| 1009 // DCHECK(layer_tree_host_impl_->SyncStateComplete(SYNCED_LAYER_PROPERTIES)); | |
| 1010 | |
| 997 if (auto* inner_scroll = LayerById(inner_viewport_scroll_layer_id_)) { | 1011 if (auto* inner_scroll = LayerById(inner_viewport_scroll_layer_id_)) { |
| 998 inner_scroll->SetViewportLayerType(INNER_VIEWPORT_SCROLL); | 1012 inner_scroll->SetViewportLayerType(INNER_VIEWPORT_SCROLL); |
| 999 if (auto* inner_container = inner_scroll->scroll_clip_layer()) | 1013 if (auto* inner_container = inner_scroll->scroll_clip_layer()) |
| 1000 inner_container->SetViewportLayerType(INNER_VIEWPORT_CONTAINER); | 1014 inner_container->SetViewportLayerType(INNER_VIEWPORT_CONTAINER); |
| 1001 } | 1015 } |
| 1002 if (auto* outer_scroll = LayerById(outer_viewport_scroll_layer_id_)) { | 1016 if (auto* outer_scroll = LayerById(outer_viewport_scroll_layer_id_)) { |
| 1003 outer_scroll->SetViewportLayerType(OUTER_VIEWPORT_SCROLL); | 1017 outer_scroll->SetViewportLayerType(OUTER_VIEWPORT_SCROLL); |
| 1004 if (auto* outer_container = outer_scroll->scroll_clip_layer()) | 1018 if (auto* outer_container = outer_scroll->scroll_clip_layer()) |
| 1005 outer_container->SetViewportLayerType(OUTER_VIEWPORT_CONTAINER); | 1019 outer_container->SetViewportLayerType(OUTER_VIEWPORT_CONTAINER); |
| 1006 } | 1020 } |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2109 | 2123 |
| 2110 void LayerTreeImpl::ResetAllChangeTracking() { | 2124 void LayerTreeImpl::ResetAllChangeTracking() { |
| 2111 layers_that_should_push_properties_.clear(); | 2125 layers_that_should_push_properties_.clear(); |
| 2112 // Iterate over all layers, including masks. | 2126 // Iterate over all layers, including masks. |
| 2113 for (auto& layer : *layers_) | 2127 for (auto& layer : *layers_) |
| 2114 layer->ResetChangeTracking(); | 2128 layer->ResetChangeTracking(); |
| 2115 property_trees_.ResetAllChangeTracking(); | 2129 property_trees_.ResetAllChangeTracking(); |
| 2116 } | 2130 } |
| 2117 | 2131 |
| 2118 } // namespace cc | 2132 } // namespace cc |
| OLD | NEW |