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_host_impl.h" | 5 #include "cc/trees/layer_tree_host_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 1946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1957 | 1957 |
1958 DCHECK(pending_tree_duration_timer_); | 1958 DCHECK(pending_tree_duration_timer_); |
1959 // Reset will call the destructor and log the timer histogram. | 1959 // Reset will call the destructor and log the timer histogram. |
1960 pending_tree_duration_timer_.reset(); | 1960 pending_tree_duration_timer_.reset(); |
1961 | 1961 |
1962 // Process any requests in the UI resource queue. The request queue is | 1962 // Process any requests in the UI resource queue. The request queue is |
1963 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place | 1963 // given in LayerTreeHost::FinishCommitOnImplThread. This must take place |
1964 // before the swap. | 1964 // before the swap. |
1965 pending_tree_->ProcessUIResourceRequestQueue(); | 1965 pending_tree_->ProcessUIResourceRequestQueue(); |
1966 | 1966 |
1967 // TODO(bokan): The tree sync might destroy the currently scrolling layer. | |
1968 // Normally, this would be fine and we'd just drop incoming scrolls but | |
1969 // some telemetry tests rely on the viewport not having this behavior. | |
1970 // Those should be fixed and this removed. crbug.com/652905. | |
1971 bool restore_currently_scrolling_viewport = IsCurrentlyScrollingViewport(); | |
bokan
2016/10/05 00:24:08
I needed to add this hack to preserver behavior te
aelias_OOO_until_Jul13
2016/10/05 21:55:42
This patch is nonurgent, so I'm not sure why we sh
| |
1972 | |
1967 if (pending_tree_->needs_full_tree_sync()) { | 1973 if (pending_tree_->needs_full_tree_sync()) { |
1968 TreeSynchronizer::SynchronizeTrees(pending_tree_.get(), | 1974 TreeSynchronizer::SynchronizeTrees(pending_tree_.get(), |
1969 active_tree_.get()); | 1975 active_tree_.get()); |
1970 } | 1976 } |
1971 | 1977 |
1972 // Property trees may store damage status. We preserve the active tree | 1978 // Property trees may store damage status. We preserve the active tree |
1973 // damage status by pushing the damage status from active tree property | 1979 // damage status by pushing the damage status from active tree property |
1974 // trees to pending tree property trees or by moving it onto the layers. | 1980 // trees to pending tree property trees or by moving it onto the layers. |
1975 if (active_tree_->property_trees()->changed) { | 1981 if (active_tree_->property_trees()->changed) { |
1976 if (pending_tree_->property_trees()->sequence_number == | 1982 if (pending_tree_->property_trees()->sequence_number == |
(...skipping 10 matching lines...) Expand all Loading... | |
1987 pending_tree_->PushPropertiesTo(active_tree_.get()); | 1993 pending_tree_->PushPropertiesTo(active_tree_.get()); |
1988 if (!pending_tree_->LayerListIsEmpty()) | 1994 if (!pending_tree_->LayerListIsEmpty()) |
1989 pending_tree_->property_trees()->ResetAllChangeTracking(); | 1995 pending_tree_->property_trees()->ResetAllChangeTracking(); |
1990 | 1996 |
1991 // Now that we've synced everything from the pending tree to the active | 1997 // Now that we've synced everything from the pending tree to the active |
1992 // tree, rename the pending tree the recycle tree so we can reuse it on the | 1998 // tree, rename the pending tree the recycle tree so we can reuse it on the |
1993 // next sync. | 1999 // next sync. |
1994 DCHECK(!recycle_tree_); | 2000 DCHECK(!recycle_tree_); |
1995 pending_tree_.swap(recycle_tree_); | 2001 pending_tree_.swap(recycle_tree_); |
1996 | 2002 |
2003 if (restore_currently_scrolling_viewport && | |
2004 !IsCurrentlyScrollingViewport()) { | |
2005 active_tree_->SetCurrentlyScrollingLayer(viewport()->MainScrollLayer()); | |
2006 } | |
2007 | |
1997 // If we commit to the active tree directly, this is already done during | 2008 // If we commit to the active tree directly, this is already done during |
1998 // commit. | 2009 // commit. |
1999 ActivateAnimations(); | 2010 ActivateAnimations(); |
2000 | 2011 |
2001 // Compositor worker operates on the active tree so we have to run again | 2012 // Compositor worker operates on the active tree so we have to run again |
2002 // after activation. | 2013 // after activation. |
2003 Mutate(CurrentBeginFrameArgs().frame_time); | 2014 Mutate(CurrentBeginFrameArgs().frame_time); |
2004 } else { | 2015 } else { |
2005 active_tree_->ProcessUIResourceRequestQueue(); | 2016 active_tree_->ProcessUIResourceRequestQueue(); |
2006 } | 2017 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2216 void LayerTreeHostImpl::SetLayerTreeMutator( | 2227 void LayerTreeHostImpl::SetLayerTreeMutator( |
2217 std::unique_ptr<LayerTreeMutator> mutator) { | 2228 std::unique_ptr<LayerTreeMutator> mutator) { |
2218 if (mutator == mutator_) | 2229 if (mutator == mutator_) |
2219 return; | 2230 return; |
2220 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 2231 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
2221 "LayerTreeHostImpl::SetLayerTreeMutator"); | 2232 "LayerTreeHostImpl::SetLayerTreeMutator"); |
2222 mutator_ = std::move(mutator); | 2233 mutator_ = std::move(mutator); |
2223 mutator_->SetClient(this); | 2234 mutator_->SetClient(this); |
2224 } | 2235 } |
2225 | 2236 |
2237 LayerImpl* LayerTreeHostImpl::ViewportMainScrollLayer() { | |
2238 return viewport()->MainScrollLayer(); | |
2239 } | |
2240 | |
2226 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2241 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
2227 ClearUIResources(); | 2242 ClearUIResources(); |
2228 tile_manager_.FinishTasksAndCleanUp(); | 2243 tile_manager_.FinishTasksAndCleanUp(); |
2229 resource_pool_ = nullptr; | 2244 resource_pool_ = nullptr; |
2230 tile_task_manager_ = nullptr; | 2245 tile_task_manager_ = nullptr; |
2231 single_thread_synchronous_task_graph_runner_ = nullptr; | 2246 single_thread_synchronous_task_graph_runner_ = nullptr; |
2232 image_decode_controller_ = nullptr; | 2247 image_decode_controller_ = nullptr; |
2233 | 2248 |
2234 // We've potentially just freed a large number of resources on our various | 2249 // We've potentially just freed a large number of resources on our various |
2235 // contexts. Flushing now helps ensure these are cleaned up quickly | 2250 // contexts. Flushing now helps ensure these are cleaned up quickly |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2824 // that can scroll and set up an animation of its scroll offset. Note that | 2839 // that can scroll and set up an animation of its scroll offset. Note that |
2825 // this does not currently go through the scroll customization machinery | 2840 // this does not currently go through the scroll customization machinery |
2826 // that ScrollBy uses for non-animated wheel scrolls. | 2841 // that ScrollBy uses for non-animated wheel scrolls. |
2827 scroll_status = ScrollBegin(&scroll_state, WHEEL); | 2842 scroll_status = ScrollBegin(&scroll_state, WHEEL); |
2828 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2843 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
2829 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2844 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
2830 gfx::Vector2dF pending_delta = scroll_delta; | 2845 gfx::Vector2dF pending_delta = scroll_delta; |
2831 if (scroll_node) { | 2846 if (scroll_node) { |
2832 for (; scroll_tree.parent(scroll_node); | 2847 for (; scroll_tree.parent(scroll_node); |
2833 scroll_node = scroll_tree.parent(scroll_node)) { | 2848 scroll_node = scroll_tree.parent(scroll_node)) { |
2834 if (!scroll_node->scrollable || | 2849 if (!scroll_node->scrollable) |
2835 scroll_node->is_outer_viewport_scroll_layer) | |
2836 continue; | 2850 continue; |
2837 | 2851 |
2838 if (scroll_node->is_inner_viewport_scroll_layer) { | 2852 if (viewport()->MainScrollLayer() && |
2853 scroll_node->owner_id == viewport()->MainScrollLayer()->id()) { | |
2839 gfx::Vector2dF scrolled = | 2854 gfx::Vector2dF scrolled = |
2840 viewport()->ScrollAnimated(pending_delta, delayed_by); | 2855 viewport()->ScrollAnimated(pending_delta, delayed_by); |
2841 // Viewport::ScrollAnimated returns pending_delta as long as it | 2856 // Viewport::ScrollAnimated returns pending_delta as long as it |
2842 // starts an animation. | 2857 // starts an animation. |
2843 if (scrolled == pending_delta) | 2858 if (scrolled == pending_delta) |
2844 return scroll_status; | 2859 return scroll_status; |
2845 pending_delta -= scrolled; | 2860 break; |
2846 continue; | |
2847 } | 2861 } |
2848 | 2862 |
2849 gfx::Vector2dF scroll_delta = | 2863 gfx::Vector2dF scroll_delta = |
2850 ComputeScrollDelta(scroll_node, pending_delta); | 2864 ComputeScrollDelta(scroll_node, pending_delta); |
2851 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) | 2865 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) |
2852 return scroll_status; | 2866 return scroll_status; |
2853 | 2867 |
2854 pending_delta -= scroll_delta; | 2868 pending_delta -= scroll_delta; |
2855 } | 2869 } |
2856 } | 2870 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3036 } | 3050 } |
3037 | 3051 |
3038 void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { | 3052 void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { |
3039 // TODO(majidvp): in Blink we compute scroll chain only at scroll begin which | 3053 // TODO(majidvp): in Blink we compute scroll chain only at scroll begin which |
3040 // is not the case here. We eventually want to have the same behaviour on both | 3054 // is not the case here. We eventually want to have the same behaviour on both |
3041 // sides but it may become a non issue if we get rid of scroll chaining (see | 3055 // sides but it may become a non issue if we get rid of scroll chaining (see |
3042 // crbug.com/526462) | 3056 // crbug.com/526462) |
3043 std::list<const ScrollNode*> current_scroll_chain; | 3057 std::list<const ScrollNode*> current_scroll_chain; |
3044 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3058 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
3045 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3059 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
3060 ScrollNode* viewport_scroll_node = | |
3061 viewport()->MainScrollLayer() | |
3062 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index()) | |
3063 : nullptr; | |
3046 if (scroll_node) { | 3064 if (scroll_node) { |
3065 // TODO(bokan): The loop checks for a null parent but don't we still want to | |
3066 // distribute to the root scroll node? | |
3047 for (; scroll_tree.parent(scroll_node); | 3067 for (; scroll_tree.parent(scroll_node); |
3048 scroll_node = scroll_tree.parent(scroll_node)) { | 3068 scroll_node = scroll_tree.parent(scroll_node)) { |
3049 if (scroll_node->is_outer_viewport_scroll_layer) { | 3069 if (scroll_node == viewport_scroll_node) { |
3050 // TODO(bokan): This should use Viewport::MainScrollLayer once that | |
3051 // returns the outer viewport scroll layer. | |
3052 // Don't chain scrolls past the outer viewport scroll layer. Once we | 3070 // Don't chain scrolls past the outer viewport scroll layer. Once we |
3053 // reach that, we should scroll the viewport which is represented by the | 3071 // reach that, we should scroll the viewport which is represented by the |
3054 // main viewport scroll layer. | 3072 // main viewport scroll layer. |
3055 DCHECK(viewport()->MainScrollLayer()); | |
3056 ScrollNode* viewport_scroll_node = scroll_tree.Node( | |
3057 viewport()->MainScrollLayer()->scroll_tree_index()); | |
3058 DCHECK(viewport_scroll_node); | 3073 DCHECK(viewport_scroll_node); |
3059 current_scroll_chain.push_front(viewport_scroll_node); | 3074 current_scroll_chain.push_front(viewport_scroll_node); |
3060 break; | 3075 break; |
3061 } | 3076 } |
3062 | 3077 |
3063 if (!scroll_node->scrollable) | 3078 if (!scroll_node->scrollable) |
3064 continue; | 3079 continue; |
3065 | 3080 |
3066 current_scroll_chain.push_front(scroll_node); | 3081 current_scroll_chain.push_front(scroll_node); |
3067 } | 3082 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3245 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 3260 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
3246 HandleMouseOverScrollbar(layer_impl); | 3261 HandleMouseOverScrollbar(layer_impl); |
3247 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) | 3262 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) |
3248 return; | 3263 return; |
3249 | 3264 |
3250 bool scroll_on_main_thread = false; | 3265 bool scroll_on_main_thread = false; |
3251 uint32_t main_thread_scrolling_reasons; | 3266 uint32_t main_thread_scrolling_reasons; |
3252 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 3267 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
3253 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, | 3268 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, |
3254 &scroll_on_main_thread, &main_thread_scrolling_reasons); | 3269 &scroll_on_main_thread, &main_thread_scrolling_reasons); |
3270 | |
3255 // Scrollbars for the viewport are registered with the outer viewport layer. | 3271 // Scrollbars for the viewport are registered with the outer viewport layer. |
3256 if (scroll_layer_impl == InnerViewportScrollLayer()) | 3272 if (scroll_layer_impl == InnerViewportScrollLayer()) |
3257 scroll_layer_impl = OuterViewportScrollLayer(); | 3273 scroll_layer_impl = OuterViewportScrollLayer(); |
3274 | |
3258 if (scroll_on_main_thread || !scroll_layer_impl) | 3275 if (scroll_on_main_thread || !scroll_layer_impl) |
3259 return; | 3276 return; |
3260 | 3277 |
3261 ScrollbarAnimationController* animation_controller = | 3278 ScrollbarAnimationController* animation_controller = |
3262 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); | 3279 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); |
3263 if (!animation_controller) | 3280 if (!animation_controller) |
3264 return; | 3281 return; |
3265 | 3282 |
3266 float distance_to_scrollbar = std::numeric_limits<float>::max(); | 3283 float distance_to_scrollbar = std::numeric_limits<float>::max(); |
3267 for (ScrollbarLayerImplBase* scrollbar : | 3284 for (ScrollbarLayerImplBase* scrollbar : |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4090 if (is_visible) { | 4107 if (is_visible) { |
4091 worker_context_visibility_ = | 4108 worker_context_visibility_ = |
4092 worker_context->CacheController()->ClientBecameVisible(); | 4109 worker_context->CacheController()->ClientBecameVisible(); |
4093 } else { | 4110 } else { |
4094 worker_context->CacheController()->ClientBecameNotVisible( | 4111 worker_context->CacheController()->ClientBecameNotVisible( |
4095 std::move(worker_context_visibility_)); | 4112 std::move(worker_context_visibility_)); |
4096 } | 4113 } |
4097 } | 4114 } |
4098 | 4115 |
4099 } // namespace cc | 4116 } // namespace cc |
OLD | NEW |