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

Side by Side Diff: cc/test/animation_test_common.cc

Issue 693883004: Make cc::animation::TrimTimeToCurrentIteration,cc::AnimationCurve::Duration use TimeTicks/TimeDelta (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/test/animation_test_common.h ('k') | cc/trees/layer_tree_host_impl.cc » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/test/animation_test_common.h" 5 #include "cc/test/animation_test_common.h"
6 6
7 #include "cc/animation/animation_id_provider.h" 7 #include "cc/animation/animation_id_provider.h"
8 #include "cc/animation/keyframed_animation_curve.h" 8 #include "cc/animation/keyframed_animation_curve.h"
9 #include "cc/animation/layer_animation_controller.h" 9 #include "cc/animation/layer_animation_controller.h"
10 #include "cc/animation/transform_operations.h" 10 #include "cc/animation/transform_operations.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 scoped_ptr<Animation> animation(Animation::Create( 118 scoped_ptr<Animation> animation(Animation::Create(
119 curve.Pass(), id, AnimationIdProvider::NextGroupId(), Animation::Filter)); 119 curve.Pass(), id, AnimationIdProvider::NextGroupId(), Animation::Filter));
120 animation->set_needs_synchronized_start_time(true); 120 animation->set_needs_synchronized_start_time(true);
121 121
122 target->AddAnimation(animation.Pass()); 122 target->AddAnimation(animation.Pass());
123 return id; 123 return id;
124 } 124 }
125 125
126 FakeFloatAnimationCurve::FakeFloatAnimationCurve() 126 FakeFloatAnimationCurve::FakeFloatAnimationCurve()
127 : duration_(1.0) {} 127 : duration_(base::TimeDelta::FromSecondsD(1.0)) {
128 }
128 129
129 FakeFloatAnimationCurve::FakeFloatAnimationCurve(double duration) 130 FakeFloatAnimationCurve::FakeFloatAnimationCurve(double duration)
130 : duration_(duration) {} 131 : duration_(base::TimeDelta::FromSecondsD(duration)) {
132 }
131 133
132 FakeFloatAnimationCurve::~FakeFloatAnimationCurve() {} 134 FakeFloatAnimationCurve::~FakeFloatAnimationCurve() {}
133 135
134 double FakeFloatAnimationCurve::Duration() const { 136 base::TimeDelta FakeFloatAnimationCurve::Duration() const {
135 return duration_; 137 return duration_;
136 } 138 }
137 139
138 float FakeFloatAnimationCurve::GetValue(double now) const { 140 float FakeFloatAnimationCurve::GetValue(double now) const {
139 return 0.0f; 141 return 0.0f;
140 } 142 }
141 143
142 scoped_ptr<AnimationCurve> FakeFloatAnimationCurve::Clone() const { 144 scoped_ptr<AnimationCurve> FakeFloatAnimationCurve::Clone() const {
143 return make_scoped_ptr(new FakeFloatAnimationCurve); 145 return make_scoped_ptr(new FakeFloatAnimationCurve);
144 } 146 }
145 147
146 FakeTransformTransition::FakeTransformTransition(double duration) 148 FakeTransformTransition::FakeTransformTransition(double duration)
147 : duration_(duration) {} 149 : duration_(base::TimeDelta::FromSecondsD(duration)) {
150 }
148 151
149 FakeTransformTransition::~FakeTransformTransition() {} 152 FakeTransformTransition::~FakeTransformTransition() {}
150 153
151 double FakeTransformTransition::Duration() const { 154 base::TimeDelta FakeTransformTransition::Duration() const {
152 return duration_; 155 return duration_;
153 } 156 }
154 157
155 gfx::Transform FakeTransformTransition::GetValue(double time) const { 158 gfx::Transform FakeTransformTransition::GetValue(double time) const {
156 return gfx::Transform(); 159 return gfx::Transform();
157 } 160 }
158 161
159 bool FakeTransformTransition::AnimatedBoundsForBox(const gfx::BoxF& box, 162 bool FakeTransformTransition::AnimatedBoundsForBox(const gfx::BoxF& box,
160 gfx::BoxF* bounds) const { 163 gfx::BoxF* bounds) const {
161 return false; 164 return false;
162 } 165 }
163 166
164 bool FakeTransformTransition::AffectsScale() const { return false; } 167 bool FakeTransformTransition::AffectsScale() const { return false; }
165 168
166 bool FakeTransformTransition::IsTranslation() const { return true; } 169 bool FakeTransformTransition::IsTranslation() const { return true; }
167 170
168 bool FakeTransformTransition::MaximumTargetScale(bool forward_direction, 171 bool FakeTransformTransition::MaximumTargetScale(bool forward_direction,
169 float* max_scale) const { 172 float* max_scale) const {
170 *max_scale = 1.f; 173 *max_scale = 1.f;
171 return true; 174 return true;
172 } 175 }
173 176
174 scoped_ptr<AnimationCurve> FakeTransformTransition::Clone() const { 177 scoped_ptr<AnimationCurve> FakeTransformTransition::Clone() const {
175 return make_scoped_ptr(new FakeTransformTransition(*this)); 178 return make_scoped_ptr(new FakeTransformTransition(*this));
176 } 179 }
177 180
178
179 FakeFloatTransition::FakeFloatTransition(double duration, float from, float to) 181 FakeFloatTransition::FakeFloatTransition(double duration, float from, float to)
180 : duration_(duration), from_(from), to_(to) {} 182 : duration_(base::TimeDelta::FromSecondsD(duration)), from_(from), to_(to) {
183 }
181 184
182 FakeFloatTransition::~FakeFloatTransition() {} 185 FakeFloatTransition::~FakeFloatTransition() {}
183 186
184 double FakeFloatTransition::Duration() const { 187 base::TimeDelta FakeFloatTransition::Duration() const {
185 return duration_; 188 return duration_;
186 } 189 }
187 190
188 float FakeFloatTransition::GetValue(double time) const { 191 float FakeFloatTransition::GetValue(double time) const {
189 time /= duration_; 192 time /= duration_.InSecondsF();
190 if (time >= 1.0) 193 if (time >= 1.0)
191 time = 1.0; 194 time = 1.0;
192 return (1.0 - time) * from_ + time * to_; 195 return (1.0 - time) * from_ + time * to_;
193 } 196 }
194 197
195 FakeLayerAnimationValueObserver::FakeLayerAnimationValueObserver() 198 FakeLayerAnimationValueObserver::FakeLayerAnimationValueObserver()
196 : opacity_(0.0f), 199 : opacity_(0.0f),
197 animation_waiting_for_deletion_(false) {} 200 animation_waiting_for_deletion_(false) {}
198 201
199 FakeLayerAnimationValueObserver::~FakeLayerAnimationValueObserver() {} 202 FakeLayerAnimationValueObserver::~FakeLayerAnimationValueObserver() {}
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 double duration, 340 double duration,
338 float start_brightness, 341 float start_brightness,
339 float end_brightness) { 342 float end_brightness) {
340 return AddAnimatedFilter(layer->layer_animation_controller(), 343 return AddAnimatedFilter(layer->layer_animation_controller(),
341 duration, 344 duration,
342 start_brightness, 345 start_brightness,
343 end_brightness); 346 end_brightness);
344 } 347 }
345 348
346 } // namespace cc 349 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/animation_test_common.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698