[librsvg/wip/dimensions-api] draw_in_viewport(): Don't take an affine argument; use the DrawingCtx's current affine



commit 2db60931fac309c03d88081b38b85abda603721b
Author: Federico Mena Quintero <federico gnome org>
Date:   Sat Feb 9 11:26:57 2019 -0600

    draw_in_viewport(): Don't take an affine argument; use the DrawingCtx's current affine
    
    That function was getting passed precisely the DrawingCtx's current
    affine anyway.

 rsvg_internals/src/structure.rs |  2 --
 rsvg_internals/src/viewport.rs  | 17 +++++++----------
 2 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index 5df520fe..149bd6fc 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -243,7 +243,6 @@ impl NodeTrait for NodeSvg {
             self.preserve_aspect_ratio.get(),
             node,
             values,
-            draw_ctx.get_cairo_context().get_matrix(),
             draw_ctx,
             clipping,
             &mut |dc| {
@@ -397,7 +396,6 @@ impl NodeTrait for NodeUse {
                     symbol.preserve_aspect_ratio.get(),
                     node,
                     values,
-                    draw_ctx.get_cairo_context().get_matrix(),
                     draw_ctx,
                     clipping,
                     &mut |dc| {
diff --git a/rsvg_internals/src/viewport.rs b/rsvg_internals/src/viewport.rs
index edcdb8ac..928ab449 100644
--- a/rsvg_internals/src/viewport.rs
+++ b/rsvg_internals/src/viewport.rs
@@ -1,5 +1,4 @@
-use cairo;
-use cairo::{MatrixTrait, Rectangle};
+use cairo::Rectangle;
 
 use aspect_ratio::AspectRatio;
 use drawing_ctx::DrawingCtx;
@@ -22,7 +21,6 @@ pub fn draw_in_viewport(
     preserve_aspect_ratio: AspectRatio,
     node: &RsvgNode,
     values: &ComputedValues,
-    mut affine: cairo::Matrix,
     draw_ctx: &mut DrawingCtx,
     clipping: bool,
     draw_fn: &mut FnMut(&mut DrawingCtx) -> Result<(), RenderingError>,
@@ -38,6 +36,8 @@ pub fn draw_in_viewport(
     }
 
     draw_ctx.with_discrete_layer(node, values, clipping, &mut |dc| {
+        let cr = dc.get_cairo_context();
+
         if let Some(ref clip) = clip_mode {
             if *clip == ClipMode::ClipToViewport {
                 dc.clip(viewport.x, viewport.y, viewport.width, viewport.height);
@@ -58,11 +58,9 @@ pub fn draw_in_viewport(
 
             let (x, y, w, h) = preserve_aspect_ratio.compute(&vbox, viewport);
 
-            affine.translate(x, y);
-            affine.scale(w / vbox.width, h / vbox.height);
-            affine.translate(-vbox.x, -vbox.y);
-
-            dc.get_cairo_context().set_matrix(affine);
+            cr.translate(x, y);
+            cr.scale(w / vbox.width, h / vbox.height);
+            cr.translate(-vbox.x, -vbox.y);
 
             if let Some(ref clip) = clip_mode {
                 if *clip == ClipMode::ClipToVbox {
@@ -73,8 +71,7 @@ pub fn draw_in_viewport(
             params
         } else {
             let params = dc.push_view_box(viewport.width, viewport.height);
-            affine.translate(viewport.x, viewport.y);
-            dc.get_cairo_context().set_matrix(affine);
+            cr.translate(viewport.x, viewport.y);
             params
         };
 


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