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 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1653 | 1653 |
| 1654 // Collect all resource ids in the render passes into a single array. | 1654 // Collect all resource ids in the render passes into a single array. |
| 1655 ResourceProvider::ResourceIdArray resources; | 1655 ResourceProvider::ResourceIdArray resources; |
| 1656 for (const auto& render_pass : frame->render_passes) { | 1656 for (const auto& render_pass : frame->render_passes) { |
| 1657 for (auto* quad : render_pass->quad_list) { | 1657 for (auto* quad : render_pass->quad_list) { |
| 1658 for (ResourceId resource_id : quad->resources) | 1658 for (ResourceId resource_id : quad->resources) |
| 1659 resources.push_back(resource_id); | 1659 resources.push_back(resource_id); |
| 1660 } | 1660 } |
| 1661 } | 1661 } |
| 1662 | 1662 |
| 1663 | |
| 1664 CompositorFrame compositor_frame; | 1663 CompositorFrame compositor_frame; |
| 1665 compositor_frame.metadata = std::move(metadata); | 1664 compositor_frame.metadata = std::move(metadata); |
| 1666 resource_provider_->PrepareSendToParent(resources, | 1665 resource_provider_->PrepareSendToParent(resources, |
| 1667 &compositor_frame.resource_list); | 1666 &compositor_frame.resource_list); |
| 1668 compositor_frame.render_pass_list = std::move(frame->render_passes); | 1667 compositor_frame.render_pass_list = std::move(frame->render_passes); |
| 1669 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame)); | 1668 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame)); |
| 1670 | 1669 |
| 1671 // The next frame should start by assuming nothing has changed, and changes | 1670 // The next frame should start by assuming nothing has changed, and changes |
| 1672 // are noted as they occur. | 1671 // are noted as they occur. |
| 1673 // TODO(boliu): If we did a temporary software renderer frame, propogate the | 1672 // TODO(boliu): If we did a temporary software renderer frame, propogate the |
| (...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3223 } | 3222 } |
| 3224 | 3223 |
| 3225 void LayerTreeHostImpl::MouseUp() { | 3224 void LayerTreeHostImpl::MouseUp() { |
| 3226 ScrollbarAnimationController* animation_controller = | 3225 ScrollbarAnimationController* animation_controller = |
| 3227 ScrollbarAnimationControllerForId(scroll_layer_id_mouse_currently_over_); | 3226 ScrollbarAnimationControllerForId(scroll_layer_id_mouse_currently_over_); |
| 3228 if (animation_controller) | 3227 if (animation_controller) |
| 3229 animation_controller->DidMouseUp(); | 3228 animation_controller->DidMouseUp(); |
| 3230 } | 3229 } |
| 3231 | 3230 |
| 3232 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { | 3231 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { |
| 3233 float distance_to_scrollbar = std::numeric_limits<float>::max(); | |
| 3234 gfx::PointF device_viewport_point = gfx::ScalePoint( | 3232 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 3235 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 3233 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 3236 LayerImpl* layer_impl = | 3234 LayerImpl* layer_impl = |
| 3237 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 3235 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 3238 | 3236 |
| 3239 // Check if mouse is over a scrollbar or not. | 3237 // Check if mouse is over a scrollbar or not. |
| 3240 // TODO(sahel): get rid of this extera checking when | 3238 // TODO(sahel): get rid of this extera checking when |
| 3241 // FindScrollLayerForDeviceViewportPoint finds the proper layer for | 3239 // FindScrollLayerForDeviceViewportPoint finds the proper layer for |
| 3242 // scrolling on main thread, as well. | 3240 // scrolling on main thread, as well. |
| 3243 int new_id = Layer::INVALID_ID; | 3241 int new_id = Layer::INVALID_ID; |
| 3244 if (layer_impl && layer_impl->ToScrollbarLayer()) | 3242 if (layer_impl && layer_impl->ToScrollbarLayer()) |
| 3245 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); | 3243 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); |
| 3246 if (new_id != Layer::INVALID_ID) { | 3244 if (new_id == Layer::INVALID_ID) { |
| 3247 // Mouse over a scrollbar. | |
| 3248 distance_to_scrollbar = 0; | |
| 3249 } else { | |
| 3250 bool scroll_on_main_thread = false; | 3245 bool scroll_on_main_thread = false; |
| 3251 uint32_t main_thread_scrolling_reasons; | 3246 uint32_t main_thread_scrolling_reasons; |
| 3252 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 3247 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 3253 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, | 3248 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, |
| 3254 &scroll_on_main_thread, &main_thread_scrolling_reasons); | 3249 &scroll_on_main_thread, &main_thread_scrolling_reasons); |
| 3255 | 3250 |
| 3256 // Scrollbars for the viewport are registered with the outer viewport layer. | 3251 // Scrollbars for the viewport are registered with the outer viewport layer. |
| 3257 if (scroll_layer_impl == InnerViewportScrollLayer()) | 3252 if (scroll_layer_impl == InnerViewportScrollLayer()) |
| 3258 scroll_layer_impl = OuterViewportScrollLayer(); | 3253 scroll_layer_impl = OuterViewportScrollLayer(); |
| 3259 | 3254 |
| 3260 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID; | 3255 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID; |
| 3261 } | 3256 } |
| 3262 | 3257 |
| 3263 if (new_id != scroll_layer_id_mouse_currently_over_) { | 3258 if (new_id != scroll_layer_id_mouse_currently_over_) { |
| 3264 ScrollbarAnimationController* old_animation_controller = | 3259 ScrollbarAnimationController* old_animation_controller = |
| 3265 ScrollbarAnimationControllerForId( | 3260 ScrollbarAnimationControllerForId( |
| 3266 scroll_layer_id_mouse_currently_over_); | 3261 scroll_layer_id_mouse_currently_over_); |
| 3267 if (old_animation_controller) { | 3262 if (old_animation_controller) { |
| 3268 old_animation_controller->DidMouseLeave(); | 3263 old_animation_controller->DidMouseLeave(); |
| 3269 } | 3264 } |
| 3270 scroll_layer_id_mouse_currently_over_ = new_id; | 3265 scroll_layer_id_mouse_currently_over_ = new_id; |
| 3271 } | 3266 } |
| 3272 | 3267 |
| 3273 ScrollbarAnimationController* new_animation_controller = | 3268 ScrollbarAnimationController* new_animation_controller = |
| 3274 ScrollbarAnimationControllerForId(new_id); | 3269 ScrollbarAnimationControllerForId(new_id); |
| 3275 if (!new_animation_controller) | 3270 if (!new_animation_controller) |
| 3276 return; | 3271 return; |
| 3277 | 3272 |
| 3278 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) | 3273 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) { |
| 3279 distance_to_scrollbar = | 3274 new_animation_controller->DidMouseMoveNear( |
| 3280 std::min(distance_to_scrollbar, | 3275 scrollbar->orientation(), |
| 3281 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); | 3276 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / |
|
bokan
2016/12/08 19:34:07
Will this return 0 if the mouse is over the scroll
chaopeng
2016/12/15 23:54:26
Yes
| |
| 3282 new_animation_controller->DidMouseMoveNear( | 3277 active_tree_->device_scale_factor()); |
| 3283 distance_to_scrollbar / active_tree_->device_scale_factor()); | 3278 } |
| 3284 } | 3279 } |
| 3285 | 3280 |
| 3286 void LayerTreeHostImpl::MouseLeave() { | 3281 void LayerTreeHostImpl::MouseLeave() { |
| 3287 for (auto& pair : scrollbar_animation_controllers_) | 3282 for (auto& pair : scrollbar_animation_controllers_) |
| 3288 pair.second->DidMouseLeave(); | 3283 pair.second->DidMouseLeave(); |
| 3289 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID; | 3284 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID; |
| 3290 } | 3285 } |
| 3291 | 3286 |
| 3292 void LayerTreeHostImpl::PinchGestureBegin() { | 3287 void LayerTreeHostImpl::PinchGestureBegin() { |
| 3293 pinch_gesture_active_ = true; | 3288 pinch_gesture_active_ = true; |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4085 worker_context_visibility_ = | 4080 worker_context_visibility_ = |
| 4086 worker_context->CacheController()->ClientBecameVisible(); | 4081 worker_context->CacheController()->ClientBecameVisible(); |
| 4087 } else { | 4082 } else { |
| 4088 worker_context->CacheController()->ClientBecameNotVisible( | 4083 worker_context->CacheController()->ClientBecameNotVisible( |
| 4089 std::move(worker_context_visibility_)); | 4084 std::move(worker_context_visibility_)); |
| 4090 } | 4085 } |
| 4091 } | 4086 } |
| 4092 } | 4087 } |
| 4093 | 4088 |
| 4094 } // namespace cc | 4089 } // namespace cc |
| OLD | NEW |