libobs: Add obs_source_skip_video_filter function

This allows a filter to skip its step and move on to the next target in
the chain without affecting performance.
This commit is contained in:
jp9000 2015-02-26 20:15:10 -08:00
parent f4af2fcadc
commit c2775eaa3d
2 changed files with 29 additions and 0 deletions

View file

@ -2065,6 +2065,32 @@ void obs_source_process_filter(obs_source_t *filter, gs_effect_t *effect,
effect, width, height, use_matrix);
}
void obs_source_skip_video_filter(obs_source_t *filter)
{
obs_source_t *target, *parent;
bool custom_draw, async;
uint32_t parent_flags;
bool use_matrix;
if (!filter) return;
target = obs_filter_get_target(filter);
parent = obs_filter_get_parent(filter);
parent_flags = parent->info.output_flags;
custom_draw = (parent_flags & OBS_SOURCE_CUSTOM_DRAW) != 0;
async = (parent_flags & OBS_SOURCE_ASYNC) != 0;
use_matrix = !!(parent_flags & OBS_SOURCE_COLOR_MATRIX);
if (target == parent && !custom_draw && !async)
obs_source_default_render(target, use_matrix);
else if (target->info.video_render)
obs_source_main_render(target);
else if (target->filter_target)
obs_source_video_render(target->filter_target);
else
obs_source_render_async_video(target);
}
signal_handler_t *obs_source_get_signal_handler(const obs_source_t *source)
{
return source ? source->context.signals : NULL;

View file

@ -882,6 +882,9 @@ EXPORT void obs_source_process_filter(obs_source_t *filter, gs_effect_t *effect,
uint32_t width, uint32_t height, enum gs_color_format format,
enum obs_allow_direct_render allow_direct);
/** Skips the filter if the filter is invalid and cannot be rendered */
EXPORT void obs_source_skip_video_filter(obs_source_t *filter);
/**
* Adds a child source. Must be called by parent sources on child sources
* when the child is added. This ensures that the source is properly activated