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

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

Issue 2377223002: CC Animations: Rewrite unit tests to work with AnimationPlayer. (Closed)
Patch Set: Reparent. Created 4 years, 2 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/element_animations_unittest.cc ('k') | cc/test/animation_test_common.h » ('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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 const gfx::Vector2dF& scroll_delta, 63 const gfx::Vector2dF& scroll_delta,
64 const gfx::ScrollOffset& max_scroll_offset, 64 const gfx::ScrollOffset& max_scroll_offset,
65 base::TimeTicks frame_monotonic_time, 65 base::TimeTicks frame_monotonic_time,
66 base::TimeDelta delayed_by) { 66 base::TimeDelta delayed_by) {
67 DCHECK(scroll_offset_animation_player_); 67 DCHECK(scroll_offset_animation_player_);
68 if (!scroll_offset_animation_player_->element_animations()) 68 if (!scroll_offset_animation_player_->element_animations())
69 return false; 69 return false;
70 70
71 DCHECK_EQ(element_id, scroll_offset_animation_player_->element_id()); 71 DCHECK_EQ(element_id, scroll_offset_animation_player_->element_id());
72 72
73 Animation* animation = 73 Animation* animation = scroll_offset_animation_player_->GetAnimation(
74 scroll_offset_animation_player_->element_animations()->GetAnimation( 74 TargetProperty::SCROLL_OFFSET);
75 TargetProperty::SCROLL_OFFSET);
76 if (!animation) { 75 if (!animation) {
77 scroll_offset_animation_player_->DetachElement(); 76 scroll_offset_animation_player_->DetachElement();
78 return false; 77 return false;
79 } 78 }
80 if (scroll_delta.IsZero()) 79 if (scroll_delta.IsZero())
81 return true; 80 return true;
82 81
83 ScrollOffsetAnimationCurve* curve = 82 ScrollOffsetAnimationCurve* curve =
84 animation->curve()->ToScrollOffsetAnimationCurve(); 83 animation->curve()->ToScrollOffsetAnimationCurve();
85 84
(...skipping 22 matching lines...) Expand all
108 void ScrollOffsetAnimationsImpl::ScrollAnimationApplyAdjustment( 107 void ScrollOffsetAnimationsImpl::ScrollAnimationApplyAdjustment(
109 ElementId element_id, 108 ElementId element_id,
110 const gfx::Vector2dF& adjustment) { 109 const gfx::Vector2dF& adjustment) {
111 DCHECK(scroll_offset_animation_player_); 110 DCHECK(scroll_offset_animation_player_);
112 if (element_id != scroll_offset_animation_player_->element_id()) 111 if (element_id != scroll_offset_animation_player_->element_id())
113 return; 112 return;
114 113
115 if (!scroll_offset_animation_player_->element_animations()) 114 if (!scroll_offset_animation_player_->element_animations())
116 return; 115 return;
117 116
118 Animation* animation = 117 Animation* animation = scroll_offset_animation_player_->GetAnimation(
119 scroll_offset_animation_player_->element_animations()->GetAnimation( 118 TargetProperty::SCROLL_OFFSET);
120 TargetProperty::SCROLL_OFFSET);
121 if (!animation) 119 if (!animation)
122 return; 120 return;
123 121
124 std::unique_ptr<ScrollOffsetAnimationCurve> new_curve = 122 std::unique_ptr<ScrollOffsetAnimationCurve> new_curve =
125 animation->curve() 123 animation->curve()
126 ->ToScrollOffsetAnimationCurve() 124 ->ToScrollOffsetAnimationCurve()
127 ->CloneToScrollOffsetAnimationCurve(); 125 ->CloneToScrollOffsetAnimationCurve();
128 new_curve->ApplyAdjustment(adjustment); 126 new_curve->ApplyAdjustment(adjustment);
129 127
130 std::unique_ptr<Animation> new_animation = Animation::Create( 128 std::unique_ptr<Animation> new_animation = Animation::Create(
(...skipping 29 matching lines...) Expand all
160 ElementId element_id) { 158 ElementId element_id) {
161 if (scroll_offset_animation_player_->element_id() != element_id) { 159 if (scroll_offset_animation_player_->element_id() != element_id) {
162 if (scroll_offset_animation_player_->element_id()) 160 if (scroll_offset_animation_player_->element_id())
163 scroll_offset_animation_player_->DetachElement(); 161 scroll_offset_animation_player_->DetachElement();
164 if (element_id) 162 if (element_id)
165 scroll_offset_animation_player_->AttachElement(element_id); 163 scroll_offset_animation_player_->AttachElement(element_id);
166 } 164 }
167 } 165 }
168 166
169 } // namespace cc 167 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_animations_unittest.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698