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

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

Powered by Google App Engine
This is Rietveld 408576698