| 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 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2214 void LayerTreeHostImpl::SetLayerTreeMutator( | 2214 void LayerTreeHostImpl::SetLayerTreeMutator( |
| 2215 std::unique_ptr<LayerTreeMutator> mutator) { | 2215 std::unique_ptr<LayerTreeMutator> mutator) { |
| 2216 if (mutator == mutator_) | 2216 if (mutator == mutator_) |
| 2217 return; | 2217 return; |
| 2218 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 2218 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 2219 "LayerTreeHostImpl::SetLayerTreeMutator"); | 2219 "LayerTreeHostImpl::SetLayerTreeMutator"); |
| 2220 mutator_ = std::move(mutator); | 2220 mutator_ = std::move(mutator); |
| 2221 mutator_->SetClient(this); | 2221 mutator_->SetClient(this); |
| 2222 } | 2222 } |
| 2223 | 2223 |
| 2224 LayerImpl* LayerTreeHostImpl::ViewportMainScrollLayer() { |
| 2225 return viewport()->MainScrollLayer(); |
| 2226 } |
| 2227 |
| 2224 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2228 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
| 2225 ClearUIResources(); | 2229 ClearUIResources(); |
| 2226 tile_manager_.FinishTasksAndCleanUp(); | 2230 tile_manager_.FinishTasksAndCleanUp(); |
| 2227 resource_pool_ = nullptr; | 2231 resource_pool_ = nullptr; |
| 2228 tile_task_manager_ = nullptr; | 2232 tile_task_manager_ = nullptr; |
| 2229 single_thread_synchronous_task_graph_runner_ = nullptr; | 2233 single_thread_synchronous_task_graph_runner_ = nullptr; |
| 2230 image_decode_controller_ = nullptr; | 2234 image_decode_controller_ = nullptr; |
| 2231 | 2235 |
| 2232 // We've potentially just freed a large number of resources on our various | 2236 // We've potentially just freed a large number of resources on our various |
| 2233 // contexts. Flushing now helps ensure these are cleaned up quickly | 2237 // contexts. Flushing now helps ensure these are cleaned up quickly |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2823 // that can scroll and set up an animation of its scroll offset. Note that | 2827 // that can scroll and set up an animation of its scroll offset. Note that |
| 2824 // this does not currently go through the scroll customization machinery | 2828 // this does not currently go through the scroll customization machinery |
| 2825 // that ScrollBy uses for non-animated wheel scrolls. | 2829 // that ScrollBy uses for non-animated wheel scrolls. |
| 2826 scroll_status = ScrollBegin(&scroll_state, WHEEL); | 2830 scroll_status = ScrollBegin(&scroll_state, WHEEL); |
| 2827 scroll_node = scroll_tree.CurrentlyScrollingNode(); | 2831 scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 2828 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { | 2832 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { |
| 2829 gfx::Vector2dF pending_delta = scroll_delta; | 2833 gfx::Vector2dF pending_delta = scroll_delta; |
| 2830 if (scroll_node) { | 2834 if (scroll_node) { |
| 2831 for (; scroll_tree.parent(scroll_node); | 2835 for (; scroll_tree.parent(scroll_node); |
| 2832 scroll_node = scroll_tree.parent(scroll_node)) { | 2836 scroll_node = scroll_tree.parent(scroll_node)) { |
| 2833 if (!scroll_node->scrollable || | 2837 if (!scroll_node->scrollable) |
| 2834 scroll_node->is_outer_viewport_scroll_layer) | |
| 2835 continue; | 2838 continue; |
| 2836 | 2839 |
| 2837 if (scroll_node->is_inner_viewport_scroll_layer) { | 2840 if (viewport()->MainScrollLayer() && |
| 2841 scroll_node->owner_id == viewport()->MainScrollLayer()->id()) { |
| 2838 gfx::Vector2dF scrolled = | 2842 gfx::Vector2dF scrolled = |
| 2839 viewport()->ScrollAnimated(pending_delta, delayed_by); | 2843 viewport()->ScrollAnimated(pending_delta, delayed_by); |
| 2840 // Viewport::ScrollAnimated returns pending_delta as long as it | 2844 // Viewport::ScrollAnimated returns pending_delta as long as it |
| 2841 // starts an animation. | 2845 // starts an animation. |
| 2842 if (scrolled == pending_delta) | 2846 if (scrolled == pending_delta) |
| 2843 return scroll_status; | 2847 return scroll_status; |
| 2844 pending_delta -= scrolled; | 2848 break; |
| 2845 continue; | |
| 2846 } | 2849 } |
| 2847 | 2850 |
| 2848 gfx::Vector2dF scroll_delta = | 2851 gfx::Vector2dF scroll_delta = |
| 2849 ComputeScrollDelta(scroll_node, pending_delta); | 2852 ComputeScrollDelta(scroll_node, pending_delta); |
| 2850 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) | 2853 if (ScrollAnimationCreate(scroll_node, scroll_delta, delayed_by)) |
| 2851 return scroll_status; | 2854 return scroll_status; |
| 2852 | 2855 |
| 2853 pending_delta -= scroll_delta; | 2856 pending_delta -= scroll_delta; |
| 2854 } | 2857 } |
| 2855 } | 2858 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3035 } | 3038 } |
| 3036 | 3039 |
| 3037 void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { | 3040 void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { |
| 3038 // TODO(majidvp): in Blink we compute scroll chain only at scroll begin which | 3041 // TODO(majidvp): in Blink we compute scroll chain only at scroll begin which |
| 3039 // is not the case here. We eventually want to have the same behaviour on both | 3042 // is not the case here. We eventually want to have the same behaviour on both |
| 3040 // sides but it may become a non issue if we get rid of scroll chaining (see | 3043 // sides but it may become a non issue if we get rid of scroll chaining (see |
| 3041 // crbug.com/526462) | 3044 // crbug.com/526462) |
| 3042 std::list<const ScrollNode*> current_scroll_chain; | 3045 std::list<const ScrollNode*> current_scroll_chain; |
| 3043 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; | 3046 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; |
| 3044 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); | 3047 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); |
| 3048 ScrollNode* viewport_scroll_node = |
| 3049 viewport()->MainScrollLayer() |
| 3050 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index()) |
| 3051 : nullptr; |
| 3045 if (scroll_node) { | 3052 if (scroll_node) { |
| 3053 // TODO(bokan): The loop checks for a null parent but don't we still want to |
| 3054 // distribute to the root scroll node? |
| 3046 for (; scroll_tree.parent(scroll_node); | 3055 for (; scroll_tree.parent(scroll_node); |
| 3047 scroll_node = scroll_tree.parent(scroll_node)) { | 3056 scroll_node = scroll_tree.parent(scroll_node)) { |
| 3048 if (scroll_node->is_outer_viewport_scroll_layer) { | 3057 if (scroll_node == viewport_scroll_node) { |
| 3049 // TODO(bokan): This should use Viewport::MainScrollLayer once that | |
| 3050 // returns the outer viewport scroll layer. | |
| 3051 // Don't chain scrolls past the outer viewport scroll layer. Once we | 3058 // Don't chain scrolls past the outer viewport scroll layer. Once we |
| 3052 // reach that, we should scroll the viewport which is represented by the | 3059 // reach that, we should scroll the viewport which is represented by the |
| 3053 // main viewport scroll layer. | 3060 // main viewport scroll layer. |
| 3054 DCHECK(viewport()->MainScrollLayer()); | |
| 3055 ScrollNode* viewport_scroll_node = scroll_tree.Node( | |
| 3056 viewport()->MainScrollLayer()->scroll_tree_index()); | |
| 3057 DCHECK(viewport_scroll_node); | 3061 DCHECK(viewport_scroll_node); |
| 3058 current_scroll_chain.push_front(viewport_scroll_node); | 3062 current_scroll_chain.push_front(viewport_scroll_node); |
| 3059 break; | 3063 break; |
| 3060 } | 3064 } |
| 3061 | 3065 |
| 3062 if (!scroll_node->scrollable) | 3066 if (!scroll_node->scrollable) |
| 3063 continue; | 3067 continue; |
| 3064 | 3068 |
| 3065 current_scroll_chain.push_front(scroll_node); | 3069 current_scroll_chain.push_front(scroll_node); |
| 3066 } | 3070 } |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3244 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 3248 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 3245 HandleMouseOverScrollbar(layer_impl); | 3249 HandleMouseOverScrollbar(layer_impl); |
| 3246 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) | 3250 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) |
| 3247 return; | 3251 return; |
| 3248 | 3252 |
| 3249 bool scroll_on_main_thread = false; | 3253 bool scroll_on_main_thread = false; |
| 3250 uint32_t main_thread_scrolling_reasons; | 3254 uint32_t main_thread_scrolling_reasons; |
| 3251 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 3255 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 3252 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, | 3256 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, |
| 3253 &scroll_on_main_thread, &main_thread_scrolling_reasons); | 3257 &scroll_on_main_thread, &main_thread_scrolling_reasons); |
| 3258 |
| 3254 // Scrollbars for the viewport are registered with the outer viewport layer. | 3259 // Scrollbars for the viewport are registered with the outer viewport layer. |
| 3255 if (scroll_layer_impl == InnerViewportScrollLayer()) | 3260 if (scroll_layer_impl == InnerViewportScrollLayer()) |
| 3256 scroll_layer_impl = OuterViewportScrollLayer(); | 3261 scroll_layer_impl = OuterViewportScrollLayer(); |
| 3262 |
| 3257 if (scroll_on_main_thread || !scroll_layer_impl) | 3263 if (scroll_on_main_thread || !scroll_layer_impl) |
| 3258 return; | 3264 return; |
| 3259 | 3265 |
| 3260 ScrollbarAnimationController* animation_controller = | 3266 ScrollbarAnimationController* animation_controller = |
| 3261 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); | 3267 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); |
| 3262 if (!animation_controller) | 3268 if (!animation_controller) |
| 3263 return; | 3269 return; |
| 3264 | 3270 |
| 3265 float distance_to_scrollbar = std::numeric_limits<float>::max(); | 3271 float distance_to_scrollbar = std::numeric_limits<float>::max(); |
| 3266 for (ScrollbarLayerImplBase* scrollbar : | 3272 for (ScrollbarLayerImplBase* scrollbar : |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4089 if (is_visible) { | 4095 if (is_visible) { |
| 4090 worker_context_visibility_ = | 4096 worker_context_visibility_ = |
| 4091 worker_context->CacheController()->ClientBecameVisible(); | 4097 worker_context->CacheController()->ClientBecameVisible(); |
| 4092 } else { | 4098 } else { |
| 4093 worker_context->CacheController()->ClientBecameNotVisible( | 4099 worker_context->CacheController()->ClientBecameNotVisible( |
| 4094 std::move(worker_context_visibility_)); | 4100 std::move(worker_context_visibility_)); |
| 4095 } | 4101 } |
| 4096 } | 4102 } |
| 4097 | 4103 |
| 4098 } // namespace cc | 4104 } // namespace cc |
| OLD | NEW |