提交 ebfe477c 编写于 作者: J jp9000

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.
上级 9cc56f25
......@@ -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;
}
......@@ -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;
......
......@@ -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 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册