HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
vertical_sync_win32.hpp
1// Copyright Take Vos 2019-2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "vertical_sync.hpp"
8#include <span>
9#include <thread>
10#include <array>
11
12namespace tt {
13
14class vertical_sync_win32 final : public vertical_sync {
15public:
16 vertical_sync_win32() noexcept;
17 ~vertical_sync_win32() override;
18
19 [[nodiscard]] utc_nanoseconds wait() noexcept override;
20
21private:
22 void *_gdi;
23 unsigned int _adapter = 0;
24 unsigned int _video_present_source_id;
25
26 utc_nanoseconds _previous_frame_time_point;
27 std::array<std::chrono::nanoseconds, 15> _frame_duration_data;
28 size_t _frame_duration_counter = 0;
29
30 void open_adapter() noexcept;
31 void close_adapter() noexcept;
32
35 [[nodiscard]] std::chrono::nanoseconds average_frame_duration(utc_nanoseconds frameTimestamp) noexcept;
36};
37
38}
STL namespace.
Definition vertical_sync.hpp:13
Definition vertical_sync_win32.hpp:14
utc_nanoseconds wait() noexcept override
Wait for the vertical sync.