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

Unified 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: add test + apply suggested improvement Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/animation/scroll_offset_animations_impl.h ('k') | cc/input/input_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/scroll_offset_animations_impl.cc
diff --git a/cc/animation/scroll_offset_animations_impl.cc b/cc/animation/scroll_offset_animations_impl.cc
index f72a2d80fa59531bef442f2988cc35bd91535451..5d52678d06d10d7b31a0d551135426f8f5d0f936 100644
--- a/cc/animation/scroll_offset_animations_impl.cc
+++ b/cc/animation/scroll_offset_animations_impl.cc
@@ -36,13 +36,14 @@ ScrollOffsetAnimationsImpl::~ScrollOffsetAnimationsImpl() {
void ScrollOffsetAnimationsImpl::ScrollAnimationCreate(
ElementId element_id,
const gfx::ScrollOffset& target_offset,
- const gfx::ScrollOffset& current_offset) {
+ const gfx::ScrollOffset& current_offset,
+ base::TimeDelta delayed_by) {
std::unique_ptr<ScrollOffsetAnimationCurve> curve =
ScrollOffsetAnimationCurve::Create(
target_offset, CubicBezierTimingFunction::CreatePreset(
CubicBezierTimingFunction::EaseType::EASE_IN_OUT),
ScrollOffsetAnimationCurve::DurationBehavior::INVERSE_DELTA);
- curve->SetInitialValue(current_offset);
+ curve->SetInitialValue(current_offset, delayed_by);
std::unique_ptr<Animation> animation = Animation::Create(
std::move(curve), AnimationIdProvider::NextAnimationId(),
@@ -61,7 +62,8 @@ bool ScrollOffsetAnimationsImpl::ScrollAnimationUpdateTarget(
ElementId element_id,
const gfx::Vector2dF& scroll_delta,
const gfx::ScrollOffset& max_scroll_offset,
- base::TimeTicks frame_monotonic_time) {
+ base::TimeTicks frame_monotonic_time,
+ base::TimeDelta delayed_by) {
DCHECK(scroll_offset_animation_player_);
if (!scroll_offset_animation_player_->element_animations())
return false;
@@ -93,6 +95,11 @@ bool ScrollOffsetAnimationsImpl::ScrollAnimationUpdateTarget(
? base::TimeDelta()
: animation->TrimTimeToCurrentIteration(frame_monotonic_time);
+ // Re-target taking the delay into account. Note that if the duration of the
+ // animation is 0, trimmed will be 0 and UpdateTarget will be called with
+ // t = -delayed_by.
+ trimmed -= delayed_by;
+
curve->UpdateTarget(trimmed.InSecondsF(), new_target);
return true;
« no previous file with comments | « cc/animation/scroll_offset_animations_impl.h ('k') | cc/input/input_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698