From 7d72b74a68f073077035985f0787aebbfc2e2321 Mon Sep 17 00:00:00 2001 From: Moses Turner Date: Sat, 28 Jan 2023 12:45:17 -0600 Subject: [PATCH] c/main: Make peek window struct private, and fix build with old SDL2 --- src/xrt/compositor/CMakeLists.txt | 1 + src/xrt/compositor/main/comp_renderer.c | 2 +- src/xrt/compositor/main/comp_window_peek.c | 28 ++++++++++++++++++ src/xrt/compositor/main/comp_window_peek.h | 34 +++++++++------------- 4 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/xrt/compositor/CMakeLists.txt b/src/xrt/compositor/CMakeLists.txt index ec0835b0e..3a8d01062 100644 --- a/src/xrt/compositor/CMakeLists.txt +++ b/src/xrt/compositor/CMakeLists.txt @@ -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) diff --git a/src/xrt/compositor/main/comp_renderer.c b/src/xrt/compositor/main/comp_renderer.c index 7f48f4b00..5726a4dc5 100644 --- a/src/xrt/compositor/main/comp_renderer.c +++ b/src/xrt/compositor/main/comp_renderer.c @@ -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); diff --git a/src/xrt/compositor/main/comp_window_peek.c b/src/xrt/compositor/main/comp_window_peek.c index 462feb26d..39cc7e9f7 100644 --- a/src/xrt/compositor/main/comp_window_peek.c +++ b/src/xrt/compositor/main/comp_window_peek.c @@ -14,6 +14,11 @@ #include "util/u_debug.h" +#ifdef XRT_HAVE_SDL2 +#include +#else +#error "comp_window_peek.h requires SDL2" +#endif #include @@ -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; +} diff --git a/src/xrt/compositor/main/comp_window_peek.h b/src/xrt/compositor/main/comp_window_peek.h index 7c3f275d3..dcac98b92 100644 --- a/src/xrt/compositor/main/comp_window_peek.h +++ b/src/xrt/compositor/main/comp_window_peek.h @@ -17,12 +17,6 @@ #include "os/os_threading.h" -#ifdef XRT_HAVE_SDL2 -#include -#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