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

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

Issue 1200113003: cc: Cleanup DelayBasedTimeSource code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_runner_refptr
Patch Set: mithro's review Created 5 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/begin_frame_source.h" 5 #include "cc/scheduler/begin_frame_source.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 BeginFrameSourceBase::AsValueInto(dict); 203 BeginFrameSourceBase::AsValueInto(dict);
204 dict->SetBoolean("send_begin_frame_posted_", send_begin_frame_posted_); 204 dict->SetBoolean("send_begin_frame_posted_", send_begin_frame_posted_);
205 } 205 }
206 206
207 // SyntheticBeginFrameSource --------------------------------------------- 207 // SyntheticBeginFrameSource ---------------------------------------------
208 scoped_ptr<SyntheticBeginFrameSource> SyntheticBeginFrameSource::Create( 208 scoped_ptr<SyntheticBeginFrameSource> SyntheticBeginFrameSource::Create(
209 base::SingleThreadTaskRunner* task_runner, 209 base::SingleThreadTaskRunner* task_runner,
210 base::TimeDelta initial_vsync_interval) { 210 base::TimeDelta initial_vsync_interval) {
211 scoped_ptr<DelayBasedTimeSource> time_source = 211 scoped_ptr<DelayBasedTimeSource> time_source =
212 DelayBasedTimeSource::Create(initial_vsync_interval, task_runner); 212 DelayBasedTimeSource::Create(initial_vsync_interval, task_runner);
213 return make_scoped_ptr(new SyntheticBeginFrameSource(time_source.Pass())); 213 return make_scoped_ptr(
214 new SyntheticBeginFrameSource(task_runner, time_source.Pass()));
214 } 215 }
215 216
216 SyntheticBeginFrameSource::SyntheticBeginFrameSource( 217 SyntheticBeginFrameSource::SyntheticBeginFrameSource(
218 base::SingleThreadTaskRunner* task_runner,
217 scoped_ptr<DelayBasedTimeSource> time_source) 219 scoped_ptr<DelayBasedTimeSource> time_source)
218 : BeginFrameSourceBase(), time_source_(time_source.Pass()) { 220 : BeginFrameSourceBase(),
221 task_runner_(task_runner),
222 time_source_(time_source.Pass()),
223 weak_factory_(this) {
219 time_source_->SetActive(false); 224 time_source_->SetActive(false);
220 time_source_->SetClient(this); 225 time_source_->SetClient(this);
221 } 226 }
222 227
223 SyntheticBeginFrameSource::~SyntheticBeginFrameSource() { 228 SyntheticBeginFrameSource::~SyntheticBeginFrameSource() {
224 if (NeedsBeginFrames()) 229 if (NeedsBeginFrames())
225 time_source_->SetActive(false); 230 time_source_->SetActive(false);
226 } 231 }
227 232
228 void SyntheticBeginFrameSource::OnUpdateVSyncParameters( 233 void SyntheticBeginFrameSource::OnUpdateVSyncParameters(
(...skipping 15 matching lines...) Expand all
244 CallOnBeginFrame(CreateBeginFrameArgs(time_source_->LastTickTime(), 249 CallOnBeginFrame(CreateBeginFrameArgs(time_source_->LastTickTime(),
245 BeginFrameArgs::NORMAL)); 250 BeginFrameArgs::NORMAL));
246 } 251 }
247 252
248 // BeginFrameSourceBase support 253 // BeginFrameSourceBase support
249 void SyntheticBeginFrameSource::OnNeedsBeginFramesChange( 254 void SyntheticBeginFrameSource::OnNeedsBeginFramesChange(
250 bool needs_begin_frames) { 255 bool needs_begin_frames) {
251 base::TimeTicks missed_tick_time = 256 base::TimeTicks missed_tick_time =
252 time_source_->SetActive(needs_begin_frames); 257 time_source_->SetActive(needs_begin_frames);
253 if (!missed_tick_time.is_null()) { 258 if (!missed_tick_time.is_null()) {
254 CallOnBeginFrame( 259 task_runner_->PostTask(
255 CreateBeginFrameArgs(missed_tick_time, BeginFrameArgs::MISSED)); 260 FROM_HERE, base::Bind(&SyntheticBeginFrameSource::CallOnBeginFrame,
261 weak_factory_.GetWeakPtr(),
262 CreateBeginFrameArgs(missed_tick_time,
263 BeginFrameArgs::MISSED)));
256 } 264 }
257 } 265 }
258 266
259 // Tracing support 267 // Tracing support
260 void SyntheticBeginFrameSource::AsValueInto( 268 void SyntheticBeginFrameSource::AsValueInto(
261 base::trace_event::TracedValue* dict) const { 269 base::trace_event::TracedValue* dict) const {
262 dict->SetString("type", "SyntheticBeginFrameSource"); 270 dict->SetString("type", "SyntheticBeginFrameSource");
263 BeginFrameSourceBase::AsValueInto(dict); 271 BeginFrameSourceBase::AsValueInto(dict);
264 272
265 dict->BeginDictionary("time_source"); 273 dict->BeginDictionary("time_source");
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 if (!observer_->LastUsedBeginFrameArgs().IsValid()) 468 if (!observer_->LastUsedBeginFrameArgs().IsValid())
461 return true; 469 return true;
462 470
463 // Only allow new args have a *strictly bigger* frame_time value and statisfy 471 // Only allow new args have a *strictly bigger* frame_time value and statisfy
464 // minimum interval requirement. 472 // minimum interval requirement.
465 return (args.frame_time >= 473 return (args.frame_time >=
466 observer_->LastUsedBeginFrameArgs().frame_time + minimum_interval_); 474 observer_->LastUsedBeginFrameArgs().frame_time + minimum_interval_);
467 } 475 }
468 476
469 } // namespace cc 477 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698