diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-11-12 16:58:25 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-11-12 16:58:25 -0800 |
commit | e78790651b5cd061bce1214790748ff51d3e62fe (patch) | |
tree | fddf3d6b10cd31d62028d4c7899011ad6d730cbe /src | |
parent | d5953892db5729fec6ffd5d8a42456c514782de4 (diff) |
modules/compose: more robust texture preservation
The existing code only really cared about preserving the incoming
texture on behalf of the caller when the compose code itself was
doing something with the texture.
But there's scenarios where the underlying module being rendered
(or its descendants) might play with the texture, and in such a
situation when the outer compose wasn't involving a texture it'd
let the descandants installed texture leak out to the callers
making the texture apply more than one'd expect.
Arguably none of the modules should be missing restoration of the
incoming texture after installing+rendering with their own. But
with this change in place, compose will clean up after nested
modules leaking their texture up.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/compose/compose.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index 7b5e2f4..613c864 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -129,6 +129,7 @@ static void compose_render_fragment(til_module_context_t *context, unsigned tick { compose_context_t *ctxt = (compose_context_t *)context; til_fb_fragment_t *fragment = *fragment_ptr, *texture = &ctxt->texture_fb; + til_fb_fragment_t *old_texture = fragment->texture; if (ctxt->texture.module) { if (!ctxt->texture_fb.buf || @@ -152,17 +153,17 @@ static void compose_render_fragment(til_module_context_t *context, unsigned tick til_module_render(ctxt->layers[0].module_ctxt, ticks, &fragment); for (size_t i = 1; i < ctxt->n_layers; i++) { - til_fb_fragment_t *old_texture = fragment->texture; - - fragment->texture = texture; + fragment->texture = texture; /* keep forcing our texture, in case something below us installed their own. */ til_module_render(ctxt->layers[i].module_ctxt, ticks, &fragment); - fragment->texture = old_texture; } } else { - for (size_t i = 0; i < ctxt->n_layers; i++) + for (size_t i = 0; i < ctxt->n_layers; i++) { + fragment->texture = NULL; /* keep forcing no texture, in case something below us installed their own. TODO: more formally define texture semantics as it pertains to module nesting */ til_module_render(ctxt->layers[i].module_ctxt, ticks, &fragment); + } } + fragment->texture = old_texture; *fragment_ptr = fragment; } |