[gnome-photos] Split out the GEGL-related utility code into a separate file
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] Split out the GEGL-related utility code into a separate file
- Date: Fri, 3 Feb 2017 00:07:28 +0000 (UTC)
commit 3b9691e8bccbce8ee84d7fe139452432adb80d4e
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Feb 2 00:31:34 2017 +0100
Split out the GEGL-related utility code into a separate file
src/Makefile.am | 2 +
src/photos-base-item.c | 35 +++---
src/photos-gegl.c | 252 ++++++++++++++++++++++++++++++++++++++++++
src/photos-gegl.h | 52 +++++++++
src/photos-image-view.c | 4 +-
src/photos-pipeline.c | 6 +-
src/photos-print-operation.c | 6 +-
src/photos-print-setup.c | 6 +-
src/photos-utils.c | 227 -------------------------------------
src/photos-utils.h | 20 ----
10 files changed, 335 insertions(+), 275 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index f69f6b6..c9af2f3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -94,6 +94,8 @@ gnome_photos_SOURCES = \
photos-filterable.h \
photos-flickr-item.c \
photos-flickr-item.h \
+ photos-gegl.c \
+ photos-gegl.h \
photos-google-item.c \
photos-google-item.h \
photos-header-bar.c \
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 1c5e305..88b5f11 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -46,6 +46,7 @@
#include "photos-debug.h"
#include "photos-delete-item-job.h"
#include "photos-filterable.h"
+#include "photos-gegl.h"
#include "photos-icons.h"
#include "photos-local-item.h"
#include "photos-pipeline.h"
@@ -1213,7 +1214,7 @@ photos_base_item_guess_save_sizes_load (GObject *source_object, GAsyncResult *re
goto out;
}
- buffer = photos_utils_get_buffer_from_node (graph, NULL);
+ buffer = photos_gegl_get_buffer_from_node (graph, NULL);
data = photos_base_item_save_data_new (NULL, buffer, priv->mime_type, 0.0);
g_task_set_task_data (task, data, (GDestroyNotify) photos_base_item_save_data_free);
@@ -1401,7 +1402,7 @@ photos_base_item_load_buffer_async (PhotosBaseItem *self,
priv->load_graph = gegl_node_new ();
priv->load = gegl_node_new_child (priv->load_graph, "operation", "gegl:load", NULL);
- orientation = photos_utils_create_orientation_node (priv->load_graph, priv->orientation);
+ orientation = photos_gegl_create_orientation_node (priv->load_graph, priv->orientation);
priv->buffer_sink = gegl_node_new_child (priv->load_graph, "operation", "gegl:buffer-sink", NULL);
gegl_node_link_many (priv->load, orientation, priv->buffer_sink, NULL);
}
@@ -1771,7 +1772,7 @@ photos_base_item_save_buffer_async (PhotosBaseItem *self,
graph = gegl_node_new ();
buffer_source = gegl_node_new_child (graph, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
- pixbuf = photos_utils_create_pixbuf_from_node (buffer_source);
+ pixbuf = photos_gegl_create_pixbuf_from_node (buffer_source);
if (pixbuf == NULL)
{
g_task_return_new_error (task, PHOTOS_ERROR, 0, "Failed to create a GdkPixbuf from the GeglBuffer");
@@ -1911,7 +1912,7 @@ photos_base_item_save_buffer_zoom (GObject *source_object, GAsyncResult *res, gp
data = (PhotosBaseItemSaveData *) g_task_get_task_data (task);
error = NULL;
- buffer_zoomed = photos_utils_buffer_zoom_finish (buffer, res, &error);
+ buffer_zoomed = photos_gegl_buffer_zoom_finish (buffer, res, &error);
if (error != NULL)
{
g_task_return_error (task, error);
@@ -2095,7 +2096,7 @@ photos_base_item_save_to_stream_buffer_zoom (GObject *source_object, GAsyncResul
data = (PhotosBaseItemSaveToStreamData *) g_task_get_task_data (task);
error = NULL;
- buffer_zoomed = photos_utils_buffer_zoom_finish (buffer, res, &error);
+ buffer_zoomed = photos_gegl_buffer_zoom_finish (buffer, res, &error);
if (error != NULL)
{
g_task_return_error (task, error);
@@ -2155,12 +2156,12 @@ photos_base_item_save_to_stream_load (GObject *source_object, GAsyncResult *res,
goto out;
}
- buffer = photos_utils_get_buffer_from_node (graph, NULL);
- photos_utils_buffer_zoom_async (buffer,
- data->zoom,
- cancellable,
- photos_base_item_save_to_stream_buffer_zoom,
- g_object_ref (task));
+ buffer = photos_gegl_get_buffer_from_node (graph, NULL);
+ photos_gegl_buffer_zoom_async (buffer,
+ data->zoom,
+ cancellable,
+ photos_base_item_save_to_stream_buffer_zoom,
+ g_object_ref (task));
out:
g_clear_object (&buffer);
@@ -3741,12 +3742,12 @@ photos_base_item_save_load (GObject *source_object, GAsyncResult *res, gpointer
goto out;
}
- buffer = photos_utils_get_buffer_from_node (graph, NULL);
- photos_utils_buffer_zoom_async (buffer,
- data->zoom,
- cancellable,
- photos_base_item_save_buffer_zoom,
- g_object_ref (task));
+ buffer = photos_gegl_get_buffer_from_node (graph, NULL);
+ photos_gegl_buffer_zoom_async (buffer,
+ data->zoom,
+ cancellable,
+ photos_base_item_save_buffer_zoom,
+ g_object_ref (task));
out:
g_clear_object (&buffer);
diff --git a/src/photos-gegl.c b/src/photos-gegl.c
new file mode 100644
index 0000000..31a9748
--- /dev/null
+++ b/src/photos-gegl.c
@@ -0,0 +1,252 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include "photos-debug.h"
+#include "photos-gegl.h"
+#include "photos-utils.h"
+
+
+static GeglBuffer *
+photos_gegl_buffer_zoom (GeglBuffer *buffer, gdouble zoom, GCancellable *cancellable, GError **error)
+{
+ GeglBuffer *ret_val = NULL;
+ GeglNode *buffer_sink;
+ GeglNode *buffer_source;
+ GeglNode *graph;
+ GeglNode *scale;
+
+ graph = gegl_node_new ();
+ buffer_source = gegl_node_new_child (graph, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
+ scale = gegl_node_new_child (graph, "operation", "gegl:scale-ratio", "x", zoom, "y", zoom, NULL);
+ buffer_sink = gegl_node_new_child (graph, "operation", "gegl:buffer-sink", "buffer", &ret_val, NULL);
+ gegl_node_link_many (buffer_source, scale, buffer_sink, NULL);
+ gegl_node_process (buffer_sink);
+
+ g_object_unref (graph);
+ return ret_val;
+}
+
+
+static void
+photos_gegl_buffer_zoom_in_thread_func (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
+{
+ GeglBuffer *buffer = GEGL_BUFFER (source_object);
+ GeglBuffer *result = NULL;
+ GError *error;
+ const gchar *zoom_str = (const gchar *) task_data;
+ gchar *endptr;
+ gdouble zoom;
+
+ zoom = g_ascii_strtod (zoom_str, &endptr);
+ g_assert (*endptr == '\0');
+
+ error = NULL;
+ result = photos_gegl_buffer_zoom (buffer, zoom, cancellable, &error);
+ if (error != NULL)
+ {
+ g_task_return_error (task, error);
+ goto out;
+ }
+
+ g_task_return_pointer (task, g_object_ref (result), g_object_unref);
+
+ out:
+ g_clear_object (&result);
+}
+
+
+void
+photos_gegl_buffer_zoom_async (GeglBuffer *buffer,
+ gdouble zoom,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GTask *task;
+ gchar zoom_str[G_ASCII_DTOSTR_BUF_SIZE];
+
+ g_return_if_fail (GEGL_IS_BUFFER (buffer));
+ g_return_if_fail (zoom > 0.0);
+
+ task = g_task_new (buffer, cancellable, callback, user_data);
+ g_task_set_source_tag (task, photos_gegl_buffer_zoom_async);
+
+ if (GEGL_FLOAT_EQUAL ((gfloat) zoom, 1.0))
+ {
+ g_task_return_pointer (task, g_object_ref (buffer), g_object_unref);
+ goto out;
+ }
+
+ g_ascii_dtostr (zoom_str, G_N_ELEMENTS (zoom_str), zoom);
+ g_task_set_task_data (task, g_strdup (zoom_str), g_free);
+
+ g_task_run_in_thread (task, photos_gegl_buffer_zoom_in_thread_func);
+
+ out:
+ g_object_unref (task);
+}
+
+
+GeglBuffer *
+photos_gegl_buffer_zoom_finish (GeglBuffer *buffer, GAsyncResult *res, GError **error)
+{
+ GTask *task = G_TASK (res);
+
+ g_return_val_if_fail (g_task_is_valid (res, buffer), NULL);
+ g_return_val_if_fail (g_task_get_source_tag (task) == photos_gegl_buffer_zoom_async, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ return g_task_propagate_pointer (task, error);
+}
+
+
+GeglNode *
+photos_gegl_create_orientation_node (GeglNode *parent, GQuark orientation)
+{
+ GeglNode *ret_val = NULL;
+ double degrees = 1.0;
+
+ if (orientation == PHOTOS_ORIENTATION_TOP)
+ goto out;
+
+ if (orientation == PHOTOS_ORIENTATION_BOTTOM)
+ degrees = -180.0;
+ else if (orientation == PHOTOS_ORIENTATION_LEFT)
+ degrees = -270.0;
+ else if (orientation == PHOTOS_ORIENTATION_RIGHT)
+ degrees = -90.0;
+
+ if (degrees < 0.0)
+ ret_val = gegl_node_new_child (parent, "operation", "gegl:rotate-on-center", "degrees", degrees, NULL);
+
+ out:
+ if (ret_val == NULL)
+ ret_val = gegl_node_new_child (parent, "operation", "gegl:nop", NULL);
+
+ return ret_val;
+}
+
+
+GdkPixbuf *
+photos_gegl_create_pixbuf_from_node (GeglNode *node)
+{
+ GdkPixbuf *pixbuf = NULL;
+ GeglNode *graph;
+ GeglNode *save_pixbuf;
+
+ graph = gegl_node_get_parent (node);
+ save_pixbuf = gegl_node_new_child (graph,
+ "operation", "gegl:save-pixbuf",
+ "pixbuf", &pixbuf,
+ NULL);
+ gegl_node_link_many (node, save_pixbuf, NULL);
+ gegl_node_process (save_pixbuf);
+ g_object_unref (save_pixbuf);
+
+ return pixbuf;
+}
+
+
+GeglBuffer *
+photos_gegl_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, "GEGL: Dup Buffer from Node: %" G_GINT64_FORMAT, end - start);
+
+ return buffer;
+}
+
+
+GeglBuffer *
+photos_gegl_get_buffer_from_node (GeglNode *node, const Babl *format)
+{
+ GeglBuffer *buffer = NULL;
+ GeglNode *buffer_sink;
+ GeglNode *graph;
+ gint64 end;
+ gint64 start;
+
+ graph = gegl_node_get_parent (node);
+ buffer_sink = gegl_node_new_child (graph,
+ "operation", "gegl:buffer-sink",
+ "buffer", &buffer,
+ "format", format,
+ NULL);
+ gegl_node_link (node, buffer_sink);
+
+ start = g_get_monotonic_time ();
+
+ gegl_node_process (buffer_sink);
+
+ end = g_get_monotonic_time ();
+ photos_debug (PHOTOS_DEBUG_GEGL, "GEGL: Get Buffer from Node: %" G_GINT64_FORMAT, end - start);
+
+ g_object_unref (buffer_sink);
+
+ return buffer;
+}
+
+
+void
+photos_gegl_remove_children_from_node (GeglNode *node)
+{
+ GeglNode *input;
+ GeglNode *last;
+ GeglNode *output;
+ GeglOperation *operation;
+
+ operation = gegl_node_get_gegl_operation (node);
+ g_return_if_fail (operation == NULL);
+
+ input = gegl_node_get_input_proxy (node, "input");
+ output = gegl_node_get_output_proxy (node, "output");
+ last = gegl_node_get_producer (output, "input", NULL);
+
+ while (last != NULL && last != input)
+ {
+ GeglNode *last2;
+
+ last2 = gegl_node_get_producer (last, "input", NULL);
+ gegl_node_remove_child (node, last);
+ last = last2;
+ }
+
+ gegl_node_link (input, output);
+}
diff --git a/src/photos-gegl.h b/src/photos-gegl.h
new file mode 100644
index 0000000..ee6ed3e
--- /dev/null
+++ b/src/photos-gegl.h
@@ -0,0 +1,52 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_GEGL_H
+#define PHOTOS_GEGL_H
+
+#include <babl/babl.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gegl.h>
+#include <gio/gio.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+void photos_gegl_buffer_zoom_async (GeglBuffer *buffer,
+ gdouble zoom,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+GeglBuffer *photos_gegl_buffer_zoom_finish (GeglBuffer *buffer, GAsyncResult *res, GError
**error);
+
+GeglNode *photos_gegl_create_orientation_node (GeglNode *parent, GQuark orientation);
+
+GdkPixbuf *photos_gegl_create_pixbuf_from_node (GeglNode *node);
+
+GeglBuffer *photos_gegl_dup_buffer_from_node (GeglNode *node, const Babl *format);
+
+GeglBuffer *photos_gegl_get_buffer_from_node (GeglNode *node, const Babl *format);
+
+void photos_gegl_remove_children_from_node (GeglNode *node);
+
+G_END_DECLS
+
+#endif /* PHOTOS_GEGL_H */
diff --git a/src/photos-image-view.c b/src/photos-image-view.c
index 4a53588..ad82e74 100644
--- a/src/photos-image-view.c
+++ b/src/photos-image-view.c
@@ -26,9 +26,9 @@
#include <glib.h>
#include "photos-debug.h"
+#include "photos-gegl.h"
#include "photos-image-view.h"
#include "photos-marshalers.h"
-#include "photos-utils.h"
struct _PhotosImageView
@@ -80,7 +80,7 @@ photos_image_view_update_buffer (PhotosImageView *self)
g_signal_handlers_block_by_func (self->node, photos_image_view_computed, self);
format = babl_format ("cairo-ARGB32");
- buffer = photos_utils_dup_buffer_from_node (self->node, format);
+ buffer = photos_gegl_dup_buffer_from_node (self->node, format);
g_set_object (&self->buffer, buffer);
g_signal_handlers_unblock_by_func (self->node, photos_image_view_computed, self);
diff --git a/src/photos-pipeline.c b/src/photos-pipeline.c
index 07db4c5..d42dd0a 100644
--- a/src/photos-pipeline.c
+++ b/src/photos-pipeline.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2015 – 2016 Red Hat, Inc.
+ * Copyright © 2015 – 2017 Red Hat, Inc.
* Copyright © 2016 Umang Jain
*
* This program is free software; you can redistribute it and/or
@@ -28,9 +28,9 @@
#include "egg-counter.h"
#include "photos-debug.h"
+#include "photos-gegl.h"
#include "photos-operation-insta-common.h"
#include "photos-pipeline.h"
-#include "photos-utils.h"
struct _PhotosPipeline
@@ -150,7 +150,7 @@ photos_pipeline_create_graph_from_xml (PhotosPipeline *self, const gchar *conten
goto out;
g_hash_table_remove_all (self->hash);
- photos_utils_remove_children_from_node (self->graph);
+ photos_gegl_remove_children_from_node (self->graph);
input = gegl_node_get_input_proxy (self->graph, "input");
output = gegl_node_get_output_proxy (self->graph, "output");
diff --git a/src/photos-print-operation.c b/src/photos-print-operation.c
index 0933900..0563474 100644
--- a/src/photos-print-operation.c
+++ b/src/photos-print-operation.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2013 – 2016 Red Hat, Inc.
+ * Copyright © 2013 – 2017 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -30,9 +30,9 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include "photos-gegl.h"
#include "photos-print-operation.h"
#include "photos-print-setup.h"
-#include "photos-utils.h"
struct _PhotosPrintOperation
@@ -145,7 +145,7 @@ photos_print_operation_draw_page (GtkPrintOperation *operation, GtkPrintContext
cairo_clip (cr);
cairo_scale (cr, scale_factor_n, scale_factor_n);
- pixbuf = photos_utils_create_pixbuf_from_node (self->node);
+ pixbuf = photos_gegl_create_pixbuf_from_node (self->node);
if (pixbuf == NULL)
goto out;
diff --git a/src/photos-print-setup.c b/src/photos-print-setup.c
index 952ef9e..0e24cbd 100644
--- a/src/photos-print-setup.c
+++ b/src/photos-print-setup.c
@@ -1,7 +1,7 @@
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2006 – 2007 The Free Software Foundation
- * Copyright © 2013 – 2016 Red Hat, Inc.
+ * Copyright © 2013 – 2017 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -33,9 +33,9 @@
#include <glib/gprintf.h>
#include <gtk/gtkunixprint.h>
+#include "photos-gegl.h"
#include "photos-print-setup.h"
#include "photos-print-preview.h"
-#include "photos-utils.h"
struct _PhotosPrintSetupPrivate
@@ -867,7 +867,7 @@ photos_print_setup_set_property (GObject *object, guint prop_id, const GValue *v
GdkPixbuf *pixbuf;
priv->node = GEGL_NODE (g_value_dup_object (value));
- pixbuf = photos_utils_create_pixbuf_from_node (priv->node);
+ pixbuf = photos_gegl_create_pixbuf_from_node (priv->node);
if (pixbuf != NULL)
{
g_object_set (priv->preview, "pixbuf", pixbuf, NULL);
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 3f49db0..a9f2b35 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -37,7 +37,6 @@
#include <libgd/gd.h>
#include "photos-application.h"
-#include "photos-debug.h"
#include "photos-facebook-item.h"
#include "photos-flickr-item.h"
#include "photos-google-item.h"
@@ -154,103 +153,6 @@ photos_utils_border_pixbuf (GdkPixbuf *pixbuf)
}
-static GeglBuffer *
-photos_utils_buffer_zoom (GeglBuffer *buffer, gdouble zoom, GCancellable *cancellable, GError **error)
-{
- GeglBuffer *ret_val = NULL;
- GeglNode *buffer_sink;
- GeglNode *buffer_source;
- GeglNode *graph;
- GeglNode *scale;
-
- graph = gegl_node_new ();
- buffer_source = gegl_node_new_child (graph, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
- scale = gegl_node_new_child (graph, "operation", "gegl:scale-ratio", "x", zoom, "y", zoom, NULL);
- buffer_sink = gegl_node_new_child (graph, "operation", "gegl:buffer-sink", "buffer", &ret_val, NULL);
- gegl_node_link_many (buffer_source, scale, buffer_sink, NULL);
- gegl_node_process (buffer_sink);
-
- g_object_unref (graph);
- return ret_val;
-}
-
-
-static void
-photos_utils_buffer_zoom_in_thread_func (GTask *task,
- gpointer source_object,
- gpointer task_data,
- GCancellable *cancellable)
-{
- GeglBuffer *buffer = GEGL_BUFFER (source_object);
- GeglBuffer *result = NULL;
- GError *error;
- const gchar *zoom_str = (const gchar *) task_data;
- gchar *endptr;
- gdouble zoom;
-
- zoom = g_ascii_strtod (zoom_str, &endptr);
- g_assert (*endptr == '\0');
-
- error = NULL;
- result = photos_utils_buffer_zoom (buffer, zoom, cancellable, &error);
- if (error != NULL)
- {
- g_task_return_error (task, error);
- goto out;
- }
-
- g_task_return_pointer (task, g_object_ref (result), g_object_unref);
-
- out:
- g_clear_object (&result);
-}
-
-
-void
-photos_utils_buffer_zoom_async (GeglBuffer *buffer,
- gdouble zoom,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GTask *task;
- gchar zoom_str[G_ASCII_DTOSTR_BUF_SIZE];
-
- g_return_if_fail (GEGL_IS_BUFFER (buffer));
- g_return_if_fail (zoom > 0.0);
-
- task = g_task_new (buffer, cancellable, callback, user_data);
- g_task_set_source_tag (task, photos_utils_buffer_zoom_async);
-
- if (GEGL_FLOAT_EQUAL ((gfloat) zoom, 1.0))
- {
- g_task_return_pointer (task, g_object_ref (buffer), g_object_unref);
- goto out;
- }
-
- g_ascii_dtostr (zoom_str, G_N_ELEMENTS (zoom_str), zoom);
- g_task_set_task_data (task, g_strdup (zoom_str), g_free);
-
- g_task_run_in_thread (task, photos_utils_buffer_zoom_in_thread_func);
-
- out:
- g_object_unref (task);
-}
-
-
-GeglBuffer *
-photos_utils_buffer_zoom_finish (GeglBuffer *buffer, GAsyncResult *res, GError **error)
-{
- GTask *task = G_TASK (res);
-
- g_return_val_if_fail (g_task_is_valid (res, buffer), NULL);
- g_return_val_if_fail (g_task_get_source_tag (task) == photos_utils_buffer_zoom_async, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- return g_task_propagate_pointer (task, error);
-}
-
-
GdkPixbuf *
photos_utils_center_pixbuf (GdkPixbuf *pixbuf, gint size)
{
@@ -387,33 +289,6 @@ photos_utils_create_collection_icon (gint base_size, GList *pixbufs)
}
-GeglNode *
-photos_utils_create_orientation_node (GeglNode *parent, GQuark orientation)
-{
- GeglNode *ret_val = NULL;
- double degrees = 1.0;
-
- if (orientation == PHOTOS_ORIENTATION_TOP)
- goto out;
-
- if (orientation == PHOTOS_ORIENTATION_BOTTOM)
- degrees = -180.0;
- else if (orientation == PHOTOS_ORIENTATION_LEFT)
- degrees = -270.0;
- else if (orientation == PHOTOS_ORIENTATION_RIGHT)
- degrees = -90.0;
-
- if (degrees < 0.0)
- ret_val = gegl_node_new_child (parent, "operation", "gegl:rotate-on-center", "degrees", degrees, NULL);
-
- out:
- if (ret_val == NULL)
- ret_val = gegl_node_new_child (parent, "operation", "gegl:nop", NULL);
-
- return ret_val;
-}
-
-
GdkPixbuf *
photos_utils_create_placeholder_icon_for_scale (const gchar *name, gint size, gint scale)
{
@@ -471,26 +346,6 @@ photos_utils_create_placeholder_icon_for_scale (const gchar *name, gint size, gi
}
-GdkPixbuf *
-photos_utils_create_pixbuf_from_node (GeglNode *node)
-{
- GdkPixbuf *pixbuf = NULL;
- GeglNode *graph;
- GeglNode *save_pixbuf;
-
- graph = gegl_node_get_parent (node);
- save_pixbuf = gegl_node_new_child (graph,
- "operation", "gegl:save-pixbuf",
- "pixbuf", &pixbuf,
- NULL);
- gegl_node_link_many (node, save_pixbuf, NULL);
- gegl_node_process (save_pixbuf);
- g_object_unref (save_pixbuf);
-
- return pixbuf;
-}
-
-
GIcon *
photos_utils_create_symbolic_icon_for_scale (const gchar *name, gint base_size, gint scale)
{
@@ -602,36 +457,6 @@ photos_utils_create_thumbnail (GFile *file,
}
-GeglBuffer *
-photos_utils_get_buffer_from_node (GeglNode *node, const Babl *format)
-{
- GeglBuffer *buffer = NULL;
- GeglNode *buffer_sink;
- GeglNode *graph;
- gint64 end;
- gint64 start;
-
- graph = gegl_node_get_parent (node);
- buffer_sink = gegl_node_new_child (graph,
- "operation", "gegl:buffer-sink",
- "buffer", &buffer,
- "format", format,
- NULL);
- gegl_node_link (node, buffer_sink);
-
- start = g_get_monotonic_time ();
-
- gegl_node_process (buffer_sink);
-
- end = g_get_monotonic_time ();
- photos_debug (PHOTOS_DEBUG_GEGL, "Utils: Create Buffer from Node: %" G_GINT64_FORMAT, end - start);
-
- g_object_unref (buffer_sink);
-
- return buffer;
-}
-
-
static GIcon *
photos_utils_get_thumbnail_icon (const gchar *uri)
{
@@ -844,30 +669,6 @@ 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)
{
@@ -1498,34 +1299,6 @@ photos_utils_update_executed (GObject *source_object, GAsyncResult *res, gpointe
void
-photos_utils_remove_children_from_node (GeglNode *node)
-{
- GeglNode *input;
- GeglNode *last;
- GeglNode *output;
- GeglOperation *operation;
-
- operation = gegl_node_get_gegl_operation (node);
- g_return_if_fail (operation == NULL);
-
- input = gegl_node_get_input_proxy (node, "input");
- output = gegl_node_get_output_proxy (node, "output");
- last = gegl_node_get_producer (output, "input", NULL);
-
- while (last != NULL && last != input)
- {
- GeglNode *last2;
-
- last2 = gegl_node_get_producer (last, "input", NULL);
- gegl_node_remove_child (node, last);
- last = last2;
- }
-
- gegl_node_link (input, output);
-}
-
-
-void
photos_utils_set_edited_name (const gchar *urn, const gchar *title)
{
GError *error;
diff --git a/src/photos-utils.h b/src/photos-utils.h
index fcb88b8..836693a 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -28,10 +28,8 @@
#ifndef PHOTOS_UTILS_H
#define PHOTOS_UTILS_H
-#include <babl/babl.h>
#include <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gegl.h>
#include <gio/gio.h>
#include <glib.h>
#include <gtk/gtk.h>
@@ -70,24 +68,12 @@ gboolean photos_utils_app_info_launch_uri (GAppInfo *appinfo,
void photos_utils_border_pixbuf (GdkPixbuf *pixbuf);
-void photos_utils_buffer_zoom_async (GeglBuffer *buffer,
- gdouble zoom,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
-GeglBuffer *photos_utils_buffer_zoom_finish (GeglBuffer *buffer, GAsyncResult *res, GError
**error);
-
GdkPixbuf *photos_utils_center_pixbuf (GdkPixbuf *pixbuf, gint size);
gchar *photos_utils_convert_path_to_uri (const gchar *path);
GIcon *photos_utils_create_collection_icon (gint base_size, GList *pixbufs);
-GeglNode *photos_utils_create_orientation_node (GeglNode *parent, GQuark orientation);
-
-GdkPixbuf *photos_utils_create_pixbuf_from_node (GeglNode *node);
-
GdkPixbuf *photos_utils_create_placeholder_icon_for_scale (const gchar *name, gint size, gint scale);
GIcon *photos_utils_create_symbolic_icon_for_scale (const gchar *name, gint base_size, gint scale);
@@ -98,8 +84,6 @@ gboolean photos_utils_create_thumbnail (GFile *file,
GCancellable *cancellable,
GError **error);
-GeglBuffer *photos_utils_get_buffer_from_node (GeglNode *node, const Babl *format);
-
GIcon *photos_utils_get_icon_from_cursor (TrackerSparqlCursor *cursor);
GdkPixbuf *photos_utils_downscale_pixbuf_for_scale (GdkPixbuf *pixbuf, gint size, gint scale);
@@ -118,8 +102,6 @@ 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);
@@ -189,8 +171,6 @@ GQuark photos_utils_orientation_right_quark (void);
GQuark photos_utils_orientation_top_quark (void);
-void photos_utils_remove_children_from_node (GeglNode *node);
-
void photos_utils_set_edited_name (const gchar *urn, const gchar *title);
void photos_utils_set_favorite (const gchar *urn, gboolean is_favorite);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]