[librsvg: 2/15] c_api: wrap get_geometry_sub here




commit e7119e6bc7f07b56ab8dc741f20e6cac5878e9a5
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Oct 27 09:28:55 2020 -0600

    c_api: wrap get_geometry_sub here
    
    We'll move that logic to c_api.

 librsvg/c_api.rs | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/librsvg/c_api.rs b/librsvg/c_api.rs
index 25555236..708acb70 100644
--- a/librsvg/c_api.rs
+++ b/librsvg/c_api.rs
@@ -32,7 +32,7 @@ use glib::types::instance_of;
 use gobject_sys::{GEnumValue, GFlagsValue};
 
 use rsvg_internals::{
-    rsvg_log, DefsLookupErrorKind, Handle, IntrinsicDimensions, LoadOptions, LoadingError,
+    rsvg_log, DefsLookupErrorKind, Handle, IntrinsicDimensions, LoadOptions, LoadingError, Rect,
     RenderingError, RsvgLength, SharedImageSurface, SurfaceType, UrlResolver, ViewBox,
 };
 
@@ -795,7 +795,6 @@ impl CHandle {
     }
 
     fn get_dimensions_sub(&self, id: Option<&str>) -> Result<RsvgDimensionData, RenderingError> {
-        let handle = self.get_handle_ref()?;
         let inner = self.inner.borrow();
 
         // This function is probably called from the cairo_render functions,
@@ -813,8 +812,8 @@ impl CHandle {
 
         inner.size_callback.start_loop();
 
-        let res = handle
-            .get_geometry_sub(id, inner.dpi.into(), inner.is_testing)
+        let res = self
+            .get_geometry_sub(id)
             .and_then(|(ink_r, _)| {
                 // Keep these in sync with tests/src/reference.rs
                 let width = checked_i32(ink_r.width().round())?;
@@ -839,15 +838,13 @@ impl CHandle {
     }
 
     fn get_position_sub(&self, id: Option<&str>) -> Result<RsvgPositionData, RenderingError> {
-        let handle = self.get_handle_ref()?;
         let inner = self.inner.borrow();
 
         if id.is_none() {
             return Ok(RsvgPositionData { x: 0, y: 0 });
         }
 
-        handle
-            .get_geometry_sub(id, inner.dpi.into(), inner.is_testing)
+        self.get_geometry_sub(id)
             .and_then(|(ink_r, _)| {
                 let width = checked_i32(ink_r.width().round())?;
                 let height = checked_i32(ink_r.height().round())?;
@@ -865,6 +862,13 @@ impl CHandle {
             .map_err(warn_on_invalid_id)
     }
 
+    fn get_geometry_sub(&self, id: Option<&str>) -> Result<(Rect, Rect), RenderingError> {
+        let handle = self.get_handle_ref()?;
+        let inner = self.inner.borrow();
+
+        handle.get_geometry_sub(id, inner.dpi.into(), inner.is_testing)
+    }
+
     fn set_stylesheet(&self, css: &str) -> Result<(), LoadingError> {
         match *self.load_state.borrow_mut() {
             LoadState::ClosedOk { ref mut handle } => handle.set_stylesheet(css),


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