libobs: Only resize display if dimensions change
parent
c639255142
commit
5d1261eddb
|
@ -33,8 +33,12 @@ bool obs_display_init(struct obs_display *display,
|
|||
return false;
|
||||
}
|
||||
|
||||
display->cx = graphics_data->cx;
|
||||
display->cy = graphics_data->cy;
|
||||
const uint32_t cx = graphics_data->cx;
|
||||
const uint32_t cy = graphics_data->cy;
|
||||
display->cx = cx;
|
||||
display->cy = cy;
|
||||
display->next_cx = cx;
|
||||
display->next_cy = cy;
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&display->draw_callbacks_mutex, NULL) != 0) {
|
||||
|
@ -114,9 +118,8 @@ void obs_display_resize(obs_display_t *display, uint32_t cx, uint32_t cy)
|
|||
|
||||
pthread_mutex_lock(&display->draw_info_mutex);
|
||||
|
||||
display->cx = cx;
|
||||
display->cy = cy;
|
||||
display->size_changed = true;
|
||||
display->next_cx = cx;
|
||||
display->next_cy = cy;
|
||||
|
||||
pthread_mutex_unlock(&display->draw_info_mutex);
|
||||
}
|
||||
|
@ -152,15 +155,17 @@ void obs_display_remove_draw_callback(obs_display_t *display,
|
|||
}
|
||||
|
||||
static inline void render_display_begin(struct obs_display *display,
|
||||
uint32_t cx, uint32_t cy,
|
||||
bool size_changed)
|
||||
uint32_t cx, uint32_t cy)
|
||||
{
|
||||
struct vec4 clear_color;
|
||||
|
||||
gs_load_swapchain(display->swap);
|
||||
|
||||
if (size_changed)
|
||||
if ((display->cx != cx) || (display->cy != cy)) {
|
||||
gs_resize(cx, cy);
|
||||
display->cx = cx;
|
||||
display->cy = cy;
|
||||
}
|
||||
|
||||
gs_begin_scene();
|
||||
|
||||
|
@ -186,7 +191,6 @@ static inline void render_display_end()
|
|||
void render_display(struct obs_display *display)
|
||||
{
|
||||
uint32_t cx, cy;
|
||||
bool size_changed;
|
||||
|
||||
if (!display || !display->enabled)
|
||||
return;
|
||||
|
@ -197,18 +201,14 @@ void render_display(struct obs_display *display)
|
|||
|
||||
pthread_mutex_lock(&display->draw_info_mutex);
|
||||
|
||||
cx = display->cx;
|
||||
cy = display->cy;
|
||||
size_changed = display->size_changed;
|
||||
|
||||
if (size_changed)
|
||||
display->size_changed = false;
|
||||
cx = display->next_cx;
|
||||
cy = display->next_cy;
|
||||
|
||||
pthread_mutex_unlock(&display->draw_info_mutex);
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
render_display_begin(display, cx, cy, size_changed);
|
||||
render_display_begin(display, cx, cy);
|
||||
|
||||
pthread_mutex_lock(&display->draw_callbacks_mutex);
|
||||
|
||||
|
|
|
@ -204,9 +204,9 @@ extern void obs_view_free(struct obs_view *view);
|
|||
/* displays */
|
||||
|
||||
struct obs_display {
|
||||
bool size_changed;
|
||||
bool enabled;
|
||||
uint32_t cx, cy;
|
||||
uint32_t next_cx, next_cy;
|
||||
uint32_t background_color;
|
||||
gs_swapchain_t *swap;
|
||||
pthread_mutex_t draw_callbacks_mutex;
|
||||
|
|
Loading…
Reference in New Issue