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

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

Issue 337693005: cc: Control defer_commits logic by Scheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 453 }
454 454
455 void SetNeedsCommit() override { 455 void SetNeedsCommit() override {
456 if (!test_started_) 456 if (!test_started_)
457 return; 457 return;
458 LayerTreeHost::SetNeedsCommit(); 458 LayerTreeHost::SetNeedsCommit();
459 } 459 }
460 460
461 void set_test_started(bool started) { test_started_ = started; } 461 void set_test_started(bool started) { test_started_ = started; }
462 462
463 void DidDeferCommit() override { test_hooks_->DidDeferCommit(); }
464
465 private: 463 private:
466 LayerTreeHostForTesting(TestHooks* test_hooks, 464 LayerTreeHostForTesting(TestHooks* test_hooks,
467 LayerTreeHostClient* client, 465 LayerTreeHostClient* client,
468 const LayerTreeSettings& settings) 466 const LayerTreeSettings& settings)
469 : LayerTreeHost(client, NULL, NULL, settings), 467 : LayerTreeHost(client, NULL, NULL, settings),
470 shared_bitmap_manager_(new TestSharedBitmapManager), 468 shared_bitmap_manager_(new TestSharedBitmapManager),
471 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), 469 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager),
472 test_hooks_(test_hooks), 470 test_hooks_(test_hooks),
473 test_started_(false) {} 471 test_started_(false) {}
474 472
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 } 515 }
518 } 516 }
519 517
520 void LayerTreeTest::EndTestAfterDelayMs(int delay_milliseconds) { 518 void LayerTreeTest::EndTestAfterDelayMs(int delay_milliseconds) {
521 main_task_runner_->PostDelayedTask( 519 main_task_runner_->PostDelayedTask(
522 FROM_HERE, 520 FROM_HERE,
523 base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_), 521 base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_),
524 base::TimeDelta::FromMilliseconds(delay_milliseconds)); 522 base::TimeDelta::FromMilliseconds(delay_milliseconds));
525 } 523 }
526 524
525 void LayerTreeTest::PostSetDeferCommitsToMainThread(bool defer_commits) {
526 main_task_runner_->PostTask(
527 FROM_HERE,
528 base::Bind(&LayerTreeTest::DispatchSetDeferCommits,
529 main_thread_weak_ptr_, defer_commits));
530 }
531
527 void LayerTreeTest::PostAddAnimationToMainThread( 532 void LayerTreeTest::PostAddAnimationToMainThread(
528 Layer* layer_to_receive_animation) { 533 Layer* layer_to_receive_animation) {
529 main_task_runner_->PostTask( 534 main_task_runner_->PostTask(
530 FROM_HERE, 535 FROM_HERE,
531 base::Bind(&LayerTreeTest::DispatchAddAnimation, main_thread_weak_ptr_, 536 base::Bind(&LayerTreeTest::DispatchAddAnimation, main_thread_weak_ptr_,
532 base::Unretained(layer_to_receive_animation), 0.000004)); 537 base::Unretained(layer_to_receive_animation), 0.000004));
533 } 538 }
534 539
535 void LayerTreeTest::PostAddInstantAnimationToMainThread( 540 void LayerTreeTest::PostAddInstantAnimationToMainThread(
536 Layer* layer_to_receive_animation) { 541 Layer* layer_to_receive_animation) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 if (layer_tree_host_) 729 if (layer_tree_host_)
725 layer_tree_host_->SetNextCommitForcesRedraw(); 730 layer_tree_host_->SetNextCommitForcesRedraw();
726 } 731 }
727 732
728 void LayerTreeTest::DispatchCompositeImmediately() { 733 void LayerTreeTest::DispatchCompositeImmediately() {
729 DCHECK(!proxy() || proxy()->IsMainThread()); 734 DCHECK(!proxy() || proxy()->IsMainThread());
730 if (layer_tree_host_) 735 if (layer_tree_host_)
731 layer_tree_host_->Composite(gfx::FrameTime::Now()); 736 layer_tree_host_->Composite(gfx::FrameTime::Now());
732 } 737 }
733 738
739 void LayerTreeTest::DispatchSetDeferCommits(bool defer_commits) {
740 DCHECK(!proxy() || proxy()->IsMainThread());
741 if (layer_tree_host_)
742 layer_tree_host_->SetDeferCommits(defer_commits);
743 }
744
734 void LayerTreeTest::RunTest(bool threaded, 745 void LayerTreeTest::RunTest(bool threaded,
735 bool delegating_renderer, 746 bool delegating_renderer,
736 bool impl_side_painting) { 747 bool impl_side_painting) {
737 if (threaded) { 748 if (threaded) {
738 impl_thread_.reset(new base::Thread("Compositor")); 749 impl_thread_.reset(new base::Thread("Compositor"));
739 ASSERT_TRUE(impl_thread_->Start()); 750 ASSERT_TRUE(impl_thread_->Start());
740 } 751 }
741 752
742 main_task_runner_ = base::MessageLoopProxy::current(); 753 main_task_runner_ = base::MessageLoopProxy::current();
743 754
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 return -1; 835 return -1;
825 } 836 }
826 837
827 void LayerTreeTest::DestroyLayerTreeHost() { 838 void LayerTreeTest::DestroyLayerTreeHost() {
828 if (layer_tree_host_ && layer_tree_host_->root_layer()) 839 if (layer_tree_host_ && layer_tree_host_->root_layer())
829 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); 840 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL);
830 layer_tree_host_ = nullptr; 841 layer_tree_host_ = nullptr;
831 } 842 }
832 843
833 } // namespace cc 844 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698