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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 input_handler_client_ = client; | 1974 input_handler_client_ = client; |
1975 } | 1975 } |
1976 | 1976 |
1977 static LayerImpl* NextScrollLayer(LayerImpl* layer) { | 1977 static LayerImpl* NextScrollLayer(LayerImpl* layer) { |
1978 if (LayerImpl* scroll_parent = layer->scroll_parent()) | 1978 if (LayerImpl* scroll_parent = layer->scroll_parent()) |
1979 return scroll_parent; | 1979 return scroll_parent; |
1980 return layer->parent(); | 1980 return layer->parent(); |
1981 } | 1981 } |
1982 | 1982 |
1983 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( | 1983 LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( |
1984 gfx::PointF device_viewport_point, InputHandler::ScrollInputType type, | 1984 const gfx::PointF& device_viewport_point, |
| 1985 InputHandler::ScrollInputType type, |
1985 LayerImpl* layer_impl, bool* scroll_on_main_thread) const { | 1986 LayerImpl* layer_impl, bool* scroll_on_main_thread) const { |
1986 DCHECK(scroll_on_main_thread); | 1987 DCHECK(scroll_on_main_thread); |
1987 | 1988 |
1988 // Walk up the hierarchy and look for a scrollable layer. | 1989 // Walk up the hierarchy and look for a scrollable layer. |
1989 LayerImpl* potentially_scrolling_layer_impl = 0; | 1990 LayerImpl* potentially_scrolling_layer_impl = 0; |
1990 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { | 1991 for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { |
1991 // The content layer can also block attempts to scroll outside the main | 1992 // The content layer can also block attempts to scroll outside the main |
1992 // thread. | 1993 // thread. |
1993 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); | 1994 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); |
1994 if (status == ScrollOnMainThread) { | 1995 if (status == ScrollOnMainThread) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 client_->RenewTreePriority(); | 2054 client_->RenewTreePriority(); |
2054 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 2055 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
2055 return ScrollStarted; | 2056 return ScrollStarted; |
2056 } | 2057 } |
2057 return ScrollIgnored; | 2058 return ScrollIgnored; |
2058 } | 2059 } |
2059 | 2060 |
2060 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( | 2061 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( |
2061 LayerImpl* layer_impl, | 2062 LayerImpl* layer_impl, |
2062 float scale_from_viewport_to_screen_space, | 2063 float scale_from_viewport_to_screen_space, |
2063 gfx::PointF viewport_point, | 2064 const gfx::PointF& viewport_point, |
2064 gfx::Vector2dF viewport_delta) { | 2065 gfx::Vector2dF viewport_delta) { |
2065 // Layers with non-invertible screen space transforms should not have passed | 2066 // Layers with non-invertible screen space transforms should not have passed |
2066 // the scroll hit test in the first place. | 2067 // the scroll hit test in the first place. |
2067 DCHECK(layer_impl->screen_space_transform().IsInvertible()); | 2068 DCHECK(layer_impl->screen_space_transform().IsInvertible()); |
2068 gfx::Transform inverse_screen_space_transform( | 2069 gfx::Transform inverse_screen_space_transform( |
2069 gfx::Transform::kSkipInitialization); | 2070 gfx::Transform::kSkipInitialization); |
2070 bool did_invert = layer_impl->screen_space_transform().GetInverse( | 2071 bool did_invert = layer_impl->screen_space_transform().GetInverse( |
2071 &inverse_screen_space_transform); | 2072 &inverse_screen_space_transform); |
2072 // TODO(shawnsingh): With the advent of impl-side crolling for non-root | 2073 // TODO(shawnsingh): With the advent of impl-side crolling for non-root |
2073 // layers, we may need to explicitly handle uninvertible transforms here. | 2074 // layers, we may need to explicitly handle uninvertible transforms here. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2340 } | 2341 } |
2341 | 2342 |
2342 return ScrollStarted; | 2343 return ScrollStarted; |
2343 } | 2344 } |
2344 | 2345 |
2345 void LayerTreeHostImpl::NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) { | 2346 void LayerTreeHostImpl::NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) { |
2346 current_fling_velocity_ = velocity; | 2347 current_fling_velocity_ = velocity; |
2347 } | 2348 } |
2348 | 2349 |
2349 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( | 2350 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( |
2350 gfx::PointF device_viewport_point, | 2351 const gfx::PointF& device_viewport_point, |
2351 LayerImpl* layer_impl) { | 2352 LayerImpl* layer_impl) { |
2352 if (!layer_impl) | 2353 if (!layer_impl) |
2353 return std::numeric_limits<float>::max(); | 2354 return std::numeric_limits<float>::max(); |
2354 | 2355 |
2355 gfx::Rect layer_impl_bounds( | 2356 gfx::Rect layer_impl_bounds( |
2356 layer_impl->content_bounds()); | 2357 layer_impl->content_bounds()); |
2357 | 2358 |
2358 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( | 2359 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( |
2359 layer_impl->screen_space_transform(), | 2360 layer_impl->screen_space_transform(), |
2360 layer_impl_bounds); | 2361 layer_impl_bounds); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2408 DeviceSpaceDistanceToLayer(device_viewport_point, | 2409 DeviceSpaceDistanceToLayer(device_viewport_point, |
2409 scroll_layer_impl->vertical_scrollbar_layer())); | 2410 scroll_layer_impl->vertical_scrollbar_layer())); |
2410 | 2411 |
2411 bool should_animate = animation_controller->DidMouseMoveNear( | 2412 bool should_animate = animation_controller->DidMouseMoveNear( |
2412 CurrentPhysicalTimeTicks(), distance_to_scrollbar / device_scale_factor_); | 2413 CurrentPhysicalTimeTicks(), distance_to_scrollbar / device_scale_factor_); |
2413 if (should_animate) | 2414 if (should_animate) |
2414 StartScrollbarAnimation(); | 2415 StartScrollbarAnimation(); |
2415 } | 2416 } |
2416 | 2417 |
2417 bool LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl, | 2418 bool LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl, |
2418 gfx::PointF device_viewport_point) { | 2419 const gfx::PointF& device_viewport_point) { |
2419 if (layer_impl && layer_impl->ToScrollbarLayer()) { | 2420 if (layer_impl && layer_impl->ToScrollbarLayer()) { |
2420 int scroll_layer_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); | 2421 int scroll_layer_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); |
2421 layer_impl = active_tree_->LayerById(scroll_layer_id); | 2422 layer_impl = active_tree_->LayerById(scroll_layer_id); |
2422 if (layer_impl && layer_impl->scrollbar_animation_controller()) { | 2423 if (layer_impl && layer_impl->scrollbar_animation_controller()) { |
2423 scroll_layer_id_when_mouse_over_scrollbar_ = scroll_layer_id; | 2424 scroll_layer_id_when_mouse_over_scrollbar_ = scroll_layer_id; |
2424 bool should_animate = | 2425 bool should_animate = |
2425 layer_impl->scrollbar_animation_controller()->DidMouseMoveNear( | 2426 layer_impl->scrollbar_animation_controller()->DidMouseMoveNear( |
2426 CurrentPhysicalTimeTicks(), 0); | 2427 CurrentPhysicalTimeTicks(), 0); |
2427 if (should_animate) | 2428 if (should_animate) |
2428 StartScrollbarAnimation(); | 2429 StartScrollbarAnimation(); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2908 swap_promise_monitor_.erase(monitor); | 2909 swap_promise_monitor_.erase(monitor); |
2909 } | 2910 } |
2910 | 2911 |
2911 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 2912 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |
2912 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 2913 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |
2913 for (; it != swap_promise_monitor_.end(); it++) | 2914 for (; it != swap_promise_monitor_.end(); it++) |
2914 (*it)->OnSetNeedsRedrawOnImpl(); | 2915 (*it)->OnSetNeedsRedrawOnImpl(); |
2915 } | 2916 } |
2916 | 2917 |
2917 } // namespace cc | 2918 } // namespace cc |
OLD | NEW |