Commit 9d5e6ff2 authored by Daniel Sabo's avatar Daniel Sabo

Move add handler functions into TileStorage

parent 68d16e8a
......@@ -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
......
......@@ -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)
{
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment