HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
gfx_system.hpp
1// Copyright Take Vos 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 "gfx_device.hpp"
8#include "../unfair_recursive_mutex.hpp"
9#include "../subsystem.hpp"
10#include <span>
11#include <memory>
12#include <mutex>
13#include <thread>
14#include <vector>
15
16namespace tt {
17class gfx_surface;
18
22public:
25
26 gfx_system() noexcept
27 {
28 }
29
30 virtual ~gfx_system() {
31 }
32
33 gfx_system(const gfx_system &) = delete;
34 gfx_system &operator=(const gfx_system &) = delete;
35 gfx_system(gfx_system &&) = delete;
36 gfx_system &operator=(gfx_system &&) = delete;
37
41 virtual void init() {};
42 virtual void deinit() {};
43
44 [[nodiscard]] virtual std::unique_ptr<gfx_surface> make_surface(os_handle instance, void *os_window) const noexcept = 0;
45
46 static inline gfx_system &global() noexcept
47 {
48 return *start_subsystem_or_terminate(_global, nullptr, subsystem_init, subsystem_deinit);
49 }
50
51 gfx_device *findBestDeviceForSurface(gfx_surface const &surface);
52
53private:
54 static inline std::atomic<gfx_system *> _global;
55
56 [[nodiscard]] static gfx_system *subsystem_init() noexcept;
57 [[nodiscard]] static void subsystem_deinit() noexcept;
58};
59
60}
Graphics system.
Definition gfx_system.hpp:21
std::vector< std::shared_ptr< gfx_device > > devices
List of all devices.
Definition gfx_system.hpp:24
virtual void init()
Initialize after construction.
Definition gfx_system.hpp:41