Fix #147274: Compositor modifier strip mask affects other strips

Using a strip mask in a compositor strip modifier causes other strips to
change in color. This is because the code converted the mask image
buffer in place, which affected its other uses. To fix this, convert the
mask out of the place.

Pull Request: https://projects.blender.org/blender/blender/pulls/147446
This commit is contained in:
Omar Emara
2025-10-06 15:24:48 +02:00
committed by Omar Emara
parent 488efb8ca9
commit 93854e97dc

View File

@@ -132,6 +132,12 @@ static void compositor_modifier_init_data(StripModifierData *strip_modifier_data
modifier_data->node_group = nullptr;
}
static bool is_linear_float_buffer(ImBuf *image_buffer)
{
return image_buffer->float_buffer.data &&
IMB_colormanagement_space_is_scene_linear(image_buffer->float_buffer.colorspace);
}
static bool ensure_linear_float_buffer(ImBuf *ibuf)
{
if (!ibuf) {
@@ -139,9 +145,7 @@ static bool ensure_linear_float_buffer(ImBuf *ibuf)
}
/* Already have scene linear float pixels, nothing to do. */
if (ibuf->float_buffer.data &&
IMB_colormanagement_space_is_scene_linear(ibuf->float_buffer.colorspace))
{
if (is_linear_float_buffer(ibuf)) {
return true;
}
@@ -176,14 +180,23 @@ static void compositor_modifier_apply(const RenderData *render_data,
return;
}
ensure_linear_float_buffer(mask);
ImBuf *linear_mask = mask;
if (mask && !is_linear_float_buffer(mask)) {
linear_mask = IMB_dupImBuf(mask);
ensure_linear_float_buffer(linear_mask);
}
const bool was_float_linear = ensure_linear_float_buffer(image_buffer);
const bool was_byte = image_buffer->float_buffer.data == nullptr;
CompositorContext context(*render_data, modifier_data, image_buffer, mask);
CompositorContext context(*render_data, modifier_data, image_buffer, linear_mask);
compositor::Evaluator evaluator(context);
evaluator.evaluate();
if (mask != linear_mask) {
IMB_freeImBuf(linear_mask);
}
if (was_float_linear) {
return;
}