[librsvg: 4/5] drawing_ctx: use the new Dpi struct



commit 920584f94cf4807ad4501d3be8a1dc09289a4d04
Author: Paolo Borelli <pborelli gnome org>
Date:   Fri Dec 7 00:50:21 2018 +0100

    drawing_ctx: use the new Dpi struct

 librsvg/rsvg-handle.c             |  4 ----
 rsvg_internals/src/drawing_ctx.rs | 23 +++++++++--------------
 rsvg_internals/src/handle.rs      |  6 ++++++
 3 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/librsvg/rsvg-handle.c b/librsvg/rsvg-handle.c
index 4b582a60..5b077785 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -156,8 +156,6 @@ extern RsvgDrawingCtx *rsvg_drawing_ctx_new (RsvgHandle *handle,
                                              guint height,
                                              double vb_width,
                                              double vb_height,
-                                             double dpi_x,
-                                             double dpi_y,
                                              gboolean testing);
 extern void rsvg_drawing_ctx_free (RsvgDrawingCtx *draw_ctx);
 extern void rsvg_drawing_ctx_add_node_and_ancestors_to_stack (RsvgDrawingCtx *draw_ctx,
@@ -1031,8 +1029,6 @@ rsvg_handle_create_drawing_ctx(RsvgHandle *handle,
                                  cr,
                                  dimensions->width, dimensions->height,
                                  dimensions->em, dimensions->ex,
-                                 rsvg_handle_rust_get_dpi_x (handle->priv->rust_handle),
-                                 rsvg_handle_rust_get_dpi_y (handle->priv->rust_handle),
                                  handle->priv->is_testing);
 }
 
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 0934a350..c1885a37 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -14,6 +14,7 @@ use bbox::BoundingBox;
 use clip_path::{ClipPathUnits, NodeClipPath};
 use coord_units::CoordUnits;
 use defs::Fragment;
+use dpi::Dpi;
 use error::RenderingError;
 use filters;
 use float_eq_cairo::ApproxEqCairo;
@@ -99,8 +100,7 @@ pub struct DrawingCtx {
     handle: *const RsvgHandle,
 
     rect: cairo::Rectangle,
-    dpi_x: f64,
-    dpi_y: f64,
+    dpi: Dpi,
 
     /// This is a mitigation for the security-related bug
     /// https://gitlab.gnome.org/GNOME/librsvg/issues/323 - imagine
@@ -140,8 +140,7 @@ impl DrawingCtx {
         height: f64,
         vb_width: f64,
         vb_height: f64,
-        dpi_x: f64,
-        dpi_y: f64,
+        dpi: Dpi,
         is_testing: bool,
     ) -> DrawingCtx {
         let mut affine = cr.get_matrix();
@@ -171,8 +170,7 @@ impl DrawingCtx {
         DrawingCtx {
             handle,
             rect,
-            dpi_x,
-            dpi_y,
+            dpi,
             num_elements_rendered_through_use: 0,
             cr_stack: Vec::new(),
             cr: cr.clone(),
@@ -235,8 +233,8 @@ impl DrawingCtx {
         let stack_top = &view_box_stack[last];
 
         ViewParams {
-            dpi_x: self.dpi_x,
-            dpi_y: self.dpi_y,
+            dpi_x: self.dpi.x(),
+            dpi_y: self.dpi.y(),
             view_box_width: stack_top.0.width,
             view_box_height: stack_top.0.height,
             view_box_stack: None,
@@ -256,8 +254,8 @@ impl DrawingCtx {
             .push(ViewBox::new(0.0, 0.0, width, height));
 
         ViewParams {
-            dpi_x: self.dpi_x,
-            dpi_y: self.dpi_y,
+            dpi_x: self.dpi.x(),
+            dpi_y: self.dpi.y(),
             view_box_width: width,
             view_box_height: height,
             view_box_stack: Some(Rc::downgrade(&self.view_box_stack)),
@@ -1190,8 +1188,6 @@ pub extern "C" fn rsvg_drawing_ctx_new(
     height: u32,
     vb_width: libc::c_double,
     vb_height: libc::c_double,
-    dpi_x: libc::c_double,
-    dpi_y: libc::c_double,
     is_testing: glib_sys::gboolean,
 ) -> *mut DrawingCtx {
     Box::into_raw(Box::new(DrawingCtx::new(
@@ -1201,8 +1197,7 @@ pub extern "C" fn rsvg_drawing_ctx_new(
         f64::from(height),
         vb_width,
         vb_height,
-        dpi_x,
-        dpi_y,
+        handle::get_dpi(handle).clone(),
         from_glib(is_testing),
     )))
 }
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 9afcc0fd..24eeac4d 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -118,6 +118,12 @@ pub fn get_unlimited_size(handle: *const RsvgHandle) -> bool {
     unsafe { (rsvg_handle_get_flags(handle) & RSVG_HANDLE_FLAG_UNLIMITED) != 0 }
 }
 
+pub fn get_dpi<'a>(handle: *const RsvgHandle) -> &'a Dpi {
+    let rhandle = get_rust_handle(handle);
+
+    &rhandle.dpi
+}
+
 pub fn get_base_url<'a>(handle: *const RsvgHandle) -> Ref<'a, Option<Url>> {
     let rhandle = get_rust_handle(handle);
 


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