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_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 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1651 | 1651 |
| 1652 // Collect all resource ids in the render passes into a single array. | 1652 // Collect all resource ids in the render passes into a single array. |
| 1653 ResourceProvider::ResourceIdArray resources; | 1653 ResourceProvider::ResourceIdArray resources; |
| 1654 for (const auto& render_pass : frame->render_passes) { | 1654 for (const auto& render_pass : frame->render_passes) { |
| 1655 for (auto* quad : render_pass->quad_list) { | 1655 for (auto* quad : render_pass->quad_list) { |
| 1656 for (ResourceId resource_id : quad->resources) | 1656 for (ResourceId resource_id : quad->resources) |
| 1657 resources.push_back(resource_id); | 1657 resources.push_back(resource_id); |
| 1658 } | 1658 } |
| 1659 } | 1659 } |
| 1660 | 1660 |
| 1661 | |
| 1662 CompositorFrame compositor_frame; | 1661 CompositorFrame compositor_frame; |
| 1663 compositor_frame.metadata = std::move(metadata); | 1662 compositor_frame.metadata = std::move(metadata); |
| 1664 resource_provider_->PrepareSendToParent(resources, | 1663 resource_provider_->PrepareSendToParent(resources, |
| 1665 &compositor_frame.resource_list); | 1664 &compositor_frame.resource_list); |
| 1666 compositor_frame.render_pass_list = std::move(frame->render_passes); | 1665 compositor_frame.render_pass_list = std::move(frame->render_passes); |
| 1667 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame)); | 1666 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame)); |
| 1668 | 1667 |
| 1669 // Clears the list of swap promises after calling DidSwap on each of them to | 1668 // Clears the list of swap promises after calling DidSwap on each of them to |
| 1670 // signal that the swap is over. | 1669 // signal that the swap is over. |
| 1671 active_tree()->ClearSwapPromises(); | 1670 active_tree()->ClearSwapPromises(); |
| (...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3226 } | 3225 } |
| 3227 | 3226 |
| 3228 void LayerTreeHostImpl::MouseUp() { | 3227 void LayerTreeHostImpl::MouseUp() { |
| 3229 ScrollbarAnimationController* animation_controller = | 3228 ScrollbarAnimationController* animation_controller = |
| 3230 ScrollbarAnimationControllerForId(scroll_layer_id_mouse_currently_over_); | 3229 ScrollbarAnimationControllerForId(scroll_layer_id_mouse_currently_over_); |
| 3231 if (animation_controller) | 3230 if (animation_controller) |
| 3232 animation_controller->DidMouseUp(); | 3231 animation_controller->DidMouseUp(); |
| 3233 } | 3232 } |
| 3234 | 3233 |
| 3235 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { | 3234 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { |
| 3236 float distance_to_scrollbar = std::numeric_limits<float>::max(); | |
| 3237 gfx::PointF device_viewport_point = gfx::ScalePoint( | 3235 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 3238 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 3236 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 3239 LayerImpl* layer_impl = | 3237 LayerImpl* layer_impl = |
| 3240 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 3238 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 3241 | 3239 |
| 3242 // Check if mouse is over a scrollbar or not. | 3240 // Check if mouse is over a scrollbar or not. |
| 3243 // TODO(sahel): get rid of this extera checking when | 3241 // TODO(sahel): get rid of this extera checking when |
| 3244 // FindScrollLayerForDeviceViewportPoint finds the proper layer for | 3242 // FindScrollLayerForDeviceViewportPoint finds the proper layer for |
| 3245 // scrolling on main thread, as well. | 3243 // scrolling on main thread, as well. |
| 3246 int new_id = Layer::INVALID_ID; | 3244 int new_id = Layer::INVALID_ID; |
| 3247 if (layer_impl && layer_impl->ToScrollbarLayer()) | 3245 if (layer_impl && layer_impl->ToScrollbarLayer()) |
| 3248 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); | 3246 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); |
| 3249 if (new_id != Layer::INVALID_ID) { | 3247 if (new_id == Layer::INVALID_ID) { |
| 3250 // Mouse over a scrollbar. | |
| 3251 distance_to_scrollbar = 0; | |
| 3252 } else { | |
| 3253 bool scroll_on_main_thread = false; | 3248 bool scroll_on_main_thread = false; |
| 3254 uint32_t main_thread_scrolling_reasons; | 3249 uint32_t main_thread_scrolling_reasons; |
| 3255 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 3250 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
|
bokan
2017/01/06 20:17:57
While trying your patch out, I noticed scroll_laye
| |
| 3256 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, | 3251 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, |
| 3257 &scroll_on_main_thread, &main_thread_scrolling_reasons); | 3252 &scroll_on_main_thread, &main_thread_scrolling_reasons); |
| 3258 | 3253 |
| 3259 // Scrollbars for the viewport are registered with the outer viewport layer. | 3254 // Scrollbars for the viewport are registered with the outer viewport layer. |
| 3260 if (scroll_layer_impl == InnerViewportScrollLayer()) | 3255 if (scroll_layer_impl == InnerViewportScrollLayer()) |
| 3261 scroll_layer_impl = OuterViewportScrollLayer(); | 3256 scroll_layer_impl = OuterViewportScrollLayer(); |
| 3262 | 3257 |
| 3263 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID; | 3258 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID; |
| 3264 } | 3259 } |
| 3265 | 3260 |
| 3266 if (new_id != scroll_layer_id_mouse_currently_over_) { | 3261 if (new_id != scroll_layer_id_mouse_currently_over_) { |
| 3267 ScrollbarAnimationController* old_animation_controller = | 3262 ScrollbarAnimationController* old_animation_controller = |
| 3268 ScrollbarAnimationControllerForId( | 3263 ScrollbarAnimationControllerForId( |
| 3269 scroll_layer_id_mouse_currently_over_); | 3264 scroll_layer_id_mouse_currently_over_); |
| 3270 if (old_animation_controller) { | 3265 if (old_animation_controller) { |
| 3271 old_animation_controller->DidMouseLeave(); | 3266 old_animation_controller->DidMouseLeave(); |
| 3272 } | 3267 } |
| 3273 scroll_layer_id_mouse_currently_over_ = new_id; | 3268 scroll_layer_id_mouse_currently_over_ = new_id; |
| 3274 } | 3269 } |
| 3275 | 3270 |
| 3276 ScrollbarAnimationController* new_animation_controller = | 3271 ScrollbarAnimationController* new_animation_controller = |
| 3277 ScrollbarAnimationControllerForId(new_id); | 3272 ScrollbarAnimationControllerForId(new_id); |
| 3278 if (!new_animation_controller) | 3273 if (!new_animation_controller) |
| 3279 return; | 3274 return; |
| 3280 | 3275 |
| 3281 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) | 3276 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) { |
| 3282 distance_to_scrollbar = | 3277 new_animation_controller->DidMouseMoveNear( |
| 3283 std::min(distance_to_scrollbar, | 3278 scrollbar->orientation(), |
| 3284 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); | 3279 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / |
| 3285 new_animation_controller->DidMouseMoveNear( | 3280 active_tree_->device_scale_factor()); |
| 3286 distance_to_scrollbar / active_tree_->device_scale_factor()); | 3281 } |
| 3287 } | 3282 } |
| 3288 | 3283 |
| 3289 void LayerTreeHostImpl::MouseLeave() { | 3284 void LayerTreeHostImpl::MouseLeave() { |
| 3290 for (auto& pair : scrollbar_animation_controllers_) | 3285 for (auto& pair : scrollbar_animation_controllers_) |
| 3291 pair.second->DidMouseLeave(); | 3286 pair.second->DidMouseLeave(); |
| 3292 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID; | 3287 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID; |
| 3293 } | 3288 } |
| 3294 | 3289 |
| 3295 void LayerTreeHostImpl::PinchGestureBegin() { | 3290 void LayerTreeHostImpl::PinchGestureBegin() { |
| 3296 pinch_gesture_active_ = true; | 3291 pinch_gesture_active_ = true; |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4088 worker_context_visibility_ = | 4083 worker_context_visibility_ = |
| 4089 worker_context->CacheController()->ClientBecameVisible(); | 4084 worker_context->CacheController()->ClientBecameVisible(); |
| 4090 } else { | 4085 } else { |
| 4091 worker_context->CacheController()->ClientBecameNotVisible( | 4086 worker_context->CacheController()->ClientBecameNotVisible( |
| 4092 std::move(worker_context_visibility_)); | 4087 std::move(worker_context_visibility_)); |
| 4093 } | 4088 } |
| 4094 } | 4089 } |
| 4095 } | 4090 } |
| 4096 | 4091 |
| 4097 } // namespace cc | 4092 } // namespace cc |
| OLD | NEW |