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

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

Issue 13613003: cc: Make animations tick regardless of drawing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop extra statemachine function Created 7 years, 8 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/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/layer_tree_test.h" 5 #include "cc/test/layer_tree_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "cc/animation/animation.h" 8 #include "cc/animation/animation.h"
9 #include "cc/animation/animation_registrar.h" 9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/layer_animation_controller.h" 10 #include "cc/animation/layer_animation_controller.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 test_hooks_->DidSetVisibleOnImplTree(this, visible); 144 test_hooks_->DidSetVisibleOnImplTree(this, visible);
145 } 145 }
146 146
147 virtual void AnimateLayers(base::TimeTicks monotonic_time, 147 virtual void AnimateLayers(base::TimeTicks monotonic_time,
148 base::Time wall_clock_time) OVERRIDE { 148 base::Time wall_clock_time) OVERRIDE {
149 test_hooks_->WillAnimateLayers(this, monotonic_time); 149 test_hooks_->WillAnimateLayers(this, monotonic_time);
150 LayerTreeHostImpl::AnimateLayers(monotonic_time, wall_clock_time); 150 LayerTreeHostImpl::AnimateLayers(monotonic_time, wall_clock_time);
151 test_hooks_->AnimateLayers(this, monotonic_time); 151 test_hooks_->AnimateLayers(this, monotonic_time);
152 } 152 }
153 153
154 virtual void UpdateAnimationState() OVERRIDE { 154 virtual void UpdateAnimationState(bool start_ready_animations) OVERRIDE {
155 LayerTreeHostImpl::UpdateAnimationState(); 155 LayerTreeHostImpl::UpdateAnimationState(start_ready_animations);
156 bool has_unfinished_animation = false; 156 bool has_unfinished_animation = false;
157 AnimationRegistrar::AnimationControllerMap::const_iterator iter = 157 AnimationRegistrar::AnimationControllerMap::const_iterator iter =
158 active_animation_controllers().begin(); 158 active_animation_controllers().begin();
159 for (; iter != active_animation_controllers().end(); ++iter) { 159 for (; iter != active_animation_controllers().end(); ++iter) {
160 if (iter->second->HasActiveAnimation()) { 160 if (iter->second->HasActiveAnimation()) {
161 has_unfinished_animation = true; 161 has_unfinished_animation = true;
162 break; 162 break;
163 } 163 }
164 } 164 }
165 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); 165 test_hooks_->UpdateAnimationState(this, has_unfinished_animation);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 339 }
340 340
341 void LayerTreeTest::PostAddAnimationToMainThread( 341 void LayerTreeTest::PostAddAnimationToMainThread(
342 Layer* layer_to_receive_animation) { 342 Layer* layer_to_receive_animation) {
343 proxy()->MainThread()->PostTask( 343 proxy()->MainThread()->PostTask(
344 base::Bind(&LayerTreeTest::DispatchAddAnimation, 344 base::Bind(&LayerTreeTest::DispatchAddAnimation,
345 main_thread_weak_ptr_, 345 main_thread_weak_ptr_,
346 base::Unretained(layer_to_receive_animation))); 346 base::Unretained(layer_to_receive_animation)));
347 } 347 }
348 348
349 void LayerTreeTest::PostAddInstantAnimationToMainThread() { 349 void LayerTreeTest::PostAddInstantAnimationToMainThread(
350 Layer* layer_to_receive_animation) {
350 proxy()->MainThread()->PostTask( 351 proxy()->MainThread()->PostTask(
351 base::Bind(&LayerTreeTest::DispatchAddInstantAnimation, 352 base::Bind(&LayerTreeTest::DispatchAddInstantAnimation,
352 main_thread_weak_ptr_)); 353 main_thread_weak_ptr_,
354 base::Unretained(layer_to_receive_animation)));
353 } 355 }
354 356
355 void LayerTreeTest::PostSetNeedsCommitToMainThread() { 357 void LayerTreeTest::PostSetNeedsCommitToMainThread() {
356 proxy()->MainThread()->PostTask( 358 proxy()->MainThread()->PostTask(
357 base::Bind(&LayerTreeTest::DispatchSetNeedsCommit, 359 base::Bind(&LayerTreeTest::DispatchSetNeedsCommit,
358 main_thread_weak_ptr_)); 360 main_thread_weak_ptr_));
359 } 361 }
360 362
361 void LayerTreeTest::PostAcquireLayerTextures() { 363 void LayerTreeTest::PostAcquireLayerTextures() {
362 proxy()->MainThread()->PostTask( 364 proxy()->MainThread()->PostTask(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 441
440 if (layer_tree_host_ && proxy()->CommitPendingForTesting()) { 442 if (layer_tree_host_ && proxy()->CommitPendingForTesting()) {
441 proxy()->MainThread()->PostTask( 443 proxy()->MainThread()->PostTask(
442 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); 444 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_));
443 return; 445 return;
444 } 446 }
445 447
446 MessageLoop::current()->Quit(); 448 MessageLoop::current()->Quit();
447 } 449 }
448 450
449 void LayerTreeTest::DispatchAddInstantAnimation() { 451 void LayerTreeTest::DispatchAddInstantAnimation(
452 Layer* layer_to_receive_animation) {
450 DCHECK(!proxy() || proxy()->IsMainThread()); 453 DCHECK(!proxy() || proxy()->IsMainThread());
451 454
452 if (layer_tree_host_.get() && layer_tree_host_->root_layer()) { 455 if (layer_to_receive_animation) {
453 AddOpacityTransitionToLayer(layer_tree_host_->root_layer(), 456 AddOpacityTransitionToLayer(layer_to_receive_animation,
454 0, 457 0,
455 0, 458 0,
456 0.5, 459 0.5,
457 false); 460 false);
458 } 461 }
459 } 462 }
460 463
461 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation) { 464 void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation) {
462 DCHECK(!proxy() || proxy()->IsMainThread()); 465 DCHECK(!proxy() || proxy()->IsMainThread());
463 466
464 if (layer_to_receive_animation) 467 if (layer_to_receive_animation) {
465 AddOpacityTransitionToLayer(layer_to_receive_animation, 10, 0, 0.5, true); 468 AddOpacityTransitionToLayer(layer_to_receive_animation,
469 0.000001,
470 0,
471 0.5,
472 true);
473 }
466 } 474 }
467 475
468 void LayerTreeTest::DispatchSetNeedsCommit() { 476 void LayerTreeTest::DispatchSetNeedsCommit() {
469 DCHECK(!proxy() || proxy()->IsMainThread()); 477 DCHECK(!proxy() || proxy()->IsMainThread());
470 478
471 if (layer_tree_host_) 479 if (layer_tree_host_)
472 layer_tree_host_->SetNeedsCommit(); 480 layer_tree_host_->SetNeedsCommit();
473 } 481 }
474 482
475 void LayerTreeTest::DispatchAcquireLayerTextures() { 483 void LayerTreeTest::DispatchAcquireLayerTextures() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 return; 515 return;
508 516
509 // If the LTH is not visible, defer the composite until the LTH is made 517 // If the LTH is not visible, defer the composite until the LTH is made
510 // visible. 518 // visible.
511 if (!layer_tree_host_->visible()) { 519 if (!layer_tree_host_->visible()) {
512 schedule_when_set_visible_true_ = true; 520 schedule_when_set_visible_true_ = true;
513 return; 521 return;
514 } 522 }
515 523
516 schedule_when_set_visible_true_ = false; 524 schedule_when_set_visible_true_ = false;
517 layer_tree_host_->Composite(base::TimeTicks::Now()); 525 base::TimeTicks now = base::TimeTicks::Now();
526 layer_tree_host_->UpdateAnimations(now);
527 layer_tree_host_->Composite(now);
518 } 528 }
519 529
520 void LayerTreeTest::RunTest(bool threaded) { 530 void LayerTreeTest::RunTest(bool threaded) {
521 if (threaded) { 531 if (threaded) {
522 impl_thread_.reset(new base::Thread("LayerTreeTest")); 532 impl_thread_.reset(new base::Thread("LayerTreeTest"));
523 ASSERT_TRUE(impl_thread_->Start()); 533 ASSERT_TRUE(impl_thread_->Start());
524 } 534 }
525 535
526 main_ccthread_ = cc::ThreadImpl::CreateForCurrentThread(); 536 main_ccthread_ = cc::ThreadImpl::CreateForCurrentThread();
527 537
(...skipping 19 matching lines...) Expand all
547 ASSERT_FALSE(layer_tree_host_.get()); 557 ASSERT_FALSE(layer_tree_host_.get());
548 client_.reset(); 558 client_.reset();
549 if (timed_out_) { 559 if (timed_out_) {
550 FAIL() << "Test timed out"; 560 FAIL() << "Test timed out";
551 return; 561 return;
552 } 562 }
553 AfterTest(); 563 AfterTest();
554 } 564 }
555 565
556 } // namespace cc 566 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.h ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698