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

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

Issue 274323004: NOT FOR LANDING - [WebView] Allow fling animation via the LayerScrollOffsetDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 if (EvictedUIResourcesExist()) { 392 if (EvictedUIResourcesExist()) {
393 TRACE_EVENT_INSTANT0( 393 TRACE_EVENT_INSTANT0(
394 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated", 394 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated",
395 TRACE_EVENT_SCOPE_THREAD); 395 TRACE_EVENT_SCOPE_THREAD);
396 return false; 396 return false;
397 } 397 }
398 return true; 398 return true;
399 } 399 }
400 400
401 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) { 401 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time) {
402 if (input_handler_client_) 402 AnimateFling(monotonic_time);
mkosiba (inactive) 2014/05/15 13:48:51 I don't think we want to call this at all if layer
jdduke (slow) 2014/05/15 14:15:43 Oops yeah that's definitely what I had planned.
403 input_handler_client_->Animate(monotonic_time);
404 AnimatePageScale(monotonic_time); 403 AnimatePageScale(monotonic_time);
405 AnimateLayers(monotonic_time); 404 AnimateLayers(monotonic_time);
406 AnimateScrollbars(monotonic_time); 405 AnimateScrollbars(monotonic_time);
407 AnimateTopControls(monotonic_time); 406 AnimateTopControls(monotonic_time);
408 } 407 }
409 408
410 void LayerTreeHostImpl::ManageTiles() { 409 void LayerTreeHostImpl::ManageTiles() {
411 if (!tile_manager_) 410 if (!tile_manager_)
412 return; 411 return;
413 if (!tile_priorities_dirty_) 412 if (!tile_priorities_dirty_)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 page_scale_animation_->ZoomTo(scaled_target_offset, 463 page_scale_animation_->ZoomTo(scaled_target_offset,
465 page_scale, 464 page_scale,
466 duration.InSecondsF()); 465 duration.InSecondsF());
467 } 466 }
468 467
469 SetNeedsAnimate(); 468 SetNeedsAnimate();
470 client_->SetNeedsCommitOnImplThread(); 469 client_->SetNeedsCommitOnImplThread();
471 client_->RenewTreePriority(); 470 client_->RenewTreePriority();
472 } 471 }
473 472
473 void LayerTreeHostImpl::SetNeedsAnimateFling() {
474 if (root_layer_scroll_offset_delegate_ &&
475 (CurrentlyScrollingLayer() == InnerViewportScrollLayer() ||
476 CurrentlyScrollingLayer() == OuterViewportScrollLayer())) {
477 // Hacky callback approach...
478 root_layer_scroll_offset_delegate_->SetNeedsAnimate(
479 base::Bind(&LayerTreeHostImpl::AnimateFling, AsWeakPtr()));
480 return;
481 }
482
483 SetNeedsAnimate();
484 }
485
474 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( 486 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt(
475 const gfx::Point& viewport_point, 487 const gfx::Point& viewport_point,
476 InputHandler::ScrollInputType type) { 488 InputHandler::ScrollInputType type) {
477 if (!CurrentlyScrollingLayer()) 489 if (!CurrentlyScrollingLayer())
478 return false; 490 return false;
479 491
480 if (!EnsureRenderSurfaceLayerList()) 492 if (!EnsureRenderSurfaceLayerList())
481 return false; 493 return false;
482 494
483 gfx::PointF device_viewport_point = 495 gfx::PointF device_viewport_point =
(...skipping 2267 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 LayerImpl* scroll_layer = OuterViewportScrollLayer() 2763 LayerImpl* scroll_layer = OuterViewportScrollLayer()
2752 ? OuterViewportScrollLayer() 2764 ? OuterViewportScrollLayer()
2753 : InnerViewportScrollLayer(); 2765 : InnerViewportScrollLayer();
2754 2766
2755 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta); 2767 gfx::Vector2dF unused_delta = scroll_layer->ScrollBy(scroll_delta);
2756 2768
2757 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer())) 2769 if (!unused_delta.IsZero() && (scroll_layer == OuterViewportScrollLayer()))
2758 InnerViewportScrollLayer()->ScrollBy(unused_delta); 2770 InnerViewportScrollLayer()->ScrollBy(unused_delta);
2759 } 2771 }
2760 2772
2773 void LayerTreeHostImpl::AnimateFling(base::TimeTicks monotonic_time) {
2774 DCHECK(proxy_->IsImplThread());
2775 if (input_handler_client_)
2776 input_handler_client_->AnimateFling(monotonic_time);
2777 }
2778
2761 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) { 2779 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks monotonic_time) {
2762 if (!page_scale_animation_) 2780 if (!page_scale_animation_)
2763 return; 2781 return;
2764 2782
2765 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic 2783 // TODO(ajuma): http://crbug.com/178171 - Animations use double for monotonic
2766 // time. 2784 // time.
2767 double monotonic_time_for_cc_animations = 2785 double monotonic_time_for_cc_animations =
2768 (monotonic_time - base::TimeTicks()).InSecondsF(); 2786 (monotonic_time - base::TimeTicks()).InSecondsF();
2769 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset(); 2787 gfx::Vector2dF scroll_total = active_tree_->TotalScrollOffset();
2770 2788
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
3119 swap_promise_monitor_.erase(monitor); 3137 swap_promise_monitor_.erase(monitor);
3120 } 3138 }
3121 3139
3122 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3140 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3123 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3141 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3124 for (; it != swap_promise_monitor_.end(); it++) 3142 for (; it != swap_promise_monitor_.end(); it++)
3125 (*it)->OnSetNeedsRedrawOnImpl(); 3143 (*it)->OnSetNeedsRedrawOnImpl();
3126 } 3144 }
3127 3145
3128 } // namespace cc 3146 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698