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

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

Issue 1009233002: CC Animations: Port Impl-only-scrolling to use compositor animation timelines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ui
Patch Set: Add unittests. Created 5 years, 8 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 #include <map> 9 #include <map>
10 10
(...skipping 3356 matching lines...) Expand 10 before | Expand all | Expand 10 after
3367 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() { 3367 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfForwardingToMainThread() {
3368 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3368 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3369 for (; it != swap_promise_monitor_.end(); it++) 3369 for (; it != swap_promise_monitor_.end(); it++)
3370 (*it)->OnForwardScrollUpdateToMainThreadOnImpl(); 3370 (*it)->OnForwardScrollUpdateToMainThreadOnImpl();
3371 } 3371 }
3372 3372
3373 void LayerTreeHostImpl::ScrollAnimationCreate( 3373 void LayerTreeHostImpl::ScrollAnimationCreate(
3374 LayerImpl* layer_impl, 3374 LayerImpl* layer_impl,
3375 const gfx::ScrollOffset& target_offset, 3375 const gfx::ScrollOffset& target_offset,
3376 const gfx::ScrollOffset& current_offset) { 3376 const gfx::ScrollOffset& current_offset) {
3377 if (animation_host_)
3378 return animation_host_->ImplOnlyScrollAnimationCreate(
3379 layer_impl->id(), target_offset, current_offset);
3380
3377 scoped_ptr<ScrollOffsetAnimationCurve> curve = 3381 scoped_ptr<ScrollOffsetAnimationCurve> curve =
3378 ScrollOffsetAnimationCurve::Create(target_offset, 3382 ScrollOffsetAnimationCurve::Create(target_offset,
3379 EaseInOutTimingFunction::Create()); 3383 EaseInOutTimingFunction::Create());
3380 curve->SetInitialValue(current_offset); 3384 curve->SetInitialValue(current_offset);
3381 3385
3382 scoped_ptr<Animation> animation = Animation::Create( 3386 scoped_ptr<Animation> animation = Animation::Create(
3383 curve.Pass(), AnimationIdProvider::NextAnimationId(), 3387 curve.Pass(), AnimationIdProvider::NextAnimationId(),
3384 AnimationIdProvider::NextGroupId(), Animation::SCROLL_OFFSET); 3388 AnimationIdProvider::NextGroupId(), Animation::SCROLL_OFFSET);
3385 animation->set_is_impl_only(true); 3389 animation->set_is_impl_only(true);
3386 3390
3387 layer_impl->layer_animation_controller()->AddAnimation(animation.Pass()); 3391 layer_impl->layer_animation_controller()->AddAnimation(animation.Pass());
3388 } 3392 }
3389 3393
3390 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( 3394 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget(
3391 LayerImpl* layer_impl, 3395 LayerImpl* layer_impl,
3392 const gfx::Vector2dF& scroll_delta) { 3396 const gfx::Vector2dF& scroll_delta) {
3397 if (animation_host_)
3398 return animation_host_->ImplOnlyScrollAnimationUpdateTarget(
3399 layer_impl->id(), scroll_delta, layer_impl->MaxScrollOffset(),
3400 CurrentBeginFrameArgs().frame_time);
3401
3393 Animation* animation = 3402 Animation* animation =
3394 layer_impl->layer_animation_controller() 3403 layer_impl->layer_animation_controller()
3395 ? layer_impl->layer_animation_controller()->GetAnimation( 3404 ? layer_impl->layer_animation_controller()->GetAnimation(
3396 Animation::SCROLL_OFFSET) 3405 Animation::SCROLL_OFFSET)
3397 : nullptr; 3406 : nullptr;
3398 if (!animation) 3407 if (!animation)
3399 return false; 3408 return false;
3400 3409
3401 ScrollOffsetAnimationCurve* curve = 3410 ScrollOffsetAnimationCurve* curve =
3402 animation->curve()->ToScrollOffsetAnimationCurve(); 3411 animation->curve()->ToScrollOffsetAnimationCurve();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3517 bool affects_active_tree, 3526 bool affects_active_tree,
3518 const gfx::ScrollOffset& scroll_offset) { 3527 const gfx::ScrollOffset& scroll_offset) {
3519 if (affects_active_tree) { 3528 if (affects_active_tree) {
3520 SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset); 3529 SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset);
3521 } else { 3530 } else {
3522 SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset); 3531 SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset);
3523 SetTreeLayerScrollOffsetMutated(layer_id, recycle_tree(), scroll_offset); 3532 SetTreeLayerScrollOffsetMutated(layer_id, recycle_tree(), scroll_offset);
3524 } 3533 }
3525 } 3534 }
3526 3535
3536 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() {
3537 ScrollEnd();
3538 }
3539
3540 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation(
3541 int layer_id) const {
3542 if (active_tree()) {
3543 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id);
3544 if (layer)
3545 return layer->ScrollOffsetForAnimation();
3546 }
3547
3548 return gfx::ScrollOffset();
3549 }
3550
3527 } // namespace cc 3551 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_unittest_animation_timelines.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698