OLD | NEW |
| (Empty) |
1 // Copyright (c) 2016 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. | |
4 | |
5 #ifndef GPU_IPC_SERVICE_GPU_VSYNC_PROVIDER_H_ | |
6 #define GPU_IPC_SERVICE_GPU_VSYNC_PROVIDER_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/time/time.h" | |
12 #include "gpu/gpu_export.h" | |
13 #include "gpu/ipc/common/surface_handle.h" | |
14 | |
15 namespace gpu { | |
16 | |
17 class GpuVSyncWorker; | |
18 | |
19 // Implements waiting for VSync signal on background thread. | |
20 class GPU_EXPORT GpuVSyncProvider { | |
21 public: | |
22 // Once VSync is enabled, this callback is repeatedly invoked on every VSync. | |
23 // The call is made on background thread to avoid increased latency due to | |
24 // serializing callback invocation with other GPU tasks. The code that | |
25 // implements the callback function is expected to handle that. | |
26 using VSyncCallback = base::Callback<void(base::TimeTicks timestamp)>; | |
27 | |
28 ~GpuVSyncProvider(); | |
29 | |
30 static std::unique_ptr<GpuVSyncProvider> Create(const VSyncCallback& callback, | |
31 SurfaceHandle surface_handle); | |
32 | |
33 // Enable or disable VSync production. | |
34 void EnableVSync(bool enabled); | |
35 | |
36 private: | |
37 #if defined(OS_WIN) | |
38 GpuVSyncProvider(const VSyncCallback& callback, SurfaceHandle surface_handle); | |
39 | |
40 std::unique_ptr<GpuVSyncWorker> vsync_worker_; | |
41 #endif // defined(OS_WIN) | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(GpuVSyncProvider); | |
44 }; | |
45 | |
46 } // namespace gpu | |
47 | |
48 #endif // GPU_IPC_SERVICE_GPU_VSYNC_PROVIDER_H_ | |
OLD | NEW |