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

Unified Diff: cc/scheduler/scheduler_state_machine.cc

Issue 621823003: Making scheduler run ANIMATE after a COMMIT (instead of LayerTreeHostImpl). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing unneeded lines in cc/trees/layer_tree_host_impl.cc Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/scheduler_state_machine.cc
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
index 6a412dcaca2d0412321360a18c833aa7e653195f..2b8210d2d2f85de8dbb86a381abff5f6f8266be0 100644
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -43,6 +43,7 @@ SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
has_pending_tree_(false),
pending_tree_is_ready_for_activation_(false),
active_tree_needs_first_draw_(false),
+ did_commit_after_animating_(false),
did_create_and_initialize_first_output_surface_(false),
impl_latency_takes_priority_(false),
skip_next_begin_main_frame_to_reduce_latency_(false),
@@ -226,6 +227,7 @@ void SchedulerStateMachine::AsValueInto(base::debug::TracedValue* state,
pending_tree_is_ready_for_activation_);
state->SetBoolean("active_tree_needs_first_draw",
active_tree_needs_first_draw_);
+ state->SetBoolean("did_commit_after_animating", did_commit_after_animating_);
state->SetBoolean("did_create_and_initialize_first_output_surface",
did_create_and_initialize_first_output_surface_);
state->SetBoolean("impl_latency_takes_priority",
@@ -254,6 +256,10 @@ void SchedulerStateMachine::AdvanceCurrentFrameNumber() {
skip_next_begin_main_frame_to_reduce_latency_ = false;
}
+bool SchedulerStateMachine::HasAnimatedThisFrame() const {
+ return last_frame_number_animate_performed_ == current_frame_number_;
+}
+
bool SchedulerStateMachine::HasSentBeginMainFrameThisFrame() const {
return current_frame_number_ ==
last_frame_number_begin_main_frame_sent_;
@@ -344,6 +350,11 @@ bool SchedulerStateMachine::ShouldDraw() const {
if (PendingDrawsShouldBeAborted())
return active_tree_needs_first_draw_;
+ // If a commit has occurred after the animate call, we need to call animate
+ // again before we should draw.
+ if (did_commit_after_animating_)
+ return false;
+
// After this line, we only want to send a swap request once per frame.
if (HasRequestedSwapThisFrame())
return false;
@@ -415,7 +426,8 @@ bool SchedulerStateMachine::ShouldAnimate() const {
if (!can_draw_)
return false;
- if (last_frame_number_animate_performed_ == current_frame_number_)
+ // If a commit occurred after our last call, we need to do animation again.
+ if (HasAnimatedThisFrame() && !did_commit_after_animating_)
return false;
if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING &&
@@ -567,6 +579,7 @@ void SchedulerStateMachine::UpdateState(Action action) {
case ACTION_ANIMATE:
last_frame_number_animate_performed_ = current_frame_number_;
needs_animate_ = false;
+ did_commit_after_animating_ = false;
// TODO(skyostil): Instead of assuming this, require the client to tell
// us.
SetNeedsRedraw();
@@ -622,6 +635,9 @@ void SchedulerStateMachine::UpdateState(Action action) {
void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) {
commit_count_++;
+ if (!commit_was_aborted && HasAnimatedThisFrame())
+ did_commit_after_animating_ = true;
+
if (commit_was_aborted || settings_.main_frame_before_activation_enabled) {
commit_state_ = COMMIT_STATE_IDLE;
} else {
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698