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_WIN_H_ | |
6 #define GPU_IPC_SERVICE_GPU_VSYNC_PROVIDER_WIN_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "base/synchronization/lock.h" | |
14 #include "base/time/time.h" | |
15 #include "gpu/gpu_export.h" | |
16 #include "gpu/ipc/common/surface_handle.h" | |
17 #include "gpu/ipc/service/image_transport_surface_delegate.h" | |
18 #include "ui/gfx/vsync_provider.h" | |
19 | |
20 namespace gl { | |
21 class VSyncProviderWin; | |
22 } // namespace gl | |
23 | |
24 namespace gpu { | |
25 | |
26 class GpuVSyncWorker; | |
27 class GpuVSyncMessageFilter; | |
28 | |
29 using VSyncCallback = base::Callback<void(base::TimeTicks timestamp)>; | |
30 | |
31 // TODO: this should be WIN only | |
stanisc
2017/02/02 22:01:23
Forgot to remove this comment. Will remove it late
| |
32 class GPU_EXPORT GpuVSyncProviderWin : public gfx::VSyncProvider { | |
33 public: | |
34 GpuVSyncProviderWin(base::WeakPtr<ImageTransportSurfaceDelegate> delegate, | |
35 SurfaceHandle surface_handle); | |
36 ~GpuVSyncProviderWin(); | |
37 | |
38 // This class ignores this method and updates VSync directly via a | |
39 // worker thread IPC call. | |
40 void GetVSyncParameters(const UpdateVSyncCallback& callback) override; | |
41 | |
42 private: | |
43 void OnVSync(base::TimeTicks timestamp); | |
44 void OnVSyncParametersUpdated(base::TimeTicks timestamp, | |
45 base::TimeDelta interval); | |
46 | |
47 // VSync worker that waits for VSync events on worker thread. | |
48 scoped_refptr<GpuVSyncWorker> vsync_worker_; | |
49 // Message filter to send/receive IPC messages. | |
50 scoped_refptr<GpuVSyncMessageFilter> message_filter_; | |
51 | |
52 // vsync_interval_ comes from the nested VSyncProvider called on the main | |
53 // thread. | |
54 // TODO(stanisc): Consider either merging VSyncProviderWin with this class or | |
55 // calculating vsync interval from consecutive VSync timestamps. | |
56 std::unique_ptr<gl::VSyncProviderWin> vsync_interval_provider_; | |
57 base::TimeDelta vsync_interval_; | |
58 base::Lock vsync_interval_lock_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(GpuVSyncProviderWin); | |
61 }; | |
62 | |
63 // Implements waiting for VSync signal on background thread. | |
64 class GPU_EXPORT GpuVSyncProviderForTest { | |
65 public: | |
66 GpuVSyncProviderForTest(const VSyncCallback& callback, | |
67 SurfaceHandle surface_handle); | |
68 ~GpuVSyncProviderForTest(); | |
69 | |
70 // Start or stop VSync production. | |
71 void SetNeedsVSync(bool needs_vsync); | |
72 | |
73 private: | |
74 scoped_refptr<GpuVSyncWorker> vsync_worker_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(GpuVSyncProviderForTest); | |
77 }; | |
78 | |
79 } // namespace gpu | |
80 | |
81 #endif // GPU_IPC_SERVICE_GPU_VSYNC_PROVIDER_WIN_H_ | |
OLD | NEW |