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

Side by Side Diff: cc/animation/scroll_offset_animation_curve.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: 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_animation_curve.h" 5 #include "cc/animation/scroll_offset_animation_curve.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 bool ScrollOffsetAnimationCurve::HasSetInitialValue() const { 107 bool ScrollOffsetAnimationCurve::HasSetInitialValue() const {
108 return has_set_initial_value_; 108 return has_set_initial_value_;
109 } 109 }
110 110
111 void ScrollOffsetAnimationCurve::ApplyAdjustment( 111 void ScrollOffsetAnimationCurve::ApplyAdjustment(
112 const gfx::Vector2dF& adjustment) { 112 const gfx::Vector2dF& adjustment) {
113 initial_value_ = ScrollOffsetWithDelta(initial_value_, adjustment); 113 initial_value_ = ScrollOffsetWithDelta(initial_value_, adjustment);
114 target_value_ = ScrollOffsetWithDelta(target_value_, adjustment); 114 target_value_ = ScrollOffsetWithDelta(target_value_, adjustment);
115 } 115 }
116 116
117 void ScrollOffsetAnimationCurve::AdjustDuration(base::TimeDelta adjustment) {
118 base::TimeDelta old_duration = total_animation_duration_ - last_retarget_;
119 base::TimeDelta new_duration = old_duration - adjustment;
120 if (new_duration <= base::TimeDelta())
121 new_duration = base::TimeDelta();
122 total_animation_duration_ -= old_duration - new_duration;
123 }
124
117 gfx::ScrollOffset ScrollOffsetAnimationCurve::GetValue( 125 gfx::ScrollOffset ScrollOffsetAnimationCurve::GetValue(
118 base::TimeDelta t) const { 126 base::TimeDelta t) const {
119 base::TimeDelta duration = total_animation_duration_ - last_retarget_; 127 base::TimeDelta duration = total_animation_duration_ - last_retarget_;
120 t -= last_retarget_; 128 t -= last_retarget_;
121 129
130 if (t >= duration)
131 return target_value_;
132
122 if (t <= base::TimeDelta()) 133 if (t <= base::TimeDelta())
123 return initial_value_; 134 return initial_value_;
124 135
125 if (t >= duration)
126 return target_value_;
127
128 double progress = timing_function_->GetValue(TimeUtil::Divide(t, duration)); 136 double progress = timing_function_->GetValue(TimeUtil::Divide(t, duration));
129 return gfx::ScrollOffset( 137 return gfx::ScrollOffset(
130 gfx::Tween::FloatValueBetween( 138 gfx::Tween::FloatValueBetween(
131 progress, initial_value_.x(), target_value_.x()), 139 progress, initial_value_.x(), target_value_.x()),
132 gfx::Tween::FloatValueBetween( 140 gfx::Tween::FloatValueBetween(
133 progress, initial_value_.y(), target_value_.y())); 141 progress, initial_value_.y(), target_value_.y()));
134 } 142 }
135 143
136 base::TimeDelta ScrollOffsetAnimationCurve::Duration() const { 144 base::TimeDelta ScrollOffsetAnimationCurve::Duration() const {
137 return total_animation_duration_; 145 return total_animation_duration_;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 (MaximumDimension(old_delta) / MaximumDimension(new_delta)); 234 (MaximumDimension(old_delta) / MaximumDimension(new_delta));
227 235
228 initial_value_ = current_position; 236 initial_value_ = current_position;
229 target_value_ = new_target; 237 target_value_ = new_target;
230 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); 238 total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration);
231 last_retarget_ = base::TimeDelta::FromSecondsD(t); 239 last_retarget_ = base::TimeDelta::FromSecondsD(t);
232 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity); 240 timing_function_ = EaseOutWithInitialVelocity(new_normalized_velocity);
233 } 241 }
234 242
235 } // namespace cc 243 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698