[librsvg] DrawingCtx::new() - take full rectangles for viewport and viewbox



commit e193bf2a4361aab52b0fa6759f4f9c0528d434c6
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Feb 19 16:56:54 2019 -0600

    DrawingCtx::new() - take full rectangles for viewport and viewbox
    
    This constructor doesn't use all the fields in those rectangles yet,
    but we'll do it bit by bit.

 rsvg_internals/src/drawing_ctx.rs | 19 +++++--------------
 rsvg_internals/src/handle.rs      | 12 ++++++++----
 2 files changed, 13 insertions(+), 18 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 59899667..8f966b70 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -114,26 +114,17 @@ impl DrawingCtx {
     pub fn new(
         svg: Rc<Svg>,
         cr: &cairo::Context,
-        width: f64,
-        height: f64,
-        vb_width: f64,
-        vb_height: f64,
+        viewport: &cairo::Rectangle,
+        vbox: &ViewBox,
         dpi: Dpi,
         testing: bool,
     ) -> DrawingCtx {
         let mut affine = cr.get_matrix();
-        let rect = cairo::Rectangle {
-            x: 0.0,
-            y: 0.0,
-            width,
-            height,
-        }
-        .transform(&affine)
-        .outer();
+        let rect = viewport.transform(&affine).outer();
 
         // scale according to size set by size_func callback
         let mut scale = cairo::Matrix::identity();
-        scale.scale(width / vb_width, height / vb_height);
+        scale.scale(viewport.width / vbox.width, viewport.height / vbox.height);
         affine = cairo::Matrix::multiply(&affine, &scale);
 
         // adjust transform so that the corner of the
@@ -143,7 +134,7 @@ impl DrawingCtx {
         cr.set_matrix(affine);
 
         let mut view_box_stack = Vec::new();
-        view_box_stack.push(ViewBox::new(0.0, 0.0, vb_width, vb_height));
+        view_box_stack.push(*vbox);
 
         DrawingCtx {
             svg: svg.clone(),
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 1a5fd110..853e1bb4 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -31,6 +31,7 @@ use structure::{IntrinsicDimensions, NodeSvg};
 use surface_utils::{shared_surface::SharedImageSurface, shared_surface::SurfaceType};
 use svg::Svg;
 use util::rsvg_g_warning;
+use viewbox::ViewBox;
 use xml::XmlState;
 use xml2_load::xml_state_load_from_possibly_compressed_stream;
 
@@ -299,10 +300,13 @@ impl Handle {
         let mut draw_ctx = DrawingCtx::new(
             self.svg.borrow().as_ref().unwrap().clone(),
             cr,
-            f64::from(dimensions.width),
-            f64::from(dimensions.height),
-            dimensions.em,
-            dimensions.ex,
+            &cairo::Rectangle {
+                x: 0.0,
+                y: 0.0,
+                width: f64::from(dimensions.width),
+                height: f64::from(dimensions.height),
+            },
+            &ViewBox::new(0.0, 0.0, dimensions.em, dimensions.ex),
             self.dpi.get(),
             self.is_testing.get(),
         );


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