Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
[chromium-blink-merge.git] / cc / scheduler / vsync_time_source.cc
blob75314fbeff76e7a9477239d69d7292ab6c491f4e
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
3 // found in the LICENSE file.
5 #include "cc/scheduler/vsync_time_source.h"
7 namespace cc {
9 scoped_refptr<VSyncTimeSource> VSyncTimeSource::Create(
10 VSyncProvider* vsync_provider) {
11 return make_scoped_refptr(new VSyncTimeSource(vsync_provider));
14 VSyncTimeSource::VSyncTimeSource(VSyncProvider* vsync_provider)
15 : active_(false),
16 notification_requested_(false),
17 vsync_provider_(vsync_provider),
18 client_(NULL) {}
20 VSyncTimeSource::~VSyncTimeSource() {}
22 void VSyncTimeSource::SetClient(TimeSourceClient* client) {
23 client_ = client;
26 void VSyncTimeSource::SetActive(bool active) {
27 if (active_ == active)
28 return;
29 active_ = active;
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
32 // transition.
33 if (active_ && !notification_requested_) {
34 notification_requested_ = true;
35 vsync_provider_->RequestVSyncNotification(this);
39 bool VSyncTimeSource::Active() const {
40 return active_;
43 base::TimeTicks VSyncTimeSource::LastTickTime() {
44 return last_tick_time_;
47 base::TimeTicks VSyncTimeSource::NextTickTime() {
48 return Active() ? last_tick_time_ + interval_ : base::TimeTicks();
51 void VSyncTimeSource::SetTimebaseAndInterval(base::TimeTicks,
52 base::TimeDelta interval) {
53 interval_ = interval;
56 void VSyncTimeSource::DidVSync(base::TimeTicks frame_time) {
57 last_tick_time_ = frame_time;
58 if (!active_) {
59 if (notification_requested_) {
60 notification_requested_ = false;
61 vsync_provider_->RequestVSyncNotification(NULL);
63 return;
65 if (client_)
66 client_->OnTimerTick();
69 } // namespace cc