HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
gfx_surface.hpp
1// Copyright Take Vos 2021-2022.
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 "draw_context.hpp"
8#include "gfx_surface_state.hpp"
9#include "gfx_system_globals.hpp"
10
11namespace hi::inline v1 {
12class gfx_device;
13class gfx_system;
14class gfx_surface_delegate;
15
17public:
18 gfx_system &system;
19
20 gfx_surface_state state = gfx_surface_state::has_window;
21 gfx_surface_loss loss = gfx_surface_loss::none;
22
23 virtual ~gfx_surface() {}
24
25 gfx_surface(const gfx_surface &) = delete;
26 gfx_surface &operator=(const gfx_surface &) = delete;
27 gfx_surface(gfx_surface &&) = delete;
28 gfx_surface &operator=(gfx_surface &&) = delete;
29
30 virtual void init() {}
31
32 gfx_surface(gfx_system &system) : system(system) {}
33
39 virtual void set_device(gfx_device *device) noexcept;
40
41 [[nodiscard]] gfx_device *device() const noexcept
42 {
43 hi_axiom(gfx_system_mutex.recurse_lock_count());
44 return _device;
45 }
46
49 [[nodiscard]] virtual extent2i size() const noexcept = 0;
50
57 virtual void update(extent2i new_size) noexcept = 0;
58
59 [[nodiscard]] virtual draw_context render_start(aarectanglei redraw_rectangle) = 0;
60 virtual void render_finish(draw_context const &context) = 0;
61
66 virtual void add_delegate(gfx_surface_delegate *delegate) noexcept = 0;
67
70 virtual void remove_delegate(gfx_surface_delegate *delegate) noexcept = 0;
71
72protected:
73 gfx_device *_device = nullptr;
74
75 virtual void teardown() noexcept = 0;
76};
77
78} // namespace hi::inline v1
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:238
DOXYGEN BUG.
Definition algorithm.hpp:13
unfair_recursive_mutex gfx_system_mutex
Global mutex for GUI elements, like gfx_system, gfx_device, Windows and Widgets.
Definition gfx_system_globals.hpp:14
gfx_surface_state
Definition gfx_surface_state.hpp:9
gfx_surface_loss
Definition gfx_surface_state.hpp:16
Definition gfx_device.hpp:20
Definition gfx_surface.hpp:16
virtual void set_device(gfx_device *device) noexcept
virtual extent2i size() const noexcept=0
Get the size of the surface.
Definition gfx_surface_delegate.hpp:9
Graphics system.
Definition gfx_system.hpp:20