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

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

Issue 27710005: cc: Use HighResNow as timebase if it is fast and reliable (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add frame_time.h Created 7 years, 2 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 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 <algorithm> 7 #include <algorithm>
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "cc/debug/traced_value.h" 11 #include "cc/debug/traced_value.h"
12 #include "ui/gfx/frame_time.h"
12 13
13 namespace cc { 14 namespace cc {
14 15
15 Scheduler::Scheduler(SchedulerClient* client, 16 Scheduler::Scheduler(SchedulerClient* client,
16 const SchedulerSettings& scheduler_settings) 17 const SchedulerSettings& scheduler_settings)
17 : settings_(scheduler_settings), 18 : settings_(scheduler_settings),
18 client_(client), 19 client_(client),
19 last_set_needs_begin_frame_(false), 20 last_set_needs_begin_frame_(false),
20 state_machine_(scheduler_settings), 21 state_machine_(scheduler_settings),
21 inside_process_scheduled_actions_(false), 22 inside_process_scheduled_actions_(false),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 ProcessScheduledActions(); 112 ProcessScheduledActions();
112 } 113 }
113 114
114 base::TimeTicks Scheduler::AnticipatedDrawTime() { 115 base::TimeTicks Scheduler::AnticipatedDrawTime() {
115 TRACE_EVENT0("cc", "Scheduler::AnticipatedDrawTime"); 116 TRACE_EVENT0("cc", "Scheduler::AnticipatedDrawTime");
116 117
117 if (!last_set_needs_begin_frame_ || 118 if (!last_set_needs_begin_frame_ ||
118 last_begin_frame_args_.interval <= base::TimeDelta()) 119 last_begin_frame_args_.interval <= base::TimeDelta())
119 return base::TimeTicks(); 120 return base::TimeTicks();
120 121
121 base::TimeTicks now = base::TimeTicks::Now(); 122 base::TimeTicks now = gfx::FrameTime::Now();
122 base::TimeTicks timebase = std::max(last_begin_frame_args_.frame_time, 123 base::TimeTicks timebase = std::max(last_begin_frame_args_.frame_time,
123 last_begin_frame_args_.deadline); 124 last_begin_frame_args_.deadline);
124 int64 intervals = 1 + ((now - timebase) / last_begin_frame_args_.interval); 125 int64 intervals = 1 + ((now - timebase) / last_begin_frame_args_.interval);
125 return timebase + (last_begin_frame_args_.interval * intervals); 126 return timebase + (last_begin_frame_args_.interval * intervals);
126 } 127 }
127 128
128 base::TimeTicks Scheduler::LastBeginFrameOnImplThreadTime() { 129 base::TimeTicks Scheduler::LastBeginFrameOnImplThreadTime() {
129 return last_begin_frame_args_.frame_time; 130 return last_begin_frame_args_.frame_time;
130 } 131 }
131 132
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 329
329 if (state_machine_.ShouldTriggerBeginFrameDeadlineEarly()) 330 if (state_machine_.ShouldTriggerBeginFrameDeadlineEarly())
330 PostBeginFrameDeadline(base::TimeTicks()); 331 PostBeginFrameDeadline(base::TimeTicks());
331 } 332 }
332 333
333 bool Scheduler::WillDrawIfNeeded() const { 334 bool Scheduler::WillDrawIfNeeded() const {
334 return !state_machine_.PendingDrawsShouldBeAborted(); 335 return !state_machine_.PendingDrawsShouldBeAborted();
335 } 336 }
336 337
337 } // namespace cc 338 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698