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

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

Issue 134623005: Make SingleThreadProxy a SchedulerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update client animations in SingleThreadProxy; test this Created 6 years, 5 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
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 virtual void DidCommit() OVERRIDE { test_hooks_->DidCommit(); } 309 virtual void DidCommit() OVERRIDE { test_hooks_->DidCommit(); }
310 310
311 virtual void DidCommitAndDrawFrame() OVERRIDE { 311 virtual void DidCommitAndDrawFrame() OVERRIDE {
312 test_hooks_->DidCommitAndDrawFrame(); 312 test_hooks_->DidCommitAndDrawFrame();
313 } 313 }
314 314
315 virtual void DidCompleteSwapBuffers() OVERRIDE { 315 virtual void DidCompleteSwapBuffers() OVERRIDE {
316 test_hooks_->DidCompleteSwapBuffers(); 316 test_hooks_->DidCompleteSwapBuffers();
317 } 317 }
318 318
319 virtual void ScheduleComposite() OVERRIDE {
320 test_hooks_->ScheduleComposite();
321 }
322
323 virtual void ScheduleAnimation() OVERRIDE {
324 test_hooks_->ScheduleAnimation();
325 }
326
327 virtual void DidPostSwapBuffers() OVERRIDE {} 319 virtual void DidPostSwapBuffers() OVERRIDE {}
328 virtual void DidAbortSwapBuffers() OVERRIDE {} 320 virtual void DidAbortSwapBuffers() OVERRIDE {}
329 321
330 private: 322 private:
331 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) 323 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks)
332 : test_hooks_(test_hooks) {} 324 : test_hooks_(test_hooks) {}
333 325
334 TestHooks* test_hooks_; 326 TestHooks* test_hooks_;
335 }; 327 };
336 328
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 381 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
390 TestHooks* test_hooks_; 382 TestHooks* test_hooks_;
391 bool test_started_; 383 bool test_started_;
392 }; 384 };
393 385
394 LayerTreeTest::LayerTreeTest() 386 LayerTreeTest::LayerTreeTest()
395 : beginning_(false), 387 : beginning_(false),
396 end_when_begin_returns_(false), 388 end_when_begin_returns_(false),
397 timed_out_(false), 389 timed_out_(false),
398 scheduled_(false), 390 scheduled_(false),
399 schedule_when_set_visible_true_(false),
400 started_(false), 391 started_(false),
401 ended_(false), 392 ended_(false),
402 delegating_renderer_(false), 393 delegating_renderer_(false),
403 timeout_seconds_(0), 394 timeout_seconds_(0),
404 weak_factory_(this) { 395 weak_factory_(this) {
405 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); 396 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr();
406 397
407 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was 398 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was
408 // specified (for running in a debugger). 399 // specified (for running in a debugger).
409 CommandLine* command_line = CommandLine::ForCurrentProcess(); 400 CommandLine* command_line = CommandLine::ForCurrentProcess();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 gfx::Size device_root_bounds = gfx::ToCeiledSize( 543 gfx::Size device_root_bounds = gfx::ToCeiledSize(
553 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor())); 544 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor()));
554 layer_tree_host_->SetViewportSize(device_root_bounds); 545 layer_tree_host_->SetViewportSize(device_root_bounds);
555 } 546 }
556 547
557 void LayerTreeTest::Timeout() { 548 void LayerTreeTest::Timeout() {
558 timed_out_ = true; 549 timed_out_ = true;
559 EndTest(); 550 EndTest();
560 } 551 }
561 552
562 void LayerTreeTest::ScheduleComposite() {
563 if (!started_ || scheduled_)
564 return;
565 scheduled_ = true;
566 main_task_runner_->PostTask(
567 FROM_HERE,
568 base::Bind(&LayerTreeTest::DispatchComposite, main_thread_weak_ptr_));
569 }
570
571 void LayerTreeTest::RealEndTest() { 553 void LayerTreeTest::RealEndTest() {
572 if (layer_tree_host_ && proxy()->CommitPendingForTesting()) { 554 if (layer_tree_host_ && proxy()->CommitPendingForTesting()) {
573 main_task_runner_->PostTask( 555 main_task_runner_->PostTask(
574 FROM_HERE, 556 FROM_HERE,
575 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); 557 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_));
576 return; 558 return;
577 } 559 }
578 560
579 base::MessageLoop::current()->Quit(); 561 base::MessageLoop::current()->Quit();
580 } 562 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 594
613 void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect) { 595 void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect) {
614 DCHECK(!proxy() || proxy()->IsMainThread()); 596 DCHECK(!proxy() || proxy()->IsMainThread());
615 597
616 if (layer_tree_host_) 598 if (layer_tree_host_)
617 layer_tree_host_->SetNeedsRedrawRect(damage_rect); 599 layer_tree_host_->SetNeedsRedrawRect(damage_rect);
618 } 600 }
619 601
620 void LayerTreeTest::DispatchSetVisible(bool visible) { 602 void LayerTreeTest::DispatchSetVisible(bool visible) {
621 DCHECK(!proxy() || proxy()->IsMainThread()); 603 DCHECK(!proxy() || proxy()->IsMainThread());
622 604 if (layer_tree_host_)
623 if (!layer_tree_host_) 605 layer_tree_host_->SetVisible(visible);
624 return;
625
626 layer_tree_host_->SetVisible(visible);
627
628 // If the LTH is being made visible and a previous ScheduleComposite() was
629 // deferred because the LTH was not visible, re-schedule the composite now.
630 if (layer_tree_host_->visible() && schedule_when_set_visible_true_)
631 ScheduleComposite();
632 } 606 }
633 607
634 void LayerTreeTest::DispatchSetNextCommitForcesRedraw() { 608 void LayerTreeTest::DispatchSetNextCommitForcesRedraw() {
635 DCHECK(!proxy() || proxy()->IsMainThread()); 609 DCHECK(!proxy() || proxy()->IsMainThread());
636 610
637 if (layer_tree_host_) 611 if (layer_tree_host_)
638 layer_tree_host_->SetNextCommitForcesRedraw(); 612 layer_tree_host_->SetNextCommitForcesRedraw();
639 } 613 }
640 614
641 void LayerTreeTest::DispatchComposite() {
642 scheduled_ = false;
643
644 if (!layer_tree_host_)
645 return;
646
647 // If the LTH is not visible, defer the composite until the LTH is made
648 // visible.
649 if (!layer_tree_host_->visible()) {
650 schedule_when_set_visible_true_ = true;
651 return;
652 }
653
654 schedule_when_set_visible_true_ = false;
655 base::TimeTicks now = gfx::FrameTime::Now();
656 layer_tree_host_->Composite(now);
657 }
658
659 void LayerTreeTest::RunTest(bool threaded, 615 void LayerTreeTest::RunTest(bool threaded,
660 bool delegating_renderer, 616 bool delegating_renderer,
661 bool impl_side_painting) { 617 bool impl_side_painting) {
662 if (threaded) { 618 if (threaded) {
663 impl_thread_.reset(new base::Thread("Compositor")); 619 impl_thread_.reset(new base::Thread("Compositor"));
664 ASSERT_TRUE(impl_thread_->Start()); 620 ASSERT_TRUE(impl_thread_->Start());
665 } 621 }
666 622
667 main_task_runner_ = base::MessageLoopProxy::current(); 623 main_task_runner_ = base::MessageLoopProxy::current();
668 624
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 return -1; 698 return -1;
743 } 699 }
744 700
745 void LayerTreeTest::DestroyLayerTreeHost() { 701 void LayerTreeTest::DestroyLayerTreeHost() {
746 if (layer_tree_host_ && layer_tree_host_->root_layer()) 702 if (layer_tree_host_ && layer_tree_host_->root_layer())
747 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); 703 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL);
748 layer_tree_host_.reset(); 704 layer_tree_host_.reset();
749 } 705 }
750 706
751 } // namespace cc 707 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698