[librsvg/librsvg-2.46] filters: use rect conversion to shorten code



commit dab00842ccb7bf0699c97e0037d0225c6eb8f97f
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Oct 13 12:24:36 2019 +0200

    filters: use rect conversion to shorten code

 rsvg_internals/src/filters/blend.rs     | 8 ++------
 rsvg_internals/src/filters/composite.rs | 8 ++------
 rsvg_internals/src/filters/flood.rs     | 8 ++------
 rsvg_internals/src/filters/merge.rs     | 8 ++------
 rsvg_internals/src/filters/offset.rs    | 8 ++------
 rsvg_internals/src/filters/tile.rs      | 8 ++------
 6 files changed, 12 insertions(+), 36 deletions(-)
---
diff --git a/rsvg_internals/src/filters/blend.rs b/rsvg_internals/src/filters/blend.rs
index 65011100..34cbe047 100755
--- a/rsvg_internals/src/filters/blend.rs
+++ b/rsvg_internals/src/filters/blend.rs
@@ -108,12 +108,8 @@ impl Filter for Blend {
         let output_surface = input_2.surface().copy_surface(bounds)?;
         {
             let cr = cairo::Context::new(&output_surface);
-            cr.rectangle(
-                bounds.x0 as f64,
-                bounds.y0 as f64,
-                (bounds.x1 - bounds.x0) as f64,
-                (bounds.y1 - bounds.y0) as f64,
-            );
+            let r = cairo::Rectangle::from(bounds);
+            cr.rectangle(r.x, r.y, r.width, r.height);
             cr.clip();
 
             input.surface().set_as_source_surface(&cr, 0f64, 0f64);
diff --git a/rsvg_internals/src/filters/composite.rs b/rsvg_internals/src/filters/composite.rs
index b42701ac..2786899f 100644
--- a/rsvg_internals/src/filters/composite.rs
+++ b/rsvg_internals/src/filters/composite.rs
@@ -185,12 +185,8 @@ impl Filter for Composite {
             let output_surface = input_2.surface().copy_surface(bounds)?;
 
             let cr = cairo::Context::new(&output_surface);
-            cr.rectangle(
-                bounds.x0 as f64,
-                bounds.y0 as f64,
-                (bounds.x1 - bounds.x0) as f64,
-                (bounds.y1 - bounds.y0) as f64,
-            );
+            let r = cairo::Rectangle::from(bounds);
+            cr.rectangle(r.x, r.y, r.width, r.height);
             cr.clip();
 
             input.surface().set_as_source_surface(&cr, 0f64, 0f64);
diff --git a/rsvg_internals/src/filters/flood.rs b/rsvg_internals/src/filters/flood.rs
index 1bae1894..e99f3f1e 100644
--- a/rsvg_internals/src/filters/flood.rs
+++ b/rsvg_internals/src/filters/flood.rs
@@ -59,12 +59,8 @@ impl Filter for Flood {
 
         if opacity > 0f64 {
             let cr = cairo::Context::new(&output_surface);
-            cr.rectangle(
-                bounds.x0 as f64,
-                bounds.y0 as f64,
-                (bounds.x1 - bounds.x0) as f64,
-                (bounds.y1 - bounds.y0) as f64,
-            );
+            let r = cairo::Rectangle::from(bounds);
+            cr.rectangle(r.x, r.y, r.width, r.height);
             cr.clip();
 
             cr.set_source_rgba(
diff --git a/rsvg_internals/src/filters/merge.rs b/rsvg_internals/src/filters/merge.rs
index bbb5e630..202068a3 100644
--- a/rsvg_internals/src/filters/merge.rs
+++ b/rsvg_internals/src/filters/merge.rs
@@ -91,12 +91,8 @@ impl MergeNode {
 
         {
             let cr = cairo::Context::new(&output_surface);
-            cr.rectangle(
-                bounds.x0 as f64,
-                bounds.y0 as f64,
-                (bounds.x1 - bounds.x0) as f64,
-                (bounds.y1 - bounds.y0) as f64,
-            );
+            let r = cairo::Rectangle::from(bounds);
+            cr.rectangle(r.x, r.y, r.width, r.height);
             cr.clip();
 
             input.surface().set_as_source_surface(&cr, 0f64, 0f64);
diff --git a/rsvg_internals/src/filters/offset.rs b/rsvg_internals/src/filters/offset.rs
index 03661c99..765076e9 100644
--- a/rsvg_internals/src/filters/offset.rs
+++ b/rsvg_internals/src/filters/offset.rs
@@ -83,12 +83,8 @@ impl Filter for Offset {
 
         {
             let cr = cairo::Context::new(&output_surface);
-            cr.rectangle(
-                output_bounds.x0 as f64,
-                output_bounds.y0 as f64,
-                (output_bounds.x1 - output_bounds.x0) as f64,
-                (output_bounds.y1 - output_bounds.y0) as f64,
-            );
+            let r = cairo::Rectangle::from(output_bounds);
+            cr.rectangle(r.x, r.y, r.width, r.height);
             cr.clip();
 
             input.surface().set_as_source_surface(&cr, ox, oy);
diff --git a/rsvg_internals/src/filters/tile.rs b/rsvg_internals/src/filters/tile.rs
index e4800d97..2baa3390 100644
--- a/rsvg_internals/src/filters/tile.rs
+++ b/rsvg_internals/src/filters/tile.rs
@@ -81,12 +81,8 @@ impl Filter for Tile {
 
                 {
                     let cr = cairo::Context::new(&output_surface);
-                    cr.rectangle(
-                        bounds.x0 as f64,
-                        bounds.y0 as f64,
-                        (bounds.x1 - bounds.x0) as f64,
-                        (bounds.y1 - bounds.y0) as f64,
-                    );
+                    let r = cairo::Rectangle::from(bounds);
+                    cr.rectangle(r.x, r.y, r.width, r.height);
                     cr.clip();
 
                     cr.set_source(&ptn);


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