diff --git a/rsvg_internals/src/filters/context.rs b/rsvg_internals/src/filters/context.rs index 1c23064346faf827e84f720fbbb1490ef3807325..ebda2a3ea89ad2caf9d6ca491cd3778a15a1dbc1 100644 --- a/rsvg_internals/src/filters/context.rs +++ b/rsvg_internals/src/filters/context.rs @@ -551,30 +551,30 @@ impl FilterContext { ) -> Result { let raw = self.get_input_raw(draw_ctx, in_)?; - // Linearize the returned surface if needed. - if self.processing_linear_rgb { - let (surface, bounds) = match raw { - FilterInput::StandardInput(ref surface) => { - (surface, self.effects_region().rect.unwrap().into()) - } - FilterInput::PrimitiveOutput(FilterOutput { - ref surface, - ref bounds, - }) => (surface, *bounds), - }; - - surface - .to_linear_rgb(bounds) - .map_err(FilterError::CairoError) - .map(|surface| match raw { - FilterInput::StandardInput(_) => FilterInput::StandardInput(surface), - FilterInput::PrimitiveOutput(ref output) => { - FilterInput::PrimitiveOutput(FilterOutput { surface, ..*output }) - } - }) + // Convert the input surface to the desired format. + let (surface, bounds) = match raw { + FilterInput::StandardInput(ref surface) => { + (surface, self.effects_region().rect.unwrap().into()) + } + FilterInput::PrimitiveOutput(FilterOutput { + ref surface, + ref bounds, + }) => (surface, *bounds), + }; + + let surface = if self.processing_linear_rgb { + surface.to_linear_rgb(bounds) } else { - Ok(raw) - } + surface.to_srgb(bounds) + }; + surface + .map_err(FilterError::CairoError) + .map(|surface| match raw { + FilterInput::StandardInput(_) => FilterInput::StandardInput(surface), + FilterInput::PrimitiveOutput(ref output) => { + FilterInput::PrimitiveOutput(FilterOutput { surface, ..*output }) + } + }) } /// Calls the given closure with linear RGB processing enabled. diff --git a/tests/fixtures/render-crash/feMerge-color-interpolation-srgb.svg b/tests/fixtures/render-crash/feMerge-color-interpolation-srgb.svg new file mode 100644 index 0000000000000000000000000000000000000000..c4344281164280a7c3790121e59cde9635a59cae --- /dev/null +++ b/tests/fixtures/render-crash/feMerge-color-interpolation-srgb.svg @@ -0,0 +1,47 @@ + + + color-interpolation-filters=sRGB + + + + + + + + + + + + + + + + + + + +