c/main: Make peek window struct private, and fix build with old SDL2

This commit is contained in:
Moses Turner 2023-01-28 12:45:17 -06:00
parent 9bd63cb37d
commit 7d72b74a68
4 changed files with 43 additions and 22 deletions

View file

@ -218,6 +218,7 @@ if(XRT_FEATURE_COMPOSITOR_MAIN)
if(XRT_FEATURE_WINDOW_PEEK)
target_sources(comp_main PRIVATE main/comp_window_peek.c)
target_link_libraries(comp_main PRIVATE ${SDL2_LIBRARIES})
target_include_directories(comp_main PRIVATE ${SDL2_INCLUDE_DIRS})
endif()
if(WIN32)
target_sources(comp_main PRIVATE main/comp_window_mswin.c)

View file

@ -1933,7 +1933,7 @@ comp_renderer_draw(struct comp_renderer *r)
#ifdef XRT_FEATURE_WINDOW_PEEK
if (c->peek) {
switch (c->peek->eye) {
switch (comp_window_peek_get_eye(c->peek)) {
case COMP_WINDOW_PEEK_EYE_LEFT:
comp_window_peek_blit(c->peek, r->lr->framebuffers[0].image, r->lr->extent.width,
r->lr->extent.height);

View file

@ -14,6 +14,11 @@
#include "util/u_debug.h"
#ifdef XRT_HAVE_SDL2
#include <SDL2/SDL.h>
#else
#error "comp_window_peek.h requires SDL2"
#endif
#include <SDL2/SDL_vulkan.h>
@ -21,6 +26,23 @@ DEBUG_GET_ONCE_OPTION(window_peek, "XRT_WINDOW_PEEK", NULL)
#define PEEK_IMAGE_USAGE (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT)
struct comp_window_peek
{
struct comp_target_swapchain base;
struct comp_compositor *c;
enum comp_window_peek_eye eye;
SDL_Window *window;
uint32_t width, height;
bool running;
bool hidden;
VkCommandBuffer cmd;
struct os_thread_helper oth;
};
static inline struct vk_bundle *
get_vk(struct comp_window_peek *w)
{
@ -392,3 +414,9 @@ comp_window_peek_blit(struct comp_window_peek *w, VkImage src, int32_t width, in
return;
}
}
enum comp_window_peek_eye
comp_window_peek_get_eye(struct comp_window_peek *w)
{
return w->eye;
}

View file

@ -17,12 +17,6 @@
#include "os/os_threading.h"
#ifdef XRT_HAVE_SDL2
#include <SDL2/SDL.h>
#else
#error "comp_window_peek.h requires SDL2"
#endif
struct comp_compositor;
struct comp_renderer;
@ -37,21 +31,7 @@ enum comp_window_peek_eye
COMP_WINDOW_PEEK_EYE_BOTH = 2,
};
struct comp_window_peek
{
struct comp_target_swapchain base;
struct comp_compositor *c;
enum comp_window_peek_eye eye;
SDL_Window *window;
uint32_t width, height;
bool running;
bool hidden;
VkCommandBuffer cmd;
struct os_thread_helper oth;
};
struct comp_window_peek;
struct comp_window_peek *
comp_window_peek_create(struct comp_compositor *c);
@ -62,6 +42,18 @@ comp_window_peek_destroy(struct comp_window_peek **w_ptr);
void
comp_window_peek_blit(struct comp_window_peek *w, VkImage src, int32_t width, int32_t height);
/*!
*
* Getter for the peek window's eye enum.
* This is a getter function so that struct comp_window_peek can be private.
*
* @param[in] w The peek window struct this compositor has.
* @return The eye that the peek window wants to display.
*
*/
enum comp_window_peek_eye
comp_window_peek_get_eye(struct comp_window_peek *w);
#ifdef __cplusplus
}
#endif