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

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

Issue 12922002: cc: Chromify FrameRateController (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 7 years, 9 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
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/test/scheduler_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 Scheduler::Scheduler(SchedulerClient* client, 13 Scheduler::Scheduler(SchedulerClient* client,
14 scoped_ptr<FrameRateController> frame_rate_controller, 14 scoped_ptr<FrameRateController> frame_rate_controller,
15 const SchedulerSettings& scheduler_settings) 15 const SchedulerSettings& scheduler_settings)
16 : settings_(scheduler_settings), 16 : settings_(scheduler_settings),
17 client_(client), 17 client_(client),
18 frame_rate_controller_(frame_rate_controller.Pass()), 18 frame_rate_controller_(frame_rate_controller.Pass()),
19 state_machine_(scheduler_settings), 19 state_machine_(scheduler_settings),
20 inside_process_scheduled_actions_(false) { 20 inside_process_scheduled_actions_(false) {
21 DCHECK(client_); 21 DCHECK(client_);
22 frame_rate_controller_->setClient(this); 22 frame_rate_controller_->SetClient(this);
23 DCHECK(!state_machine_.VSyncCallbackNeeded()); 23 DCHECK(!state_machine_.VSyncCallbackNeeded());
24 } 24 }
25 25
26 Scheduler::~Scheduler() { frame_rate_controller_->setActive(false); } 26 Scheduler::~Scheduler() { frame_rate_controller_->SetActive(false); }
27 27
28 void Scheduler::SetCanBeginFrame(bool can) { 28 void Scheduler::SetCanBeginFrame(bool can) {
29 state_machine_.SetCanBeginFrame(can); 29 state_machine_.SetCanBeginFrame(can);
30 ProcessScheduledActions(); 30 ProcessScheduledActions();
31 } 31 }
32 32
33 void Scheduler::SetVisible(bool visible) { 33 void Scheduler::SetVisible(bool visible) {
34 state_machine_.SetVisible(visible); 34 state_machine_.SetVisible(visible);
35 ProcessScheduledActions(); 35 ProcessScheduledActions();
36 } 36 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ProcessScheduledActions(); 82 ProcessScheduledActions();
83 } 83 }
84 84
85 void Scheduler::BeginFrameAborted() { 85 void Scheduler::BeginFrameAborted() {
86 TRACE_EVENT0("cc", "Scheduler::beginFrameAborted"); 86 TRACE_EVENT0("cc", "Scheduler::beginFrameAborted");
87 state_machine_.BeginFrameAborted(); 87 state_machine_.BeginFrameAborted();
88 ProcessScheduledActions(); 88 ProcessScheduledActions();
89 } 89 }
90 90
91 void Scheduler::SetMaxFramesPending(int max_frames_pending) { 91 void Scheduler::SetMaxFramesPending(int max_frames_pending) {
92 frame_rate_controller_->setMaxFramesPending(max_frames_pending); 92 frame_rate_controller_->SetMaxFramesPending(max_frames_pending);
93 } 93 }
94 94
95 int Scheduler::MaxFramesPending() const { 95 int Scheduler::MaxFramesPending() const {
96 return frame_rate_controller_->maxFramesPending(); 96 return frame_rate_controller_->MaxFramesPending();
97 } 97 }
98 98
99 void Scheduler::SetSwapBuffersCompleteSupported(bool supported) { 99 void Scheduler::SetSwapBuffersCompleteSupported(bool supported) {
100 frame_rate_controller_->setSwapBuffersCompleteSupported(supported); 100 frame_rate_controller_->SetSwapBuffersCompleteSupported(supported);
101 } 101 }
102 102
103 void Scheduler::DidSwapBuffersComplete() { 103 void Scheduler::DidSwapBuffersComplete() {
104 TRACE_EVENT0("cc", "Scheduler::didSwapBuffersComplete"); 104 TRACE_EVENT0("cc", "Scheduler::didSwapBuffersComplete");
105 frame_rate_controller_->didFinishFrame(); 105 frame_rate_controller_->DidFinishFrame();
106 } 106 }
107 107
108 void Scheduler::DidLoseOutputSurface() { 108 void Scheduler::DidLoseOutputSurface() {
109 TRACE_EVENT0("cc", "Scheduler::didLoseOutputSurface"); 109 TRACE_EVENT0("cc", "Scheduler::didLoseOutputSurface");
110 state_machine_.DidLoseOutputSurface(); 110 state_machine_.DidLoseOutputSurface();
111 ProcessScheduledActions(); 111 ProcessScheduledActions();
112 } 112 }
113 113
114 void Scheduler::DidRecreateOutputSurface() { 114 void Scheduler::DidRecreateOutputSurface() {
115 TRACE_EVENT0("cc", "Scheduler::didRecreateOutputSurface"); 115 TRACE_EVENT0("cc", "Scheduler::didRecreateOutputSurface");
116 frame_rate_controller_->didAbortAllPendingFrames(); 116 frame_rate_controller_->DidAbortAllPendingFrames();
117 state_machine_.DidRecreateOutputSurface(); 117 state_machine_.DidRecreateOutputSurface();
118 ProcessScheduledActions(); 118 ProcessScheduledActions();
119 } 119 }
120 120
121 void Scheduler::SetTimebaseAndInterval(base::TimeTicks timebase, 121 void Scheduler::SetTimebaseAndInterval(base::TimeTicks timebase,
122 base::TimeDelta interval) { 122 base::TimeDelta interval) {
123 frame_rate_controller_->setTimebaseAndInterval(timebase, interval); 123 frame_rate_controller_->SetTimebaseAndInterval(timebase, interval);
124 } 124 }
125 125
126 base::TimeTicks Scheduler::AnticipatedDrawTime() { 126 base::TimeTicks Scheduler::AnticipatedDrawTime() {
127 return frame_rate_controller_->nextTickTime(); 127 return frame_rate_controller_->NextTickTime();
128 } 128 }
129 129
130 base::TimeTicks Scheduler::LastVSyncTime() { 130 base::TimeTicks Scheduler::LastVSyncTime() {
131 return frame_rate_controller_->lastTickTime(); 131 return frame_rate_controller_->LastTickTime();
132 } 132 }
133 133
134 void Scheduler::vsyncTick(bool throttled) { 134 void Scheduler::VSyncTick(bool throttled) {
135 TRACE_EVENT1("cc", "Scheduler::vsyncTick", "throttled", throttled); 135 TRACE_EVENT1("cc", "Scheduler::VSyncTick", "throttled", throttled);
136 if (!throttled) 136 if (!throttled)
137 state_machine_.DidEnterVSync(); 137 state_machine_.DidEnterVSync();
138 ProcessScheduledActions(); 138 ProcessScheduledActions();
139 if (!throttled) 139 if (!throttled)
140 state_machine_.DidLeaveVSync(); 140 state_machine_.DidLeaveVSync();
141 } 141 }
142 142
143 void Scheduler::ProcessScheduledActions() { 143 void Scheduler::ProcessScheduledActions() {
144 // We do not allow ProcessScheduledActions to be recursive. 144 // We do not allow ProcessScheduledActions to be recursive.
145 // The top-level call will iteratively execute the next action for us anyway. 145 // The top-level call will iteratively execute the next action for us anyway.
(...skipping 21 matching lines...) Expand all
167 client_->ScheduledActionCheckForCompletedTileUploads(); 167 client_->ScheduledActionCheckForCompletedTileUploads();
168 break; 168 break;
169 case SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED: 169 case SchedulerStateMachine::ACTION_ACTIVATE_PENDING_TREE_IF_NEEDED:
170 client_->ScheduledActionActivatePendingTreeIfNeeded(); 170 client_->ScheduledActionActivatePendingTreeIfNeeded();
171 break; 171 break;
172 case SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: { 172 case SchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: {
173 ScheduledActionDrawAndSwapResult result = 173 ScheduledActionDrawAndSwapResult result =
174 client_->ScheduledActionDrawAndSwapIfPossible(); 174 client_->ScheduledActionDrawAndSwapIfPossible();
175 state_machine_.DidDrawIfPossibleCompleted(result.did_draw); 175 state_machine_.DidDrawIfPossibleCompleted(result.did_draw);
176 if (result.did_swap) 176 if (result.did_swap)
177 frame_rate_controller_->didBeginFrame(); 177 frame_rate_controller_->DidBeginFrame();
178 break; 178 break;
179 } 179 }
180 case SchedulerStateMachine::ACTION_DRAW_FORCED: { 180 case SchedulerStateMachine::ACTION_DRAW_FORCED: {
181 ScheduledActionDrawAndSwapResult result = 181 ScheduledActionDrawAndSwapResult result =
182 client_->ScheduledActionDrawAndSwapForced(); 182 client_->ScheduledActionDrawAndSwapForced();
183 if (result.did_swap) 183 if (result.did_swap)
184 frame_rate_controller_->didBeginFrame(); 184 frame_rate_controller_->DidBeginFrame();
185 break; 185 break;
186 } 186 }
187 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION: 187 case SchedulerStateMachine::ACTION_BEGIN_OUTPUT_SURFACE_RECREATION:
188 client_->ScheduledActionBeginContextRecreation(); 188 client_->ScheduledActionBeginContextRecreation();
189 break; 189 break;
190 case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD: 190 case SchedulerStateMachine::ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD:
191 client_->ScheduledActionAcquireLayerTexturesForMainThread(); 191 client_->ScheduledActionAcquireLayerTexturesForMainThread();
192 break; 192 break;
193 } 193 }
194 action = state_machine_.NextAction(); 194 action = state_machine_.NextAction();
195 } 195 }
196 196
197 // Activate or deactivate the frame rate controller. 197 // Activate or deactivate the frame rate controller.
198 frame_rate_controller_->setActive(state_machine_.VSyncCallbackNeeded()); 198 frame_rate_controller_->SetActive(state_machine_.VSyncCallbackNeeded());
199 client_->DidAnticipatedDrawTimeChange(frame_rate_controller_->nextTickTime()); 199 client_->DidAnticipatedDrawTimeChange(frame_rate_controller_->NextTickTime());
200 } 200 }
201 201
202 } // namespace cc 202 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/test/scheduler_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698