[librsvg] Turn Handle::get_pixbuf_sub() from a method to a standalone function



commit f9edd4e07e03dea279dca7dcc41595d844d1e9af
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Jan 10 19:10:13 2019 -0600

    Turn Handle::get_pixbuf_sub() from a method to a standalone function

 rsvg_internals/src/handle.rs | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index a8eb0459..999c8833 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -538,22 +538,6 @@ impl Handle {
         res
     }
 
-    fn get_pixbuf_sub(&mut self, id: Option<&str>) -> Result<Pixbuf, RenderingError> {
-        let dimensions = self.get_dimensions()?;
-
-        let surface =
-            ImageSurface::create(cairo::Format::ARgb32, dimensions.width, dimensions.height)?;
-
-        {
-            let cr = cairo::Context::new(&surface);
-            self.render_cairo_sub(&cr, id)?;
-        }
-
-        let surface = SharedImageSurface::new(surface, SurfaceType::SRgb)?;
-
-        pixbuf_from_surface(&surface)
-    }
-
     fn construct_new_from_gfile_sync(
         &mut self,
         handle: *mut RsvgHandle,
@@ -1032,6 +1016,21 @@ pub unsafe extern "C" fn rsvg_handle_rust_render_cairo_sub(
     }
 }
 
+fn get_pixbuf_sub(handle: &mut Handle, id: Option<&str>) -> Result<Pixbuf, RenderingError> {
+    let dimensions = handle.get_dimensions()?;
+
+    let surface = ImageSurface::create(cairo::Format::ARgb32, dimensions.width, dimensions.height)?;
+
+    {
+        let cr = cairo::Context::new(&surface);
+        handle.render_cairo_sub(&cr, id)?;
+    }
+
+    let surface = SharedImageSurface::new(surface, SurfaceType::SRgb)?;
+
+    pixbuf_from_surface(&surface)
+}
+
 #[no_mangle]
 pub unsafe extern "C" fn rsvg_handle_rust_get_pixbuf_sub(
     handle: *mut RsvgHandle,
@@ -1044,7 +1043,7 @@ pub unsafe extern "C" fn rsvg_handle_rust_get_pixbuf_sub(
         return ptr::null_mut();
     }
 
-    match rhandle.get_pixbuf_sub(id.as_ref().map(String::as_str)) {
+    match get_pixbuf_sub(rhandle, id.as_ref().map(String::as_str)) {
         Ok(pixbuf) => pixbuf.to_glib_full(),
         Err(_) => ptr::null_mut(),
     }


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