[librsvg] ViewParams: Make the numeric fields public to avoid accessors



commit 5dcd8210288631f898868c1f5688ba83354207cf
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Jan 21 19:08:57 2019 -0600

    ViewParams: Make the numeric fields public to avoid accessors

 rsvg_internals/src/drawing_ctx.rs | 24 ++++--------------------
 rsvg_internals/src/length.rs      |  9 +++------
 2 files changed, 7 insertions(+), 26 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 41521169..4b784386 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -44,10 +44,10 @@ use viewbox::ViewBox;
 /// returned `ViewParams` is dropped; at that point, the `DrawingCtx` will resume using its
 /// previous viewport.
 pub struct ViewParams {
-    dpi_x: f64,
-    dpi_y: f64,
-    view_box_width: f64,
-    view_box_height: f64,
+    pub dpi_x: f64,
+    pub dpi_y: f64,
+    pub view_box_width: f64,
+    pub view_box_height: f64,
     view_box_stack: Option<Weak<RefCell<Vec<ViewBox>>>>,
 }
 
@@ -62,22 +62,6 @@ impl ViewParams {
             view_box_stack: None,
         }
     }
-
-    pub fn dpi_x(&self) -> f64 {
-        self.dpi_x
-    }
-
-    pub fn dpi_y(&self) -> f64 {
-        self.dpi_y
-    }
-
-    pub fn view_box_width(&self) -> f64 {
-        self.view_box_width
-    }
-
-    pub fn view_box_height(&self) -> f64 {
-        self.view_box_height
-    }
 }
 
 impl Drop for ViewParams {
diff --git a/rsvg_internals/src/length.rs b/rsvg_internals/src/length.rs
index a494d770..5e1412b3 100644
--- a/rsvg_internals/src/length.rs
+++ b/rsvg_internals/src/length.rs
@@ -182,7 +182,7 @@ impl Length {
                 self.length
                     * self
                         .dir
-                        .scaling_factor(|| params.view_box_width(), || params.view_box_height())
+                        .scaling_factor(|| params.view_box_width, || params.view_box_height)
             }
 
             LengthUnit::FontEm => self.length * font_size_from_values(values, params),
@@ -190,10 +190,7 @@ impl Length {
             LengthUnit::FontEx => self.length * font_size_from_values(values, params) / 2.0,
 
             LengthUnit::Inch => {
-                self.length
-                    * self
-                        .dir
-                        .scaling_factor(|| params.dpi_x(), || params.dpi_y())
+                self.length * self.dir.scaling_factor(|| params.dpi_x, || params.dpi_y)
             }
         }
     }
@@ -316,7 +313,7 @@ fn font_size_from_values(values: &ComputedValues, params: &ViewParams) -> f64 {
     match v.unit {
         LengthUnit::Default => v.length,
 
-        LengthUnit::Inch => v.length * v.dir.scaling_factor(|| params.dpi_x(), || params.dpi_y()),
+        LengthUnit::Inch => v.length * v.dir.scaling_factor(|| params.dpi_x, || params.dpi_y),
 
         LengthUnit::Percent => unreachable!("ComputedValues can't have a relative font size"),
 


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