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

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

Issue 12623026: cc: Chromify TimeSource, DelayBasedTimeSource and test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Back to doubles 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 | Annotate | Revision Log
« no previous file with comments | « cc/scheduler/vsync_time_source.h ('k') | cc/scheduler/vsync_time_source_unittest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/vsync_time_source.h" 5 #include "cc/scheduler/vsync_time_source.h"
6 6
7 namespace cc { 7 namespace cc {
8 8
9 scoped_refptr<VSyncTimeSource> VSyncTimeSource::create( 9 scoped_refptr<VSyncTimeSource> VSyncTimeSource::create(
10 VSyncProvider* vsync_provider) { 10 VSyncProvider* vsync_provider) {
11 return make_scoped_refptr(new VSyncTimeSource(vsync_provider)); 11 return make_scoped_refptr(new VSyncTimeSource(vsync_provider));
12 } 12 }
13 13
14 VSyncTimeSource::VSyncTimeSource(VSyncProvider* vsync_provider) 14 VSyncTimeSource::VSyncTimeSource(VSyncProvider* vsync_provider)
15 : vsync_provider_(vsync_provider) 15 : vsync_provider_(vsync_provider)
16 , client_(0) 16 , client_(NULL)
17 , active_(false) 17 , active_(false)
18 , notification_requested_(false) {} 18 , notification_requested_(false) {}
19 19
20 VSyncTimeSource::~VSyncTimeSource() {} 20 VSyncTimeSource::~VSyncTimeSource() {}
21 21
22 void VSyncTimeSource::setClient(TimeSourceClient* client) { 22 void VSyncTimeSource::SetClient(TimeSourceClient* client) {
23 client_ = client; 23 client_ = client;
24 } 24 }
25 25
26 void VSyncTimeSource::setActive(bool active) { 26 void VSyncTimeSource::SetActive(bool active) {
27 if (active_ == active) 27 if (active_ == active)
28 return; 28 return;
29 active_ = active; 29 active_ = active;
30 // The notification will be lazily disabled in the callback to ensure 30 // The notification will be lazily disabled in the callback to ensure
31 // we get notified of the frame immediately following a quick on-off-on 31 // we get notified of the frame immediately following a quick on-off-on
32 // transition. 32 // transition.
33 if (active_ && !notification_requested_) { 33 if (active_ && !notification_requested_) {
34 notification_requested_ = true; 34 notification_requested_ = true;
35 vsync_provider_->RequestVSyncNotification(this); 35 vsync_provider_->RequestVSyncNotification(this);
36 } 36 }
37 } 37 }
38 38
39 bool VSyncTimeSource::active() const { 39 bool VSyncTimeSource::Active() const {
40 return active_; 40 return active_;
41 } 41 }
42 42
43 base::TimeTicks VSyncTimeSource::lastTickTime() { 43 base::TimeTicks VSyncTimeSource::LastTickTime() {
44 return last_tick_time_; 44 return last_tick_time_;
45 } 45 }
46 46
47 base::TimeTicks VSyncTimeSource::nextTickTime() { 47 base::TimeTicks VSyncTimeSource::NextTickTime() {
48 return active() ? last_tick_time_ + interval_ : base::TimeTicks(); 48 return Active() ? last_tick_time_ + interval_ : base::TimeTicks();
49 } 49 }
50 50
51 void VSyncTimeSource::setTimebaseAndInterval(base::TimeTicks, 51 void VSyncTimeSource::SetTimebaseAndInterval(base::TimeTicks,
52 base::TimeDelta interval) { 52 base::TimeDelta interval) {
53 interval_ = interval; 53 interval_ = interval;
54 } 54 }
55 55
56 void VSyncTimeSource::DidVSync(base::TimeTicks frame_time) { 56 void VSyncTimeSource::DidVSync(base::TimeTicks frame_time) {
57 last_tick_time_ = frame_time; 57 last_tick_time_ = frame_time;
58 if (!active_) { 58 if (!active_) {
59 if (notification_requested_) { 59 if (notification_requested_) {
60 notification_requested_ = false; 60 notification_requested_ = false;
61 vsync_provider_->RequestVSyncNotification(NULL); 61 vsync_provider_->RequestVSyncNotification(NULL);
62 } 62 }
63 return; 63 return;
64 } 64 }
65 if (client_) 65 if (client_)
66 client_->onTimerTick(); 66 client_->OnTimerTick();
67 } 67 }
68 68
69 } // namespace cc 69 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/vsync_time_source.h ('k') | cc/scheduler/vsync_time_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698