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

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: Add scoped_abort_remaining_swap_promises.h 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 | « 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 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_ && !timed_out_ && 553 if (layer_tree_host_ && !timed_out_ &&
572 proxy()->MainFrameWillHappenForTesting()) { 554 proxy()->MainFrameWillHappenForTesting()) {
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();
(...skipping 32 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
« 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