From 279ca988cd6681dc95b06c93fcc1c601e9750d38 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 11 May 2021 00:41:34 -0700 Subject: [PATCH] obs-transitions: Free matte texrender when not in use This prevents the texrender object from lingering if the user changes the transition properties. --- plugins/obs-transitions/transition-stinger.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/obs-transitions/transition-stinger.c b/plugins/obs-transitions/transition-stinger.c index bdf1e293b..e17b2a788 100644 --- a/plugins/obs-transitions/transition-stinger.c +++ b/plugins/obs-transitions/transition-stinger.c @@ -86,6 +86,8 @@ static void stinger_update(void *data, obs_data_t *settings) else s->transition_point_ns = (uint64_t)(point * 1000000LL); + bool track_matte_was_enabled = s->track_matte_enabled; + s->track_matte_enabled = obs_data_get_bool(settings, "track_matte_enabled"); s->matte_layout = (int)obs_data_get_int(settings, "track_matte_layout"); @@ -134,6 +136,15 @@ static void stinger_update(void *data, obs_data_t *settings) s->mix_b = mix_b_cross_fade; break; } + + if (s->track_matte_enabled != track_matte_was_enabled) { + gs_texrender_destroy(s->matte_tex); + s->matte_tex = NULL; + + if (s->track_matte_enabled) { + s->matte_tex = gs_texrender_create(GS_RGBA, GS_ZS_NONE); + } + } } static void *stinger_create(obs_data_t *settings, obs_source_t *source) @@ -169,8 +180,6 @@ static void *stinger_create(obs_data_t *settings, obs_source_t *source) s->ep_invert_matte = gs_effect_get_param_by_name(s->matte_effect, "invert_matte"); - s->matte_tex = gs_texrender_create(GS_RGBA, GS_ZS_NONE); - obs_transition_enable_fixed(s->source, true, 0); obs_source_update(source, settings); return s;