[gegl] buffer: add private "cache" and "tile_storage" members to GeglTileHandler
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: add private "cache" and "tile_storage" members to GeglTileHandler
- Date: Thu, 5 Jul 2012 17:32:24 +0000 (UTC)
commit c66bf7af8e369f47238f214084905b5bc9b34ee0
Author: Michael Natterer <mitch gimp org>
Date: Thu Jul 5 19:25:18 2012 +0200
buffer: add private "cache" and "tile_storage" members to GeglTileHandler
and private API to set/get them. Also add to-become-public API to create
and dup tiles. In gegl_tile_handler_chain_add(), set the chain's own
storage and cache on the added handlers. Set them on the chain itself
in GeglTileStorage (which is a chain). Port the cache, zoom and empty
tile handlers to use the new stuff.
gegl/buffer/Makefile.am | 1 +
gegl/buffer/gegl-tile-handler-cache.c | 2 +-
gegl/buffer/gegl-tile-handler-cache.h | 15 ++--
gegl/buffer/gegl-tile-handler-chain.c | 21 ++++--
gegl/buffer/gegl-tile-handler-empty.c | 35 ++++-----
gegl/buffer/gegl-tile-handler-empty.h | 7 +-
gegl/buffer/gegl-tile-handler-private.h | 30 ++++++++
gegl/buffer/gegl-tile-handler-zoom.c | 67 +++++++----------
gegl/buffer/gegl-tile-handler-zoom.h | 8 +-
gegl/buffer/gegl-tile-handler.c | 124 +++++++++++++++++++++++++------
gegl/buffer/gegl-tile-handler.h | 32 +++++---
gegl/buffer/gegl-tile-storage.c | 17 +++--
12 files changed, 234 insertions(+), 125 deletions(-)
---
diff --git a/gegl/buffer/Makefile.am b/gegl/buffer/Makefile.am
index 505906f..2bd884b 100644
--- a/gegl/buffer/Makefile.am
+++ b/gegl/buffer/Makefile.am
@@ -39,6 +39,7 @@ libbuffer_la_SOURCES = \
gegl-tile-backend-file.c \
gegl-tile-backend-ram.c \
gegl-tile-handler.c \
+ gegl-tile-handler-private.h \
gegl-tile-handler-cache.c \
gegl-tile-handler-chain.c \
gegl-tile-handler-empty.c \
diff --git a/gegl/buffer/gegl-tile-handler-cache.c b/gegl/buffer/gegl-tile-handler-cache.c
index 060477e..62c6298 100644
--- a/gegl/buffer/gegl-tile-handler-cache.c
+++ b/gegl/buffer/gegl-tile-handler-cache.c
@@ -535,7 +535,7 @@ gegl_tile_handler_cache_insert (GeglTileHandlerCache *cache,
g_static_mutex_unlock (&mutex);
}
-GeglTileHandlerCache *
+GeglTileHandler *
gegl_tile_handler_cache_new (void)
{
return g_object_new (GEGL_TYPE_TILE_HANDLER_CACHE, NULL);
diff --git a/gegl/buffer/gegl-tile-handler-cache.h b/gegl/buffer/gegl-tile-handler-cache.h
index c716698..b130a62 100644
--- a/gegl/buffer/gegl-tile-handler-cache.h
+++ b/gegl/buffer/gegl-tile-handler-cache.h
@@ -49,12 +49,13 @@ struct _GeglTileHandlerCacheClass
GeglTileHandlerClass parent_class;
};
-GType gegl_tile_handler_cache_get_type (void) G_GNUC_CONST;
-GeglTileHandlerCache * gegl_tile_handler_cache_new (void);
-void gegl_tile_handler_cache_insert (GeglTileHandlerCache *cache,
- GeglTile *tile,
- gint x,
- gint y,
- gint z);
+GType gegl_tile_handler_cache_get_type (void) G_GNUC_CONST;
+
+GeglTileHandler * gegl_tile_handler_cache_new (void);
+void gegl_tile_handler_cache_insert (GeglTileHandlerCache *cache,
+ GeglTile *tile,
+ gint x,
+ gint y,
+ gint z);
#endif
diff --git a/gegl/buffer/gegl-tile-handler-chain.c b/gegl/buffer/gegl-tile-handler-chain.c
index 85f1890..28e193c 100644
--- a/gegl/buffer/gegl-tile-handler-chain.c
+++ b/gegl/buffer/gegl-tile-handler-chain.c
@@ -18,15 +18,16 @@
#include "config.h"
-#include <glib.h>
+#include <glib-object.h>
-#include "glib-object.h"
#include "gegl-buffer-types.h"
#include "gegl-tile-handler-chain.h"
#include "gegl-tile-handler-cache.h"
+#include "gegl-tile-handler-private.h"
-G_DEFINE_TYPE (GeglTileHandlerChain, gegl_tile_handler_chain, GEGL_TYPE_TILE_HANDLER)
+G_DEFINE_TYPE (GeglTileHandlerChain, gegl_tile_handler_chain,
+ GEGL_TYPE_TILE_HANDLER)
static void
gegl_tile_handler_chain_nuke_cache (GeglTileHandlerChain *tile_handler_chain)
@@ -161,11 +162,19 @@ gegl_tile_handler_chain_bind (GeglTileHandlerChain *tile_handler_chain)
}
GeglTileHandler *
-gegl_tile_handler_chain_add (GeglTileHandlerChain *tile_handler_chain,
+gegl_tile_handler_chain_add (GeglTileHandlerChain *chain,
GeglTileHandler *handler)
{
- tile_handler_chain->chain = g_slist_prepend (tile_handler_chain->chain,
- g_object_ref (handler));
+ GeglTileStorage *storage;
+ GeglTileHandlerCache *cache;
+
+ storage = _gegl_tile_handler_get_tile_storage ((GeglTileHandler *) chain);
+ cache = _gegl_tile_handler_get_cache ((GeglTileHandler *) chain);
+
+ _gegl_tile_handler_set_tile_storage (handler, storage);
+ _gegl_tile_handler_set_cache (handler, cache);
+
+ chain->chain = g_slist_prepend (chain->chain, g_object_ref (handler));
return handler;
}
diff --git a/gegl/buffer/gegl-tile-handler-empty.c b/gegl/buffer/gegl-tile-handler-empty.c
index d320f6d..c4b40fe 100644
--- a/gegl/buffer/gegl-tile-handler-empty.c
+++ b/gegl/buffer/gegl-tile-handler-empty.c
@@ -26,10 +26,10 @@
#include "gegl-buffer-private.h"
#include "gegl-tile-handler.h"
#include "gegl-tile-handler-empty.h"
-#include "gegl-tile-handler-cache.h"
#include "gegl-tile-backend.h"
-G_DEFINE_TYPE (GeglTileHandlerEmpty, gegl_tile_handler_empty, GEGL_TYPE_TILE_HANDLER)
+G_DEFINE_TYPE (GeglTileHandlerEmpty, gegl_tile_handler_empty,
+ GEGL_TYPE_TILE_HANDLER)
static void
finalize (GObject *object)
@@ -49,24 +49,17 @@ get_tile (GeglTileSource *gegl_tile_source,
gint y,
gint z)
{
- GeglTileSource *source = ((GeglTileHandler*)(gegl_tile_source))->source;
- GeglTileHandlerEmpty *empty = (GeglTileHandlerEmpty*) (gegl_tile_source);
+ GeglTileSource *source = ((GeglTileHandler *) gegl_tile_source)->source;
+ GeglTileHandlerEmpty *empty = (GeglTileHandlerEmpty *) gegl_tile_source;
GeglTile *tile = NULL;
if (source)
tile = gegl_tile_source_get_tile (source, x, y, z);
- if (tile != NULL)
+ if (tile)
return tile;
- tile = gegl_tile_dup (empty->tile);
- tile->x = x;
- tile->y = y;
- tile->z = z;
-
- if (empty->cache)
- gegl_tile_handler_cache_insert (empty->cache, tile, x, y, z);
-
- return tile;
+ return gegl_tile_handler_dup_tile (GEGL_TILE_HANDLER (empty),
+ empty->tile, x, y, z);
}
static gpointer
@@ -79,6 +72,7 @@ gegl_tile_handler_empty_command (GeglTileSource *buffer,
{
if (command == GEGL_TILE_GET)
return get_tile (buffer, x, y, z);
+
return gegl_tile_handler_source_command (buffer, command, x, y, z, data);
}
@@ -86,24 +80,25 @@ static void
gegl_tile_handler_empty_class_init (GeglTileHandlerEmptyClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = finalize;
+
+ gobject_class->finalize = finalize;
}
static void
gegl_tile_handler_empty_init (GeglTileHandlerEmpty *self)
{
- ((GeglTileSource*)self)->command = gegl_tile_handler_empty_command;
+ ((GeglTileSource *) self)->command = gegl_tile_handler_empty_command;
}
GeglTileHandler *
-gegl_tile_handler_empty_new (GeglTileBackend *backend,
- GeglTileHandlerCache *cache)
+gegl_tile_handler_empty_new (GeglTileBackend *backend)
{
GeglTileHandlerEmpty *empty = g_object_new (GEGL_TYPE_TILE_HANDLER_EMPTY, NULL);
gint tile_size = gegl_tile_backend_get_tile_size (backend);
+
empty->backend = backend;
- empty->cache = cache;
- empty->tile = gegl_tile_new (tile_size);
+ empty->tile = gegl_tile_new (tile_size);
memset (gegl_tile_get_data (empty->tile), 0x00, tile_size);
+
return (void*)empty;
}
diff --git a/gegl/buffer/gegl-tile-handler-empty.h b/gegl/buffer/gegl-tile-handler-empty.h
index db66eb1..02a744f 100644
--- a/gegl/buffer/gegl-tile-handler-empty.h
+++ b/gegl/buffer/gegl-tile-handler-empty.h
@@ -47,7 +47,6 @@ struct _GeglTileHandlerEmpty
GeglTile *tile;
GeglTileBackend *backend;
- GeglTileHandlerCache *cache;
};
struct _GeglTileHandlerEmptyClass
@@ -55,9 +54,9 @@ struct _GeglTileHandlerEmptyClass
GeglTileHandlerClass parent_class;
};
-GType gegl_tile_handler_empty_get_type (void) G_GNUC_CONST;
-GeglTileHandler *gegl_tile_handler_empty_new (GeglTileBackend *backend,
- GeglTileHandlerCache *cache);
+GType gegl_tile_handler_empty_get_type (void) G_GNUC_CONST;
+
+GeglTileHandler * gegl_tile_handler_empty_new (GeglTileBackend *backend);
G_END_DECLS
diff --git a/gegl/buffer/gegl-tile-handler-private.h b/gegl/buffer/gegl-tile-handler-private.h
new file mode 100644
index 0000000..46c94e3
--- /dev/null
+++ b/gegl/buffer/gegl-tile-handler-private.h
@@ -0,0 +1,30 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2006,2007 Ãyvind KolÃs <pippin gimp org>
+ */
+
+#ifndef __GEGL_TILE_HANDLER_PRIVATE_H__
+#define __GEGL_TILE_HANDLER_PRIVATE_H__
+
+void _gegl_tile_handler_set_tile_storage (GeglTileHandler *handler,
+ GeglTileStorage *tile_storage);
+void _gegl_tile_handler_set_cache (GeglTileHandler *handler,
+ GeglTileHandlerCache *cache);
+
+GeglTileStorage * _gegl_tile_handler_get_tile_storage (GeglTileHandler *handler);
+GeglTileHandlerCache * _gegl_tile_handler_get_cache (GeglTileHandler *handler);
+
+#endif
diff --git a/gegl/buffer/gegl-tile-handler-zoom.c b/gegl/buffer/gegl-tile-handler-zoom.c
index 8da214d..9ad6833 100644
--- a/gegl/buffer/gegl-tile-handler-zoom.c
+++ b/gegl/buffer/gegl-tile-handler-zoom.c
@@ -15,31 +15,29 @@
*
* Copyright 2006,2007 Ãyvind KolÃs <pippin gimp org>
*/
+
#include "config.h"
-#include <glib.h>
-#include <glib-object.h>
+
#include <string.h>
+#include <babl/babl.h>
+#include <glib-object.h>
+
#include "gegl-types.h"
#include "gegl-matrix.h"
#include "gegl-buffer-types.h"
#include "gegl-buffer-private.h"
#include "gegl-tile-handler.h"
-#include "gegl-tile-handler-zoom.h"
#include "gegl-tile-handler-cache.h"
-
-
-G_DEFINE_TYPE (GeglTileHandlerZoom, gegl_tile_handler_zoom, GEGL_TYPE_TILE_HANDLER)
-
-#include <babl/babl.h>
+#include "gegl-tile-handler-private.h"
+#include "gegl-tile-handler-zoom.h"
#include "gegl-tile-backend.h"
#include "gegl-tile-storage.h"
-void gegl_tile_handler_cache_insert (GeglTileHandlerCache *cache,
- GeglTile *tile,
- gint x,
- gint y,
- gint z);
+
+G_DEFINE_TYPE (GeglTileHandlerZoom, gegl_tile_handler_zoom,
+ GEGL_TYPE_TILE_HANDLER)
+
static inline void set_blank (GeglTile *dst_tile,
gint width,
gint height,
@@ -201,18 +199,17 @@ get_tile (GeglTileSource *gegl_tile_source,
gint y,
gint z)
{
- GeglTileSource *source = ((GeglTileHandler*)(gegl_tile_source))->source;
- GeglTileHandlerZoom *zoom = (GeglTileHandlerZoom*)(gegl_tile_source);
+ GeglTileSource *source = ((GeglTileHandler *) gegl_tile_source)->source;
+ GeglTileHandlerZoom *zoom = (GeglTileHandlerZoom *) gegl_tile_source;
GeglTile *tile = NULL;
const Babl *format = gegl_tile_backend_get_format (zoom->backend);
+ GeglTileStorage *tile_storage;
gint tile_width;
gint tile_height;
gint tile_size;
if (source)
- {
- tile = gegl_tile_source_get_tile (source, x, y, z);
- }
+ tile = gegl_tile_source_get_tile (source, x, y, z);
if (tile)
return tile;
@@ -223,11 +220,13 @@ get_tile (GeglTileSource *gegl_tile_source,
return NULL;
}
- if (z>zoom->tile_storage->seen_zoom)
- zoom->tile_storage->seen_zoom = z;
+ tile_storage = _gegl_tile_handler_get_tile_storage ((GeglTileHandler *) zoom);
- g_assert (zoom->backend);
- g_object_get (zoom->backend, "tile-width", &tile_width,
+ if (z > tile_storage->seen_zoom)
+ tile_storage->seen_zoom = z;
+
+ g_object_get (zoom->backend,
+ "tile-width", &tile_width,
"tile-height", &tile_height,
"tile-size", &tile_size,
NULL);
@@ -255,18 +254,9 @@ get_tile (GeglTileSource *gegl_tile_source,
}
g_assert (tile == NULL);
- if (tile == NULL)
- {
- tile = gegl_tile_new (tile_size);
- tile->x = x;
- tile->y = y;
- tile->z = z;
- tile->tile_storage = zoom->tile_storage;
+ tile = gegl_tile_handler_create_tile (GEGL_TILE_HANDLER (zoom), x, y, z);
- if (zoom->cache)
- gegl_tile_handler_cache_insert (zoom->cache, tile, x, y, z);
- }
gegl_tile_lock (tile);
for (i = 0; i < 2; i++)
@@ -312,20 +302,15 @@ gegl_tile_handler_zoom_class_init (GeglTileHandlerZoomClass *klass)
static void
gegl_tile_handler_zoom_init (GeglTileHandlerZoom *self)
{
- ((GeglTileSource*)self)->command = gegl_tile_handler_zoom_command;
- self->backend = NULL;
- self->tile_storage = NULL;
+ ((GeglTileSource *) self)->command = gegl_tile_handler_zoom_command;
}
GeglTileHandler *
-gegl_tile_handler_zoom_new (GeglTileBackend *backend,
- GeglTileStorage *tile_storage,
- GeglTileHandlerCache *cache)
+gegl_tile_handler_zoom_new (GeglTileBackend *backend)
{
GeglTileHandlerZoom *ret = g_object_new (GEGL_TYPE_TILE_HANDLER_ZOOM, NULL);
- ((GeglTileSource*)ret)->command = gegl_tile_handler_zoom_command;
+
ret->backend = backend;
- ret->tile_storage = tile_storage;
- ret->cache = cache;
+
return (void*)ret;
}
diff --git a/gegl/buffer/gegl-tile-handler-zoom.h b/gegl/buffer/gegl-tile-handler-zoom.h
index 749f6e1..b3fa0f2 100644
--- a/gegl/buffer/gegl-tile-handler-zoom.h
+++ b/gegl/buffer/gegl-tile-handler-zoom.h
@@ -42,7 +42,6 @@ typedef struct _GeglTileHandlerZoomClass GeglTileHandlerZoomClass;
struct _GeglTileHandlerZoom
{
GeglTileHandler parent_instance;
- GeglTileHandlerCache *cache;
GeglTileBackend *backend;
GeglTileStorage *tile_storage;
};
@@ -52,10 +51,9 @@ struct _GeglTileHandlerZoomClass
GeglTileHandlerClass parent_class;
};
-GType gegl_tile_handler_zoom_get_type (void) G_GNUC_CONST;
-GeglTileHandler *gegl_tile_handler_zoom_new (GeglTileBackend *backend,
- GeglTileStorage *tile_storage,
- GeglTileHandlerCache *cache);
+GType gegl_tile_handler_zoom_get_type (void) G_GNUC_CONST;
+
+GeglTileHandler * gegl_tile_handler_zoom_new (GeglTileBackend *backend);
G_END_DECLS
diff --git a/gegl/buffer/gegl-tile-handler.c b/gegl/buffer/gegl-tile-handler.c
index 601f770..3cfc27c 100644
--- a/gegl/buffer/gegl-tile-handler.c
+++ b/gegl/buffer/gegl-tile-handler.c
@@ -23,10 +23,16 @@
#include <glib-object.h>
#include "gegl-buffer-types.h"
-#include "gegl-tile-source.h"
-#include "gegl-tile-handler.h"
-#include "gegl-tile-handler-chain.h"
+#include "gegl-tile-handler-cache.h"
+#include "gegl-tile-handler-private.h"
#include "gegl-tile-storage.h"
+#include "gegl-buffer-private.h"
+
+struct _GeglTileHandlerPrivate
+{
+ GeglTileStorage *tile_storage;
+ GeglTileHandlerCache *cache;
+};
G_DEFINE_TYPE (GeglTileHandler, gegl_tile_handler, GEGL_TYPE_TILE_SOURCE)
@@ -87,22 +93,6 @@ gegl_tile_handler_get_property (GObject *gobject,
}
}
-void
-gegl_tile_handler_set_source (GeglTileHandler *handler,
- GeglTileSource *source)
-{
- if (handler->source != NULL)
- g_object_unref (handler->source);
-
- if (source == NULL)
- {
- handler->source = NULL;
- return;
- }
- handler->source = g_object_ref (source);
-
-}
-
static void
gegl_tile_handler_set_property (GObject *gobject,
guint property_id,
@@ -114,7 +104,7 @@ gegl_tile_handler_set_property (GObject *gobject,
switch (property_id)
{
case PROP_SOURCE:
- gegl_tile_handler_set_source (handler, GEGL_TILE_SOURCE (g_value_get_object (value)));
+ gegl_tile_handler_set_source (handler, g_value_get_object (value));
return;
default:
@@ -126,7 +116,7 @@ gegl_tile_handler_set_property (GObject *gobject,
static void
gegl_tile_handler_class_init (GeglTileHandlerClass *klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property = gegl_tile_handler_set_property;
gobject_class->get_property = gegl_tile_handler_get_property;
@@ -137,14 +127,100 @@ gegl_tile_handler_class_init (GeglTileHandlerClass *klass)
"GeglBuffer",
"The tilestore to be a facade for",
G_TYPE_OBJECT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_type_class_add_private (gobject_class, sizeof (GeglTileHandlerPrivate));
}
static void
gegl_tile_handler_init (GeglTileHandler *self)
{
- ((GeglTileSource*)self)->command = gegl_tile_handler_command;
- self->source = NULL;
+ ((GeglTileSource *) self)->command = gegl_tile_handler_command;
+
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GEGL_TYPE_TILE_HANDLER,
+ GeglTileHandlerPrivate);
}
+void
+gegl_tile_handler_set_source (GeglTileHandler *handler,
+ GeglTileSource *source)
+{
+ if (source != handler->source)
+ {
+ if (handler->source)
+ g_object_unref (handler->source);
+
+ handler->source = source;
+
+ if (handler->source)
+ g_object_ref (handler->source);
+ }
+}
+void
+_gegl_tile_handler_set_tile_storage (GeglTileHandler *handler,
+ GeglTileStorage *tile_storage)
+{
+ handler->priv->tile_storage = tile_storage;
+}
+
+void
+_gegl_tile_handler_set_cache (GeglTileHandler *handler,
+ GeglTileHandlerCache *cache)
+{
+ handler->priv->cache = cache;
+}
+
+GeglTileStorage *
+_gegl_tile_handler_get_tile_storage (GeglTileHandler *handler)
+{
+ return handler->priv->tile_storage;
+}
+
+GeglTileHandlerCache *
+_gegl_tile_handler_get_cache (GeglTileHandler *handler)
+{
+ return handler->priv->cache;
+}
+
+GeglTile *
+gegl_tile_handler_create_tile (GeglTileHandler *handler,
+ gint x,
+ gint y,
+ gint z)
+{
+ GeglTile *tile;
+
+ tile = gegl_tile_new (handler->priv->tile_storage->tile_size);
+
+ tile->tile_storage = handler->priv->tile_storage;
+ tile->x = x;
+ tile->y = y;
+ tile->z = z;
+
+ if (handler->priv->cache)
+ gegl_tile_handler_cache_insert (handler->priv->cache, tile, x, y, z);
+
+ return tile;
+}
+
+GeglTile *
+gegl_tile_handler_dup_tile (GeglTileHandler *handler,
+ GeglTile *tile,
+ gint x,
+ gint y,
+ gint z)
+{
+ tile = gegl_tile_dup (tile);
+
+ tile->x = x;
+ tile->y = y;
+ tile->z = z;
+
+ if (handler->priv->cache)
+ gegl_tile_handler_cache_insert (handler->priv->cache, tile, x, y, z);
+
+ return tile;
+}
diff --git a/gegl/buffer/gegl-tile-handler.h b/gegl/buffer/gegl-tile-handler.h
index a86e334..8d6f192 100644
--- a/gegl/buffer/gegl-tile-handler.h
+++ b/gegl/buffer/gegl-tile-handler.h
@@ -39,15 +39,18 @@ G_BEGIN_DECLS
#define GEGL_IS_TILE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEGL_TYPE_TILE_HANDLER))
#define GEGL_TILE_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEGL_TYPE_TILE_HANDLER, GeglTileHandlerClass))
-typedef struct _GeglTileHandlerClass GeglTileHandlerClass;
+typedef struct _GeglTileHandlerClass GeglTileHandlerClass;
+typedef struct _GeglTileHandlerPrivate GeglTileHandlerPrivate;
struct _GeglTileHandler
{
GeglTileSource parent_instance;
- GeglTileSource *source; /* The source of the data, which we can rely on if
- our command handler doesn't handle a command, this
- is typically done with gegl_tile_handler_source_command
- passing ourself as the first parameter. */
+ GeglTileSource *source; /* The source of the data, which we can rely
+ on if our command handler doesn't handle
+ a command, this is typically done with
+ gegl_tile_handler_source_command passing
+ ourself as the first parameter. */
+ GeglTileHandlerPrivate *priv;
};
struct _GeglTileHandlerClass
@@ -55,17 +58,24 @@ struct _GeglTileHandlerClass
GeglTileSourceClass parent_class;
};
-GType gegl_tile_handler_get_type (void) G_GNUC_CONST;
+GType gegl_tile_handler_get_type (void) G_GNUC_CONST;
-void
-gegl_tile_handler_set_source (GeglTileHandler *handler,
- GeglTileSource *source);
+void gegl_tile_handler_set_source (GeglTileHandler *handler,
+ GeglTileSource *source);
-
-#define gegl_tile_handler_get_source(handler) (((GeglTileHandler*)handler)->source)
+#define gegl_tile_handler_get_source(handler) (((GeglTileHandler*)handler)->source)
#define gegl_tile_handler_source_command(handler,command,x,y,z,data) (gegl_tile_handler_get_source(handler)?gegl_tile_source_command(gegl_tile_handler_get_source(handler), command, x, y, z, data):NULL)
+GeglTile * gegl_tile_handler_create_tile (GeglTileHandler *handler,
+ gint x,
+ gint y,
+ gint z);
+GeglTile * gegl_tile_handler_dup_tile (GeglTileHandler *handler,
+ GeglTile *tile,
+ gint x,
+ gint y,
+ gint z);
G_END_DECLS
diff --git a/gegl/buffer/gegl-tile-storage.c b/gegl/buffer/gegl-tile-storage.c
index 8b7514b..db1a369 100644
--- a/gegl/buffer/gegl-tile-storage.c
+++ b/gegl/buffer/gegl-tile-storage.c
@@ -32,6 +32,7 @@
#include "gegl-tile-handler-zoom.h"
#include "gegl-tile-handler-cache.h"
#include "gegl-tile-handler-log.h"
+#include "gegl-tile-handler-private.h"
#include "gegl-types-internal.h"
#include "gegl-utils.h"
#include "gegl-config.h"
@@ -72,9 +73,9 @@ gegl_tile_storage_new (GeglTileBackend *backend)
GeglTileStorage *tile_storage = g_object_new (GEGL_TYPE_TILE_STORAGE, NULL);
GeglTileHandlerChain *tile_handler_chain;
GeglTileHandler *handler;
+ GeglTileHandler *cache = NULL;
GeglTileHandler *empty = NULL;
GeglTileHandler *zoom = NULL;
- GeglTileHandlerCache *cache = NULL;
tile_storage->seen_zoom = 0;
tile_storage->mutex = g_mutex_new ();
@@ -119,10 +120,14 @@ gegl_tile_storage_new (GeglTileBackend *backend)
#endif
cache = gegl_tile_handler_cache_new ();
- empty = gegl_tile_handler_empty_new (backend, cache);
- zoom = gegl_tile_handler_zoom_new (backend, tile_storage, cache);
+ empty = gegl_tile_handler_empty_new (backend);
+ zoom = gegl_tile_handler_zoom_new (backend);
- gegl_tile_handler_chain_add (tile_handler_chain, (void*)cache);
+ /* set storage and cache on ourself so chain_add() can use it */
+ _gegl_tile_handler_set_tile_storage (handler, tile_storage);
+ _gegl_tile_handler_set_cache (handler, (GeglTileHandlerCache *) cache);
+
+ gegl_tile_handler_chain_add (tile_handler_chain, cache);
gegl_tile_handler_chain_add (tile_handler_chain, zoom);
gegl_tile_handler_chain_add (tile_handler_chain, empty);
@@ -136,8 +141,8 @@ gegl_tile_storage_new (GeglTileBackend *backend)
g_object_new (GEGL_TYPE_TILE_HANDLER_LOG, NULL));
#endif
- tile_storage->cache = cache;
- cache->tile_storage = tile_storage;
+ tile_storage->cache = (GeglTileHandlerCache *) cache;
+ ((GeglTileHandlerCache *) cache)->tile_storage = tile_storage;
gegl_tile_handler_chain_bind (tile_handler_chain);
((GeglTileBackend *)gegl_buffer_backend2 ((void*)tile_storage))->priv->storage = (gpointer)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]