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

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

Issue 25494009: cc: Fix disabled vsync state freezing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Now with test, and formatted Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/trees/layer_tree_host_unittest.cc » ('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 4
5 #include "cc/scheduler/scheduler_state_machine.h" 5 #include "cc/scheduler/scheduler_state_machine.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 DCHECK_NE(texture_state_, LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD); 744 DCHECK_NE(texture_state_, LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD);
745 main_thread_needs_layer_textures_ = true; 745 main_thread_needs_layer_textures_ = true;
746 } 746 }
747 747
748 bool SchedulerStateMachine::BeginFrameNeededByImplThread() const { 748 bool SchedulerStateMachine::BeginFrameNeededByImplThread() const {
749 // Proactive BeginFrames are bad for the synchronous compositor because we 749 // Proactive BeginFrames are bad for the synchronous compositor because we
750 // have to draw when we get the BeginFrame and could end up drawing many 750 // have to draw when we get the BeginFrame and could end up drawing many
751 // duplicate frames if our new frame isn't ready in time. 751 // duplicate frames if our new frame isn't ready in time.
752 // To poll for state with the synchronous compositor without having to draw, 752 // To poll for state with the synchronous compositor without having to draw,
753 // we rely on ShouldPollForAnticipatedDrawTriggers instead. 753 // we rely on ShouldPollForAnticipatedDrawTriggers instead.
754 if (settings_.using_synchronous_renderer_compositor) 754 if (!SupportsProactiveBeginFrame())
755 return BeginFrameNeededToDrawByImplThread(); 755 return BeginFrameNeededToDrawByImplThread();
756 756
757 return BeginFrameNeededToDrawByImplThread() || 757 return BeginFrameNeededToDrawByImplThread() ||
758 ProactiveBeginFrameWantedByImplThread(); 758 ProactiveBeginFrameWantedByImplThread();
759 } 759 }
760 760
761 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const { 761 bool SchedulerStateMachine::ShouldPollForAnticipatedDrawTriggers() const {
762 // ShouldPollForAnticipatedDrawTriggers is what we use in place of 762 // ShouldPollForAnticipatedDrawTriggers is what we use in place of
763 // ProactiveBeginFrameWantedByImplThread when we are using the synchronous 763 // ProactiveBeginFrameWantedByImplThread when we are using the synchronous
764 // compositor. 764 // compositor.
765 if (settings_.using_synchronous_renderer_compositor) { 765 if (!SupportsProactiveBeginFrame()) {
766 return !BeginFrameNeededToDrawByImplThread() && 766 return !BeginFrameNeededToDrawByImplThread() &&
767 ProactiveBeginFrameWantedByImplThread(); 767 ProactiveBeginFrameWantedByImplThread();
768 } 768 }
769 769
770 // Non synchronous compositors should rely on 770 // Non synchronous compositors should rely on
771 // ProactiveBeginFrameWantedByImplThread to poll for state instead. 771 // ProactiveBeginFrameWantedByImplThread to poll for state instead.
772 return false; 772 return false;
773 } 773 }
774 774
775 bool SchedulerStateMachine::SupportsProactiveBeginFrame() const {
776 // Both the synchronous compositor and disabled vsync settings
777 // make it undesirable to proactively request begin frames.
778 // If this is true, the scheduler should poll.
779 return !settings_.using_synchronous_renderer_compositor &&
780 settings_.throttle_frame_production;
781 }
782
775 // These are the cases where we definitely (or almost definitely) have a 783 // These are the cases where we definitely (or almost definitely) have a
776 // new frame to draw and can draw. 784 // new frame to draw and can draw.
777 bool SchedulerStateMachine::BeginFrameNeededToDrawByImplThread() const { 785 bool SchedulerStateMachine::BeginFrameNeededToDrawByImplThread() const {
778 // The output surface is the provider of BeginFrames for the impl thread, 786 // The output surface is the provider of BeginFrames for the impl thread,
779 // so we are not going to get them even if we ask for them. 787 // so we are not going to get them even if we ask for them.
780 if (!HasInitializedOutputSurface()) 788 if (!HasInitializedOutputSurface())
781 return false; 789 return false;
782 790
783 // If we can't draw, don't tick until we are notified that we can draw again. 791 // If we can't draw, don't tick until we are notified that we can draw again.
784 if (!can_draw_) 792 if (!can_draw_)
(...skipping 20 matching lines...) Expand all
805 // These are cases where we are very likely to draw soon, but might not 813 // These are cases where we are very likely to draw soon, but might not
806 // actually have a new frame to draw when we receive the next BeginFrame. 814 // actually have a new frame to draw when we receive the next BeginFrame.
807 // Proactively requesting the BeginFrame helps hide the round trip latency of 815 // Proactively requesting the BeginFrame helps hide the round trip latency of
808 // the SetNeedsBeginFrame request that has to go to the Browser. 816 // the SetNeedsBeginFrame request that has to go to the Browser.
809 bool SchedulerStateMachine::ProactiveBeginFrameWantedByImplThread() const { 817 bool SchedulerStateMachine::ProactiveBeginFrameWantedByImplThread() const {
810 // The output surface is the provider of BeginFrames for the impl thread, 818 // The output surface is the provider of BeginFrames for the impl thread,
811 // so we are not going to get them even if we ask for them. 819 // so we are not going to get them even if we ask for them.
812 if (!HasInitializedOutputSurface()) 820 if (!HasInitializedOutputSurface())
813 return false; 821 return false;
814 822
815 // Do not be proactive if vsync is off.
816 if (!settings_.throttle_frame_production)
817 return false;
818
819 // Do not be proactive when invisible. 823 // Do not be proactive when invisible.
820 if (!visible_) 824 if (!visible_)
821 return false; 825 return false;
822 826
823 // We should proactively request a BeginFrame if a commit is pending 827 // We should proactively request a BeginFrame if a commit is pending
824 // because we will want to draw if the commit completes quickly. 828 // because we will want to draw if the commit completes quickly.
825 if (needs_commit_ || commit_state_ != COMMIT_STATE_IDLE) 829 if (needs_commit_ || commit_state_ != COMMIT_STATE_IDLE)
826 return true; 830 return true;
827 831
828 // If the pending tree activates quickly, we'll want a BeginFrame soon 832 // If the pending tree activates quickly, we'll want a BeginFrame soon
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 case OUTPUT_SURFACE_ACTIVE: 1003 case OUTPUT_SURFACE_ACTIVE:
1000 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1004 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1001 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1005 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1002 return true; 1006 return true;
1003 } 1007 }
1004 NOTREACHED(); 1008 NOTREACHED();
1005 return false; 1009 return false;
1006 } 1010 }
1007 1011
1008 } // namespace cc 1012 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698