[librsvg/rustify-rsvg-convert: 64/78] rsvg-convert: Extract function to compute the natural size of the requested input




commit 844de20489df31e1d299c4319fd7046e801148c9
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Jan 25 15:46:13 2021 -0600

    rsvg-convert: Extract function to compute the natural size of the requested input

 src/bin/rsvg-convert.rs | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index db7f2c7a..6ce42c32 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -397,8 +397,8 @@ impl Converter {
         };
     }
 
-    fn create_surface(&self, renderer: &CairoRenderer, input: &Input) -> Surface {
-        let (natural_width, natural_height) = renderer
+    fn natural_size(&self, renderer: &CairoRenderer, input: &Input) -> (f64, f64) {
+        renderer
             .legacy_layer_size(self.export_id.as_deref())
             .unwrap_or_else(|e| match e {
                 RenderingError::IdNotFound => exit!(
@@ -407,7 +407,11 @@ impl Converter {
                     self.export_id.as_deref().unwrap()
                 ),
                 _ => exit!("Error rendering SVG {}: {}", input, e),
-            });
+            })
+    }
+
+    fn create_surface(&self, renderer: &CairoRenderer, input: &Input) -> Surface {
+        let (natural_width, natural_height) = self.natural_size(renderer, input);
 
         let strategy = match (self.width, self.height) {
             // when w and h are not specified, scale to the requested zoom (if any)


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