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

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: attempt to fix rebase issue 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
« no previous file with comments | « cc/animation/scroll_offset_animations_impl.h ('k') | cc/cc.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DCHECK(scroll_offset_animation_player_);
99 if (element_id != scroll_offset_animation_player_->element_id())
100 return;
101
102 if (!scroll_offset_animation_player_->element_animations())
103 return;
104
105 Animation* animation =
106 scroll_offset_animation_player_->element_animations()->GetAnimation(
107 TargetProperty::SCROLL_OFFSET);
108 if (!animation)
109 return;
110
111 std::unique_ptr<ScrollOffsetAnimationCurve> new_curve =
112 animation->curve()
113 ->ToScrollOffsetAnimationCurve()
114 ->CloneToScrollOffsetAnimationCurve();
115 new_curve->ApplyAdjustment(adjustment);
116
117 std::unique_ptr<Animation> new_animation = Animation::Create(
118 std::move(new_curve), AnimationIdProvider::NextAnimationId(),
119 AnimationIdProvider::NextGroupId(), TargetProperty::SCROLL_OFFSET);
120 new_animation->set_start_time(animation->start_time());
121 new_animation->set_is_impl_only(true);
122 new_animation->set_affects_active_elements(false);
123
124 // Abort the old animation.
125 ScrollAnimationAbort(/* needs_completion */ false);
126
127 // Start a new one with the adjusment.
128 scroll_offset_animation_player_->AddAnimation(std::move(new_animation));
129 }
130
95 void ScrollOffsetAnimationsImpl::ScrollAnimationAbort(bool needs_completion) { 131 void ScrollOffsetAnimationsImpl::ScrollAnimationAbort(bool needs_completion) {
96 DCHECK(scroll_offset_animation_player_); 132 DCHECK(scroll_offset_animation_player_);
97 scroll_offset_animation_player_->AbortAnimations( 133 scroll_offset_animation_player_->AbortAnimations(
98 TargetProperty::SCROLL_OFFSET, needs_completion); 134 TargetProperty::SCROLL_OFFSET, needs_completion);
99 } 135 }
100 136
101 void ScrollOffsetAnimationsImpl::NotifyAnimationFinished( 137 void ScrollOffsetAnimationsImpl::NotifyAnimationFinished(
102 base::TimeTicks monotonic_time, 138 base::TimeTicks monotonic_time,
103 TargetProperty::Type target_property, 139 TargetProperty::Type target_property,
104 int group) { 140 int group) {
105 DCHECK_EQ(target_property, TargetProperty::SCROLL_OFFSET); 141 DCHECK_EQ(target_property, TargetProperty::SCROLL_OFFSET);
106 DCHECK(animation_host_->mutator_host_client()); 142 DCHECK(animation_host_->mutator_host_client());
107 animation_host_->mutator_host_client()->ScrollOffsetAnimationFinished(); 143 animation_host_->mutator_host_client()->ScrollOffsetAnimationFinished();
108 } 144 }
109 145
110 void ScrollOffsetAnimationsImpl::ReattachScrollOffsetPlayerIfNeeded( 146 void ScrollOffsetAnimationsImpl::ReattachScrollOffsetPlayerIfNeeded(
111 ElementId element_id) { 147 ElementId element_id) {
112 if (scroll_offset_animation_player_->element_id() != element_id) { 148 if (scroll_offset_animation_player_->element_id() != element_id) {
113 if (scroll_offset_animation_player_->element_id()) 149 if (scroll_offset_animation_player_->element_id())
114 scroll_offset_animation_player_->DetachElement(); 150 scroll_offset_animation_player_->DetachElement();
115 if (element_id) 151 if (element_id)
116 scroll_offset_animation_player_->AttachElement(element_id); 152 scroll_offset_animation_player_->AttachElement(element_id);
117 } 153 }
118 } 154 }
119 155
120 } // namespace cc 156 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/scroll_offset_animations_impl.h ('k') | cc/cc.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698