| OLD | NEW |
| 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 #ifndef CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 5 #ifndef CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| 6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 6 #define CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 bool CommitPending() const { | 52 bool CommitPending() const { |
| 53 return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || | 53 return commit_state_ == COMMIT_STATE_FRAME_IN_PROGRESS || |
| 54 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; | 54 commit_state_ == COMMIT_STATE_READY_TO_COMMIT; |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool RedrawPending() const { return needs_redraw_; } | 57 bool RedrawPending() const { return needs_redraw_; } |
| 58 | 58 |
| 59 enum Action { | 59 enum Action { |
| 60 ACTION_NONE, | 60 ACTION_NONE, |
| 61 ACTION_BEGIN_FRAME, | 61 ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD, |
| 62 ACTION_COMMIT, | 62 ACTION_COMMIT, |
| 63 ACTION_CHECK_FOR_COMPLETED_TILE_UPLOADS, | 63 ACTION_CHECK_FOR_COMPLETED_TILE_UPLOADS, |
| 64 ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED, | 64 ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED, |
| 65 ACTION_DRAW_IF_POSSIBLE, | 65 ACTION_DRAW_IF_POSSIBLE, |
| 66 ACTION_DRAW_FORCED, | 66 ACTION_DRAW_FORCED, |
| 67 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, | 67 ACTION_BEGIN_OUTPUT_SURFACE_CREATION, |
| 68 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, | 68 ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD, |
| 69 }; | 69 }; |
| 70 Action NextAction() const; | 70 Action NextAction() const; |
| 71 void UpdateState(Action action); | 71 void UpdateState(Action action); |
| 72 | 72 |
| 73 // Indicates whether the scheduler needs a vsync callback in order to make | 73 // Indicates whether the main thread needs a begin frame callback in order to |
| 74 // progress. | 74 // make progress. |
| 75 bool VSyncCallbackNeeded() const; | 75 bool BeginFrameNeededByImplThread() const; |
| 76 | 76 |
| 77 // Indicates that the system has entered and left a vsync callback. | 77 // Indicates that the system has entered and left a BeginFrame callback. |
| 78 // The scheduler will not draw more than once in a given vsync callback. | 78 // The scheduler will not draw more than once in a given BeginFrame |
| 79 void DidEnterVSync(); | 79 // callback. |
| 80 void DidLeaveVSync(); | 80 void DidEnterBeginFrame(); |
| 81 void DidLeaveBeginFrame(); |
| 81 | 82 |
| 82 // Indicates whether the LayerTreeHostImpl is visible. | 83 // Indicates whether the LayerTreeHostImpl is visible. |
| 83 void SetVisible(bool visible); | 84 void SetVisible(bool visible); |
| 84 | 85 |
| 85 // Indicates that a redraw is required, either due to the impl tree changing | 86 // Indicates that a redraw is required, either due to the impl tree changing |
| 86 // or the screen being damaged and simply needing redisplay. | 87 // or the screen being damaged and simply needing redisplay. |
| 87 void SetNeedsRedraw(); | 88 void SetNeedsRedraw(); |
| 88 | 89 |
| 89 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if | 90 // As SetNeedsRedraw(), but ensures the draw will definitely happen even if |
| 90 // we are not visible. | 91 // we are not visible. |
| 91 void SetNeedsForcedRedraw(); | 92 void SetNeedsForcedRedraw(); |
| 92 | 93 |
| 93 // Indicates that a redraw is required because we are currently rendering | 94 // Indicates that a redraw is required because we are currently rendering |
| 94 // with a low resolution or checkerboarded tile. | 95 // with a low resolution or checkerboarded tile. |
| 95 void DidSwapUseIncompleteTile(); | 96 void DidSwapUseIncompleteTile(); |
| 96 | 97 |
| 97 // Indicates whether ACTION_DRAW_IF_POSSIBLE drew to the screen or not. | 98 // Indicates whether ACTION_DRAW_IF_POSSIBLE drew to the screen or not. |
| 98 void DidDrawIfPossibleCompleted(bool success); | 99 void DidDrawIfPossibleCompleted(bool success); |
| 99 | 100 |
| 100 // Indicates that a new commit flow needs to be performed, either to pull | 101 // Indicates that a new commit flow needs to be performed, either to pull |
| 101 // updates from the main thread to the impl, or to push deltas from the impl | 102 // updates from the main thread to the impl, or to push deltas from the impl |
| 102 // thread to main. | 103 // thread to main. |
| 103 void SetNeedsCommit(); | 104 void SetNeedsCommit(); |
| 104 | 105 |
| 105 // As SetNeedsCommit(), but ensures the BeginFrame will definitely happen even | 106 // As SetNeedsCommit(), but ensures the begin frame will be sent to the main |
| 106 // if we are not visible. After this call we expect to go through the forced | 107 // thread even if we are not visible. After this call we expect to go through |
| 107 // commit flow and then return to waiting for a non-forced BeginFrame to | 108 // the forced commit flow and then return to waiting for a non-forced |
| 108 // finish. | 109 // begin frame to finish. |
| 109 void SetNeedsForcedCommit(); | 110 void SetNeedsForcedCommit(); |
| 110 | 111 |
| 111 // Call this only in response to receiving an ACTION_BEGIN_FRAME | 112 // Call this only in response to receiving an |
| 112 // from NextAction. Indicates that all painting is complete. | 113 // ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD from NextAction. |
| 113 void BeginFrameComplete(); | 114 // Indicates that all painting is complete. |
| 115 void FinishCommit(); |
| 114 | 116 |
| 115 // Call this only in response to receiving an ACTION_BEGIN_FRAME | 117 // Call this only in response to receiving an |
| 116 // from NextAction if the client rejects the BeginFrame message. | 118 // ACTION_SEND_BEGIN_FRAME_TO_MAIN_THREAD from NextAction if the client |
| 117 void BeginFrameAborted(); | 119 // rejects the begin frame message. |
| 120 void BeginFrameAbortedByMainThread(); |
| 118 | 121 |
| 119 // Request exclusive access to the textures that back single buffered | 122 // Request exclusive access to the textures that back single buffered |
| 120 // layers on behalf of the main thread. Upon acquisition, | 123 // layers on behalf of the main thread. Upon acquisition, |
| 121 // ACTION_DRAW_IF_POSSIBLE will not draw until the main thread releases the | 124 // ACTION_DRAW_IF_POSSIBLE will not draw until the main thread releases the |
| 122 // textures to the impl thread by committing the layers. | 125 // textures to the impl thread by committing the layers. |
| 123 void SetMainThreadNeedsLayerTextures(); | 126 void SetMainThreadNeedsLayerTextures(); |
| 124 | 127 |
| 125 // Set that we can create the first OutputSurface and start the scheduler. | 128 // Set that we can create the first OutputSurface and start the scheduler. |
| 126 void SetCanStart() { can_start_ = true; } | 129 void SetCanStart() { can_start_ = true; } |
| 127 | 130 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 int last_frame_number_where_tree_activation_attempted_; | 174 int last_frame_number_where_tree_activation_attempted_; |
| 172 int last_frame_number_where_check_for_completed_tile_uploads_called_; | 175 int last_frame_number_where_check_for_completed_tile_uploads_called_; |
| 173 int consecutive_failed_draws_; | 176 int consecutive_failed_draws_; |
| 174 int maximum_number_of_failed_draws_before_draw_is_forced_; | 177 int maximum_number_of_failed_draws_before_draw_is_forced_; |
| 175 bool needs_redraw_; | 178 bool needs_redraw_; |
| 176 bool swap_used_incomplete_tile_; | 179 bool swap_used_incomplete_tile_; |
| 177 bool needs_forced_redraw_; | 180 bool needs_forced_redraw_; |
| 178 bool needs_forced_redraw_after_next_commit_; | 181 bool needs_forced_redraw_after_next_commit_; |
| 179 bool needs_commit_; | 182 bool needs_commit_; |
| 180 bool needs_forced_commit_; | 183 bool needs_forced_commit_; |
| 181 bool expect_immediate_begin_frame_; | 184 bool expect_immediate_begin_frame_for_main_thread_; |
| 182 bool main_thread_needs_layer_textures_; | 185 bool main_thread_needs_layer_textures_; |
| 183 bool inside_vsync_; | 186 bool inside_begin_frame_; |
| 184 bool visible_; | 187 bool visible_; |
| 185 bool can_start_; | 188 bool can_start_; |
| 186 bool can_draw_; | 189 bool can_draw_; |
| 187 bool has_pending_tree_; | 190 bool has_pending_tree_; |
| 188 bool draw_if_possible_failed_; | 191 bool draw_if_possible_failed_; |
| 189 TextureState texture_state_; | 192 TextureState texture_state_; |
| 190 OutputSurfaceState output_surface_state_; | 193 OutputSurfaceState output_surface_state_; |
| 191 bool did_create_and_initialize_first_output_surface_; | 194 bool did_create_and_initialize_first_output_surface_; |
| 192 | 195 |
| 193 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); | 196 DISALLOW_COPY_AND_ASSIGN(SchedulerStateMachine); |
| 194 }; | 197 }; |
| 195 | 198 |
| 196 } // namespace cc | 199 } // namespace cc |
| 197 | 200 |
| 198 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ | 201 #endif // CC_SCHEDULER_SCHEDULER_STATE_MACHINE_H_ |
| OLD | NEW |