| 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(); | 3232 std::vector<ScrollbarAnimationController::DistanceToScrollbar> |
| 3233 distance_to_scrollbars; |
| 3234 gfx::PointF device_viewport_point = gfx::ScalePoint( | 3234 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 3235 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 3235 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 3236 LayerImpl* layer_impl = | 3236 LayerImpl* layer_impl = |
| 3237 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 3237 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
| 3238 | 3238 |
| 3239 // Check if mouse is over a scrollbar or not. | 3239 // Check if mouse is over a scrollbar or not. |
| 3240 // TODO(sahel): get rid of this extera checking when | 3240 // TODO(sahel): get rid of this extera checking when |
| 3241 // FindScrollLayerForDeviceViewportPoint finds the proper layer for | 3241 // FindScrollLayerForDeviceViewportPoint finds the proper layer for |
| 3242 // scrolling on main thread, as well. | 3242 // scrolling on main thread, as well. |
| 3243 int new_id = Layer::INVALID_ID; | 3243 int new_id = Layer::INVALID_ID; |
| 3244 if (layer_impl && layer_impl->ToScrollbarLayer()) | 3244 if (layer_impl && layer_impl->ToScrollbarLayer()) |
| 3245 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); | 3245 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); |
| 3246 if (new_id != Layer::INVALID_ID) { | 3246 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; | 3247 bool scroll_on_main_thread = false; |
| 3251 uint32_t main_thread_scrolling_reasons; | 3248 uint32_t main_thread_scrolling_reasons; |
| 3252 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 3249 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 3253 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, | 3250 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, |
| 3254 &scroll_on_main_thread, &main_thread_scrolling_reasons); | 3251 &scroll_on_main_thread, &main_thread_scrolling_reasons); |
| 3255 | 3252 |
| 3256 // Scrollbars for the viewport are registered with the outer viewport layer. | 3253 // Scrollbars for the viewport are registered with the outer viewport layer. |
| 3257 if (scroll_layer_impl == InnerViewportScrollLayer()) | 3254 if (scroll_layer_impl == InnerViewportScrollLayer()) |
| 3258 scroll_layer_impl = OuterViewportScrollLayer(); | 3255 scroll_layer_impl = OuterViewportScrollLayer(); |
| 3259 | 3256 |
| 3260 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID; | 3257 new_id = scroll_layer_impl ? scroll_layer_impl->id() : Layer::INVALID_ID; |
| 3261 } | 3258 } |
| 3262 | 3259 |
| 3263 if (new_id != scroll_layer_id_mouse_currently_over_) { | 3260 if (new_id != scroll_layer_id_mouse_currently_over_) { |
| 3264 ScrollbarAnimationController* old_animation_controller = | 3261 ScrollbarAnimationController* old_animation_controller = |
| 3265 ScrollbarAnimationControllerForId( | 3262 ScrollbarAnimationControllerForId( |
| 3266 scroll_layer_id_mouse_currently_over_); | 3263 scroll_layer_id_mouse_currently_over_); |
| 3267 if (old_animation_controller) { | 3264 if (old_animation_controller) { |
| 3268 old_animation_controller->DidMouseLeave(); | 3265 old_animation_controller->DidMouseLeave(); |
| 3269 } | 3266 } |
| 3270 scroll_layer_id_mouse_currently_over_ = new_id; | 3267 scroll_layer_id_mouse_currently_over_ = new_id; |
| 3271 } | 3268 } |
| 3272 | 3269 |
| 3273 ScrollbarAnimationController* new_animation_controller = | 3270 ScrollbarAnimationController* new_animation_controller = |
| 3274 ScrollbarAnimationControllerForId(new_id); | 3271 ScrollbarAnimationControllerForId(new_id); |
| 3275 if (!new_animation_controller) | 3272 if (!new_animation_controller) |
| 3276 return; | 3273 return; |
| 3277 | 3274 |
| 3278 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) | 3275 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(new_id)) { |
| 3279 distance_to_scrollbar = | 3276 distance_to_scrollbars.push_back( |
| 3280 std::min(distance_to_scrollbar, | 3277 {scrollbar->orientation(), |
| 3281 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); | 3278 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / |
| 3282 new_animation_controller->DidMouseMoveNear( | 3279 active_tree_->device_scale_factor()}); |
| 3283 distance_to_scrollbar / active_tree_->device_scale_factor()); | 3280 } |
| 3281 new_animation_controller->DidMouseMoveNear(distance_to_scrollbars); |
| 3284 } | 3282 } |
| 3285 | 3283 |
| 3286 void LayerTreeHostImpl::MouseLeave() { | 3284 void LayerTreeHostImpl::MouseLeave() { |
| 3287 for (auto& pair : scrollbar_animation_controllers_) | 3285 for (auto& pair : scrollbar_animation_controllers_) |
| 3288 pair.second->DidMouseLeave(); | 3286 pair.second->DidMouseLeave(); |
| 3289 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID; | 3287 scroll_layer_id_mouse_currently_over_ = Layer::INVALID_ID; |
| 3290 } | 3288 } |
| 3291 | 3289 |
| 3292 void LayerTreeHostImpl::PinchGestureBegin() { | 3290 void LayerTreeHostImpl::PinchGestureBegin() { |
| 3293 pinch_gesture_active_ = true; | 3291 pinch_gesture_active_ = true; |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4085 worker_context_visibility_ = | 4083 worker_context_visibility_ = |
| 4086 worker_context->CacheController()->ClientBecameVisible(); | 4084 worker_context->CacheController()->ClientBecameVisible(); |
| 4087 } else { | 4085 } else { |
| 4088 worker_context->CacheController()->ClientBecameNotVisible( | 4086 worker_context->CacheController()->ClientBecameNotVisible( |
| 4089 std::move(worker_context_visibility_)); | 4087 std::move(worker_context_visibility_)); |
| 4090 } | 4088 } |
| 4091 } | 4089 } |
| 4092 } | 4090 } |
| 4093 | 4091 |
| 4094 } // namespace cc | 4092 } // namespace cc |
| OLD | NEW |