[gegl] Move add handler functions into TileStorage



commit 9d5e6ff288e023297f64b4178803c077bb9973e5
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Wed Mar 5 08:28:10 2014 -0800

    Move add handler functions into TileStorage

 gegl/buffer/gegl-buffer.c       |   32 ++------------------------------
 gegl/buffer/gegl-tile-storage.c |   33 +++++++++++++++++++++++++++++++++
 gegl/buffer/gegl-tile-storage.h |    3 +++
 3 files changed, 38 insertions(+), 30 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index 3b03e8b..c1e07f0 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -1033,42 +1033,14 @@ void
 gegl_buffer_add_handler (GeglBuffer *buffer,
                          gpointer    handler)
 {
-  GeglTileHandlerChain *chain;
-
-  g_return_if_fail (GEGL_IS_BUFFER (buffer));
-  g_return_if_fail (GEGL_IS_TILE_HANDLER (handler));
-
-  chain = GEGL_TILE_HANDLER_CHAIN (buffer->tile_storage);
-
-  gegl_tile_handler_chain_add (chain, handler);
-
-  /* XXX */
-  chain->chain = g_slist_remove (chain->chain, handler);
-  chain->chain = g_slist_insert (chain->chain, handler, 2);
-
-  gegl_tile_handler_chain_bind (chain);
+  gegl_tile_storage_add_handler (buffer->tile_storage, handler);
 }
 
 void
 gegl_buffer_remove_handler (GeglBuffer *buffer,
                             gpointer    handler)
 {
-  GeglTileHandlerChain *chain;
-
-  g_return_if_fail (GEGL_IS_BUFFER (buffer));
-  g_return_if_fail (GEGL_IS_TILE_HANDLER (handler));
-
-  chain = GEGL_TILE_HANDLER_CHAIN (buffer->tile_storage);
-
-  g_return_if_fail (g_slist_find (chain->chain, handler));
-
-  chain->chain = g_slist_remove (chain->chain, handler);
-
-  gegl_tile_handler_set_source (handler, NULL);
-
-  g_object_unref (handler);
-
-  gegl_tile_handler_chain_bind (chain);
+  gegl_tile_storage_remove_handler (buffer->tile_storage, handler);
 }
 
 /* FIXME: this function needs optimizing, perhaps keep a pool
diff --git a/gegl/buffer/gegl-tile-storage.c b/gegl/buffer/gegl-tile-storage.c
index f0a4884..9240b46 100644
--- a/gegl/buffer/gegl-tile-storage.c
+++ b/gegl/buffer/gegl-tile-storage.c
@@ -96,6 +96,39 @@ gegl_tile_storage_new (GeglTileBackend *backend)
   return tile_storage;
 }
 
+void
+gegl_tile_storage_add_handler (GeglTileStorage *tile_storage,
+                               GeglTileHandler *handler)
+{
+  GeglTileHandlerChain *chain = GEGL_TILE_HANDLER_CHAIN (tile_storage);
+
+  g_return_if_fail (GEGL_IS_TILE_HANDLER (handler));
+
+  gegl_tile_handler_chain_add (chain, handler);
+
+  /* FIXME: Move the handler to before the cache and other custom handlers */
+  chain->chain = g_slist_remove (chain->chain, handler);
+  chain->chain = g_slist_insert (chain->chain, handler, 2);
+
+  gegl_tile_handler_chain_bind (chain);
+}
+
+void
+gegl_tile_storage_remove_handler (GeglTileStorage *tile_storage,
+                                  GeglTileHandler *handler)
+{
+  GeglTileHandlerChain *chain = GEGL_TILE_HANDLER_CHAIN (tile_storage);
+
+  g_return_if_fail (GEGL_IS_TILE_HANDLER (handler));
+  g_return_if_fail (g_slist_find (chain->chain, handler));
+
+  chain->chain = g_slist_remove (chain->chain, handler);
+  gegl_tile_handler_set_source (handler, NULL);
+  g_object_unref (handler);
+
+  gegl_tile_handler_chain_bind (chain);
+}
+
 static void
 gegl_tile_storage_finalize (GObject *object)
 {
diff --git a/gegl/buffer/gegl-tile-storage.h b/gegl/buffer/gegl-tile-storage.h
index a55dc2e..c32536e 100644
--- a/gegl/buffer/gegl-tile-storage.h
+++ b/gegl/buffer/gegl-tile-storage.h
@@ -62,4 +62,7 @@ GType gegl_tile_storage_get_type (void) G_GNUC_CONST;
 GeglTileStorage *
 gegl_tile_storage_new (GeglTileBackend *backend);
 
+void gegl_tile_storage_add_handler (GeglTileStorage *tile_storage, GeglTileHandler *handler);
+void gegl_tile_storage_remove_handler (GeglTileStorage *tile_storage, GeglTileHandler *handler);
+
 #endif


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