[gdk-pixbuf] io: Split out a function for use by animations



commit 38fe0dd043de3503462aea1c425368d31a1e61cc
Author: Benjamin Otte <otte redhat com>
Date:   Wed Jan 30 15:09:08 2013 +0100

    io: Split out a function for use by animations

 gdk-pixbuf/gdk-pixbuf-io.c      |   53 +++++++++++++++++++++++---------------
 gdk-pixbuf/gdk-pixbuf-private.h |    2 +
 2 files changed, 34 insertions(+), 21 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 2dc7cd8..dac21b8 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -1646,29 +1646,9 @@ gdk_pixbuf_new_from_stream (GInputStream  *stream,
         return pixbuf;
 }
 
-/**
- * gdk_pixbuf_new_from_resource:
- * @resource_path: the path of the resource file
- * @error: Return location for an error
- *
- * Creates a new pixbuf by loading an image from an resource.
- *
- * The file format is detected automatically. If %NULL is returned, then
- * @error will be set.
- *
- * Return value: A newly-created pixbuf, or %NULL if any of several error
- * conditions occurred: the file could not be opened, the image format is
- * not supported, there was not enough memory to allocate the image buffer,
- * the stream contained invalid data, or the operation was cancelled.
- *
- * Since: 2.26
- **/
 GdkPixbuf *
-gdk_pixbuf_new_from_resource (const char *resource_path,
-			      GError    **error)
+_gdk_pixbuf_new_from_resource_try_mmap (const char *resource_path)
 {
-	GInputStream *stream;
-	GdkPixbuf *pixbuf;
 	guint32 flags;
 	gsize data_size;
 	GBytes *bytes;
@@ -1699,6 +1679,37 @@ gdk_pixbuf_new_from_resource (const char *resource_path,
 		}
 	}
 
+        return NULL;
+}
+
+/**
+ * gdk_pixbuf_new_from_resource:
+ * @resource_path: the path of the resource file
+ * @error: Return location for an error
+ *
+ * Creates a new pixbuf by loading an image from an resource.
+ *
+ * The file format is detected automatically. If %NULL is returned, then
+ * @error will be set.
+ *
+ * Return value: A newly-created pixbuf, or %NULL if any of several error
+ * conditions occurred: the file could not be opened, the image format is
+ * not supported, there was not enough memory to allocate the image buffer,
+ * the stream contained invalid data, or the operation was cancelled.
+ *
+ * Since: 2.26
+ **/
+GdkPixbuf *
+gdk_pixbuf_new_from_resource (const char *resource_path,
+			      GError    **error)
+{
+	GInputStream *stream;
+	GdkPixbuf *pixbuf;
+
+        pixbuf = _gdk_pixbuf_new_from_resource_try_mmap (resource_path);
+        if (pixbuf)
+                return pixbuf;
+
 	stream = g_resources_open_stream (resource_path, 0, error);
 	if (stream == NULL)
 		return NULL;
diff --git a/gdk-pixbuf/gdk-pixbuf-private.h b/gdk-pixbuf/gdk-pixbuf-private.h
index 001e747..e13426d 100644
--- a/gdk-pixbuf/gdk-pixbuf-private.h
+++ b/gdk-pixbuf/gdk-pixbuf-private.h
@@ -100,6 +100,8 @@ GdkPixbufFormat *_gdk_pixbuf_get_format (GdkPixbufModule *image_module);
 
 #endif /* GDK_PIXBUF_ENABLE_BACKEND */
 
+GdkPixbuf * _gdk_pixbuf_new_from_resource_try_mmap (const char *resource_path);
+
 #endif /* GDK_PIXBUF_PRIVATE_H */
 
 



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