| 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 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2062     UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |  2062     UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 
|  2063     return ScrollStarted; |  2063     return ScrollStarted; | 
|  2064   } |  2064   } | 
|  2065   return ScrollIgnored; |  2065   return ScrollIgnored; | 
|  2066 } |  2066 } | 
|  2067  |  2067  | 
|  2068 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( |  2068 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( | 
|  2069     LayerImpl* layer_impl, |  2069     LayerImpl* layer_impl, | 
|  2070     float scale_from_viewport_to_screen_space, |  2070     float scale_from_viewport_to_screen_space, | 
|  2071     const gfx::PointF& viewport_point, |  2071     const gfx::PointF& viewport_point, | 
|  2072     gfx::Vector2dF viewport_delta) { |  2072     const gfx::Vector2dF& viewport_delta) { | 
|  2073   // Layers with non-invertible screen space transforms should not have passed |  2073   // Layers with non-invertible screen space transforms should not have passed | 
|  2074   // the scroll hit test in the first place. |  2074   // the scroll hit test in the first place. | 
|  2075   DCHECK(layer_impl->screen_space_transform().IsInvertible()); |  2075   DCHECK(layer_impl->screen_space_transform().IsInvertible()); | 
|  2076   gfx::Transform inverse_screen_space_transform( |  2076   gfx::Transform inverse_screen_space_transform( | 
|  2077       gfx::Transform::kSkipInitialization); |  2077       gfx::Transform::kSkipInitialization); | 
|  2078   bool did_invert = layer_impl->screen_space_transform().GetInverse( |  2078   bool did_invert = layer_impl->screen_space_transform().GetInverse( | 
|  2079       &inverse_screen_space_transform); |  2079       &inverse_screen_space_transform); | 
|  2080   // TODO(shawnsingh): With the advent of impl-side crolling for non-root |  2080   // TODO(shawnsingh): With the advent of impl-side crolling for non-root | 
|  2081   // layers, we may need to explicitly handle uninvertible transforms here. |  2081   // layers, we may need to explicitly handle uninvertible transforms here. | 
|  2082   DCHECK(did_invert); |  2082   DCHECK(did_invert); | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2135   DCHECK(!end_clipped); |  2135   DCHECK(!end_clipped); | 
|  2136   if (end_clipped) |  2136   if (end_clipped) | 
|  2137     return gfx::Vector2dF(); |  2137     return gfx::Vector2dF(); | 
|  2138   gfx::PointF actual_viewport_end_point = |  2138   gfx::PointF actual_viewport_end_point = | 
|  2139       gfx::ScalePoint(actual_screen_space_end_point, |  2139       gfx::ScalePoint(actual_screen_space_end_point, | 
|  2140                       1.f / scale_from_viewport_to_screen_space); |  2140                       1.f / scale_from_viewport_to_screen_space); | 
|  2141   return actual_viewport_end_point - viewport_point; |  2141   return actual_viewport_end_point - viewport_point; | 
|  2142 } |  2142 } | 
|  2143  |  2143  | 
|  2144 static gfx::Vector2dF ScrollLayerWithLocalDelta(LayerImpl* layer_impl, |  2144 static gfx::Vector2dF ScrollLayerWithLocalDelta(LayerImpl* layer_impl, | 
|  2145                                                 gfx::Vector2dF local_delta) { |  2145     const gfx::Vector2dF& local_delta) { | 
|  2146   gfx::Vector2dF previous_delta(layer_impl->ScrollDelta()); |  2146   gfx::Vector2dF previous_delta(layer_impl->ScrollDelta()); | 
|  2147   layer_impl->ScrollBy(local_delta); |  2147   layer_impl->ScrollBy(local_delta); | 
|  2148   return layer_impl->ScrollDelta() - previous_delta; |  2148   return layer_impl->ScrollDelta() - previous_delta; | 
|  2149 } |  2149 } | 
|  2150  |  2150  | 
|  2151 bool LayerTreeHostImpl::ScrollBy(gfx::Point viewport_point, |  2151 bool LayerTreeHostImpl::ScrollBy(gfx::Point viewport_point, | 
|  2152                                  gfx::Vector2dF scroll_delta) { |  2152                                  const gfx::Vector2dF& scroll_delta) { | 
|  2153   TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); |  2153   TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); | 
|  2154   if (!CurrentlyScrollingLayer()) |  2154   if (!CurrentlyScrollingLayer()) | 
|  2155     return false; |  2155     return false; | 
|  2156  |  2156  | 
|  2157   gfx::Vector2dF pending_delta = scroll_delta; |  2157   gfx::Vector2dF pending_delta = scroll_delta; | 
|  2158   gfx::Vector2dF unused_root_delta; |  2158   gfx::Vector2dF unused_root_delta; | 
|  2159   bool did_scroll_x = false; |  2159   bool did_scroll_x = false; | 
|  2160   bool did_scroll_y = false; |  2160   bool did_scroll_y = false; | 
|  2161   bool consume_by_top_controls = top_controls_manager_ && |  2161   bool consume_by_top_controls = top_controls_manager_ && | 
|  2162       (scroll_delta.y() < 0 || |  2162       (scroll_delta.y() < 0 || | 
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2343   if (!wheel_scrolling_) { |  2343   if (!wheel_scrolling_) { | 
|  2344     // Allow the fling to lock to the first layer that moves after the initial |  2344     // Allow the fling to lock to the first layer that moves after the initial | 
|  2345     // fling |ScrollBy()| event. |  2345     // fling |ScrollBy()| event. | 
|  2346     did_lock_scrolling_layer_ = false; |  2346     did_lock_scrolling_layer_ = false; | 
|  2347     should_bubble_scrolls_ = false; |  2347     should_bubble_scrolls_ = false; | 
|  2348   } |  2348   } | 
|  2349  |  2349  | 
|  2350   return ScrollStarted; |  2350   return ScrollStarted; | 
|  2351 } |  2351 } | 
|  2352  |  2352  | 
|  2353 void LayerTreeHostImpl::NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) { |  2353 void LayerTreeHostImpl::NotifyCurrentFlingVelocity( | 
 |  2354     const gfx::Vector2dF& velocity) { | 
|  2354   current_fling_velocity_ = velocity; |  2355   current_fling_velocity_ = velocity; | 
|  2355 } |  2356 } | 
|  2356  |  2357  | 
|  2357 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( |  2358 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( | 
|  2358     const gfx::PointF& device_viewport_point, |  2359     const gfx::PointF& device_viewport_point, | 
|  2359     LayerImpl* layer_impl) { |  2360     LayerImpl* layer_impl) { | 
|  2360   if (!layer_impl) |  2361   if (!layer_impl) | 
|  2361     return std::numeric_limits<float>::max(); |  2362     return std::numeric_limits<float>::max(); | 
|  2362  |  2363  | 
|  2363   gfx::Rect layer_impl_bounds( |  2364   gfx::Rect layer_impl_bounds( | 
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2921   swap_promise_monitor_.erase(monitor); |  2922   swap_promise_monitor_.erase(monitor); | 
|  2922 } |  2923 } | 
|  2923  |  2924  | 
|  2924 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { |  2925 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { | 
|  2925   std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); |  2926   std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); | 
|  2926   for (; it != swap_promise_monitor_.end(); it++) |  2927   for (; it != swap_promise_monitor_.end(); it++) | 
|  2927     (*it)->OnSetNeedsRedrawOnImpl(); |  2928     (*it)->OnSetNeedsRedrawOnImpl(); | 
|  2928 } |  2929 } | 
|  2929  |  2930  | 
|  2930 }  // namespace cc |  2931 }  // namespace cc | 
| OLD | NEW |