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

Unified Diff: cc/scheduler/scheduler.cc

Issue 387493002: Fixing and enhancing OrderedSimpleTaskRunner to allow 100% deterministic tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for Brian's comments. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/scheduler/scheduler.cc
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index 65f63fc8b641040ad3e26a8e572ae97fd9c6943f..1c66f01ab320d34187eca2bf73b1cad3687e22da 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -19,15 +19,8 @@ namespace cc {
Scheduler::SyntheticBeginFrameSource::SyntheticBeginFrameSource(
Scheduler* scheduler,
- base::SingleThreadTaskRunner* task_runner)
- : scheduler_(scheduler) {
- if (gfx::FrameTime::TimestampsAreHighRes()) {
- time_source_ = DelayBasedTimeSourceHighRes::Create(
- scheduler_->VSyncInterval(), task_runner);
- } else {
- time_source_ = DelayBasedTimeSource::Create(scheduler_->VSyncInterval(),
- task_runner);
- }
+ scoped_refptr<DelayBasedTimeSource> time_source)
+ : scheduler_(scheduler), time_source_(time_source) {
time_source_->SetClient(this);
}
@@ -126,9 +119,21 @@ Scheduler::~Scheduler() {
}
void Scheduler::SetupSyntheticBeginFrames() {
+ scoped_refptr<DelayBasedTimeSource> time_source;
+ if (gfx::FrameTime::TimestampsAreHighRes()) {
+ time_source = DelayBasedTimeSourceHighRes::Create(VSyncInterval(),
+ task_runner_.get());
+ } else {
+ time_source =
+ DelayBasedTimeSource::Create(VSyncInterval(), task_runner_.get());
+ }
DCHECK(!synthetic_begin_frame_source_);
synthetic_begin_frame_source_.reset(
- new SyntheticBeginFrameSource(this, task_runner_.get()));
+ new SyntheticBeginFrameSource(this, time_source));
+}
+
+base::TimeTicks Scheduler::Now() const {
+ return gfx::FrameTime::Now();
}
void Scheduler::CommitVSyncParameters(base::TimeTicks timebase,
@@ -262,7 +267,7 @@ base::TimeTicks Scheduler::AnticipatedDrawTime() const {
begin_impl_frame_args_.interval <= base::TimeDelta())
return base::TimeTicks();
- base::TimeTicks now = gfx::FrameTime::Now();
+ base::TimeTicks now = Now();
base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time,
begin_impl_frame_args_.deadline);
int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval);
@@ -340,7 +345,7 @@ void Scheduler::BeginUnthrottledFrame() {
DCHECK(!settings_.throttle_frame_production);
DCHECK(begin_retro_frame_args_.empty());
- base::TimeTicks now = gfx::FrameTime::Now();
+ base::TimeTicks now = Now();
base::TimeTicks deadline = now + vsync_interval_;
BeginFrameArgs begin_frame_args =
@@ -451,7 +456,7 @@ void Scheduler::BeginRetroFrame() {
// TODO(brianderson): In the future, long deadlines could result in us not
// draining the queue if we don't catch up. If we consistently can't catch
// up, our fallback should be to lower our frame rate.
- base::TimeTicks now = gfx::FrameTime::Now();
+ base::TimeTicks now = Now();
base::TimeDelta draw_duration_estimate = client_->DrawDurationEstimate();
while (!begin_retro_frame_args_.empty() &&
now > AdjustedBeginImplFrameDeadline(begin_retro_frame_args_.front(),
@@ -479,6 +484,10 @@ void Scheduler::BeginRetroFrame() {
// will check if there is a pending BeginRetroFrame to ensure we handle
// BeginFrames in FIFO order.
void Scheduler::PostBeginRetroFrameIfNeeded() {
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler"),
+ "Scheduler::PostBeginRetroFrameIfNeeded",
+ "state",
+ AsValue());
if (!last_set_needs_begin_frame_)
return;
@@ -555,6 +564,8 @@ base::TimeTicks Scheduler::AdjustedBeginImplFrameDeadline(
}
void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) {
+ TRACE_EVENT1(
+ "cc", "Scheduler::ScheduleBeginImplFrameDeadline", "deadline", deadline);
if (settings_.using_synchronous_renderer_compositor) {
// The synchronous renderer compositor has to make its GL calls
// within this call.
@@ -567,7 +578,7 @@ void Scheduler::ScheduleBeginImplFrameDeadline(base::TimeTicks deadline) {
begin_impl_frame_deadline_task_.Cancel();
begin_impl_frame_deadline_task_.Reset(begin_impl_frame_deadline_closure_);
- base::TimeDelta delta = deadline - gfx::FrameTime::Now();
+ base::TimeDelta delta = deadline - Now();
if (delta <= base::TimeDelta())
delta = base::TimeDelta();
task_runner_->PostDelayedTask(
@@ -697,9 +708,8 @@ scoped_refptr<base::debug::ConvertableToTraceFormat> Scheduler::AsValue()
}
state->BeginDictionary("scheduler_state");
- state->SetDouble(
- "time_until_anticipated_draw_time_ms",
- (AnticipatedDrawTime() - base::TimeTicks::Now()).InMillisecondsF());
+ state->SetDouble("time_until_anticipated_draw_time_ms",
+ (AnticipatedDrawTime() - Now()).InMillisecondsF());
state->SetDouble("vsync_interval_ms", vsync_interval_.InMillisecondsF());
state->SetDouble("estimated_parent_draw_time_ms",
estimated_parent_draw_time_.InMillisecondsF());
« no previous file with comments | « cc/scheduler/scheduler.h ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698