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

Side by Side Diff: cc/layer_tree_host_unittest_animation.cc

Issue 11636051: Rename ActiveAnimation -> Animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « cc/layer_impl.cc ('k') | cc/layer_unittest.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/layer_tree_host.h" 5 #include "cc/layer_tree_host.h"
6 6
7 #include "cc/animation_curve.h" 7 #include "cc/animation_curve.h"
8 #include "cc/layer.h" 8 #include "cc/layer.h"
9 #include "cc/layer_animation_controller.h" 9 #include "cc/layer_animation_controller.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 virtual void beginTest() OVERRIDE { 241 virtual void beginTest() OVERRIDE {
242 postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); 242 postAddAnimationToMainThread(m_layerTreeHost->rootLayer());
243 } 243 }
244 244
245 virtual void animateLayers( 245 virtual void animateLayers(
246 LayerTreeHostImpl* host_impl, 246 LayerTreeHostImpl* host_impl,
247 base::TimeTicks monotonicTime, 247 base::TimeTicks monotonicTime,
248 bool hasUnfinishedAnimation) OVERRIDE { 248 bool hasUnfinishedAnimation) OVERRIDE {
249 LayerAnimationController* controller = 249 LayerAnimationController* controller =
250 m_layerTreeHost->rootLayer()->layerAnimationController(); 250 m_layerTreeHost->rootLayer()->layerAnimationController();
251 ActiveAnimation* animation = 251 Animation* animation =
252 controller->getActiveAnimation(0, ActiveAnimation::Opacity); 252 controller->getAnimation(0, Animation::Opacity);
253 if (!animation) 253 if (!animation)
254 return; 254 return;
255 255
256 const FloatAnimationCurve* curve = 256 const FloatAnimationCurve* curve =
257 animation->curve()->toFloatAnimationCurve(); 257 animation->curve()->toFloatAnimationCurve();
258 float startOpacity = curve->getValue(0); 258 float startOpacity = curve->getValue(0);
259 float endOpacity = curve->getValue(curve->duration()); 259 float endOpacity = curve->getValue(curve->duration());
260 float linearly_interpolated_opacity = 260 float linearly_interpolated_opacity =
261 0.25 * endOpacity + 0.75 * startOpacity; 261 0.25 * endOpacity + 0.75 * startOpacity;
262 double time = curve->duration() * 0.25; 262 double time = curve->duration() * 0.25;
263 // If the linear timing function associated with this animation was not 263 // If the linear timing function associated with this animation was not
264 // picked up, then the linearly interpolated opacity would be different 264 // picked up, then the linearly interpolated opacity would be different
265 // because of the default ease timing function. 265 // because of the default ease timing function.
266 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->getValue(time)); 266 EXPECT_FLOAT_EQ(linearly_interpolated_opacity, curve->getValue(time));
267 267
268 LayerAnimationController* controller_impl = 268 LayerAnimationController* controller_impl =
269 host_impl->rootLayer()->layerAnimationController(); 269 host_impl->rootLayer()->layerAnimationController();
270 ActiveAnimation* animation_impl = 270 Animation* animation_impl =
271 controller_impl->getActiveAnimation(0, ActiveAnimation::Opacity); 271 controller_impl->getAnimation(0, Animation::Opacity);
272 272
273 controller->removeAnimation(animation->id()); 273 controller->removeAnimation(animation->id());
274 controller_impl->removeAnimation(animation_impl->id()); 274 controller_impl->removeAnimation(animation_impl->id());
275 endTest(); 275 endTest();
276 } 276 }
277 277
278 virtual void afterTest() OVERRIDE {} 278 virtual void afterTest() OVERRIDE {}
279 }; 279 };
280 280
281 SINGLE_AND_MULTI_THREAD_TEST_F( 281 SINGLE_AND_MULTI_THREAD_TEST_F(
282 LayerTreeHostAnimationTestAddAnimationWithTimingFunction) 282 LayerTreeHostAnimationTestAddAnimationWithTimingFunction)
283 283
284 // Ensures that main thread animations have their start times synchronized with 284 // Ensures that main thread animations have their start times synchronized with
285 // impl thread animations. 285 // impl thread animations.
286 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes : 286 class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes :
287 public LayerTreeHostAnimationTest { 287 public LayerTreeHostAnimationTest {
288 public: 288 public:
289 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes() 289 LayerTreeHostAnimationTestSynchronizeAnimationStartTimes()
290 : main_start_time_(-1), 290 : main_start_time_(-1),
291 impl_start_time_(-1) { 291 impl_start_time_(-1) {
292 } 292 }
293 293
294 virtual void beginTest() OVERRIDE { 294 virtual void beginTest() OVERRIDE {
295 postAddAnimationToMainThread(m_layerTreeHost->rootLayer()); 295 postAddAnimationToMainThread(m_layerTreeHost->rootLayer());
296 } 296 }
297 297
298 virtual void notifyAnimationStarted(double time) OVERRIDE { 298 virtual void notifyAnimationStarted(double time) OVERRIDE {
299 LayerAnimationController* controller = 299 LayerAnimationController* controller =
300 m_layerTreeHost->rootLayer()->layerAnimationController(); 300 m_layerTreeHost->rootLayer()->layerAnimationController();
301 ActiveAnimation* animation = 301 Animation* animation =
302 controller->getActiveAnimation(0, ActiveAnimation::Opacity); 302 controller->getAnimation(0, Animation::Opacity);
303 main_start_time_ = animation->startTime(); 303 main_start_time_ = animation->startTime();
304 controller->removeAnimation(animation->id()); 304 controller->removeAnimation(animation->id());
305 305
306 if (impl_start_time_ > 0) 306 if (impl_start_time_ > 0)
307 endTest(); 307 endTest();
308 } 308 }
309 309
310 virtual void animateLayers( 310 virtual void animateLayers(
311 LayerTreeHostImpl* impl_host, 311 LayerTreeHostImpl* impl_host,
312 base::TimeTicks monotonicTime, 312 base::TimeTicks monotonicTime,
313 bool hasUnfinishedAnimation) OVERRIDE { 313 bool hasUnfinishedAnimation) OVERRIDE {
314 LayerAnimationController* controller = 314 LayerAnimationController* controller =
315 impl_host->rootLayer()->layerAnimationController(); 315 impl_host->rootLayer()->layerAnimationController();
316 ActiveAnimation* animation = 316 Animation* animation =
317 controller->getActiveAnimation(0, ActiveAnimation::Opacity); 317 controller->getAnimation(0, Animation::Opacity);
318 if (!animation) 318 if (!animation)
319 return; 319 return;
320 320
321 impl_start_time_ = animation->startTime(); 321 impl_start_time_ = animation->startTime();
322 controller->removeAnimation(animation->id()); 322 controller->removeAnimation(animation->id());
323 323
324 if (main_start_time_ > 0) 324 if (main_start_time_ > 0)
325 endTest(); 325 endTest();
326 } 326 }
327 327
(...skipping 14 matching lines...) Expand all
342 public: 342 public:
343 LayerTreeHostAnimationTestAnimationFinishedEvents() {} 343 LayerTreeHostAnimationTestAnimationFinishedEvents() {}
344 344
345 virtual void beginTest() OVERRIDE { 345 virtual void beginTest() OVERRIDE {
346 postAddInstantAnimationToMainThread(); 346 postAddInstantAnimationToMainThread();
347 } 347 }
348 348
349 virtual void notifyAnimationFinished(double time) OVERRIDE { 349 virtual void notifyAnimationFinished(double time) OVERRIDE {
350 LayerAnimationController* controller = 350 LayerAnimationController* controller =
351 m_layerTreeHost->rootLayer()->layerAnimationController(); 351 m_layerTreeHost->rootLayer()->layerAnimationController();
352 ActiveAnimation* animation = 352 Animation* animation =
353 controller->getActiveAnimation(0, ActiveAnimation::Opacity); 353 controller->getAnimation(0, Animation::Opacity);
354 controller->removeAnimation(animation->id()); 354 controller->removeAnimation(animation->id());
355 endTest(); 355 endTest();
356 } 356 }
357 357
358 virtual void afterTest() OVERRIDE {} 358 virtual void afterTest() OVERRIDE {}
359 }; 359 };
360 360
361 SINGLE_AND_MULTI_THREAD_TEST_F( 361 SINGLE_AND_MULTI_THREAD_TEST_F(
362 LayerTreeHostAnimationTestAnimationFinishedEvents) 362 LayerTreeHostAnimationTestAnimationFinishedEvents)
363 363
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 postSetNeedsCommitToMainThread(); 412 postSetNeedsCommitToMainThread();
413 } 413 }
414 414
415 virtual void didCommit() OVERRIDE { 415 virtual void didCommit() OVERRIDE {
416 if (m_layerTreeHost->commitNumber() == 1) { 416 if (m_layerTreeHost->commitNumber() == 1) {
417 scoped_refptr<Layer> layer = Layer::create(); 417 scoped_refptr<Layer> layer = Layer::create();
418 layer->setLayerAnimationDelegate(this); 418 layer->setLayerAnimationDelegate(this);
419 419
420 // Any valid AnimationCurve will do here. 420 // Any valid AnimationCurve will do here.
421 scoped_ptr<AnimationCurve> curve(EaseTimingFunction::create()); 421 scoped_ptr<AnimationCurve> curve(EaseTimingFunction::create());
422 scoped_ptr<ActiveAnimation> animation( 422 scoped_ptr<Animation> animation(
423 ActiveAnimation::create(curve.Pass(), 1, 1, 423 Animation::create(curve.Pass(), 1, 1,
424 ActiveAnimation::Opacity)); 424 Animation::Opacity));
425 layer->layerAnimationController()->addAnimation(animation.Pass()); 425 layer->layerAnimationController()->addAnimation(animation.Pass());
426 426
427 // We add the animation *before* attaching the layer to the tree. 427 // We add the animation *before* attaching the layer to the tree.
428 m_layerTreeHost->rootLayer()->addChild(layer); 428 m_layerTreeHost->rootLayer()->addChild(layer);
429 } 429 }
430 } 430 }
431 431
432 virtual void animateLayers( 432 virtual void animateLayers(
433 LayerTreeHostImpl* impl_host, 433 LayerTreeHostImpl* impl_host,
434 base::TimeTicks monotonic_time, 434 base::TimeTicks monotonic_time,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 532
533 private: 533 private:
534 int num_commit_complete_; 534 int num_commit_complete_;
535 int num_draw_layers_; 535 int num_draw_layers_;
536 }; 536 };
537 537
538 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate) 538 MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestContinuousAnimate)
539 539
540 } // namespace 540 } // namespace
541 } // namespace cc 541 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_impl.cc ('k') | cc/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698