[gegl] buffer: removed properties from tile-storage
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: removed properties from tile-storage
- Date: Tue, 20 Jul 2010 20:35:40 +0000 (UTC)
commit fbe7470735689d834c2d8d6b3e0a32a381c856fc
Author: �yvind Kolås <pippin gimp org>
Date: Tue Jul 20 03:22:27 2010 +0100
buffer: removed properties from tile-storage
gegl/buffer/gegl-buffer-index.h | 2 +-
gegl/buffer/gegl-buffer-save.c | 2 +-
gegl/buffer/gegl-buffer.c | 35 +------
gegl/buffer/gegl-tile-storage.c | 202 +++++---------------------------------
gegl/buffer/gegl-tile-storage.h | 7 +-
5 files changed, 41 insertions(+), 207 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-index.h b/gegl/buffer/gegl-buffer-index.h
index 5f6e4b9..9c2f970 100644
--- a/gegl/buffer/gegl-buffer-index.h
+++ b/gegl/buffer/gegl-buffer-index.h
@@ -118,7 +118,7 @@ void gegl_buffer_header_init (GeglBufferHeader *header,
gint tile_width,
gint tile_height,
gint bpp,
- Babl* format);
+ const Babl* format);
void gegl_tile_entry_destroy (GeglBufferTile *entry);
diff --git a/gegl/buffer/gegl-buffer-save.c b/gegl/buffer/gegl-buffer-save.c
index ba5149a..37b89e7 100644
--- a/gegl/buffer/gegl-buffer-save.c
+++ b/gegl/buffer/gegl-buffer-save.c
@@ -195,7 +195,7 @@ gegl_buffer_header_init (GeglBufferHeader *header,
gint tile_width,
gint tile_height,
gint bpp,
- Babl* format)
+ const Babl* format)
{
memcpy (header->magic, "GEGL", 4);
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index f7d6a0e..d8cc450 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -510,22 +510,12 @@ gegl_buffer_constructor (GType type,
else if (buffer->path)
{
GeglBufferHeader *header;
- GeglTileSource *storage;
+ void *storage;
if (buffer->format)
- {
- storage = GEGL_TILE_SOURCE (g_object_new (GEGL_TYPE_TILE_STORAGE,
- "path", buffer->path,
- "format", buffer->format,
- NULL));
- }
+ storage = gegl_tile_storage_new (-1, -1, buffer->format, buffer->path);
else
- {
- storage = GEGL_TILE_SOURCE (g_object_new (GEGL_TYPE_TILE_STORAGE,
- "path", buffer->path,
- "format", babl_format ("RGBA float"),
- NULL));
- }
+ storage = gegl_tile_storage_new (-1, -1, babl_format ("RGBA float"), buffer->path);
source = g_object_new (GEGL_TYPE_BUFFER, "source", storage, NULL);
@@ -1048,10 +1038,6 @@ gegl_buffer_destroy (GeglBuffer *buffer)
}
-
-
-
-
static GeglBuffer *
gegl_buffer_new_from_format (const void *babl_format,
gint x,
@@ -1069,12 +1055,8 @@ gegl_buffer_new_from_format (const void *babl_format,
!gegl_config()->swap ||
g_str_equal (gegl_config()->swap, "RAM") ||
g_str_equal (gegl_config()->swap, "ram"))
- {
- tile_storage = g_object_new (GEGL_TYPE_TILE_STORAGE,
- "format", babl_format,
- "tile-width", tile_width,
- "tile-height", tile_height,
- NULL);
+ {
+ tile_storage = gegl_tile_storage_new (tile_width, tile_height, babl_format, NULL);
}
else
{
@@ -1095,12 +1077,7 @@ gegl_buffer_new_from_format (const void *babl_format,
path = g_build_filename (gegl_config()->swap, filename, NULL);
g_free (filename);
- tile_storage = g_object_new (GEGL_TYPE_TILE_STORAGE,
- "format", babl_format,
- "tile-width", tile_width,
- "tile-height", tile_height,
- "path", path,
- NULL);
+ tile_storage = gegl_tile_storage_new (tile_width, tile_height, babl_format, path);
g_free (path);
}
diff --git a/gegl/buffer/gegl-tile-storage.c b/gegl/buffer/gegl-tile-storage.c
index 8cfe362..2691b32 100644
--- a/gegl/buffer/gegl-tile-storage.c
+++ b/gegl/buffer/gegl-tile-storage.c
@@ -43,123 +43,12 @@ static GObjectClass * parent_class = NULL;
enum
{
- PROP_0,
- PROP_WIDTH,
- PROP_HEIGHT,
- PROP_TILE_WIDTH,
- PROP_TILE_HEIGHT,
- PROP_TILE_SIZE,
- PROP_FORMAT,
- PROP_PX_SIZE,
- PROP_PATH
-};
-
-enum
-{
CHANGED,
LAST_SIGNAL
};
guint gegl_tile_storage_signals[LAST_SIGNAL] = { 0 };
-static void
-get_property (GObject *gobject,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GeglTileStorage *tile_storage = GEGL_TILE_STORAGE (gobject);
-
- switch (property_id)
- {
- case PROP_WIDTH:
- g_value_set_int (value, tile_storage->width);
- break;
-
- case PROP_HEIGHT:
- g_value_set_int (value, tile_storage->height);
- break;
-
- case PROP_TILE_WIDTH:
- g_value_set_int (value, tile_storage->tile_width);
- break;
-
- case PROP_TILE_HEIGHT:
- g_value_set_int (value, tile_storage->tile_height);
- break;
-
- case PROP_TILE_SIZE:
- g_value_set_int (value, tile_storage->tile_size);
- break;
-
- case PROP_PX_SIZE:
- g_value_set_int (value, tile_storage->px_size);
- break;
-
- case PROP_PATH:
- g_value_set_string (value, tile_storage->path);
- break;
-
- case PROP_FORMAT:
- g_value_set_pointer (value, tile_storage->format);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
- break;
- }
-}
-
-static void
-set_property (GObject *gobject,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GeglTileStorage *tile_storage = GEGL_TILE_STORAGE (gobject);
-
- switch (property_id)
- {
- case PROP_WIDTH:
- tile_storage->width = g_value_get_int (value);
- return;
-
- case PROP_HEIGHT:
- tile_storage->height = g_value_get_int (value);
- return;
-
- case PROP_TILE_WIDTH:
- tile_storage->tile_width = g_value_get_int (value);
- break;
-
- case PROP_TILE_HEIGHT:
- tile_storage->tile_height = g_value_get_int (value);
- break;
-
- case PROP_TILE_SIZE:
- tile_storage->tile_size = g_value_get_int (value);
- break;
-
- case PROP_PX_SIZE:
- tile_storage->px_size = g_value_get_int (value);
- break;
-
- case PROP_PATH:
- if (tile_storage->path)
- g_free (tile_storage->path);
- tile_storage->path = g_value_dup_string (value);
- break;
-
- case PROP_FORMAT:
- tile_storage->format = g_value_get_pointer (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
- break;
- }
-}
-
static gboolean
tile_storage_idle (gpointer data)
{
@@ -176,13 +65,13 @@ tile_storage_idle (gpointer data)
GeglTileBackend *gegl_buffer_backend (GObject *buffer);
-static GObject *
-gegl_tile_storage_constructor (GType type,
- guint n_params,
- GObjectConstructParam *params)
+GeglTileStorage *
+gegl_tile_storage_new (gint tile_width,
+ gint tile_height,
+ const Babl *format,
+ const gchar *path)
{
- GObject *object;
- GeglTileStorage *tile_storage;
+ GeglTileStorage *tile_storage = g_object_new (GEGL_TYPE_TILE_STORAGE, NULL);
GeglTileHandlerChain *tile_handler_chain;
GeglTileHandler *handler;
GeglTileBackend *backend = NULL;
@@ -190,13 +79,24 @@ gegl_tile_storage_constructor (GType type,
GeglTileHandler *zoom = NULL;
GeglTileHandlerCache *cache = NULL;
- object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
+ if (tile_width <= 0)
+ tile_width = 128;
+ if (tile_height <= 0)
+ tile_height = 64;
+
+ tile_storage->seen_zoom = 0;
+ tile_storage->mutex = g_mutex_new ();
+ tile_storage->width = G_MAXINT;
+ tile_storage->height = G_MAXINT;
+ tile_storage->tile_width = tile_width;
+ tile_storage->tile_height = tile_height;
+ tile_storage->format = format;
+ if (path)
+ tile_storage->path = g_strdup (path);
- tile_storage = GEGL_TILE_STORAGE (object);
tile_handler_chain = GEGL_TILE_HANDLER_CHAIN (tile_storage);
handler = GEGL_HANDLER (tile_storage);
-
if (tile_storage->path != NULL)
{
#if 1
@@ -242,10 +142,12 @@ gegl_tile_storage_constructor (GType type,
g_object_unref (handler->source); /* eeek */
backend = GEGL_TILE_BACKEND (handler->source);
+#if 0
if (g_getenv("GEGL_LOG_TILE_BACKEND")||
g_getenv("GEGL_TILE_LOG"))
gegl_tile_handler_chain_add (tile_handler_chain,
g_object_new (GEGL_TYPE_TILE_HANDLER_LOG, NULL));
+#endif
cache = gegl_tile_handler_cache_new ();
empty = gegl_tile_handler_empty_new (backend, cache);
@@ -255,28 +157,24 @@ gegl_tile_storage_constructor (GType type,
gegl_tile_handler_chain_add (tile_handler_chain, zoom);
gegl_tile_handler_chain_add (tile_handler_chain, empty);
+#if 0
if (g_getenv("GEGL_LOG_TILE_CACHE"))
gegl_tile_handler_chain_add (tile_handler_chain,
g_object_new (GEGL_TYPE_TILE_HANDLER_LOG, NULL));
+#endif
tile_storage->cache = cache;
-
gegl_tile_handler_chain_bind (tile_handler_chain);
- {
- GeglTileBackend *backend;
- backend = gegl_buffer_backend (object);
- backend->storage = (gpointer)object;
- }
+ ((GeglTileBackend *)gegl_buffer_backend ((void*)tile_storage))->storage = (gpointer)
+ tile_storage;
tile_storage->idle_swapper = g_timeout_add_full (G_PRIORITY_LOW,
250,
tile_storage_idle,
tile_storage,
NULL);
- tile_storage->seen_zoom = 0;
- tile_storage->mutex = g_mutex_new ();
- return object;
+ return tile_storage;
}
static void
@@ -300,52 +198,7 @@ gegl_tile_storage_class_init (GeglTileStorageClass *class)
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
parent_class = g_type_class_peek_parent (class);
- gobject_class->constructor = gegl_tile_storage_constructor;
gobject_class->finalize = gegl_tile_storage_finalize;
- gobject_class->set_property = set_property;
- gobject_class->get_property = get_property;
-
- g_object_class_install_property (gobject_class, PROP_TILE_WIDTH,
- g_param_spec_int ("tile-width", "tile-width", "width of a tile in pixels",
- 0, G_MAXINT, 128,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (gobject_class, PROP_TILE_HEIGHT,
- g_param_spec_int ("tile-height", "tile-height", "height of a tile in pixels",
- 0, G_MAXINT, 64,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (gobject_class, PROP_TILE_SIZE,
- g_param_spec_int ("tile-size", "tile-size", "size of a tile in bytes",
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_PX_SIZE,
- g_param_spec_int ("px-size", "px-size", "size of a a pixel in bytes",
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_WIDTH,
- g_param_spec_int ("width", "width", "pixel width of buffer",
- 0, G_MAXINT, G_MAXINT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (gobject_class, PROP_HEIGHT,
- g_param_spec_int ("height", "height", "pixel height of buffer",
- 0, G_MAXINT, G_MAXINT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (gobject_class, PROP_PATH,
- g_param_spec_string ("path",
- "path",
- "The filesystem directory with swap for this sparse tile store, NULL to make this be a heap tile_storage.",
- NULL,
- G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
-
-
- g_object_class_install_property (gobject_class, PROP_FORMAT,
- g_param_spec_pointer ("format", "format", "babl format",
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
gegl_tile_storage_signals[CHANGED] =
g_signal_new ("changed",
@@ -356,7 +209,6 @@ gegl_tile_storage_class_init (GeglTileStorageClass *class)
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1,
GEGL_TYPE_RECTANGLE);
-
}
static void
diff --git a/gegl/buffer/gegl-tile-storage.h b/gegl/buffer/gegl-tile-storage.h
index cc9d214..e4d34ae 100644
--- a/gegl/buffer/gegl-tile-storage.h
+++ b/gegl/buffer/gegl-tile-storage.h
@@ -34,7 +34,7 @@ struct _GeglTileStorage
GeglTileHandlerChain parent_instance;
GeglTileHandlerCache *cache;
GMutex *mutex;
- Babl *format;
+ const Babl *format;
gint tile_width;
gint tile_height;
gint tile_size;
@@ -53,5 +53,10 @@ struct _GeglTileStorageClass
};
GType gegl_tile_storage_get_type (void) G_GNUC_CONST;
+GeglTileStorage *
+gegl_tile_storage_new (gint tile_width,
+ gint tile_height,
+ const Babl *format,
+ const gchar *path);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]