libobs: Add ability to disable displays

Sometimes it can be useful to turn off rendering to the display in order
to reduce the number of draw calls and present calls.
master
jp9000 2015-04-01 16:22:28 -07:00
parent 9cc56f2516
commit ebfe477caf
3 changed files with 17 additions and 1 deletions

View File

@ -41,6 +41,7 @@ bool obs_display_init(struct obs_display *display,
return false;
}
display->enabled = true;
return true;
}
@ -170,7 +171,7 @@ static inline void render_display_end()
void render_display(struct obs_display *display)
{
if (!display) return;
if (!display || !display->enabled) return;
render_display_begin(display);
@ -187,3 +188,14 @@ void render_display(struct obs_display *display)
render_display_end();
}
void obs_display_set_enabled(obs_display_t *display, bool enable)
{
if (display)
display->enabled = enable;
}
bool obs_display_enabled(obs_display_t *display)
{
return display ? display->enabled : false;
}

View File

@ -112,6 +112,7 @@ extern void obs_view_free(struct obs_view *view);
struct obs_display {
bool size_changed;
bool enabled;
uint32_t cx, cy;
gs_swapchain_t *swap;
pthread_mutex_t draw_callbacks_mutex;

View File

@ -619,6 +619,9 @@ EXPORT void obs_display_remove_draw_callback(obs_display_t *display,
void (*draw)(void *param, uint32_t cx, uint32_t cy),
void *param);
EXPORT void obs_display_set_enabled(obs_display_t *display, bool enable);
EXPORT bool obs_display_enabled(obs_display_t *display);
/* ------------------------------------------------------------------------- */
/* Sources */