HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
gfx_surface.hpp
1// Copyright Take Vos 2021.
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;
14
16public:
17 gfx_system &system;
18
19 gfx_surface_state state = gfx_surface_state::has_window;
20 gfx_surface_loss loss = gfx_surface_loss::none;
21
22 virtual ~gfx_surface() {}
23
24 gfx_surface(const gfx_surface &) = delete;
25 gfx_surface &operator=(const gfx_surface &) = delete;
26 gfx_surface(gfx_surface &&) = delete;
27 gfx_surface &operator=(gfx_surface &&) = delete;
28
29 virtual void init() {}
30
31 gfx_surface(gfx_system &system) : system(system) {}
32
38 virtual void set_device(gfx_device *device) noexcept;
39
40 [[nodiscard]] gfx_device *device() const noexcept
41 {
42 hi_axiom(gfx_system_mutex.recurse_lock_count());
43 return _device;
44 }
45
48 [[nodiscard]] virtual extent2 size() const noexcept = 0;
49
56 virtual void update(extent2 new_size) noexcept = 0;
57
58 [[nodiscard]] virtual draw_context render_start(aarectangle redraw_rectangle) = 0;
59 virtual void render_finish(draw_context const &context) = 0;
60
61protected:
62 gfx_device *_device = nullptr;
63
64 virtual void teardown() = 0;
65};
66
67} // namespace hi::inline v1
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:51
Definition gfx_device.hpp:22
Definition gfx_surface.hpp:15
virtual void set_device(gfx_device *device) noexcept
virtual extent2 size() const noexcept=0
Get the size of the surface.
Graphics system.
Definition gfx_system.hpp:21
int recurse_lock_count() const noexcept
This function should be used in hi_axiom() to check if the lock is held by current thread.
Definition unfair_recursive_mutex.hpp:60