libobs: Add obs_display_update_color_space
This commit is contained in:
parent
cd22df09c9
commit
01c0486aad
@ -124,6 +124,18 @@ void obs_display_resize(obs_display_t *display, uint32_t cx, uint32_t cy)
|
||||
pthread_mutex_unlock(&display->draw_info_mutex);
|
||||
}
|
||||
|
||||
void obs_display_update_color_space(obs_display_t *display)
|
||||
{
|
||||
if (!display)
|
||||
return;
|
||||
|
||||
pthread_mutex_lock(&display->draw_info_mutex);
|
||||
|
||||
display->update_color_space = true;
|
||||
|
||||
pthread_mutex_unlock(&display->draw_info_mutex);
|
||||
}
|
||||
|
||||
void obs_display_add_draw_callback(obs_display_t *display,
|
||||
void (*draw)(void *param, uint32_t cx,
|
||||
uint32_t cy),
|
||||
@ -155,7 +167,8 @@ 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)
|
||||
uint32_t cx, uint32_t cy,
|
||||
bool update_color_space)
|
||||
{
|
||||
struct vec4 clear_color;
|
||||
|
||||
@ -165,11 +178,16 @@ static inline void render_display_begin(struct obs_display *display,
|
||||
gs_resize(cx, cy);
|
||||
display->cx = cx;
|
||||
display->cy = cy;
|
||||
} else if (update_color_space) {
|
||||
gs_update_color_space();
|
||||
}
|
||||
|
||||
gs_begin_scene();
|
||||
|
||||
vec4_from_rgba(&clear_color, display->background_color);
|
||||
if (gs_get_color_space() == GS_CS_SRGB)
|
||||
vec4_from_rgba(&clear_color, display->background_color);
|
||||
else
|
||||
vec4_from_rgba_srgb(&clear_color, display->background_color);
|
||||
clear_color.w = 1.0f;
|
||||
|
||||
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH | GS_CLEAR_STENCIL,
|
||||
@ -191,6 +209,7 @@ static inline void render_display_end()
|
||||
void render_display(struct obs_display *display)
|
||||
{
|
||||
uint32_t cx, cy;
|
||||
bool update_color_space;
|
||||
|
||||
if (!display || !display->enabled)
|
||||
return;
|
||||
@ -203,12 +222,15 @@ void render_display(struct obs_display *display)
|
||||
|
||||
cx = display->next_cx;
|
||||
cy = display->next_cy;
|
||||
update_color_space = display->update_color_space;
|
||||
|
||||
display->update_color_space = false;
|
||||
|
||||
pthread_mutex_unlock(&display->draw_info_mutex);
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
render_display_begin(display, cx, cy);
|
||||
render_display_begin(display, cx, cy, update_color_space);
|
||||
|
||||
pthread_mutex_lock(&display->draw_callbacks_mutex);
|
||||
|
||||
|
@ -204,6 +204,7 @@ extern void obs_view_free(struct obs_view *view);
|
||||
/* displays */
|
||||
|
||||
struct obs_display {
|
||||
bool update_color_space;
|
||||
bool enabled;
|
||||
uint32_t cx, cy;
|
||||
uint32_t next_cx, next_cy;
|
||||
|
@ -887,6 +887,9 @@ EXPORT void obs_display_destroy(obs_display_t *display);
|
||||
EXPORT void obs_display_resize(obs_display_t *display, uint32_t cx,
|
||||
uint32_t cy);
|
||||
|
||||
/** Updates the color space of this display */
|
||||
EXPORT void obs_display_update_color_space(obs_display_t *display);
|
||||
|
||||
/**
|
||||
* Adds a draw callback for this display context
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user