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

Side by Side Diff: cc/animation/scroll_offset_animations_impl.cc

Issue 2040543002: Take MT jank into account when animating the scroll offset on CC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix constant Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/animation/scroll_offset_animations_impl.h" 5 #include "cc/animation/scroll_offset_animations_impl.h"
6 6
7 #include "cc/animation/animation_events.h" 7 #include "cc/animation/animation_events.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "cc/animation/animation_id_provider.h" 9 #include "cc/animation/animation_id_provider.h"
10 #include "cc/animation/animation_player.h" 10 #include "cc/animation/animation_player.h"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 ScrollOffsetAnimationsImpl::~ScrollOffsetAnimationsImpl() { 31 ScrollOffsetAnimationsImpl::~ScrollOffsetAnimationsImpl() {
32 scroll_offset_timeline_->DetachPlayer(scroll_offset_animation_player_.get()); 32 scroll_offset_timeline_->DetachPlayer(scroll_offset_animation_player_.get());
33 animation_host_->RemoveAnimationTimeline(scroll_offset_timeline_.get()); 33 animation_host_->RemoveAnimationTimeline(scroll_offset_timeline_.get());
34 } 34 }
35 35
36 void ScrollOffsetAnimationsImpl::ScrollAnimationCreate( 36 void ScrollOffsetAnimationsImpl::ScrollAnimationCreate(
37 ElementId element_id, 37 ElementId element_id,
38 const gfx::ScrollOffset& target_offset, 38 const gfx::ScrollOffset& target_offset,
39 const gfx::ScrollOffset& current_offset) { 39 const gfx::ScrollOffset& current_offset,
40 base::TimeTicks original_timestamp) {
40 std::unique_ptr<ScrollOffsetAnimationCurve> curve = 41 std::unique_ptr<ScrollOffsetAnimationCurve> curve =
41 ScrollOffsetAnimationCurve::Create( 42 ScrollOffsetAnimationCurve::Create(
42 target_offset, CubicBezierTimingFunction::CreatePreset( 43 target_offset, CubicBezierTimingFunction::CreatePreset(
43 CubicBezierTimingFunction::EaseType::EASE_IN_OUT), 44 CubicBezierTimingFunction::EaseType::EASE_IN_OUT),
44 ScrollOffsetAnimationCurve::DurationBehavior::INVERSE_DELTA); 45 ScrollOffsetAnimationCurve::DurationBehavior::INVERSE_DELTA);
45 curve->SetInitialValue(current_offset); 46 curve->SetInitialValue(current_offset,
47 base::TimeTicks::Now() - original_timestamp);
46 48
47 std::unique_ptr<Animation> animation = Animation::Create( 49 std::unique_ptr<Animation> animation = Animation::Create(
48 std::move(curve), AnimationIdProvider::NextAnimationId(), 50 std::move(curve), AnimationIdProvider::NextAnimationId(),
49 AnimationIdProvider::NextGroupId(), TargetProperty::SCROLL_OFFSET); 51 AnimationIdProvider::NextGroupId(), TargetProperty::SCROLL_OFFSET);
50 animation->set_is_impl_only(true); 52 animation->set_is_impl_only(true);
51 53
52 DCHECK(scroll_offset_animation_player_); 54 DCHECK(scroll_offset_animation_player_);
53 DCHECK(scroll_offset_animation_player_->animation_timeline()); 55 DCHECK(scroll_offset_animation_player_->animation_timeline());
54 56
55 ReattachScrollOffsetPlayerIfNeeded(element_id); 57 ReattachScrollOffsetPlayerIfNeeded(element_id);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ElementId element_id) { 150 ElementId element_id) {
149 if (scroll_offset_animation_player_->element_id() != element_id) { 151 if (scroll_offset_animation_player_->element_id() != element_id) {
150 if (scroll_offset_animation_player_->element_id()) 152 if (scroll_offset_animation_player_->element_id())
151 scroll_offset_animation_player_->DetachElement(); 153 scroll_offset_animation_player_->DetachElement();
152 if (element_id) 154 if (element_id)
153 scroll_offset_animation_player_->AttachElement(element_id); 155 scroll_offset_animation_player_->AttachElement(element_id);
154 } 156 }
155 } 157 }
156 158
157 } // namespace cc 159 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698