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

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

Issue 441343002: Revert 287747 "Make SingleThreadProxy a SchedulerClient" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
« no previous file with comments | « trunk/src/cc/test/layer_tree_test.h ('k') | trunk/src/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 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
315 virtual void DidPostSwapBuffers() OVERRIDE {} 323 virtual void DidPostSwapBuffers() OVERRIDE {}
316 virtual void DidAbortSwapBuffers() OVERRIDE {} 324 virtual void DidAbortSwapBuffers() OVERRIDE {}
317 325
318 private: 326 private:
319 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks) 327 explicit LayerTreeHostClientForTesting(TestHooks* test_hooks)
320 : test_hooks_(test_hooks) {} 328 : test_hooks_(test_hooks) {}
321 329
322 TestHooks* test_hooks_; 330 TestHooks* test_hooks_;
323 }; 331 };
324 332
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 387 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
380 TestHooks* test_hooks_; 388 TestHooks* test_hooks_;
381 bool test_started_; 389 bool test_started_;
382 }; 390 };
383 391
384 LayerTreeTest::LayerTreeTest() 392 LayerTreeTest::LayerTreeTest()
385 : beginning_(false), 393 : beginning_(false),
386 end_when_begin_returns_(false), 394 end_when_begin_returns_(false),
387 timed_out_(false), 395 timed_out_(false),
388 scheduled_(false), 396 scheduled_(false),
397 schedule_when_set_visible_true_(false),
389 started_(false), 398 started_(false),
390 ended_(false), 399 ended_(false),
391 delegating_renderer_(false), 400 delegating_renderer_(false),
392 timeout_seconds_(0), 401 timeout_seconds_(0),
393 weak_factory_(this) { 402 weak_factory_(this) {
394 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); 403 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr();
395 404
396 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was 405 // Tests should timeout quickly unless --cc-layer-tree-test-no-timeout was
397 // specified (for running in a debugger). 406 // specified (for running in a debugger).
398 CommandLine* command_line = CommandLine::ForCurrentProcess(); 407 CommandLine* command_line = CommandLine::ForCurrentProcess();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 gfx::Size device_root_bounds = gfx::ToCeiledSize( 551 gfx::Size device_root_bounds = gfx::ToCeiledSize(
543 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor())); 552 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor()));
544 layer_tree_host_->SetViewportSize(device_root_bounds); 553 layer_tree_host_->SetViewportSize(device_root_bounds);
545 } 554 }
546 555
547 void LayerTreeTest::Timeout() { 556 void LayerTreeTest::Timeout() {
548 timed_out_ = true; 557 timed_out_ = true;
549 EndTest(); 558 EndTest();
550 } 559 }
551 560
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
552 void LayerTreeTest::RealEndTest() { 570 void LayerTreeTest::RealEndTest() {
553 if (layer_tree_host_ && proxy()->CommitPendingForTesting()) { 571 if (layer_tree_host_ && proxy()->CommitPendingForTesting()) {
554 main_task_runner_->PostTask( 572 main_task_runner_->PostTask(
555 FROM_HERE, 573 FROM_HERE,
556 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); 574 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_));
557 return; 575 return;
558 } 576 }
559 577
560 base::MessageLoop::current()->Quit(); 578 base::MessageLoop::current()->Quit();
561 } 579 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 611
594 void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect) { 612 void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect) {
595 DCHECK(!proxy() || proxy()->IsMainThread()); 613 DCHECK(!proxy() || proxy()->IsMainThread());
596 614
597 if (layer_tree_host_) 615 if (layer_tree_host_)
598 layer_tree_host_->SetNeedsRedrawRect(damage_rect); 616 layer_tree_host_->SetNeedsRedrawRect(damage_rect);
599 } 617 }
600 618
601 void LayerTreeTest::DispatchSetVisible(bool visible) { 619 void LayerTreeTest::DispatchSetVisible(bool visible) {
602 DCHECK(!proxy() || proxy()->IsMainThread()); 620 DCHECK(!proxy() || proxy()->IsMainThread());
603 if (layer_tree_host_) 621
604 layer_tree_host_->SetVisible(visible); 622 if (!layer_tree_host_)
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();
605 } 631 }
606 632
607 void LayerTreeTest::DispatchSetNextCommitForcesRedraw() { 633 void LayerTreeTest::DispatchSetNextCommitForcesRedraw() {
608 DCHECK(!proxy() || proxy()->IsMainThread()); 634 DCHECK(!proxy() || proxy()->IsMainThread());
609 635
610 if (layer_tree_host_) 636 if (layer_tree_host_)
611 layer_tree_host_->SetNextCommitForcesRedraw(); 637 layer_tree_host_->SetNextCommitForcesRedraw();
612 } 638 }
613 639
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
614 void LayerTreeTest::RunTest(bool threaded, 658 void LayerTreeTest::RunTest(bool threaded,
615 bool delegating_renderer, 659 bool delegating_renderer,
616 bool impl_side_painting) { 660 bool impl_side_painting) {
617 if (threaded) { 661 if (threaded) {
618 impl_thread_.reset(new base::Thread("Compositor")); 662 impl_thread_.reset(new base::Thread("Compositor"));
619 ASSERT_TRUE(impl_thread_->Start()); 663 ASSERT_TRUE(impl_thread_->Start());
620 } 664 }
621 665
622 main_task_runner_ = base::MessageLoopProxy::current(); 666 main_task_runner_ = base::MessageLoopProxy::current();
623 667
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 return -1; 741 return -1;
698 } 742 }
699 743
700 void LayerTreeTest::DestroyLayerTreeHost() { 744 void LayerTreeTest::DestroyLayerTreeHost() {
701 if (layer_tree_host_ && layer_tree_host_->root_layer()) 745 if (layer_tree_host_ && layer_tree_host_->root_layer())
702 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); 746 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL);
703 layer_tree_host_.reset(); 747 layer_tree_host_.reset();
704 } 748 }
705 749
706 } // namespace cc 750 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/test/layer_tree_test.h ('k') | trunk/src/cc/trees/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698