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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 // If we're making a frame to draw, it better have at least one render pass. | 858 // If we're making a frame to draw, it better have at least one render pass. |
859 DCHECK(!frame->render_passes.empty()); | 859 DCHECK(!frame->render_passes.empty()); |
860 | 860 |
861 // Should only have one render pass in resourceless software mode. | 861 // Should only have one render pass in resourceless software mode. |
862 if (output_surface_->ForcedDrawToSoftwareDevice()) | 862 if (output_surface_->ForcedDrawToSoftwareDevice()) |
863 DCHECK_EQ(1u, frame->render_passes.size()); | 863 DCHECK_EQ(1u, frame->render_passes.size()); |
864 | 864 |
865 return draw_frame; | 865 return draw_frame; |
866 } | 866 } |
867 | 867 |
868 void LayerTreeHostImpl::MainThreadHasStoppedFlinging() { | |
869 if (input_handler_client_) | |
870 input_handler_client_->MainThreadHasStoppedFlinging(); | |
871 } | |
872 | |
873 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( | 868 void LayerTreeHostImpl::UpdateBackgroundAnimateTicking( |
874 bool should_background_tick) { | 869 bool should_background_tick) { |
875 DCHECK(proxy_->IsImplThread()); | 870 DCHECK(proxy_->IsImplThread()); |
876 if (should_background_tick) | 871 if (should_background_tick) |
877 DCHECK(active_tree_->root_layer()); | 872 DCHECK(active_tree_->root_layer()); |
878 | 873 |
879 bool enabled = should_background_tick && | 874 bool enabled = should_background_tick && |
880 !animation_registrar_->active_animation_controllers().empty(); | 875 !animation_registrar_->active_animation_controllers().empty(); |
881 | 876 |
882 // Lazily create the time_source adapter so that we can vary the interval for | 877 // Lazily create the time_source adapter so that we can vary the interval for |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 | 1430 |
1436 LayerImpl* LayerTreeHostImpl::RootScrollLayer() const { | 1431 LayerImpl* LayerTreeHostImpl::RootScrollLayer() const { |
1437 return active_tree_->RootScrollLayer(); | 1432 return active_tree_->RootScrollLayer(); |
1438 } | 1433 } |
1439 | 1434 |
1440 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { | 1435 LayerImpl* LayerTreeHostImpl::CurrentlyScrollingLayer() const { |
1441 return active_tree_->CurrentlyScrollingLayer(); | 1436 return active_tree_->CurrentlyScrollingLayer(); |
1442 } | 1437 } |
1443 | 1438 |
1444 bool LayerTreeHostImpl::IsCurrentlyScrolling() const { | 1439 bool LayerTreeHostImpl::IsCurrentlyScrolling() const { |
1445 return CurrentlyScrollingLayer() || | 1440 return CurrentlyScrollingLayer(); |
1446 (RootScrollLayer() && RootScrollLayer()->IsExternalFlingActive()); | |
1447 } | 1441 } |
1448 | 1442 |
1449 // Content layers can be either directly scrollable or contained in an outer | 1443 // Content layers can be either directly scrollable or contained in an outer |
1450 // scrolling layer which applies the scroll transform. Given a content layer, | 1444 // scrolling layer which applies the scroll transform. Given a content layer, |
1451 // this function returns the associated scroll layer if any. | 1445 // this function returns the associated scroll layer if any. |
1452 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { | 1446 static LayerImpl* FindScrollLayerForContentLayer(LayerImpl* layer_impl) { |
1453 if (!layer_impl) | 1447 if (!layer_impl) |
1454 return NULL; | 1448 return NULL; |
1455 | 1449 |
1456 if (layer_impl->scrollable()) | 1450 if (layer_impl->scrollable()) |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2171 accumulated_root_overscroll_.set_x(0); | 2165 accumulated_root_overscroll_.set_x(0); |
2172 if (did_scroll_y) | 2166 if (did_scroll_y) |
2173 accumulated_root_overscroll_.set_y(0); | 2167 accumulated_root_overscroll_.set_y(0); |
2174 | 2168 |
2175 accumulated_root_overscroll_ += unused_root_delta; | 2169 accumulated_root_overscroll_ += unused_root_delta; |
2176 bool did_overscroll = !gfx::ToRoundedVector2d(unused_root_delta).IsZero(); | 2170 bool did_overscroll = !gfx::ToRoundedVector2d(unused_root_delta).IsZero(); |
2177 if (did_overscroll && input_handler_client_) { | 2171 if (did_overscroll && input_handler_client_) { |
2178 DidOverscrollParams params; | 2172 DidOverscrollParams params; |
2179 params.accumulated_overscroll = accumulated_root_overscroll_; | 2173 params.accumulated_overscroll = accumulated_root_overscroll_; |
2180 params.latest_overscroll_delta = unused_root_delta; | 2174 params.latest_overscroll_delta = unused_root_delta; |
2181 params.current_fling_velocity = current_fling_velocity_; | |
2182 input_handler_client_->DidOverscroll(params); | 2175 input_handler_client_->DidOverscroll(params); |
2183 } | 2176 } |
2184 | 2177 |
2185 return did_scroll; | 2178 return did_scroll; |
2186 } | 2179 } |
2187 | 2180 |
2188 // This implements scrolling by page as described here: | 2181 // This implements scrolling by page as described here: |
2189 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel | 2182 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp
x#_win32_The_Mouse_Wheel |
2190 // for events with WHEEL_PAGESCROLL set. | 2183 // for events with WHEEL_PAGESCROLL set. |
2191 bool LayerTreeHostImpl::ScrollVerticallyByPage(gfx::Point viewport_point, | 2184 bool LayerTreeHostImpl::ScrollVerticallyByPage(gfx::Point viewport_point, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2235 | 2228 |
2236 void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { | 2229 void LayerTreeHostImpl::OnRootLayerDelegatedScrollOffsetChanged() { |
2237 DCHECK(root_layer_scroll_offset_delegate_ != NULL); | 2230 DCHECK(root_layer_scroll_offset_delegate_ != NULL); |
2238 client_->SetNeedsCommitOnImplThread(); | 2231 client_->SetNeedsCommitOnImplThread(); |
2239 } | 2232 } |
2240 | 2233 |
2241 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { | 2234 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { |
2242 active_tree_->ClearCurrentlyScrollingLayer(); | 2235 active_tree_->ClearCurrentlyScrollingLayer(); |
2243 did_lock_scrolling_layer_ = false; | 2236 did_lock_scrolling_layer_ = false; |
2244 accumulated_root_overscroll_ = gfx::Vector2dF(); | 2237 accumulated_root_overscroll_ = gfx::Vector2dF(); |
2245 current_fling_velocity_ = gfx::Vector2dF(); | |
2246 } | 2238 } |
2247 | 2239 |
2248 void LayerTreeHostImpl::ScrollEnd() { | 2240 void LayerTreeHostImpl::ScrollEnd() { |
2249 if (top_controls_manager_) | 2241 if (top_controls_manager_) |
2250 top_controls_manager_->ScrollEnd(); | 2242 top_controls_manager_->ScrollEnd(); |
2251 ClearCurrentlyScrollingLayer(); | 2243 ClearCurrentlyScrollingLayer(); |
2252 StartScrollbarAnimation(); | 2244 StartScrollbarAnimation(); |
2253 } | 2245 } |
2254 | 2246 |
2255 InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() { | |
2256 if (!active_tree_->CurrentlyScrollingLayer()) | |
2257 return ScrollIgnored; | |
2258 | |
2259 if (settings_.ignore_root_layer_flings && | |
2260 active_tree_->CurrentlyScrollingLayer() == | |
2261 active_tree_->RootScrollLayer()) { | |
2262 ClearCurrentlyScrollingLayer(); | |
2263 return ScrollIgnored; | |
2264 } | |
2265 | |
2266 if (!wheel_scrolling_) | |
2267 should_bubble_scrolls_ = last_scroll_did_bubble_; | |
2268 | |
2269 return ScrollStarted; | |
2270 } | |
2271 | |
2272 void LayerTreeHostImpl::NotifyCurrentFlingVelocity(gfx::Vector2dF velocity) { | |
2273 current_fling_velocity_ = velocity; | |
2274 } | |
2275 | |
2276 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( | 2247 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( |
2277 gfx::PointF device_viewport_point, | 2248 gfx::PointF device_viewport_point, |
2278 LayerImpl* layer_impl) { | 2249 LayerImpl* layer_impl) { |
2279 if (!layer_impl) | 2250 if (!layer_impl) |
2280 return std::numeric_limits<float>::max(); | 2251 return std::numeric_limits<float>::max(); |
2281 | 2252 |
2282 gfx::Rect layer_impl_bounds( | 2253 gfx::Rect layer_impl_bounds( |
2283 layer_impl->content_bounds()); | 2254 layer_impl->content_bounds()); |
2284 | 2255 |
2285 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( | 2256 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2813 std::set<UIResourceId>::iterator found_in_evicted = | 2784 std::set<UIResourceId>::iterator found_in_evicted = |
2814 evicted_ui_resources_.find(uid); | 2785 evicted_ui_resources_.find(uid); |
2815 if (found_in_evicted == evicted_ui_resources_.end()) | 2786 if (found_in_evicted == evicted_ui_resources_.end()) |
2816 return; | 2787 return; |
2817 evicted_ui_resources_.erase(found_in_evicted); | 2788 evicted_ui_resources_.erase(found_in_evicted); |
2818 if (evicted_ui_resources_.empty()) | 2789 if (evicted_ui_resources_.empty()) |
2819 client_->OnCanDrawStateChanged(CanDraw()); | 2790 client_->OnCanDrawStateChanged(CanDraw()); |
2820 } | 2791 } |
2821 | 2792 |
2822 } // namespace cc | 2793 } // namespace cc |
OLD | NEW |