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
17extern "C" {
18#endif
19
20struct 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 //! Scale
46 float scale;
47
48 //! Rotate the image by 180 degrees
50
51 //! Set to GUI_WIDGET_SWAPCHAIN_INVALID_INDEX on invalid.
52 uint32_t active_index;
53
54 //! Should the image be flipped in y direction.
55 bool flip_y;
56};
57
58/*!
59 * A single record in a native image widget storage.
60 *
61 * @ingroup gui
62 */
64{
65 void *ptr;
66 struct gui_widget_native_images gwni;
67};
68
69/*!
70 * Helper struct to cache @ref gui_widget_native_images.
71 *
72 * @ingroup gui
73 */
75{
76 struct gui_widget_native_images_record records[32];
77};
78
79
80/*
81 *
82 * Swapchain functions.
83 *
84 */
85
86/*!
87 * Initialise a embeddable record window.
88 *
89 * @ingroup gui
90 */
91void
93
94/*!
95 * Update the swapchain widget.
96 *
97 * @ingroup gui
98 */
99void
101
102/*!
103 * Renders all controls of a record window.
104 *
105 * @ingroup gui
106 */
107void
109
110/*!
111 * Draw the sink image as the background to the background of the render view.
112 * Basically the main window in which all ImGui windows lives in, not to a
113 * ImGui window.
114 *
115 * @ingroup gui
116 */
117void
119
120/*!
121 * Frees all resources associated with a record window. Make sure to only call
122 * this function on the main gui thread, and that nothing is pushing into the
123 * record windows sink.
124 *
125 * @ingroup gui
126 */
127void
129
130
131/*
132 *
133 * Storage functions.
134 *
135 */
136
137/*!
138 * Search the storage for the matching record for the debug swapchain and
139 * return it, if not found and there is room create it.
140 *
141 * @ingroup gui
142 */
145 struct u_native_images_debug *unid);
146
147/*!
148 * Close the storage.
149 *
150 * @ingroup gui
151 */
154 struct u_native_images_debug *unid);
155
156
157#ifdef __cplusplus
158}
159#endif
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:184
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_init(struct gui_widget_native_images *gwni)
Initialise a embeddable record window.
Definition: gui_widget_native_images.c:129
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:160
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:201
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:137
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:215
#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:64
Helper struct to cache gui_widget_native_images.
Definition: gui_widget_native_images.h:75
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:55
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:52
bool rotate_180
Rotate the image by 180 degrees.
Definition: gui_widget_native_images.h:49
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
float scale
Scale.
Definition: gui_widget_native_images.h:46
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.