[librsvg: 2/3] (#408): Don't clip feImage to integer bounds



commit 2fa0d4099462b384ed14e58425f95781f24d360c
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Dec 9 19:52:45 2019 -0600

    (#408): Don't clip feImage to integer bounds
    
    feImage doesn't do pixel processing, so it is able to use exact
    floating-point bounds.
    
    Thanks to Paolo Borelli for unlocking the solution to this in !262.
    
    Fixes https://gitlab.gnome.org/GNOME/librsvg/issues/408

 rsvg_internals/src/filters/bounds.rs                |  11 +++++++----
 rsvg_internals/src/filters/image.rs                 |   9 ++++-----
 .../filter-image-from-reference-page-ref.png        | Bin 16648 -> 14681 bytes
 .../reftests/svg1.1/filters-image-03-f-ref.png      | Bin 10815 -> 11561 bytes
 .../reftests/svg1.1/filters-image-04-f-ref.png      | Bin 12582 -> 11319 bytes
 5 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/rsvg_internals/src/filters/bounds.rs b/rsvg_internals/src/filters/bounds.rs
index f757e99d..f4542837 100644
--- a/rsvg_internals/src/filters/bounds.rs
+++ b/rsvg_internals/src/filters/bounds.rs
@@ -73,9 +73,8 @@ impl<'a> BoundsBuilder<'a> {
         self
     }
 
-    /// Returns the final pixel bounds.
-    #[inline]
-    pub fn into_irect(self, draw_ctx: &mut DrawingCtx) -> IRect {
+    /// Returns the final exact bounds.
+    pub fn into_rect(self, draw_ctx: &mut DrawingCtx) -> cairo::Rectangle {
         let mut bbox = self.apply_properties(draw_ctx);
 
         let effects_region = self.ctx.effects_region();
@@ -84,10 +83,14 @@ impl<'a> BoundsBuilder<'a> {
         bbox.rect.unwrap().into()
     }
 
+    /// Returns the final pixel bounds.
+    pub fn into_irect(self, draw_ctx: &mut DrawingCtx) -> IRect {
+        self.into_rect(draw_ctx).into()
+    }
+
     /// Returns the final pixel bounds without clipping to the filter effects region.
     ///
     /// Used by feImage.
-    #[inline]
     pub fn into_rect_without_clipping(self, draw_ctx: &mut DrawingCtx) -> cairo::Rectangle {
         self.apply_properties(draw_ctx).rect.unwrap().into()
     }
diff --git a/rsvg_internals/src/filters/image.rs b/rsvg_internals/src/filters/image.rs
index 42aef892..22c0e22e 100644
--- a/rsvg_internals/src/filters/image.rs
+++ b/rsvg_internals/src/filters/image.rs
@@ -9,7 +9,6 @@ use crate::float_eq_cairo::ApproxEqCairo;
 use crate::node::{CascadedValues, NodeResult, NodeTrait, RsvgNode};
 use crate::parsers::ParseValue;
 use crate::property_bag::PropertyBag;
-use crate::rect::IRect;
 use crate::surface_utils::shared_surface::{SharedImageSurface, SurfaceType};
 use crate::viewbox::ViewBox;
 
@@ -41,7 +40,7 @@ impl FeImage {
         &self,
         ctx: &FilterContext,
         draw_ctx: &mut DrawingCtx,
-        bounds: IRect,
+        bounds: cairo::Rectangle,
         fragment: &Fragment,
     ) -> Result<ImageSurface, FilterError> {
         let acquired_drawable = draw_ctx
@@ -100,7 +99,7 @@ impl FeImage {
         &self,
         ctx: &FilterContext,
         draw_ctx: &DrawingCtx,
-        bounds: &IRect,
+        bounds: &cairo::Rectangle,
         unclipped_bounds: &cairo::Rectangle,
         href: &Href,
     ) -> Result<ImageSurface, FilterError> {
@@ -192,7 +191,7 @@ impl FilterEffect for FeImage {
         draw_ctx: &mut DrawingCtx,
     ) -> Result<FilterResult, FilterError> {
         let bounds_builder = self.base.get_bounds(ctx);
-        let bounds = bounds_builder.into_irect(draw_ctx);
+        let bounds = bounds_builder.into_rect(draw_ctx);
 
         if let Some(href) = self.href.as_ref() {
             let output_surface = match href {
@@ -207,7 +206,7 @@ impl FilterEffect for FeImage {
                 name: self.base.result.clone(),
                 output: FilterOutput {
                     surface: SharedImageSurface::new(output_surface, SurfaceType::SRgb)?,
-                    bounds,
+                    bounds: bounds.into(),
                 },
             })
         } else {
diff --git a/tests/fixtures/reftests/filter-image-from-reference-page-ref.png 
b/tests/fixtures/reftests/filter-image-from-reference-page-ref.png
index e6e88263..f8cb24a6 100644
Binary files a/tests/fixtures/reftests/filter-image-from-reference-page-ref.png and 
b/tests/fixtures/reftests/filter-image-from-reference-page-ref.png differ
diff --git a/tests/fixtures/reftests/svg1.1/filters-image-03-f-ref.png 
b/tests/fixtures/reftests/svg1.1/filters-image-03-f-ref.png
index c13d6e54..06198716 100644
Binary files a/tests/fixtures/reftests/svg1.1/filters-image-03-f-ref.png and 
b/tests/fixtures/reftests/svg1.1/filters-image-03-f-ref.png differ
diff --git a/tests/fixtures/reftests/svg1.1/filters-image-04-f-ref.png 
b/tests/fixtures/reftests/svg1.1/filters-image-04-f-ref.png
index 670003f7..fbc5ada1 100644
Binary files a/tests/fixtures/reftests/svg1.1/filters-image-04-f-ref.png and 
b/tests/fixtures/reftests/svg1.1/filters-image-04-f-ref.png differ


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