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

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

Powered by Google App Engine
This is Rietveld 408576698