[gnome-photos/wip/rishi/double-buffering: 3/12] utils: Add photos_utils_dup_buffer_from_node
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/double-buffering: 3/12] utils: Add photos_utils_dup_buffer_from_node
- Date: Wed, 18 Jan 2017 11:03:42 +0000 (UTC)
commit ca8d50a9f4461994f69822ebf51540eb480e1f45
Author: Debarshi Ray <debarshir gnome org>
Date: Tue Jan 17 12:31:19 2017 +0100
utils: Add photos_utils_dup_buffer_from_node
Unlike photos_utils_get_buffer_from_node, this won't just return a new
reference on the GeglNode's output buffer. Instead, the buffer will be
copied and have copy-on-write tiles.
src/photos-utils.c | 24 ++++++++++++++++++++++++
src/photos-utils.h | 3 +++
2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 86db6c4..dbee5cb 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -843,6 +843,30 @@ photos_utils_draw_rectangle_thirds (cairo_t *cr, gdouble x, gdouble y, gdouble w
}
+GeglBuffer *
+photos_utils_dup_buffer_from_node (GeglNode *node, const Babl *format)
+{
+ GeglBuffer *buffer;
+ GeglRectangle bbox;
+ gint64 end;
+ gint64 start;
+
+ g_return_val_if_fail (GEGL_IS_NODE (node), NULL);
+
+ bbox = gegl_node_get_bounding_box (node);
+ buffer = gegl_buffer_new (&bbox, format);
+
+ start = g_get_monotonic_time ();
+
+ gegl_node_blit_buffer (node, buffer, &bbox, 0, GEGL_ABYSS_NONE);
+
+ end = g_get_monotonic_time ();
+ photos_debug (PHOTOS_DEBUG_GEGL, "Utils: Dup Buffer from Node: %" G_GINT64_FORMAT, end - start);
+
+ return buffer;
+}
+
+
void
photos_utils_ensure_builtins (void)
{
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 26a5db1..a9810f5 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -28,6 +28,7 @@
#ifndef PHOTOS_UTILS_H
#define PHOTOS_UTILS_H
+#include <babl/babl.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
@@ -117,6 +118,8 @@ void photos_utils_draw_rectangle_thirds (cairo_t *cr,
gdouble width,
gdouble height);
+GeglBuffer *photos_utils_dup_buffer_from_node (GeglNode *node, const Babl *format);
+
void photos_utils_ensure_builtins (void);
void photos_utils_ensure_extension_points (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]