summaryrefslogtreecommitdiffstats
path: root/cc/scheduler
diff options
context:
space:
mode:
authorbrianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 10:45:03 +0000
committerbrianderson@chromium.org <brianderson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 10:45:03 +0000
commitc8cbae7f41a1212bce61523021a60ee78783993b (patch)
tree8a57d88602df03a587c2dcd2a95039b20ec4ef83 /cc/scheduler
parent280755cad298b37cd6ead4d16337c4e1ed79f1a0 (diff)
downloadchromium_src-c8cbae7f41a1212bce61523021a60ee78783993b.zip
chromium_src-c8cbae7f41a1212bce61523021a60ee78783993b.tar.gz
chromium_src-c8cbae7f41a1212bce61523021a60ee78783993b.tar.bz2
cc: Rename VSync to BeginFrame
We are replacing hard vsync scheduling with BeginFrame+deadline intervals. This patch removes references to vsync in CC where it will no longer make sense. (One exception is cc::VSyncTimeSource, which will be removed in future patches to be incorporated into the scheduler itself.) Additionally, BeginFrames are clarified with suffixes whenever context is not enough and existing identifiers associated with BeginFrame when it no longer makes sense are renamed. A summary of the important renames are as follows: Browser Side Renames: COutputSurface::EnableVSyncNotification -> SetNeedsBeginFrame COutputSurface::OnDidVSync -> OnBeginFrame ViewHostMsg_SetVSyncNotificationEnabled -> ViewHostMsg_SetNeedsBeginFrame ViewMsg_DidVSync -> ViewMsg_BeginFrame Impl Side Renames: LTHI::EnableVSyncNotification -> SetNeedsBeginFrame LTHI::DidVSync -> BeginFrame LTHI::DidRecieveLastInputEventForVSync -> DidReceiveLastInputEventForBeginFrame Main+Impl Side Renames: LTHIClient::DidVSync -> BeginFrameOnImplThread LTHIClient::DidRecieveLastInputEventForVSync -> DidReceiveLastInputEventForBeginFrameOnImplThread TProxy::BeginFrame -> BeginFrameOnMainThread TProxy::ForceBeginFrameOnImplThread -> ForceCommitOnImplThread TProxy::BeginFrameCompleteOnImplThread -> StartCommitOnImplThread Scheduler::BeginFrameComplete -> FinishCommit Scheduler::BeginFrameAborted -> BeginFrameAbortedByMainThread Scheduler::LastVsyncTime -> LastBeginFrameOnImplThreadTime Scheduler::VSyncTick -> BeginFrame SchedulerSM::VSyncCallbackNeeded -> BeginFrameNeededByImplThread SchedulerSM::ACTION_BEGIN_FRAME -> ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD FRC::DidBeginFrame -> DidSwapBuffers FRC::DidFinishFrame -> DidSwapBuffersComplete Random Renames: LTSettings::render_vsync_enabled -> throttle_frame_production LTSettings::render_vsync_notification_enabled -> render_parent_drives_begin_frame LTSettings::synchronously_disable_vsync -> using_synchronous_renderer_compositor RenderWidget::SynchronouslyDisableVSync -> UsingSynchronousRendererCompositor BUG=240945 Review URL: https://chromiumcodereview.appspot.com/15058004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/scheduler')
-rw-r--r--cc/scheduler/frame_rate_controller.cc8
-rw-r--r--cc/scheduler/frame_rate_controller.h8
-rw-r--r--cc/scheduler/frame_rate_controller_unittest.cc85
-rw-r--r--cc/scheduler/scheduler.cc37
-rw-r--r--cc/scheduler/scheduler.h10
-rw-r--r--cc/scheduler/scheduler_state_machine.cc59
-rw-r--r--cc/scheduler/scheduler_state_machine.h43
-rw-r--r--cc/scheduler/scheduler_state_machine_unittest.cc361
-rw-r--r--cc/scheduler/scheduler_unittest.cc40
9 files changed, 351 insertions, 300 deletions
diff --git a/cc/scheduler/frame_rate_controller.cc b/cc/scheduler/frame_rate_controller.cc
index 4e523d78..4fcea23 100644
--- a/cc/scheduler/frame_rate_controller.cc
+++ b/cc/scheduler/frame_rate_controller.cc
@@ -98,10 +98,10 @@ void FrameRateController::OnTimerTick() {
// Check if we have too many frames in flight.
bool throttled =
max_frames_pending_ && num_frames_pending_ >= max_frames_pending_;
- TRACE_COUNTER_ID1("cc", "ThrottledVSyncInterval", thread_, throttled);
+ TRACE_COUNTER_ID1("cc", "ThrottledCompositor", thread_, throttled);
if (client_)
- client_->VSyncTick(throttled);
+ client_->BeginFrame(throttled);
if (swap_buffers_complete_supported_ && !is_time_source_throttling_ &&
!throttled)
@@ -117,14 +117,14 @@ void FrameRateController::PostManualTick() {
void FrameRateController::ManualTick() { OnTimerTick(); }
-void FrameRateController::DidBeginFrame() {
+void FrameRateController::DidSwapBuffers() {
if (swap_buffers_complete_supported_)
num_frames_pending_++;
else if (!is_time_source_throttling_)
PostManualTick();
}
-void FrameRateController::DidFinishFrame() {
+void FrameRateController::DidSwapBuffersComplete() {
DCHECK(swap_buffers_complete_supported_);
DCHECK_GT(num_frames_pending_, 0);
diff --git a/cc/scheduler/frame_rate_controller.h b/cc/scheduler/frame_rate_controller.h
index fe25866..9210a670 100644
--- a/cc/scheduler/frame_rate_controller.h
+++ b/cc/scheduler/frame_rate_controller.h
@@ -19,7 +19,7 @@ class TimeSource;
class CC_EXPORT FrameRateControllerClient {
public:
// Throttled is true when we have a maximum number of frames pending.
- virtual void VSyncTick(bool throttled) = 0;
+ virtual void BeginFrame(bool throttled) = 0;
protected:
virtual ~FrameRateControllerClient() {}
@@ -44,12 +44,12 @@ class CC_EXPORT FrameRateController {
// Use the following methods to adjust target frame rate.
//
- // Multiple frames can be in-progress, but for every DidBeginFrame, a
+ // Multiple frames can be in-progress, but for every DidSwapBuffers, a
// DidFinishFrame should be posted.
//
// If the rendering pipeline crashes, call DidAbortAllPendingFrames.
- void DidBeginFrame();
- void DidFinishFrame();
+ void DidSwapBuffers();
+ void DidSwapBuffersComplete();
void DidAbortAllPendingFrames();
void SetMaxFramesPending(int max_frames_pending); // 0 for unlimited.
int MaxFramesPending() const { return max_frames_pending_; }
diff --git a/cc/scheduler/frame_rate_controller_unittest.cc b/cc/scheduler/frame_rate_controller_unittest.cc
index 0ed600a..183f576 100644
--- a/cc/scheduler/frame_rate_controller_unittest.cc
+++ b/cc/scheduler/frame_rate_controller_unittest.cc
@@ -14,15 +14,15 @@ class FakeFrameRateControllerClient : public cc::FrameRateControllerClient {
public:
FakeFrameRateControllerClient() { Reset(); }
- void Reset() { vsync_ticked_ = false; }
- bool VSyncTicked() const { return vsync_ticked_; }
+ void Reset() { began_frame_ = false; }
+ bool BeganFrame() const { return began_frame_; }
- virtual void VSyncTick(bool throttled) OVERRIDE {
- vsync_ticked_ = !throttled;
+ virtual void BeginFrame(bool throttled) OVERRIDE {
+ began_frame_ = !throttled;
}
protected:
- bool vsync_ticked_;
+ bool began_frame_;
};
TEST(FrameRateControllerTest, TestFrameThrottling_ImmediateAck) {
@@ -39,28 +39,28 @@ TEST(FrameRateControllerTest, TestFrameThrottling_ImmediateAck) {
base::TimeTicks elapsed; // Muck around with time a bit
- // Trigger one frame, make sure the vsync callback is called
+ // Trigger one frame, make sure the BeginFrame callback is called
elapsed += base::TimeDelta::FromMilliseconds(thread.PendingDelayMs());
time_source->SetNow(elapsed);
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
client.Reset();
// Tell the controller we drew
- controller.DidBeginFrame();
+ controller.DidSwapBuffers();
// Tell the controller the frame ended 5ms later
time_source->SetNow(time_source->Now() +
base::TimeDelta::FromMilliseconds(5));
- controller.DidFinishFrame();
+ controller.DidSwapBuffersComplete();
- // Trigger another frame, make sure vsync runs again
+ // Trigger another frame, make sure BeginFrame runs again
elapsed += base::TimeDelta::FromMilliseconds(thread.PendingDelayMs());
// Sanity check that previous code didn't move time backward.
EXPECT_GE(elapsed, time_source->Now());
time_source->SetNow(elapsed);
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
}
TEST(FrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight) {
@@ -78,27 +78,27 @@ TEST(FrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight) {
base::TimeTicks elapsed; // Muck around with time a bit
- // Trigger one frame, make sure the vsync callback is called
+ // Trigger one frame, make sure the BeginFrame callback is called
elapsed += base::TimeDelta::FromMilliseconds(thread.PendingDelayMs());
time_source->SetNow(elapsed);
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
client.Reset();
// Tell the controller we drew
- controller.DidBeginFrame();
+ controller.DidSwapBuffers();
- // Trigger another frame, make sure vsync callback runs again
+ // Trigger another frame, make sure BeginFrame callback runs again
elapsed += base::TimeDelta::FromMilliseconds(thread.PendingDelayMs());
// Sanity check that previous code didn't move time backward.
EXPECT_GE(elapsed, time_source->Now());
time_source->SetNow(elapsed);
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
client.Reset();
// Tell the controller we drew, again.
- controller.DidBeginFrame();
+ controller.DidSwapBuffers();
// Trigger another frame. Since two frames are pending, we should not draw.
elapsed += base::TimeDelta::FromMilliseconds(thread.PendingDelayMs());
@@ -106,24 +106,24 @@ TEST(FrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight) {
EXPECT_GE(elapsed, time_source->Now());
time_source->SetNow(elapsed);
thread.RunPendingTask();
- EXPECT_FALSE(client.VSyncTicked());
+ EXPECT_FALSE(client.BeganFrame());
// Tell the controller the first frame ended 5ms later
time_source->SetNow(time_source->Now() +
base::TimeDelta::FromMilliseconds(5));
- controller.DidFinishFrame();
+ controller.DidSwapBuffersComplete();
// Tick should not have been called
- EXPECT_FALSE(client.VSyncTicked());
+ EXPECT_FALSE(client.BeganFrame());
- // Trigger yet another frame. Since one frames is pending, another vsync
- // callback should run.
+ // Trigger yet another frame. Since one frames is pending, another
+ // BeginFrame callback should run.
elapsed += base::TimeDelta::FromMilliseconds(thread.PendingDelayMs());
// Sanity check that previous code didn't move time backward.
EXPECT_GE(elapsed, time_source->Now());
time_source->SetNow(elapsed);
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
}
TEST(FrameRateControllerTest, TestFrameThrottling_Unthrottled) {
@@ -134,44 +134,47 @@ TEST(FrameRateControllerTest, TestFrameThrottling_Unthrottled) {
controller.SetClient(&client);
controller.SetMaxFramesPending(2);
- // SetActive triggers 1st frame, make sure the vsync callback is called
+ // SetActive triggers 1st frame, make sure the BeginFrame callback
+ // is called
controller.SetActive(true);
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
client.Reset();
- // Even if we don't call DidBeginFrame, FrameRateController should
- // still attempt to vsync tick multiple times until it does result in
- // a DidBeginFrame.
+ // Even if we don't call DidSwapBuffers, FrameRateController should
+ // still attempt to tick multiple times until it does result in
+ // a DidSwapBuffers.
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
client.Reset();
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
client.Reset();
- // DidBeginFrame triggers 2nd frame, make sure the vsync callback is called
- controller.DidBeginFrame();
+ // DidSwapBuffers triggers 2nd frame, make sure the BeginFrame callback is
+ // called
+ controller.DidSwapBuffers();
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
client.Reset();
- // DidBeginFrame triggers 3rd frame (> max_frames_pending),
- // make sure the vsync callback is NOT called
- controller.DidBeginFrame();
+ // DidSwapBuffers triggers 3rd frame (> max_frames_pending),
+ // make sure the BeginFrame callback is NOT called
+ controller.DidSwapBuffers();
thread.RunPendingTask();
- EXPECT_FALSE(client.VSyncTicked());
+ EXPECT_FALSE(client.BeganFrame());
client.Reset();
// Make sure there is no pending task since we can't do anything until we
- // receive a DidFinishFrame anyway.
+ // receive a DidSwapBuffersComplete anyway.
EXPECT_FALSE(thread.HasPendingTask());
- // DidFinishFrame triggers a frame, make sure the vsync callback is called
- controller.DidFinishFrame();
+ // DidSwapBuffersComplete triggers a frame, make sure the BeginFrame
+ // callback is called
+ controller.DidSwapBuffersComplete();
thread.RunPendingTask();
- EXPECT_TRUE(client.VSyncTicked());
+ EXPECT_TRUE(client.BeganFrame());
}
} // namespace
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index abbc7aa..737ffc1 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -20,7 +20,7 @@ Scheduler::Scheduler(SchedulerClient* client,
inside_process_scheduled_actions_(false) {
DCHECK(client_);
frame_rate_controller_->SetClient(this);
- DCHECK(!state_machine_.VSyncCallbackNeeded());
+ DCHECK(!state_machine_.BeginFrameNeededByImplThread());
}
Scheduler::~Scheduler() { frame_rate_controller_->SetActive(false); }
@@ -76,15 +76,15 @@ void Scheduler::SetMainThreadNeedsLayerTextures() {
ProcessScheduledActions();
}
-void Scheduler::BeginFrameComplete() {
- TRACE_EVENT0("cc", "Scheduler::BeginFrameComplete");
- state_machine_.BeginFrameComplete();
+void Scheduler::FinishCommit() {
+ TRACE_EVENT0("cc", "Scheduler::FinishCommit");
+ state_machine_.FinishCommit();
ProcessScheduledActions();
}
-void Scheduler::BeginFrameAborted() {
- TRACE_EVENT0("cc", "Scheduler::BeginFrameAborted");
- state_machine_.BeginFrameAborted();
+void Scheduler::BeginFrameAbortedByMainThread() {
+ TRACE_EVENT0("cc", "Scheduler::BeginFrameAbortedByMainThread");
+ state_machine_.BeginFrameAbortedByMainThread();
ProcessScheduledActions();
}
@@ -106,7 +106,7 @@ void Scheduler::SetSwapBuffersCompleteSupported(bool supported) {
void Scheduler::DidSwapBuffersComplete() {
TRACE_EVENT0("cc", "Scheduler::DidSwapBuffersComplete");
- frame_rate_controller_->DidFinishFrame();
+ frame_rate_controller_->DidSwapBuffersComplete();
}
void Scheduler::DidLoseOutputSurface() {
@@ -131,17 +131,17 @@ base::TimeTicks Scheduler::AnticipatedDrawTime() {
return frame_rate_controller_->NextTickTime();
}
-base::TimeTicks Scheduler::LastVSyncTime() {
+base::TimeTicks Scheduler::LastBeginFrameOnImplThreadTime() {
return frame_rate_controller_->LastTickTime();
}
-void Scheduler::VSyncTick(bool throttled) {
- TRACE_EVENT1("cc", "Scheduler::VSyncTick", "throttled", throttled);
+void Scheduler::BeginFrame(bool throttled) {
+ TRACE_EVENT1("cc", "Scheduler::BeginFrame", "throttled", throttled);
if (!throttled)
- state_machine_.DidEnterVSync();
+ state_machine_.DidEnterBeginFrame();
ProcessScheduledActions();
if (!throttled)
- state_machine_.DidLeaveVSync();
+ state_machine_.DidLeaveBeginFrame();
}
void Scheduler::ProcessScheduledActions() {
@@ -161,8 +161,8 @@ void Scheduler::ProcessScheduledActions() {
switch (action) {
case SchedulerStateMachine::ACTION_NONE:
break;
- case SchedulerStateMachine::ACTION_BEGIN_FRAME:
- client_->ScheduledActionBeginFrame();
+ case SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD:
+ client_->ScheduledActionSendBeginFrameToMainThread();
break;
case SchedulerStateMachine::ACTION_COMMIT:
client_->ScheduledActionCommit();
@@ -178,14 +178,14 @@ void Scheduler::ProcessScheduledActions() {
client_->ScheduledActionDrawAndSwapIfPossible();
state_machine_.DidDrawIfPossibleCompleted(result.did_draw);
if (result.did_swap)
- frame_rate_controller_->DidBeginFrame();
+ frame_rate_controller_->DidSwapBuffers();
break;
}
case SchedulerStateMachine::ACTION_DRAW_FORCED: {
ScheduledActionDrawAndSwapResult result =
client_->ScheduledActionDrawAndSwapForced();
if (result.did_swap)
- frame_rate_controller_->DidBeginFrame();
+ frame_rate_controller_->DidSwapBuffers();
break;
}
case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
@@ -199,7 +199,8 @@ void Scheduler::ProcessScheduledActions() {
}
// Activate or deactivate the frame rate controller.
- frame_rate_controller_->SetActive(state_machine_.VSyncCallbackNeeded());
+ frame_rate_controller_->SetActive(
+ state_machine_.BeginFrameNeededByImplThread());
client_->DidAnticipatedDrawTimeChange(frame_rate_controller_->NextTickTime());
}
diff --git a/cc/scheduler/scheduler.h b/cc/scheduler/scheduler.h
index 5f4c2ab..aec0cdf 100644
--- a/cc/scheduler/scheduler.h
+++ b/cc/scheduler/scheduler.h
@@ -33,7 +33,7 @@ struct ScheduledActionDrawAndSwapResult {
class SchedulerClient {
public:
- virtual void ScheduledActionBeginFrame() = 0;
+ virtual void ScheduledActionSendBeginFrameToMainThread() = 0;
virtual ScheduledActionDrawAndSwapResult
ScheduledActionDrawAndSwapIfPossible() = 0;
virtual ScheduledActionDrawAndSwapResult
@@ -83,8 +83,8 @@ class CC_EXPORT Scheduler : FrameRateControllerClient {
void DidSwapUseIncompleteTile();
- void BeginFrameComplete();
- void BeginFrameAborted();
+ void FinishCommit();
+ void BeginFrameAbortedByMainThread();
void SetMaxFramesPending(int max);
int MaxFramesPending() const;
@@ -109,10 +109,10 @@ class CC_EXPORT Scheduler : FrameRateControllerClient {
base::TimeTicks AnticipatedDrawTime();
- base::TimeTicks LastVSyncTime();
+ base::TimeTicks LastBeginFrameOnImplThreadTime();
// FrameRateControllerClient implementation
- virtual void VSyncTick(bool throttled) OVERRIDE;
+ virtual void BeginFrame(bool throttled) OVERRIDE;
std::string StateAsStringForTesting() { return state_machine_.ToString(); }
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
index 63ba414..01252dd 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -24,9 +24,9 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
needs_forced_redraw_after_next_commit_(false),
needs_commit_(false),
needs_forced_commit_(false),
- expect_immediate_begin_frame_(false),
+ expect_immediate_begin_frame_for_main_thread_(false),
main_thread_needs_layer_textures_(false),
- inside_vsync_(false),
+ inside_begin_frame_(false),
visible_(false),
can_start_(false),
can_draw_(false),
@@ -73,12 +73,13 @@ std::string SchedulerStateMachine::ToString() {
base::StringAppendF(
&str, "needs_forced_commit_ = %d; ", needs_forced_commit_);
base::StringAppendF(&str,
- "expect_immediate_begin_frame_ = %d; ",
- expect_immediate_begin_frame_);
+ "expect_immediate_begin_frame_for_main_thread_ = %d; ",
+ expect_immediate_begin_frame_for_main_thread_);
base::StringAppendF(&str,
"main_thread_needs_layer_textures_ = %d; ",
main_thread_needs_layer_textures_);
- base::StringAppendF(&str, "inside_vsync_ = %d; ", inside_vsync_);
+ base::StringAppendF(&str, "inside_begin_frame_ = %d; ",
+ inside_begin_frame_);
base::StringAppendF(&str, "visible_ = %d; ", visible_);
base::StringAppendF(&str, "can_start_ = %d; ", can_start_);
base::StringAppendF(&str, "can_draw_ = %d; ", can_draw_);
@@ -129,7 +130,7 @@ bool SchedulerStateMachine::ShouldDraw() const {
if (!ScheduledToDraw())
return false;
- if (!inside_vsync_)
+ if (!inside_begin_frame_)
return false;
if (HasDrawnThisFrame())
return false;
@@ -139,7 +140,7 @@ bool SchedulerStateMachine::ShouldDraw() const {
}
bool SchedulerStateMachine::ShouldAttemptTreeActivation() const {
- return has_pending_tree_ && inside_vsync_ &&
+ return has_pending_tree_ && inside_begin_frame_ &&
!HasAttemptedTreeActivationThisFrame();
}
@@ -163,7 +164,7 @@ bool SchedulerStateMachine::ShouldAcquireLayerTexturesForMainThread() const {
// impl thread is not even scheduled to draw. Guards against deadlocking.
if (!ScheduledToDraw())
return true;
- if (!VSyncCallbackNeeded())
+ if (!BeginFrameNeededByImplThread())
return true;
return false;
}
@@ -180,7 +181,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE &&
needs_forced_commit_)
// TODO(enne): Should probably drop the active tree on force commit.
- return has_pending_tree_ ? ACTION_NONE : ACTION_BEGIN_FRAME;
+ return has_pending_tree_ ? ACTION_NONE
+ : ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD;
if (output_surface_state_ == OUTPUT_SURFACE_LOST && can_start_)
return ACTION_BEGIN_OUTPUT_SURFACE_CREATION;
if (output_surface_state_ == OUTPUT_SURFACE_CREATING)
@@ -197,7 +199,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
((visible_ && output_surface_state_ == OUTPUT_SURFACE_ACTIVE)
|| needs_forced_commit_))
// TODO(enne): Should probably drop the active tree on force commit.
- return has_pending_tree_ ? ACTION_NONE : ACTION_BEGIN_FRAME;
+ return has_pending_tree_ ? ACTION_NONE
+ : ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD;
return ACTION_NONE;
case COMMIT_STATE_FRAME_IN_PROGRESS:
@@ -228,7 +231,8 @@ SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
// step (similar as in COMMIT_STATE_IDLE).
bool can_commit = visible_ || needs_forced_commit_;
if (needs_commit_ && can_commit && DrawSuspendedUntilCommit())
- return has_pending_tree_ ? ACTION_NONE : ACTION_BEGIN_FRAME;
+ return has_pending_tree_ ? ACTION_NONE
+ : ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD;
return ACTION_NONE;
}
@@ -260,7 +264,7 @@ void SchedulerStateMachine::UpdateState(Action action) {
current_frame_number_;
return;
- case ACTION_BEGIN_FRAME:
+ case ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD:
DCHECK(!has_pending_tree_);
DCHECK(visible_ || needs_forced_commit_);
commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS;
@@ -269,7 +273,7 @@ void SchedulerStateMachine::UpdateState(Action action) {
return;
case ACTION_COMMIT:
- if (expect_immediate_begin_frame_)
+ if (expect_immediate_begin_frame_for_main_thread_)
commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW;
else
commit_state_ = COMMIT_STATE_WAITING_FOR_FIRST_DRAW;
@@ -293,12 +297,12 @@ void SchedulerStateMachine::UpdateState(Action action) {
needs_forced_redraw_ = false;
draw_if_possible_failed_ = false;
swap_used_incomplete_tile_ = false;
- if (inside_vsync_)
+ if (inside_begin_frame_)
last_frame_number_where_draw_was_called_ = current_frame_number_;
if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW) {
- DCHECK(expect_immediate_begin_frame_);
+ DCHECK(expect_immediate_begin_frame_for_main_thread_);
commit_state_ = COMMIT_STATE_FRAME_IN_PROGRESS;
- expect_immediate_begin_frame_ = false;
+ expect_immediate_begin_frame_for_main_thread_ = false;
} else if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) {
commit_state_ = COMMIT_STATE_IDLE;
}
@@ -327,7 +331,7 @@ void SchedulerStateMachine::SetMainThreadNeedsLayerTextures() {
main_thread_needs_layer_textures_ = true;
}
-bool SchedulerStateMachine::VSyncCallbackNeeded() const {
+bool SchedulerStateMachine::BeginFrameNeededByImplThread() const {
// If we have a pending tree, need to keep getting notifications until
// the tree is ready to be swapped.
if (has_pending_tree_)
@@ -347,11 +351,13 @@ bool SchedulerStateMachine::VSyncCallbackNeeded() const {
output_surface_state_ == OUTPUT_SURFACE_ACTIVE;
}
-void SchedulerStateMachine::DidEnterVSync() { inside_vsync_ = true; }
+void SchedulerStateMachine::DidEnterBeginFrame() {
+ inside_begin_frame_ = true;
+}
-void SchedulerStateMachine::DidLeaveVSync() {
+void SchedulerStateMachine::DidLeaveBeginFrame() {
current_frame_number_++;
- inside_vsync_ = false;
+ inside_begin_frame_ = false;
}
void SchedulerStateMachine::SetVisible(bool visible) { visible_ = visible; }
@@ -389,20 +395,21 @@ void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; }
void SchedulerStateMachine::SetNeedsForcedCommit() {
needs_forced_commit_ = true;
- expect_immediate_begin_frame_ = true;
+ expect_immediate_begin_frame_for_main_thread_ = true;
}
-void SchedulerStateMachine::BeginFrameComplete() {
+void SchedulerStateMachine::FinishCommit() {
DCHECK(commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS ||
- (expect_immediate_begin_frame_ && commit_state_ != COMMIT_STATE_IDLE))
+ (expect_immediate_begin_frame_for_main_thread_ &&
+ commit_state_ != COMMIT_STATE_IDLE))
<< ToString();
commit_state_ = COMMIT_STATE_READY_TO_COMMIT;
}
-void SchedulerStateMachine::BeginFrameAborted() {
+void SchedulerStateMachine::BeginFrameAbortedByMainThread() {
DCHECK_EQ(commit_state_, COMMIT_STATE_FRAME_IN_PROGRESS);
- if (expect_immediate_begin_frame_) {
- expect_immediate_begin_frame_ = false;
+ if (expect_immediate_begin_frame_for_main_thread_) {
+ expect_immediate_begin_frame_for_main_thread_ = false;
} else {
commit_state_ = COMMIT_STATE_IDLE;
SetNeedsCommit();
diff --git a/cc/scheduler/scheduler_state_machine.h b/cc/scheduler/scheduler_state_machine.h
index fb3908b..1be0749 100644
--- a/cc/scheduler/scheduler_state_machine.h
+++ b/cc/scheduler/scheduler_state_machine.h
@@ -58,7 +58,7 @@ class CC_EXPORT SchedulerStateMachine {
enum Action {
ACTION_NONE,
- ACTION_BEGIN_FRAME,
+ ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
ACTION_COMMIT,
ACTION_CHECK_FOR_COMPLETED_TILE_UPLOADS,
ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED,
@@ -70,14 +70,15 @@ class CC_EXPORT SchedulerStateMachine {
Action NextAction() const;
void UpdateState(Action action);
- // Indicates whether the scheduler needs a vsync callback in order to make
- // progress.
- bool VSyncCallbackNeeded() const;
+ // Indicates whether the main thread needs a begin frame callback in order to
+ // make progress.
+ bool BeginFrameNeededByImplThread() const;
- // Indicates that the system has entered and left a vsync callback.
- // The scheduler will not draw more than once in a given vsync callback.
- void DidEnterVSync();
- void DidLeaveVSync();
+ // Indicates that the system has entered and left a BeginFrame callback.
+ // The scheduler will not draw more than once in a given BeginFrame
+ // callback.
+ void DidEnterBeginFrame();
+ void DidLeaveBeginFrame();
// Indicates whether the LayerTreeHostImpl is visible.
void SetVisible(bool visible);
@@ -102,19 +103,21 @@ class CC_EXPORT SchedulerStateMachine {
// thread to main.
void SetNeedsCommit();
- // As SetNeedsCommit(), but ensures the BeginFrame will definitely happen even
- // if we are not visible. After this call we expect to go through the forced
- // commit flow and then return to waiting for a non-forced BeginFrame to
- // finish.
+ // As SetNeedsCommit(), but ensures the begin frame will be sent to the main
+ // thread even if we are not visible. After this call we expect to go through
+ // the forced commit flow and then return to waiting for a non-forced
+ // begin frame to finish.
void SetNeedsForcedCommit();
- // Call this only in response to receiving an ACTION_BEGIN_FRAME
- // from NextAction. Indicates that all painting is complete.
- void BeginFrameComplete();
+ // Call this only in response to receiving an
+ // ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD from NextAction.
+ // Indicates that all painting is complete.
+ void FinishCommit();
- // Call this only in response to receiving an ACTION_BEGIN_FRAME
- // from NextAction if the client rejects the BeginFrame message.
- void BeginFrameAborted();
+ // Call this only in response to receiving an
+ // ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD from NextAction if the client
+ // rejects the begin frame message.
+ void BeginFrameAbortedByMainThread();
// Request exclusive access to the textures that back single buffered
// layers on behalf of the main thread. Upon acquisition,
@@ -178,9 +181,9 @@ class CC_EXPORT SchedulerStateMachine {
bool needs_forced_redraw_after_next_commit_;
bool needs_commit_;
bool needs_forced_commit_;
- bool expect_immediate_begin_frame_;
+ bool expect_immediate_begin_frame_for_main_thread_;
bool main_thread_needs_layer_textures_;
- bool inside_vsync_;
+ bool inside_begin_frame_;
bool visible_;
bool can_start_;
bool can_draw_;
diff --git a/cc/scheduler/scheduler_state_machine_unittest.cc b/cc/scheduler/scheduler_state_machine_unittest.cc
index 117c778..001a229 100644
--- a/cc/scheduler/scheduler_state_machine_unittest.cc
+++ b/cc/scheduler/scheduler_state_machine_unittest.cc
@@ -35,11 +35,10 @@ class StateMachine : public SchedulerStateMachine {
bool NeedsForcedRedraw() const { return needs_forced_redraw_; }
bool CanDraw() const { return can_draw_; }
- bool InsideVSync() const { return inside_vsync_; }
bool Visible() const { return visible_; }
};
-TEST(SchedulerStateMachineTest, TestNextActionBeginsFrameIfNeeded) {
+TEST(SchedulerStateMachineTest, TestNextActionBeginsMainFrameIfNeeded) {
SchedulerSettings default_scheduler_settings;
// If no commit needed, do nothing.
@@ -52,39 +51,39 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsFrameIfNeeded) {
state.SetNeedsRedraw(false);
state.SetVisible(true);
- EXPECT_FALSE(state.VSyncCallbackNeeded());
+ EXPECT_FALSE(state.BeginFrameNeededByImplThread());
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
- EXPECT_FALSE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ EXPECT_FALSE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
}
- // If commit requested but can_begin_frame is still false, do nothing.
+ // If commit requested but can_start is still false, do nothing.
{
StateMachine state(default_scheduler_settings);
state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE);
state.SetNeedsRedraw(false);
state.SetVisible(true);
- EXPECT_FALSE(state.VSyncCallbackNeeded());
+ EXPECT_FALSE(state.BeginFrameNeededByImplThread());
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
- EXPECT_FALSE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ EXPECT_FALSE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
}
- // If commit requested, begin a frame.
+ // If commit requested, begin a main frame.
{
StateMachine state(default_scheduler_settings);
state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_IDLE);
state.SetCanStart();
state.SetNeedsRedraw(false);
state.SetVisible(true);
- EXPECT_FALSE(state.VSyncCallbackNeeded());
+ EXPECT_FALSE(state.BeginFrameNeededByImplThread());
}
// Begin the frame, make sure needs_commit and commit_state update correctly.
@@ -94,11 +93,12 @@ TEST(SchedulerStateMachineTest, TestNextActionBeginsFrameIfNeeded) {
state.UpdateState(state.NextAction());
state.DidCreateAndInitializeOutputSurface();
state.SetVisible(true);
- state.UpdateState(SchedulerStateMachine::ACTION_BEGIN_FRAME);
+ state.UpdateState(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD);
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
state.CommitState());
EXPECT_FALSE(state.NeedsCommit());
- EXPECT_FALSE(state.VSyncCallbackNeeded());
+ EXPECT_FALSE(state.BeginFrameNeededByImplThread());
}
}
@@ -108,7 +108,7 @@ TEST(SchedulerStateMachineTest, TestSetForcedRedrawDoesNotSetsNormalRedraw) {
state.SetCanDraw(true);
state.SetNeedsForcedRedraw();
EXPECT_FALSE(state.RedrawPending());
- EXPECT_TRUE(state.VSyncCallbackNeeded());
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
}
TEST(SchedulerStateMachineTest,
@@ -122,8 +122,8 @@ TEST(SchedulerStateMachineTest,
state.SetCanDraw(true);
state.SetNeedsRedraw();
EXPECT_TRUE(state.RedrawPending());
- EXPECT_TRUE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
// We're drawing now.
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
@@ -134,8 +134,10 @@ TEST(SchedulerStateMachineTest,
// Failing the draw makes us require a commit.
state.DidDrawIfPossibleCompleted(false);
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
- state.UpdateState(SchedulerStateMachine::ACTION_BEGIN_FRAME);
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
+ state.UpdateState(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD);
EXPECT_TRUE(state.RedrawPending());
EXPECT_TRUE(state.CommitPending());
}
@@ -152,8 +154,8 @@ TEST(SchedulerStateMachineTest,
state.SetCanDraw(true);
state.SetNeedsRedraw();
EXPECT_TRUE(state.RedrawPending());
- EXPECT_TRUE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
// We're drawing now.
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
@@ -162,14 +164,15 @@ TEST(SchedulerStateMachineTest,
EXPECT_FALSE(state.RedrawPending());
EXPECT_FALSE(state.CommitPending());
- // While still in the same vsync callback, set needs redraw again.
- // This should not redraw.
+ // While still in the same begin frame callback on the main thread,
+ // set needs redraw again. This should not redraw.
state.SetNeedsRedraw();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
// Failing the draw makes us require a commit.
state.DidDrawIfPossibleCompleted(false);
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
EXPECT_TRUE(state.RedrawPending());
}
@@ -185,14 +188,16 @@ TEST(SchedulerStateMachineTest,
// Start a commit.
state.SetNeedsCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
- state.UpdateState(SchedulerStateMachine::ACTION_BEGIN_FRAME);
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
+ state.UpdateState(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD);
EXPECT_TRUE(state.CommitPending());
// Then initiate a draw.
state.SetNeedsRedraw();
- EXPECT_TRUE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
EXPECT_TRUE(state.RedrawPending());
@@ -205,7 +210,7 @@ TEST(SchedulerStateMachineTest,
EXPECT_TRUE(state.CommitPending());
// Finish the commit.
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_COMMIT);
EXPECT_TRUE(state.RedrawPending());
@@ -226,14 +231,16 @@ TEST(SchedulerStateMachineTest,
// Start a commit.
state.SetNeedsCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
- state.UpdateState(SchedulerStateMachine::ACTION_BEGIN_FRAME);
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
+ state.UpdateState(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD);
EXPECT_TRUE(state.CommitPending());
// Then initiate a draw.
state.SetNeedsRedraw();
- EXPECT_TRUE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
EXPECT_TRUE(state.RedrawPending());
@@ -257,7 +264,7 @@ TEST(SchedulerStateMachineTest,
EXPECT_TRUE(state.CommitPending());
// Finish the commit.
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_COMMIT);
EXPECT_TRUE(state.RedrawPending());
@@ -279,14 +286,16 @@ TEST(SchedulerStateMachineTest,
// Start a commit.
state.SetNeedsCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
- state.UpdateState(SchedulerStateMachine::ACTION_BEGIN_FRAME);
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
+ state.UpdateState(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD);
EXPECT_TRUE(state.CommitPending());
// Then initiate a draw.
state.SetNeedsRedraw();
- EXPECT_TRUE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
EXPECT_TRUE(state.RedrawPending());
@@ -300,7 +309,7 @@ TEST(SchedulerStateMachineTest,
// Finish the commit. Note, we should not yet be forcing a draw, but should
// continue the commit as usual.
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_COMMIT);
EXPECT_TRUE(state.RedrawPending());
@@ -309,7 +318,8 @@ TEST(SchedulerStateMachineTest,
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.NextAction());
}
-TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedNextVSync) {
+TEST(SchedulerStateMachineTest,
+ TestFailedDrawIsRetriedInNextBeginFrameForImplThread) {
SchedulerSettings default_scheduler_settings;
SchedulerStateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -320,8 +330,8 @@ TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedNextVSync) {
// Start a draw.
state.SetNeedsRedraw();
- EXPECT_TRUE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
EXPECT_TRUE(state.RedrawPending());
@@ -332,13 +342,14 @@ TEST(SchedulerStateMachineTest, TestFailedDrawIsRetriedNextVSync) {
EXPECT_TRUE(state.RedrawPending());
// We should not be trying to draw again now, but we have a commit pending.
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
- state.DidLeaveVSync();
- EXPECT_TRUE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ state.DidLeaveBeginFrame();
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
- // We should try draw again in the next vsync.
+ // We should try to draw again in the next begin frame on the impl thread.
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
}
@@ -351,32 +362,33 @@ TEST(SchedulerStateMachineTest, TestDoestDrawTwiceInSameFrame) {
state.SetVisible(true);
state.SetCanDraw(true);
state.SetNeedsRedraw();
- EXPECT_TRUE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
- // While still in the same vsync callback, set needs redraw again.
- // This should not redraw.
+ // While still in the same begin frame for the impl thread, set needs redraw
+ // again. This should not redraw.
state.SetNeedsRedraw();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
// Move to another frame. This should now draw.
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveVSync();
- EXPECT_TRUE(state.VSyncCallbackNeeded());
- state.DidEnterVSync();
+ state.DidLeaveBeginFrame();
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
state.DidDrawIfPossibleCompleted(true);
- EXPECT_FALSE(state.VSyncCallbackNeeded());
+ EXPECT_FALSE(state.BeginFrameNeededByImplThread());
}
-TEST(SchedulerStateMachineTest, TestNextActionDrawsOnVSync) {
+TEST(SchedulerStateMachineTest, TestNextActionDrawsOnBeginFrame) {
SchedulerSettings default_scheduler_settings;
- // When not on vsync, or on vsync but not visible, don't draw.
+ // When not in BeginFrame, or in BeginFrame but not visible,
+ // don't draw.
size_t num_commit_states =
sizeof(all_commit_states) / sizeof(SchedulerStateMachine::CommitState);
for (size_t i = 0; i < num_commit_states; ++i) {
@@ -388,7 +400,7 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnVSync) {
state.SetCommitState(all_commit_states[i]);
bool visible = j;
if (!visible) {
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
state.SetVisible(false);
} else {
state.SetVisible(true);
@@ -405,8 +417,9 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnVSync) {
}
}
- // When on vsync, or not on vsync but needs_forced_dedraw set, should always
- // draw except if you're ready to commit, in which case commit.
+ // When in BeginFrame, or not in BeginFrame but needs_forced_dedraw
+ // set, should always draw except if you're ready to commit, in which case
+ // commit.
for (size_t i = 0; i < num_commit_states; ++i) {
for (size_t j = 0; j < 2; ++j) {
StateMachine state(default_scheduler_settings);
@@ -417,7 +430,7 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnVSync) {
state.SetCommitState(all_commit_states[i]);
bool forced_draw = j;
if (!forced_draw) {
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
state.SetNeedsRedraw(true);
state.SetVisible(true);
} else {
@@ -435,12 +448,12 @@ TEST(SchedulerStateMachineTest, TestNextActionDrawsOnVSync) {
}
// Case 1: needs_commit=false.
- EXPECT_TRUE(state.VSyncCallbackNeeded());
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
EXPECT_EQ(expected_action, state.NextAction());
// Case 2: needs_commit=true.
state.SetNeedsCommit();
- EXPECT_TRUE(state.VSyncCallbackNeeded());
+ EXPECT_TRUE(state.BeginFrameNeededByImplThread());
EXPECT_EQ(expected_action, state.NextAction());
}
}
@@ -452,7 +465,7 @@ TEST(SchedulerStateMachineTest, TestNoCommitStatesRedrawWhenInvisible) {
size_t num_commit_states =
sizeof(all_commit_states) / sizeof(SchedulerStateMachine::CommitState);
for (size_t i = 0; i < num_commit_states; ++i) {
- // There shouldn't be any drawing regardless of vsync.
+ // There shouldn't be any drawing regardless of BeginFrame.
for (size_t j = 0; j < 2; ++j) {
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -463,7 +476,7 @@ TEST(SchedulerStateMachineTest, TestNoCommitStatesRedrawWhenInvisible) {
state.SetNeedsRedraw(true);
state.SetNeedsForcedRedraw(false);
if (j == 1)
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
// Case 1: needs_commit=false.
EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE,
@@ -483,7 +496,7 @@ TEST(SchedulerStateMachineTest, TestCanRedraw_StopsDraw) {
size_t num_commit_states =
sizeof(all_commit_states) / sizeof(SchedulerStateMachine::CommitState);
for (size_t i = 0; i < num_commit_states; ++i) {
- // There shouldn't be any drawing regardless of vsync.
+ // There shouldn't be any drawing regardless of BeginFrame.
for (size_t j = 0; j < 2; ++j) {
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -494,7 +507,7 @@ TEST(SchedulerStateMachineTest, TestCanRedraw_StopsDraw) {
state.SetNeedsRedraw(true);
state.SetNeedsForcedRedraw(false);
if (j == 1)
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
state.SetCanDraw(false);
EXPECT_NE(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE,
@@ -516,7 +529,8 @@ TEST(SchedulerStateMachineTest,
state.SetNeedsRedraw(true);
state.SetVisible(true);
state.SetCanDraw(false);
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
}
TEST(SchedulerStateMachineTest, TestsetNeedsCommitIsNotLost) {
@@ -530,7 +544,8 @@ TEST(SchedulerStateMachineTest, TestsetNeedsCommitIsNotLost) {
state.SetCanDraw(true);
// Begin the frame.
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
state.UpdateState(state.NextAction());
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
state.CommitState());
@@ -540,17 +555,17 @@ TEST(SchedulerStateMachineTest, TestsetNeedsCommitIsNotLost) {
EXPECT_TRUE(state.NeedsCommit());
// Let the frame finish.
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
state.CommitState());
- // Expect to commit regardless of vsync state.
- state.DidLeaveVSync();
+ // Expect to commit regardless of BeginFrame state.
+ state.DidLeaveBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
- // Commit and make sure we draw on next vsync
+ // Commit and make sure we draw on next BeginFrame
state.UpdateState(SchedulerStateMachine::ACTION_COMMIT);
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_DRAW,
@@ -559,8 +574,9 @@ TEST(SchedulerStateMachineTest, TestsetNeedsCommitIsNotLost) {
state.DidDrawIfPossibleCompleted(true);
// Verify that another commit will begin.
- state.DidLeaveVSync();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ state.DidLeaveBeginFrame();
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
}
TEST(SchedulerStateMachineTest, TestFullCycle) {
@@ -574,17 +590,19 @@ TEST(SchedulerStateMachineTest, TestFullCycle) {
// Start clean and set commit.
state.SetNeedsCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
// Begin the frame.
- state.UpdateState(SchedulerStateMachine::ACTION_BEGIN_FRAME);
+ state.UpdateState(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD);
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
state.CommitState());
EXPECT_FALSE(state.NeedsCommit());
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
// Tell the scheduler the frame finished.
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
state.CommitState());
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
@@ -595,15 +613,15 @@ TEST(SchedulerStateMachineTest, TestFullCycle) {
state.CommitState());
EXPECT_TRUE(state.NeedsRedraw());
- // Expect to do nothing until vsync.
+ // Expect to do nothing until BeginFrame.
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
- // At vsync, draw.
- state.DidEnterVSync();
+ // At BeginFrame, draw.
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
// Should be synchronized, no draw needed, no action needed.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
@@ -622,10 +640,12 @@ TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) {
// Start clean and set commit.
state.SetNeedsCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
// Begin the frame.
- state.UpdateState(SchedulerStateMachine::ACTION_BEGIN_FRAME);
+ state.UpdateState(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD);
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
state.CommitState());
EXPECT_FALSE(state.NeedsCommit());
@@ -636,7 +656,7 @@ TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) {
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
// Tell the scheduler the frame finished.
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
state.CommitState());
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
@@ -647,20 +667,21 @@ TEST(SchedulerStateMachineTest, TestFullCycleWithCommitRequestInbetween) {
state.CommitState());
EXPECT_TRUE(state.NeedsRedraw());
- // Expect to do nothing until vsync.
+ // Expect to do nothing until BeginFrame.
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
- // At vsync, draw.
- state.DidEnterVSync();
+ // At BeginFrame, draw.
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE);
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
// Should be synchronized, no draw needed, no action needed.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
EXPECT_FALSE(state.NeedsRedraw());
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
}
TEST(SchedulerStateMachineTest, TestRequestCommitInvisible) {
@@ -673,7 +694,7 @@ TEST(SchedulerStateMachineTest, TestRequestCommitInvisible) {
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
}
-TEST(SchedulerStateMachineTest, TestGoesInvisibleBeforeBeginFrameCompletes) {
+TEST(SchedulerStateMachineTest, TestGoesInvisibleBeforeFinishCommit) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -684,18 +705,20 @@ TEST(SchedulerStateMachineTest, TestGoesInvisibleBeforeBeginFrameCompletes) {
// Start clean and set commit.
state.SetNeedsCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
// Begin the frame while visible.
- state.UpdateState(SchedulerStateMachine::ACTION_BEGIN_FRAME);
+ state.UpdateState(
+ SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD);
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
state.CommitState());
EXPECT_FALSE(state.NeedsCommit());
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
- // Become invisible and abort the BeginFrame.
+ // Become invisible and abort the main thread's begin frame.
state.SetVisible(false);
- state.BeginFrameAborted();
+ state.BeginFrameAbortedByMainThread();
// We should now be back in the idle state as if we didn't start a frame at
// all.
@@ -707,7 +730,8 @@ TEST(SchedulerStateMachineTest, TestGoesInvisibleBeforeBeginFrameCompletes) {
// We should be beginning a frame now.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
// Begin the frame.
state.UpdateState(state.NextAction());
@@ -760,7 +784,8 @@ TEST(SchedulerStateMachineTest, TestContextLostWhenCompletelyIdle) {
state.DidCreateAndInitializeOutputSurface();
// When the context is recreated, we should begin a commit.
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
state.UpdateState(state.NextAction());
}
@@ -793,18 +818,19 @@ TEST(SchedulerStateMachineTest,
state.DidCreateAndInitializeOutputSurface();
// When the context is recreated, we should begin a commit
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
state.UpdateState(state.NextAction());
// Once the context is recreated, whether we draw should be based on
// SetCanDraw.
state.SetNeedsRedraw(true);
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.SetCanDraw(false);
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
state.SetCanDraw(true);
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
}
TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) {
@@ -818,17 +844,19 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) {
// Get a commit in flight.
state.SetNeedsCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
state.UpdateState(state.NextAction());
// Set damage and expect a draw.
state.SetNeedsRedraw(true);
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(state.NextAction());
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
- // Cause a lost context while the begin frame is in flight.
+ // Cause a lost context while the begin frame is in flight
+ // for the main thread.
state.DidLoseOutputSurface();
// Ask for another draw. Expect nothing happens.
@@ -836,7 +864,7 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) {
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
// Finish the frame, and commit.
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
state.UpdateState(state.NextAction());
@@ -846,11 +874,12 @@ TEST(SchedulerStateMachineTest, TestContextLostWhileCommitInProgress) {
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(state.NextAction());
- // Expect to be told to begin context recreation, independent of vsync state.
- state.DidEnterVSync();
+ // Expect to be told to begin context recreation, independent of
+ // BeginFrame state.
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
state.NextAction());
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
state.NextAction());
}
@@ -867,17 +896,19 @@ TEST(SchedulerStateMachineTest,
// Get a commit in flight.
state.SetNeedsCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
state.UpdateState(state.NextAction());
// Set damage and expect a draw.
state.SetNeedsRedraw(true);
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(state.NextAction());
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
- // Cause a lost context while the begin frame is in flight.
+ // Cause a lost context while the begin frame is in flight
+ // for the main thread.
state.DidLoseOutputSurface();
// Ask for another draw and also set needs commit. Expect nothing happens.
@@ -886,7 +917,7 @@ TEST(SchedulerStateMachineTest,
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
// Finish the frame, and commit.
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
state.UpdateState(state.NextAction());
@@ -896,11 +927,12 @@ TEST(SchedulerStateMachineTest,
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE, state.NextAction());
state.UpdateState(state.NextAction());
- // Expect to be told to begin context recreation, independent of vsync state
- state.DidEnterVSync();
+ // Expect to be told to begin context recreation, independent of
+ // BeginFrame state
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
state.NextAction());
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
state.NextAction());
}
@@ -919,23 +951,24 @@ TEST(SchedulerStateMachineTest, TestFinishAllRenderingWhileContextLost) {
// Ask a forced redraw and verify it ocurrs.
state.SetNeedsForcedRedraw(true);
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.NextAction());
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
// Clear the forced redraw bit.
state.SetNeedsForcedRedraw(false);
- // Expect to be told to begin context recreation, independent of vsync state
+ // Expect to be told to begin context recreation, independent of
+ // BeginFrame state
EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_CREATION,
state.NextAction());
state.UpdateState(state.NextAction());
// Ask a forced redraw and verify it ocurrs.
state.SetNeedsForcedRedraw(true);
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.NextAction());
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
}
TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) {
@@ -957,10 +990,12 @@ TEST(SchedulerStateMachineTest, DontDrawBeforeCommitAfterLostOutputSurface) {
state.DidCreateAndInitializeOutputSurface();
EXPECT_FALSE(state.RedrawPending());
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
}
-TEST(SchedulerStateMachineTest, TestBeginFrameWhenInvisibleAndForceCommit) {
+TEST(SchedulerStateMachineTest,
+ TestSendBeginFrameToMainThreadWhenInvisibleAndForceCommit) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -969,24 +1004,23 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenInvisibleAndForceCommit) {
state.SetVisible(false);
state.SetNeedsCommit();
state.SetNeedsForcedCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
}
TEST(SchedulerStateMachineTest,
- TestBeginFrameWhenCanBeginFrameFalseAndForceCommit) {
+ TestSendBeginFrameToMainThreadWhenCanStartFalseAndForceCommit) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
- state.SetCanStart();
- state.UpdateState(state.NextAction());
- state.DidCreateAndInitializeOutputSurface();
state.SetVisible(true);
state.SetCanDraw(true);
state.SetNeedsCommit();
state.SetNeedsForcedCommit();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
}
-TEST(SchedulerStateMachineTest, TestBeginFrameWhenCommitInProgress) {
+TEST(SchedulerStateMachineTest, TestFinishCommitWhenCommitInProgress) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -996,7 +1030,7 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenCommitInProgress) {
state.SetCommitState(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS);
state.SetNeedsCommit();
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
state.UpdateState(state.NextAction());
@@ -1006,7 +1040,7 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenCommitInProgress) {
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
}
-TEST(SchedulerStateMachineTest, TestBeginFrameWhenForcedCommitInProgress) {
+TEST(SchedulerStateMachineTest, TestFinishCommitWhenForcedCommitInProgress) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -1017,19 +1051,19 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenForcedCommitInProgress) {
state.SetNeedsCommit();
state.SetNeedsForcedCommit();
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
state.UpdateState(state.NextAction());
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
state.CommitState());
- // If we are waiting for forced draw then we know a begin frame is already in
- // flight.
+ // If we are waiting for forced draw then we know a begin frame is already
+ // in flight for the main thread.
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
}
-TEST(SchedulerStateMachineTest, TestBeginFrameWhenContextLost) {
+TEST(SchedulerStateMachineTest, TestSendBeginFrameToMainThreadWhenContextLost) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -1040,10 +1074,11 @@ TEST(SchedulerStateMachineTest, TestBeginFrameWhenContextLost) {
state.SetNeedsCommit();
state.SetNeedsForcedCommit();
state.DidLoseOutputSurface();
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
}
-TEST(SchedulerStateMachineTest, TestImmediateBeginFrame) {
+TEST(SchedulerStateMachineTest, TestImmediateFinishCommit) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -1056,7 +1091,7 @@ TEST(SchedulerStateMachineTest, TestImmediateBeginFrame) {
state.SetNeedsCommit();
state.SetNeedsForcedCommit();
state.UpdateState(state.NextAction());
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
state.CommitState());
@@ -1065,20 +1100,20 @@ TEST(SchedulerStateMachineTest, TestImmediateBeginFrame) {
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
state.CommitState());
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
state.SetNeedsForcedRedraw(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.NextAction());
state.UpdateState(state.NextAction());
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
- // Should be waiting for the normal begin frame.
+ // Should be waiting for the normal begin frame from the main thread.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
state.CommitState());
}
-TEST(SchedulerStateMachineTest, TestImmediateBeginFrameDuringCommit) {
+TEST(SchedulerStateMachineTest, TestImmediateFinishCommitDuringCommit) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -1095,7 +1130,7 @@ TEST(SchedulerStateMachineTest, TestImmediateBeginFrameDuringCommit) {
state.SetNeedsCommit();
state.SetNeedsForcedCommit();
state.UpdateState(state.NextAction());
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
state.CommitState());
@@ -1104,20 +1139,21 @@ TEST(SchedulerStateMachineTest, TestImmediateBeginFrameDuringCommit) {
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
state.CommitState());
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
state.SetNeedsForcedRedraw(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.NextAction());
state.UpdateState(state.NextAction());
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
- // Should be waiting for the normal begin frame.
+ // Should be waiting for the normal begin frame from the main thread.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
state.CommitState()) << state.ToString();
}
-TEST(SchedulerStateMachineTest, ImmediateBeginFrameWhileInvisible) {
+TEST(SchedulerStateMachineTest,
+ ImmediateBeginFrameAbortedByMainThreadWhileInvisible) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -1132,7 +1168,7 @@ TEST(SchedulerStateMachineTest, ImmediateBeginFrameWhileInvisible) {
state.SetNeedsCommit();
state.SetNeedsForcedCommit();
state.UpdateState(state.NextAction());
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
@@ -1142,28 +1178,28 @@ TEST(SchedulerStateMachineTest, ImmediateBeginFrameWhileInvisible) {
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
state.CommitState());
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
state.SetNeedsForcedRedraw(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.NextAction());
state.UpdateState(state.NextAction());
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
- // Should be waiting for the normal begin frame.
+ // Should be waiting for the main thread's begin frame.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_FRAME_IN_PROGRESS,
state.CommitState()) << state.ToString();
- // Become invisible and abort the "normal" begin frame.
+ // Become invisible and abort the main thread's begin frame.
state.SetVisible(false);
- state.BeginFrameAborted();
+ state.BeginFrameAbortedByMainThread();
// Should be back in the idle state, but needing a commit.
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_IDLE, state.CommitState());
EXPECT_TRUE(state.NeedsCommit());
}
-TEST(SchedulerStateMachineTest, ImmediateBeginFrameWhileCantDraw) {
+TEST(SchedulerStateMachineTest, ImmediateFinishCommitWhileCantDraw) {
SchedulerSettings default_scheduler_settings;
StateMachine state(default_scheduler_settings);
state.SetCanStart();
@@ -1178,7 +1214,7 @@ TEST(SchedulerStateMachineTest, ImmediateBeginFrameWhileCantDraw) {
state.SetNeedsCommit();
state.SetNeedsForcedCommit();
state.UpdateState(state.NextAction());
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_READY_TO_COMMIT,
@@ -1188,13 +1224,13 @@ TEST(SchedulerStateMachineTest, ImmediateBeginFrameWhileCantDraw) {
EXPECT_EQ(SchedulerStateMachine::COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW,
state.CommitState());
- state.DidEnterVSync();
+ state.DidEnterBeginFrame();
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
state.SetNeedsForcedRedraw(true);
EXPECT_EQ(SchedulerStateMachine::ACTION_DRAW_FORCED, state.NextAction());
state.UpdateState(state.NextAction());
state.DidDrawIfPossibleCompleted(true);
- state.DidLeaveVSync();
+ state.DidLeaveBeginFrame();
}
TEST(SchedulerStateMachineTest, ReportIfNotDrawing) {
@@ -1239,14 +1275,15 @@ TEST(SchedulerStateMachineTest, ReportIfNotDrawingFromAcquiredTextures) {
state.UpdateState(state.NextAction());
EXPECT_TRUE(state.DrawSuspendedUntilCommit());
- EXPECT_EQ(SchedulerStateMachine::ACTION_BEGIN_FRAME, state.NextAction());
+ EXPECT_EQ(SchedulerStateMachine::ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD,
+ state.NextAction());
state.UpdateState(state.NextAction());
EXPECT_TRUE(state.DrawSuspendedUntilCommit());
EXPECT_EQ(SchedulerStateMachine::ACTION_NONE, state.NextAction());
- state.BeginFrameComplete();
+ state.FinishCommit();
EXPECT_TRUE(state.DrawSuspendedUntilCommit());
EXPECT_EQ(SchedulerStateMachine::ACTION_COMMIT, state.NextAction());
diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc
index 0bcc499..5f5551d 100644
--- a/cc/scheduler/scheduler_unittest.cc
+++ b/cc/scheduler/scheduler_unittest.cc
@@ -68,8 +68,8 @@ class FakeSchedulerClient : public SchedulerClient {
}
// Scheduler Implementation.
- virtual void ScheduledActionBeginFrame() OVERRIDE {
- actions_.push_back("ScheduledActionBeginFrame");
+ virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {
+ actions_.push_back("ScheduledActionSendBeginFrameToMainThread");
states_.push_back(scheduler_->StateAsStringForTesting());
}
virtual ScheduledActionDrawAndSwapResult
@@ -153,12 +153,12 @@ TEST(SchedulerTest, RequestCommit) {
// SetNeedsCommit should begin the frame.
scheduler->SetNeedsCommit();
- EXPECT_SINGLE_ACTION("ScheduledActionBeginFrame", client);
+ EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client);
EXPECT_FALSE(time_source->Active());
client.Reset();
- // BeginFrameComplete should commit
- scheduler->BeginFrameComplete();
+ // FinishCommit should commit
+ scheduler->FinishCommit();
EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
EXPECT_TRUE(time_source->Active());
client.Reset();
@@ -173,7 +173,7 @@ TEST(SchedulerTest, RequestCommit) {
EXPECT_FALSE(time_source->Active());
}
-TEST(SchedulerTest, RequestCommitAfterBeginFrame) {
+TEST(SchedulerTest, RequestCommitAfterBeginFrameSentToMainThread) {
FakeSchedulerClient client;
scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
SchedulerSettings default_scheduler_settings;
@@ -190,15 +190,15 @@ TEST(SchedulerTest, RequestCommitAfterBeginFrame) {
// SetNedsCommit should begin the frame.
scheduler->SetNeedsCommit();
- EXPECT_SINGLE_ACTION("ScheduledActionBeginFrame", client);
+ EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client);
client.Reset();
// Now SetNeedsCommit again. Calling here means we need a second frame.
scheduler->SetNeedsCommit();
- // Since, another commit is needed, BeginFrameComplete should commit,
+ // Since another commit is needed, FinishCommit should commit,
// then begin another frame.
- scheduler->BeginFrameComplete();
+ scheduler->FinishCommit();
EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
client.Reset();
@@ -206,7 +206,7 @@ TEST(SchedulerTest, RequestCommitAfterBeginFrame) {
time_source->Tick();
EXPECT_FALSE(time_source->Active());
EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
- EXPECT_ACTION("ScheduledActionBeginFrame", client, 1, 2);
+ EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2);
client.Reset();
}
@@ -227,7 +227,7 @@ TEST(SchedulerTest, TextureAcquisitionCollision) {
scheduler->SetNeedsCommit();
scheduler->SetMainThreadNeedsLayerTextures();
- EXPECT_ACTION("ScheduledActionBeginFrame", client, 0, 2);
+ EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
client,
1,
@@ -238,7 +238,7 @@ TEST(SchedulerTest, TextureAcquisitionCollision) {
EXPECT_FALSE(time_source->Active());
// Trigger the commit
- scheduler->BeginFrameComplete();
+ scheduler->FinishCommit();
EXPECT_TRUE(time_source->Active());
client.Reset();
@@ -255,7 +255,7 @@ TEST(SchedulerTest, TextureAcquisitionCollision) {
client,
1,
3);
- EXPECT_ACTION("ScheduledActionBeginFrame", client, 2, 3);
+ EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 2, 3);
client.Reset();
}
@@ -275,7 +275,7 @@ TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
scheduler->DidCreateAndInitializeOutputSurface();
scheduler->SetNeedsCommit();
- scheduler->BeginFrameComplete();
+ scheduler->FinishCommit();
scheduler->SetMainThreadNeedsLayerTextures();
client.Reset();
// Verify that pending texture acquisition fires when visibility
@@ -289,13 +289,13 @@ TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
// compositor is waiting for first draw should result in a request
// for a new frame in order to escape a deadlock.
scheduler->SetVisible(true);
- EXPECT_SINGLE_ACTION("ScheduledActionBeginFrame", client);
+ EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client);
client.Reset();
}
class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient {
public:
- virtual void ScheduledActionBeginFrame() OVERRIDE {}
+ virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {}
virtual ScheduledActionDrawAndSwapResult
ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
// Only SetNeedsRedraw the first time this is called
@@ -395,7 +395,7 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw) {
class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient {
public:
- virtual void ScheduledActionBeginFrame() OVERRIDE {}
+ virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {}
virtual ScheduledActionDrawAndSwapResult
ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
// Only SetNeedsCommit the first time this is called
@@ -438,7 +438,7 @@ TEST(SchedulerTest, RequestCommitInsideDraw) {
EXPECT_FALSE(time_source->Active());
EXPECT_EQ(1, client.num_draws());
EXPECT_TRUE(scheduler->CommitPending());
- scheduler->BeginFrameComplete();
+ scheduler->FinishCommit();
time_source->Tick();
EXPECT_EQ(2, client.num_draws());
@@ -492,7 +492,7 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw) {
EXPECT_FALSE(time_source->Active());
}
-TEST(SchedulerTest, NoBeginFrameWhenDrawFails) {
+TEST(SchedulerTest, NoSwapWhenDrawFails) {
scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
SchedulerClientThatsetNeedsCommitInsideDraw client;
scoped_ptr<FakeFrameRateController> controller(
@@ -532,7 +532,7 @@ TEST(SchedulerTest, NoBeginFrameWhenDrawFails) {
EXPECT_EQ(0, controller_ptr->NumFramesPending());
}
-TEST(SchedulerTest, NoBeginFrameWhenSwapFailsDuringForcedCommit) {
+TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) {
scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
FakeSchedulerClient client;
scoped_ptr<FakeFrameRateController> controller(