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

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

Issue 24019008: cc: Remove safe_to_expect_begin_frame workaround (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 3 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') | no next file » | 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 #include "cc/debug/traced_value.h" 10 #include "cc/debug/traced_value.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 Scheduler::Scheduler(SchedulerClient* client, 14 Scheduler::Scheduler(SchedulerClient* client,
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 weak_factory_(this), 18 weak_factory_(this),
19 last_set_needs_begin_frame_(false), 19 last_set_needs_begin_frame_(false),
20 has_pending_begin_frame_(false), 20 has_pending_begin_frame_(false),
21 safe_to_expect_begin_frame_(false),
22 state_machine_(scheduler_settings), 21 state_machine_(scheduler_settings),
23 inside_process_scheduled_actions_(false) { 22 inside_process_scheduled_actions_(false) {
24 DCHECK(client_); 23 DCHECK(client_);
25 DCHECK(!state_machine_.BeginFrameNeededToDrawByImplThread()); 24 DCHECK(!state_machine_.BeginFrameNeededToDrawByImplThread());
26 } 25 }
27 26
28 Scheduler::~Scheduler() { 27 Scheduler::~Scheduler() {
29 client_->SetNeedsBeginFrameOnImplThread(false); 28 client_->SetNeedsBeginFrameOnImplThread(false);
30 } 29 }
31 30
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface"); 90 TRACE_EVENT0("cc", "Scheduler::DidLoseOutputSurface");
92 state_machine_.DidLoseOutputSurface(); 91 state_machine_.DidLoseOutputSurface();
93 ProcessScheduledActions(); 92 ProcessScheduledActions();
94 } 93 }
95 94
96 void Scheduler::DidCreateAndInitializeOutputSurface() { 95 void Scheduler::DidCreateAndInitializeOutputSurface() {
97 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface"); 96 TRACE_EVENT0("cc", "Scheduler::DidCreateAndInitializeOutputSurface");
98 state_machine_.DidCreateAndInitializeOutputSurface(); 97 state_machine_.DidCreateAndInitializeOutputSurface();
99 has_pending_begin_frame_ = false; 98 has_pending_begin_frame_ = false;
100 last_set_needs_begin_frame_ = false; 99 last_set_needs_begin_frame_ = false;
101 safe_to_expect_begin_frame_ = false;
102 ProcessScheduledActions(); 100 ProcessScheduledActions();
103 } 101 }
104 102
105 base::TimeTicks Scheduler::AnticipatedDrawTime() { 103 base::TimeTicks Scheduler::AnticipatedDrawTime() {
106 TRACE_EVENT0("cc", "Scheduler::AnticipatedDrawTime"); 104 TRACE_EVENT0("cc", "Scheduler::AnticipatedDrawTime");
107 105
108 if (!last_set_needs_begin_frame_ || 106 if (!last_set_needs_begin_frame_ ||
109 last_begin_frame_args_.interval <= base::TimeDelta()) 107 last_begin_frame_args_.interval <= base::TimeDelta())
110 return base::TimeTicks(); 108 return base::TimeTicks();
111 109
(...skipping 16 matching lines...) Expand all
128 // because every SetNeedsBeginFrame will force a redraw. 126 // because every SetNeedsBeginFrame will force a redraw.
129 bool proactive_begin_frame_wanted = 127 bool proactive_begin_frame_wanted =
130 state_machine_.ProactiveBeginFrameWantedByImplThread() && 128 state_machine_.ProactiveBeginFrameWantedByImplThread() &&
131 !settings_.using_synchronous_renderer_compositor && 129 !settings_.using_synchronous_renderer_compositor &&
132 settings_.throttle_frame_production; 130 settings_.throttle_frame_production;
133 bool needs_begin_frame = needs_begin_frame_to_draw || 131 bool needs_begin_frame = needs_begin_frame_to_draw ||
134 proactive_begin_frame_wanted; 132 proactive_begin_frame_wanted;
135 bool immediate_disables_needed = 133 bool immediate_disables_needed =
136 settings_.using_synchronous_renderer_compositor; 134 settings_.using_synchronous_renderer_compositor;
137 135
138 if (needs_begin_frame_to_draw)
139 safe_to_expect_begin_frame_ = true;
140
141 // Determine if we need BeginFrame notifications. 136 // Determine if we need BeginFrame notifications.
142 // If we do, always request the BeginFrame immediately. 137 // If we do, always request the BeginFrame immediately.
143 // If not, only disable on the next BeginFrame to avoid unnecessary toggles. 138 // If not, only disable on the next BeginFrame to avoid unnecessary toggles.
144 // The synchronous renderer compositor requires immediate disables though. 139 // The synchronous renderer compositor requires immediate disables though.
145 if ((needs_begin_frame || 140 if ((needs_begin_frame ||
146 state_machine_.inside_begin_frame() || 141 state_machine_.inside_begin_frame() ||
147 immediate_disables_needed) && 142 immediate_disables_needed) &&
148 (needs_begin_frame != last_set_needs_begin_frame_)) { 143 (needs_begin_frame != last_set_needs_begin_frame_)) {
149 has_pending_begin_frame_ = false; 144 has_pending_begin_frame_ = false;
150 client_->SetNeedsBeginFrameOnImplThread(needs_begin_frame); 145 client_->SetNeedsBeginFrameOnImplThread(needs_begin_frame);
151 if (safe_to_expect_begin_frame_) 146 last_set_needs_begin_frame_ = needs_begin_frame;
152 last_set_needs_begin_frame_ = needs_begin_frame;
153 } 147 }
154 148
155 // Request another BeginFrame if we haven't drawn for now until we have 149 // Request another BeginFrame if we haven't drawn for now until we have
156 // deadlines implemented. 150 // deadlines implemented.
157 if (state_machine_.inside_begin_frame() && has_pending_begin_frame_) { 151 if (state_machine_.inside_begin_frame() && has_pending_begin_frame_) {
158 has_pending_begin_frame_ = false; 152 has_pending_begin_frame_ = false;
159 client_->SetNeedsBeginFrameOnImplThread(true); 153 client_->SetNeedsBeginFrameOnImplThread(true);
160 return; 154 return;
161 } 155 }
162 } 156 }
163 157
164 void Scheduler::BeginFrame(const BeginFrameArgs& args) { 158 void Scheduler::BeginFrame(const BeginFrameArgs& args) {
165 TRACE_EVENT0("cc", "Scheduler::BeginFrame"); 159 TRACE_EVENT0("cc", "Scheduler::BeginFrame");
166 DCHECK(!has_pending_begin_frame_); 160 DCHECK(!has_pending_begin_frame_);
167 has_pending_begin_frame_ = true; 161 has_pending_begin_frame_ = true;
168 safe_to_expect_begin_frame_ = true;
169 last_begin_frame_args_ = args; 162 last_begin_frame_args_ = args;
170 state_machine_.DidEnterBeginFrame(args); 163 state_machine_.DidEnterBeginFrame(args);
171 ProcessScheduledActions(); 164 ProcessScheduledActions();
172 state_machine_.DidLeaveBeginFrame(); 165 state_machine_.DidLeaveBeginFrame();
173 } 166 }
174 167
175 void Scheduler::DrawAndSwapIfPossible() { 168 void Scheduler::DrawAndSwapIfPossible() {
176 DrawSwapReadbackResult result = 169 DrawSwapReadbackResult result =
177 client_->ScheduledActionDrawAndSwapIfPossible(); 170 client_->ScheduledActionDrawAndSwapIfPossible();
178 state_machine_.DidDrawIfPossibleCompleted(result.did_draw); 171 state_machine_.DidDrawIfPossibleCompleted(result.did_draw);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 240
248 SetupNextBeginFrameIfNeeded(); 241 SetupNextBeginFrameIfNeeded();
249 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); 242 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime());
250 } 243 }
251 244
252 bool Scheduler::WillDrawIfNeeded() const { 245 bool Scheduler::WillDrawIfNeeded() const {
253 return !state_machine_.PendingDrawsShouldBeAborted(); 246 return !state_machine_.PendingDrawsShouldBeAborted();
254 } 247 }
255 248
256 } // namespace cc 249 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698