Monado OpenXR Runtime
gui_widget_native_images.h
Go to the documentation of this file.
1 // Copyright 2019-2024, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Swapchain rendering helper code.
6  * @author Jakob Bornecrantz <jakob@collabora.com>
7  * @ingroup gui
8  */
9 
10 #pragma once
11 
12 #include "xrt/xrt_compositor.h"
13 #include "xrt/xrt_defines.h"
14 #include "xrt/xrt_limits.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 struct gui_program;
22 
23 #define GUI_WIDGET_SWAPCHAIN_INVALID_INDEX 0xffffffff
24 
25 /*!
26  * A small widget that interfaces a @ref u_native_images_debug struct, caching the
27  * imports from the listed @ref xrt_image_native list.
28  *
29  * @ingroup gui
30  */
32 {
33  //! To check if swapchain has been changed.
35 
36  uint32_t memories[XRT_MAX_SWAPCHAIN_IMAGES];
37  uint32_t textures[XRT_MAX_SWAPCHAIN_IMAGES];
38 
39  //! The current number of images that has been imported.
40  uint32_t texture_count;
41 
42  //! Dimensions.
43  uint32_t width, height;
44 
45  //! Set to GUI_WIDGET_SWAPCHAIN_INVALID_INDEX on invalid.
46  uint32_t active_index;
47 
48  //! Should the image be flipped in y direction.
49  bool flip_y;
50 };
51 
52 /*!
53  * A single record in a native image widget storage.
54  *
55  * @ingroup gui
56  */
58 {
59  void *ptr;
60  struct gui_widget_native_images gwni;
61 };
62 
63 /*!
64  * Helper struct to cache @ref gui_widget_native_images.
65  *
66  * @ingroup gui
67  */
69 {
70  struct gui_widget_native_images_record records[32];
71 };
72 
73 
74 /*
75  *
76  * Swapchain functions.
77  *
78  */
79 
80 /*!
81  * Initialise a embeddable record window.
82  *
83  * @ingroup gui
84  */
85 void
87 
88 /*!
89  * Update the swapchain widget.
90  *
91  * @ingroup gui
92  */
93 void
95 
96 /*!
97  * Renders all controls of a record window.
98  *
99  * @ingroup gui
100  */
101 void
103 
104 /*!
105  * Draw the sink image as the background to the background of the render view.
106  * Basically the main window in which all ImGui windows lives in, not to a
107  * ImGui window.
108  *
109  * @ingroup gui
110  */
111 void
113 
114 /*!
115  * Frees all resources associated with a record window. Make sure to only call
116  * this function on the main gui thread, and that nothing is pushing into the
117  * record windows sink.
118  *
119  * @ingroup gui
120  */
121 void
123 
124 
125 /*
126  *
127  * Storage functions.
128  *
129  */
130 
131 /*!
132  * Search the storage for the matching record for the debug swapchain and
133  * return it, if not found and there is room create it.
134  *
135  * @ingroup gui
136  */
139  struct u_native_images_debug *unid);
140 
141 /*!
142  * Close the storage.
143  *
144  * @ingroup gui
145  */
148  struct u_native_images_debug *unid);
149 
150 
151 #ifdef __cplusplus
152 }
153 #endif
struct gui_widget_native_images * gui_widget_native_images_storage_ensure(struct gui_widget_native_images_storage *gwnis, struct u_native_images_debug *unid)
Search the storage for the matching record for the debug swapchain and return it, if not found and th...
Definition: gui_widget_native_images.c:162
void gui_widget_native_images_to_background(struct gui_widget_native_images *gwni, struct gui_program *p)
Draw the sink image as the background to the background of the render view.
Definition: gui_widget_native_images.c:131
void gui_widget_native_images_init(struct gui_widget_native_images *gwni)
Initialise a embeddable record window.
Definition: gui_widget_native_images.c:83
void gui_widget_native_images_render(struct gui_widget_native_images *gwni, struct gui_program *p)
Renders all controls of a record window.
Definition: gui_widget_native_images.c:113
void gui_widget_native_images_close(struct gui_widget_native_images *gwni)
Frees all resources associated with a record window.
Definition: gui_widget_native_images.c:148
struct gui_widget_native_images * gui_widget_native_images_storage_close(struct gui_widget_native_images_storage *gwnis, struct u_native_images_debug *unid)
Close the storage.
void gui_widget_native_images_update(struct gui_widget_native_images *gwni, struct u_native_images_debug *unid)
Update the swapchain widget.
Definition: gui_widget_native_images.c:90
#define XRT_MAX_SWAPCHAIN_IMAGES
Max swapchain images, artificial limit.
Definition: xrt_limits.h:34
A gui program.
Definition: gui_common.h:44
A single record in a native image widget storage.
Definition: gui_widget_native_images.h:58
Helper struct to cache gui_widget_native_images.
Definition: gui_widget_native_images.h:69
A small widget that interfaces a u_native_images_debug struct, caching the imports from the listed xr...
Definition: gui_widget_native_images.h:32
bool flip_y
Should the image be flipped in y direction.
Definition: gui_widget_native_images.h:49
xrt_limited_unique_id_t cache_id
To check if swapchain has been changed.
Definition: gui_widget_native_images.h:34
uint32_t active_index
Set to GUI_WIDGET_SWAPCHAIN_INVALID_INDEX on invalid.
Definition: gui_widget_native_images.h:46
uint32_t width
Dimensions.
Definition: gui_widget_native_images.h:43
uint32_t texture_count
The current number of images that has been imported.
Definition: gui_widget_native_images.h:40
A struct for debugging one or more native images.
Definition: u_native_images_debug.h:27
A limited unique id, it is only unique for the process it is in, so must not be used or synchronized ...
Definition: xrt_defines.h:79
Header declaring XRT graphics interfaces.
Common defines and enums for XRT.
Header for limits of the XRT interfaces.