[librsvg: 29/90] NodeClipPath.to_cairo_context() - Simplify the way in which the affine is set



commit 08f9bb3feb411348206fa3fb1d341d65d444ee4b
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Mar 13 17:31:56 2019 -0600

    NodeClipPath.to_cairo_context() - Simplify the way in which the affine is set

 rsvg_internals/src/clip_path.rs | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/rsvg_internals/src/clip_path.rs b/rsvg_internals/src/clip_path.rs
index b704b72d..0e76aaec 100644
--- a/rsvg_internals/src/clip_path.rs
+++ b/rsvg_internals/src/clip_path.rs
@@ -42,7 +42,9 @@ impl NodeClipPath {
         let cr = draw_ctx.get_cairo_context();
         let save_affine = cr.get_matrix();
 
-        let child_matrix = if clip_units == ClipPathUnits(CoordUnits::ObjectBoundingBox) {
+        cr.set_matrix(*affine_before_clip);
+
+        if clip_units == ClipPathUnits(CoordUnits::ObjectBoundingBox) {
             if bbox.rect.is_none() {
                 // The node being clipped is empty / doesn't have a
                 // bounding box, so there's nothing to clip!
@@ -51,13 +53,8 @@ impl NodeClipPath {
 
             let rect = bbox.rect.as_ref().unwrap();
 
-            let bbtransform = cairo::Matrix::new(rect.width, 0.0, 0.0, rect.height, rect.x, rect.y);
-            cairo::Matrix::multiply(&bbtransform, affine_before_clip)
-        } else {
-            *affine_before_clip
-        };
-
-        cr.set_matrix(child_matrix);
+            cr.transform(cairo::Matrix::new(rect.width, 0.0, 0.0, rect.height, rect.x, rect.y))
+        }
 
         // here we don't push a layer because we are clipping
         let res = node.draw_children(&cascaded, draw_ctx, true);


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