[librsvg/librsvg-2.44] Make sure to convert to sRGB in filter get_input



commit 6f41c15dcea884fb25de7c8189dff83c83adc10d
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Fri Dec 14 10:22:43 2018 +0300

    Make sure to convert to sRGB in filter get_input

 rsvg_internals/src/filters/context.rs | 46 +++++++++++++++++------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/rsvg_internals/src/filters/context.rs b/rsvg_internals/src/filters/context.rs
index 62d07930..3e8f7412 100644
--- a/rsvg_internals/src/filters/context.rs
+++ b/rsvg_internals/src/filters/context.rs
@@ -551,30 +551,30 @@ impl FilterContext {
     ) -> Result<FilterInput, FilterError> {
         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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]