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

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: fix UpdateTarget 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
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..2956dafead9a77e9b387dcf2024d6bddfe348f05 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,10 @@ bool ScrollOffsetAnimationsImpl::ScrollAnimationUpdateTarget(
? base::TimeDelta()
: animation->TrimTimeToCurrentIteration(frame_monotonic_time);
+ // Re-target taking the delay into account.
+ if (delayed_by > base::TimeDelta())
+ trimmed = delayed_by < trimmed ? trimmed - delayed_by : base::TimeDelta();
+
curve->UpdateTarget(trimmed.InSecondsF(), new_target);
return true;

Powered by Google App Engine
This is Rietveld 408576698