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

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 292533002: Remove forced commit and readback from the scheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm-cnr-scheduler: moretest Created 6 years, 7 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/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/trees/thread_proxy.h » ('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 #include "cc/scheduler/scheduler.h" 4 #include "cc/scheduler/scheduler.h"
5 5
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (automatic_swap_ack_) 127 if (automatic_swap_ack_)
128 scheduler_->DidSwapBuffersComplete(); 128 scheduler_->DidSwapBuffersComplete();
129 } 129 }
130 return result; 130 return result;
131 } 131 }
132 virtual DrawResult ScheduledActionDrawAndSwapForced() OVERRIDE { 132 virtual DrawResult ScheduledActionDrawAndSwapForced() OVERRIDE {
133 actions_.push_back("ScheduledActionDrawAndSwapForced"); 133 actions_.push_back("ScheduledActionDrawAndSwapForced");
134 states_.push_back(scheduler_->AsValue().release()); 134 states_.push_back(scheduler_->AsValue().release());
135 return DRAW_SUCCESS; 135 return DRAW_SUCCESS;
136 } 136 }
137 virtual DrawResult ScheduledActionDrawAndReadback() OVERRIDE {
138 actions_.push_back("ScheduledActionDrawAndReadback");
139 states_.push_back(scheduler_->AsValue().release());
140 return DRAW_SUCCESS;
141 }
142 virtual void ScheduledActionCommit() OVERRIDE { 137 virtual void ScheduledActionCommit() OVERRIDE {
143 actions_.push_back("ScheduledActionCommit"); 138 actions_.push_back("ScheduledActionCommit");
144 states_.push_back(scheduler_->AsValue().release()); 139 states_.push_back(scheduler_->AsValue().release());
145 } 140 }
146 virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE { 141 virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE {
147 actions_.push_back("ScheduledActionUpdateVisibleTiles"); 142 actions_.push_back("ScheduledActionUpdateVisibleTiles");
148 states_.push_back(scheduler_->AsValue().release()); 143 states_.push_back(scheduler_->AsValue().release());
149 } 144 }
150 virtual void ScheduledActionActivatePendingTree() OVERRIDE { 145 virtual void ScheduledActionActivatePendingTree() OVERRIDE {
151 actions_.push_back("ScheduledActionActivatePendingTree"); 146 actions_.push_back("ScheduledActionActivatePendingTree");
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 EXPECT_TRUE(client.needs_begin_frame()); 633 EXPECT_TRUE(client.needs_begin_frame());
639 634
640 // Fail to draw, this should not start a frame. 635 // Fail to draw, this should not start a frame.
641 client.SetDrawWillHappen(false); 636 client.SetDrawWillHappen(false);
642 client.SetNeedsCommitOnNextDraw(); 637 client.SetNeedsCommitOnNextDraw();
643 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 638 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
644 client.task_runner().RunPendingTasks(); // Run posted deadline. 639 client.task_runner().RunPendingTasks(); // Run posted deadline.
645 EXPECT_EQ(2, client.num_draws()); 640 EXPECT_EQ(2, client.num_draws());
646 } 641 }
647 642
648 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) {
649 FakeSchedulerClient client;
650 SchedulerSettings default_scheduler_settings;
651 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
652
653 // Tell the client that it will fail to swap.
654 client.SetDrawWillHappen(true);
655 client.SetSwapWillHappenIfDrawHappens(false);
656
657 // Get the compositor to do a ScheduledActionDrawAndReadback.
658 scheduler->SetCanDraw(true);
659 scheduler->SetNeedsRedraw();
660 scheduler->SetNeedsForcedCommitForReadback();
661 scheduler->NotifyBeginMainFrameStarted();
662 scheduler->NotifyReadyToCommit();
663 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
664 }
665
666 TEST(SchedulerTest, BackToBackReadbackAllowed) {
667 // Some clients call readbacks twice in a row before the replacement
668 // commit comes in. Make sure it is allowed.
669 FakeSchedulerClient client;
670 SchedulerSettings default_scheduler_settings;
671 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
672
673 // Get the compositor to do 2 ScheduledActionDrawAndReadbacks before
674 // the replacement commit comes in.
675 scheduler->SetCanDraw(true);
676 scheduler->SetNeedsRedraw();
677 scheduler->SetNeedsForcedCommitForReadback();
678 scheduler->NotifyBeginMainFrameStarted();
679 scheduler->NotifyReadyToCommit();
680 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
681
682 client.Reset();
683 scheduler->SetNeedsForcedCommitForReadback();
684 scheduler->NotifyBeginMainFrameStarted();
685 scheduler->NotifyReadyToCommit();
686 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
687
688 // The replacement commit comes in after 2 readbacks.
689 client.Reset();
690 scheduler->NotifyBeginMainFrameStarted();
691 scheduler->NotifyReadyToCommit();
692 }
693
694
695 class SchedulerClientNeedsManageTilesInDraw : public FakeSchedulerClient { 643 class SchedulerClientNeedsManageTilesInDraw : public FakeSchedulerClient {
696 public: 644 public:
697 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() 645 virtual DrawResult ScheduledActionDrawAndSwapIfPossible()
698 OVERRIDE { 646 OVERRIDE {
699 scheduler_->SetNeedsManageTiles(); 647 scheduler_->SetNeedsManageTiles();
700 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 648 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
701 } 649 }
702 }; 650 };
703 651
704 // Test manage tiles is independant of draws. 652 // Test manage tiles is independant of draws.
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 TEST(SchedulerTest, 1414 TEST(SchedulerTest,
1467 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) { 1415 SyntheticBeginFrames_And_VSyncThrottlingDisabled_SwapThrottled) {
1468 bool begin_frame_scheduling_enabled = false; 1416 bool begin_frame_scheduling_enabled = false;
1469 bool throttle_frame_production = false; 1417 bool throttle_frame_production = false;
1470 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled, 1418 BeginFramesNotFromClient_SwapThrottled(begin_frame_scheduling_enabled,
1471 throttle_frame_production); 1419 throttle_frame_production);
1472 } 1420 }
1473 1421
1474 } // namespace 1422 } // namespace
1475 } // namespace cc 1423 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/trees/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698