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

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

Issue 1950243005: Communicate MT changes to impl-only scroll offset animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 7 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 new_target.SetToMax(gfx::ScrollOffset()); 85 new_target.SetToMax(gfx::ScrollOffset());
86 new_target.SetToMin(max_scroll_offset); 86 new_target.SetToMin(max_scroll_offset);
87 87
88 curve->UpdateTarget( 88 curve->UpdateTarget(
89 animation->TrimTimeToCurrentIteration(frame_monotonic_time).InSecondsF(), 89 animation->TrimTimeToCurrentIteration(frame_monotonic_time).InSecondsF(),
90 new_target); 90 new_target);
91 91
92 return true; 92 return true;
93 } 93 }
94 94
95 void ScrollOffsetAnimationsImpl::ScrollAnimationApplyAdjustment(
96 ElementId element_id,
97 const gfx::Vector2dF& adjustment,
98 base::TimeTicks frame_monotonic_time) {
99 DCHECK(scroll_offset_animation_player_);
100 if (element_id != scroll_offset_animation_player_->element_id())
101 return;
102
103 if (!scroll_offset_animation_player_->element_animations())
104 return;
105
106 Animation* animation =
107 scroll_offset_animation_player_->element_animations()->GetAnimation(
108 TargetProperty::SCROLL_OFFSET);
109 if (!animation)
110 return;
111
112 // Abort the old animation.
113 ScrollAnimationAbort(/* needs_completion */ false);
114
115 // Start a new one with the adjusment.
116 std::unique_ptr<ScrollOffsetAnimationCurve> new_curve =
117 animation->curve()
118 ->ToScrollOffsetAnimationCurve()
119 ->CloneToScrollOffsetAnimationCurve();
120 new_curve->ApplyAdjustment(
121 animation->TrimTimeToCurrentIteration(frame_monotonic_time), adjustment);
122
123 std::unique_ptr<Animation> new_animation = Animation::Create(
124 std::move(new_curve), AnimationIdProvider::NextAnimationId(),
125 AnimationIdProvider::NextGroupId(), TargetProperty::SCROLL_OFFSET);
126 new_animation->set_is_impl_only(true);
127 new_animation->set_affects_active_elements(false);
128
129 scroll_offset_animation_player_->AddAnimation(std::move(new_animation));
130 }
131
95 void ScrollOffsetAnimationsImpl::ScrollAnimationAbort(bool needs_completion) { 132 void ScrollOffsetAnimationsImpl::ScrollAnimationAbort(bool needs_completion) {
96 DCHECK(scroll_offset_animation_player_); 133 DCHECK(scroll_offset_animation_player_);
97 scroll_offset_animation_player_->AbortAnimations( 134 scroll_offset_animation_player_->AbortAnimations(
98 TargetProperty::SCROLL_OFFSET, needs_completion); 135 TargetProperty::SCROLL_OFFSET, needs_completion);
99 } 136 }
100 137
101 void ScrollOffsetAnimationsImpl::NotifyAnimationFinished( 138 void ScrollOffsetAnimationsImpl::NotifyAnimationFinished(
102 base::TimeTicks monotonic_time, 139 base::TimeTicks monotonic_time,
103 TargetProperty::Type target_property, 140 TargetProperty::Type target_property,
104 int group) { 141 int group) {
105 DCHECK_EQ(target_property, TargetProperty::SCROLL_OFFSET); 142 DCHECK_EQ(target_property, TargetProperty::SCROLL_OFFSET);
106 DCHECK(animation_host_->mutator_host_client()); 143 DCHECK(animation_host_->mutator_host_client());
107 animation_host_->mutator_host_client()->ScrollOffsetAnimationFinished(); 144 animation_host_->mutator_host_client()->ScrollOffsetAnimationFinished();
108 } 145 }
109 146
110 void ScrollOffsetAnimationsImpl::ReattachScrollOffsetPlayerIfNeeded( 147 void ScrollOffsetAnimationsImpl::ReattachScrollOffsetPlayerIfNeeded(
111 ElementId element_id) { 148 ElementId element_id) {
112 if (scroll_offset_animation_player_->element_id() != element_id) { 149 if (scroll_offset_animation_player_->element_id() != element_id) {
113 if (scroll_offset_animation_player_->element_id()) 150 if (scroll_offset_animation_player_->element_id())
114 scroll_offset_animation_player_->DetachElement(); 151 scroll_offset_animation_player_->DetachElement();
115 if (element_id) 152 if (element_id)
116 scroll_offset_animation_player_->AttachElement(element_id); 153 scroll_offset_animation_player_->AttachElement(element_id);
117 } 154 }
118 } 155 }
119 156
120 } // namespace cc 157 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698