Chromium Code Reviews| Index: gpu/ipc/service/gpu_vsync_provider_win.h |
| diff --git a/gpu/ipc/service/gpu_vsync_provider_win.h b/gpu/ipc/service/gpu_vsync_provider_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b375e04ad789d791fa7be3daa79e6679b1346e53 |
| --- /dev/null |
| +++ b/gpu/ipc/service/gpu_vsync_provider_win.h |
| @@ -0,0 +1,81 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef GPU_IPC_SERVICE_GPU_VSYNC_PROVIDER_WIN_H_ |
| +#define GPU_IPC_SERVICE_GPU_VSYNC_PROVIDER_WIN_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/synchronization/lock.h" |
| +#include "base/time/time.h" |
| +#include "gpu/gpu_export.h" |
| +#include "gpu/ipc/common/surface_handle.h" |
| +#include "gpu/ipc/service/image_transport_surface_delegate.h" |
| +#include "ui/gfx/vsync_provider.h" |
| + |
| +namespace gl { |
| +class VSyncProviderWin; |
| +} // namespace gl |
| + |
| +namespace gpu { |
| + |
| +class GpuVSyncWorker; |
| +class GpuVSyncMessageFilter; |
| + |
| +using VSyncCallback = base::Callback<void(base::TimeTicks timestamp)>; |
| + |
| +// TODO: this should be WIN only |
|
stanisc
2017/02/02 22:01:23
Forgot to remove this comment. Will remove it late
|
| +class GPU_EXPORT GpuVSyncProviderWin : public gfx::VSyncProvider { |
| + public: |
| + GpuVSyncProviderWin(base::WeakPtr<ImageTransportSurfaceDelegate> delegate, |
| + SurfaceHandle surface_handle); |
| + ~GpuVSyncProviderWin(); |
| + |
| + // This class ignores this method and updates VSync directly via a |
| + // worker thread IPC call. |
| + void GetVSyncParameters(const UpdateVSyncCallback& callback) override; |
| + |
| + private: |
| + void OnVSync(base::TimeTicks timestamp); |
| + void OnVSyncParametersUpdated(base::TimeTicks timestamp, |
| + base::TimeDelta interval); |
| + |
| + // VSync worker that waits for VSync events on worker thread. |
| + scoped_refptr<GpuVSyncWorker> vsync_worker_; |
| + // Message filter to send/receive IPC messages. |
| + scoped_refptr<GpuVSyncMessageFilter> message_filter_; |
| + |
| + // vsync_interval_ comes from the nested VSyncProvider called on the main |
| + // thread. |
| + // TODO(stanisc): Consider either merging VSyncProviderWin with this class or |
| + // calculating vsync interval from consecutive VSync timestamps. |
| + std::unique_ptr<gl::VSyncProviderWin> vsync_interval_provider_; |
| + base::TimeDelta vsync_interval_; |
| + base::Lock vsync_interval_lock_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GpuVSyncProviderWin); |
| +}; |
| + |
| +// Implements waiting for VSync signal on background thread. |
| +class GPU_EXPORT GpuVSyncProviderForTest { |
| + public: |
| + GpuVSyncProviderForTest(const VSyncCallback& callback, |
| + SurfaceHandle surface_handle); |
| + ~GpuVSyncProviderForTest(); |
| + |
| + // Start or stop VSync production. |
| + void SetNeedsVSync(bool needs_vsync); |
| + |
| + private: |
| + scoped_refptr<GpuVSyncWorker> vsync_worker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GpuVSyncProviderForTest); |
| +}; |
| + |
| +} // namespace gpu |
| + |
| +#endif // GPU_IPC_SERVICE_GPU_VSYNC_PROVIDER_WIN_H_ |