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 #ifndef CC_SCHEDULER_VSYNC_TIME_SOURCE_H_
6 #define CC_SCHEDULER_VSYNC_TIME_SOURCE_H_
8 #include "cc/base/cc_export.h"
9 #include "cc/scheduler/time_source.h"
13 class CC_EXPORT VSyncClient
{
15 virtual void DidVSync(base::TimeTicks frame_time
) = 0;
18 virtual ~VSyncClient() {}
23 // Request to be notified of future vsync events. The notifications will be
24 // delivered until they are disabled by calling this function with a null
26 virtual void RequestVSyncNotification(VSyncClient
* client
) = 0;
29 virtual ~VSyncProvider() {}
32 // This timer implements a time source that is explicitly triggered by an
33 // external vsync signal.
34 class CC_EXPORT VSyncTimeSource
: public TimeSource
, public VSyncClient
{
36 static scoped_refptr
<VSyncTimeSource
> Create(VSyncProvider
* vsync_provider
);
38 // TimeSource implementation
39 virtual void SetClient(TimeSourceClient
* client
) OVERRIDE
;
40 virtual void SetTimebaseAndInterval(base::TimeTicks timebase
,
41 base::TimeDelta interval
) OVERRIDE
;
42 virtual void SetActive(bool active
) OVERRIDE
;
43 virtual bool Active() const OVERRIDE
;
44 virtual base::TimeTicks
LastTickTime() OVERRIDE
;
45 virtual base::TimeTicks
NextTickTime() OVERRIDE
;
47 // VSyncClient implementation
48 virtual void DidVSync(base::TimeTicks frame_time
) OVERRIDE
;
51 explicit VSyncTimeSource(VSyncProvider
* vsync_provider
);
52 virtual ~VSyncTimeSource();
54 base::TimeTicks last_tick_time_
;
55 base::TimeDelta interval_
;
57 bool notification_requested_
;
59 VSyncProvider
* vsync_provider_
;
60 TimeSourceClient
* client_
;
62 DISALLOW_COPY_AND_ASSIGN(VSyncTimeSource
);
67 #endif // CC_SCHEDULER_VSYNC_TIME_SOURCE_H_