Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 185653013: [#8] Pass gfx::Point by const ref. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build errors on other platforms Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | content/renderer/input/input_handler_proxy_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 SetNeedsRedraw(); 470 SetNeedsRedraw();
471 client_->SetNeedsCommitOnImplThread(); 471 client_->SetNeedsCommitOnImplThread();
472 client_->RenewTreePriority(); 472 client_->RenewTreePriority();
473 } 473 }
474 474
475 void LayerTreeHostImpl::ScheduleAnimation() { 475 void LayerTreeHostImpl::ScheduleAnimation() {
476 SetNeedsRedraw(); 476 SetNeedsRedraw();
477 } 477 }
478 478
479 bool LayerTreeHostImpl::HaveTouchEventHandlersAt(gfx::Point viewport_point) { 479 bool LayerTreeHostImpl::HaveTouchEventHandlersAt(
480 const gfx::Point& viewport_point) {
480 if (!settings_.touch_hit_testing) 481 if (!settings_.touch_hit_testing)
481 return true; 482 return true;
482 if (!EnsureRenderSurfaceLayerList()) 483 if (!EnsureRenderSurfaceLayerList())
483 return false; 484 return false;
484 485
485 gfx::PointF device_viewport_point = 486 gfx::PointF device_viewport_point =
486 gfx::ScalePoint(viewport_point, device_scale_factor_); 487 gfx::ScalePoint(viewport_point, device_scale_factor_);
487 488
488 LayerImpl* layer_impl = 489 LayerImpl* layer_impl =
489 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion( 490 LayerTreeHostCommon::FindLayerThatIsHitByPointInTouchHandlerRegion(
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 } 2063 }
2063 2064
2064 if (status == ScrollStarted && !potentially_scrolling_layer_impl) 2065 if (status == ScrollStarted && !potentially_scrolling_layer_impl)
2065 potentially_scrolling_layer_impl = scroll_layer_impl; 2066 potentially_scrolling_layer_impl = scroll_layer_impl;
2066 } 2067 }
2067 2068
2068 return potentially_scrolling_layer_impl; 2069 return potentially_scrolling_layer_impl;
2069 } 2070 }
2070 2071
2071 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( 2072 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin(
2072 gfx::Point viewport_point, InputHandler::ScrollInputType type) { 2073 const gfx::Point& viewport_point,
2074 InputHandler::ScrollInputType type) {
2073 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin"); 2075 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBegin");
2074 2076
2075 if (top_controls_manager_) 2077 if (top_controls_manager_)
2076 top_controls_manager_->ScrollBegin(); 2078 top_controls_manager_->ScrollBegin();
2077 2079
2078 DCHECK(!CurrentlyScrollingLayer()); 2080 DCHECK(!CurrentlyScrollingLayer());
2079 ClearCurrentlyScrollingLayer(); 2081 ClearCurrentlyScrollingLayer();
2080 2082
2081 if (!EnsureRenderSurfaceLayerList()) 2083 if (!EnsureRenderSurfaceLayerList())
2082 return ScrollIgnored; 2084 return ScrollIgnored;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 return actual_viewport_end_point - viewport_point; 2192 return actual_viewport_end_point - viewport_point;
2191 } 2193 }
2192 2194
2193 static gfx::Vector2dF ScrollLayerWithLocalDelta(LayerImpl* layer_impl, 2195 static gfx::Vector2dF ScrollLayerWithLocalDelta(LayerImpl* layer_impl,
2194 const gfx::Vector2dF& local_delta) { 2196 const gfx::Vector2dF& local_delta) {
2195 gfx::Vector2dF previous_delta(layer_impl->ScrollDelta()); 2197 gfx::Vector2dF previous_delta(layer_impl->ScrollDelta());
2196 layer_impl->ScrollBy(local_delta); 2198 layer_impl->ScrollBy(local_delta);
2197 return layer_impl->ScrollDelta() - previous_delta; 2199 return layer_impl->ScrollDelta() - previous_delta;
2198 } 2200 }
2199 2201
2200 bool LayerTreeHostImpl::ScrollBy(gfx::Point viewport_point, 2202 bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point,
2201 const gfx::Vector2dF& scroll_delta) { 2203 const gfx::Vector2dF& scroll_delta) {
2202 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); 2204 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy");
2203 if (!CurrentlyScrollingLayer()) 2205 if (!CurrentlyScrollingLayer())
2204 return false; 2206 return false;
2205 2207
2206 gfx::Vector2dF pending_delta = scroll_delta; 2208 gfx::Vector2dF pending_delta = scroll_delta;
2207 gfx::Vector2dF unused_root_delta; 2209 gfx::Vector2dF unused_root_delta;
2208 bool did_scroll_x = false; 2210 bool did_scroll_x = false;
2209 bool did_scroll_y = false; 2211 bool did_scroll_y = false;
2210 // TODO(wjmaclean) Should we guard against CurrentlyScrollingLayer() == 0 2212 // TODO(wjmaclean) Should we guard against CurrentlyScrollingLayer() == 0
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 params.current_fling_velocity = current_fling_velocity_; 2321 params.current_fling_velocity = current_fling_velocity_;
2320 input_handler_client_->DidOverscroll(params); 2322 input_handler_client_->DidOverscroll(params);
2321 } 2323 }
2322 2324
2323 return did_scroll; 2325 return did_scroll;
2324 } 2326 }
2325 2327
2326 // This implements scrolling by page as described here: 2328 // This implements scrolling by page as described here:
2327 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel 2329 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645601(v=vs.85).asp x#_win32_The_Mouse_Wheel
2328 // for events with WHEEL_PAGESCROLL set. 2330 // for events with WHEEL_PAGESCROLL set.
2329 bool LayerTreeHostImpl::ScrollVerticallyByPage(gfx::Point viewport_point, 2331 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point,
2330 ScrollDirection direction) { 2332 ScrollDirection direction) {
2331 DCHECK(wheel_scrolling_); 2333 DCHECK(wheel_scrolling_);
2332 2334
2333 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); 2335 for (LayerImpl* layer_impl = CurrentlyScrollingLayer();
2334 layer_impl; 2336 layer_impl;
2335 layer_impl = layer_impl->parent()) { 2337 layer_impl = layer_impl->parent()) {
2336 if (!layer_impl->scrollable()) 2338 if (!layer_impl->scrollable())
2337 continue; 2339 continue;
2338 2340
2339 if (!layer_impl->HasScrollbar(VERTICAL)) 2341 if (!layer_impl->HasScrollbar(VERTICAL))
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 layer_impl->content_bounds()); 2428 layer_impl->content_bounds());
2427 2429
2428 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( 2430 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect(
2429 layer_impl->screen_space_transform(), 2431 layer_impl->screen_space_transform(),
2430 layer_impl_bounds); 2432 layer_impl_bounds);
2431 2433
2432 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint( 2434 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint(
2433 device_viewport_point); 2435 device_viewport_point);
2434 } 2436 }
2435 2437
2436 void LayerTreeHostImpl::MouseMoveAt(gfx::Point viewport_point) { 2438 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) {
2437 if (!EnsureRenderSurfaceLayerList()) 2439 if (!EnsureRenderSurfaceLayerList())
2438 return; 2440 return;
2439 2441
2440 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, 2442 gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point,
2441 device_scale_factor_); 2443 device_scale_factor_);
2442 2444
2443 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint( 2445 LayerImpl* layer_impl = LayerTreeHostCommon::FindLayerThatIsHitByPoint(
2444 device_viewport_point, 2446 device_viewport_point,
2445 active_tree_->RenderSurfaceLayerList()); 2447 active_tree_->RenderSurfaceLayerList());
2446 if (HandleMouseOverScrollbar(layer_impl, device_viewport_point)) 2448 if (HandleMouseOverScrollbar(layer_impl, device_viewport_point))
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2524 active_tree_->OuterViewportScrollLayer()); 2526 active_tree_->OuterViewportScrollLayer());
2525 } else { 2527 } else {
2526 active_tree_->SetCurrentlyScrollingLayer( 2528 active_tree_->SetCurrentlyScrollingLayer(
2527 active_tree_->InnerViewportScrollLayer()); 2529 active_tree_->InnerViewportScrollLayer());
2528 } 2530 }
2529 if (top_controls_manager_) 2531 if (top_controls_manager_)
2530 top_controls_manager_->PinchBegin(); 2532 top_controls_manager_->PinchBegin();
2531 } 2533 }
2532 2534
2533 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, 2535 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
2534 gfx::Point anchor) { 2536 const gfx::Point& anchor) {
2535 if (!InnerViewportScrollLayer()) 2537 if (!InnerViewportScrollLayer())
2536 return; 2538 return;
2537 2539
2538 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); 2540 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate");
2539 2541
2540 // Keep the center-of-pinch anchor specified by (x, y) in a stable 2542 // Keep the center-of-pinch anchor specified by (x, y) in a stable
2541 // position over the course of the magnify. 2543 // position over the course of the magnify.
2542 float page_scale_delta = active_tree_->page_scale_delta(); 2544 float page_scale_delta = active_tree_->page_scale_delta();
2543 gfx::PointF previous_scale_anchor = 2545 gfx::PointF previous_scale_anchor =
2544 gfx::ScalePoint(anchor, 1.f / page_scale_delta); 2546 gfx::ScalePoint(anchor, 1.f / page_scale_delta);
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 swap_promise_monitor_.erase(monitor); 3025 swap_promise_monitor_.erase(monitor);
3024 } 3026 }
3025 3027
3026 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3028 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3027 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3029 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3028 for (; it != swap_promise_monitor_.end(); it++) 3030 for (; it != swap_promise_monitor_.end(); it++)
3029 (*it)->OnSetNeedsRedrawOnImpl(); 3031 (*it)->OnSetNeedsRedrawOnImpl();
3030 } 3032 }
3031 3033
3032 } // namespace cc 3034 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | content/renderer/input/input_handler_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698