[gnome-photos/wip/rishi/thumbnailer: 6/8] base-item: Shorten the lifetime of the loading graph
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/thumbnailer: 6/8] base-item: Shorten the lifetime of the loading graph
- Date: Sun, 26 Feb 2017 12:10:17 +0000 (UTC)
commit 209bf4570312cfe234faa57622ceb4eb539a3cca
Author: Debarshi Ray <debarshir gnome org>
Date: Sat Feb 25 21:40:31 2017 +0100
base-item: Shorten the lifetime of the loading graph
There is no need to keep the graph that loaded the GeglBuffer as an
instance variable for the entire lifetime of the BaseItem. It can be
entirely local to the function that does the loading.
This reduces the memory footprint of each BaseItem by three pointers.
Plus, any GeglBuffer that might be left loitering around in the graph.
src/photos-base-item.c | 36 ++++++++++++------------------------
1 files changed, 12 insertions(+), 24 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 043134a..7350853 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -68,11 +68,8 @@ struct _PhotosBaseItemPrivate
GCancellable *cancellable;
GdkPixbuf *original_icon;
GeglBuffer *preview_source_buffer;
- GeglNode *buffer_sink;
GeglNode *buffer_source;
GeglNode *edit_graph;
- GeglNode *load_graph;
- GeglNode *load;
GeglProcessor *processor;
GMutex mutex_download;
GMutex mutex_save_metadata;
@@ -1079,7 +1076,6 @@ photos_base_item_get_preview_source_buffer (PhotosBaseItem *self, gint size, gin
g_return_val_if_fail (!priv->collection, NULL);
g_return_val_if_fail (priv->buffer_source != NULL, NULL);
g_return_val_if_fail (priv->edit_graph != NULL, NULL);
- g_return_val_if_fail (priv->load_graph != NULL, NULL);
op = gegl_node_get_gegl_operation (priv->buffer_source);
g_return_val_if_fail (op != NULL, NULL);
@@ -1363,6 +1359,10 @@ photos_base_item_load_buffer (PhotosBaseItem *self, GCancellable *cancellable, G
{
PhotosBaseItemPrivate *priv;
GeglBuffer *ret_val = NULL;
+ GeglNode *buffer_sink;
+ GeglNode *graph = NULL;
+ GeglNode *load;
+ GeglNode *orientation;
gchar *path = NULL;
priv = photos_base_item_get_instance_private (self);
@@ -1371,11 +1371,16 @@ photos_base_item_load_buffer (PhotosBaseItem *self, GCancellable *cancellable, G
if (path == NULL)
goto out;
- gegl_node_set (priv->load, "path", path, NULL);
- gegl_node_set (priv->buffer_sink, "buffer", &ret_val, NULL);
- gegl_node_process (priv->buffer_sink);
+ graph = gegl_node_new ();
+ load = gegl_node_new_child (graph, "operation", "gegl:load", "path", path, NULL);
+ orientation = photos_gegl_create_orientation_node (graph, priv->orientation);
+ buffer_sink = gegl_node_new_child (graph, "operation", "gegl:buffer-sink", "buffer", &ret_val, NULL);
+
+ gegl_node_link_many (load, orientation, buffer_sink, NULL);
+ gegl_node_process (buffer_sink);
out:
+ g_clear_object (&graph);
g_free (path);
return ret_val;
}
@@ -1411,22 +1416,9 @@ photos_base_item_load_buffer_async (PhotosBaseItem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- PhotosBaseItemPrivate *priv;
GTask *task;
g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
- priv = photos_base_item_get_instance_private (self);
-
- if (priv->load_graph == NULL)
- {
- GeglNode *orientation;
-
- priv->load_graph = gegl_node_new ();
- priv->load = gegl_node_new_child (priv->load_graph, "operation", "gegl:load", NULL);
- 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);
- }
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, photos_base_item_load_buffer_async);
@@ -2506,7 +2498,6 @@ photos_base_item_dispose (GObject *object)
g_clear_object (&priv->default_app);
g_clear_object (&priv->preview_source_buffer);
g_clear_object (&priv->edit_graph);
- g_clear_object (&priv->load_graph);
g_clear_object (&priv->processor);
g_clear_object (&priv->original_icon);
g_clear_object (&priv->watcher);
@@ -2768,7 +2759,6 @@ photos_base_item_create_preview (PhotosBaseItem *self,
g_return_val_if_fail (operation != NULL && operation[0] != '\0', NULL);
g_return_val_if_fail (priv->buffer_source != NULL, NULL);
g_return_val_if_fail (priv->edit_graph != NULL, NULL);
- g_return_val_if_fail (priv->load_graph != NULL, NULL);
op = gegl_node_get_gegl_operation (priv->buffer_source);
g_return_val_if_fail (op != NULL, NULL);
@@ -2908,7 +2898,6 @@ photos_base_item_get_bbox_edited (PhotosBaseItem *self, GeglRectangle *out_bbox)
g_return_val_if_fail (!priv->collection, FALSE);
g_return_val_if_fail (priv->edit_graph != NULL, FALSE);
- g_return_val_if_fail (priv->load_graph != NULL, FALSE);
g_return_val_if_fail (priv->pipeline != NULL, FALSE);
g_return_val_if_fail (priv->processor != NULL, FALSE);
g_return_val_if_fail (!gegl_processor_work (priv->processor, NULL), FALSE);
@@ -3729,7 +3718,6 @@ photos_base_item_pipeline_save_async (PhotosBaseItem *self,
g_return_if_fail (!priv->collection);
g_return_if_fail (priv->edit_graph != NULL);
- g_return_if_fail (priv->load_graph != NULL);
g_return_if_fail (priv->pipeline != NULL);
task = g_task_new (self, cancellable, callback, user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]