[gegl] Remove unused TileStorageCache code
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Remove unused TileStorageCache code
- Date: Fri, 29 Mar 2013 19:03:27 +0000 (UTC)
commit 406e74a6b84eb676f70a1c755a5d729f750edf0f
Author: Daniel Sabo <DanielSabo gmail com>
Date: Thu Mar 28 15:07:07 2013 -0700
Remove unused TileStorageCache code
gegl/buffer/gegl-buffer.c | 156 +++++++++++++--------------------------------
gegl/gegl-init.c | 3 -
2 files changed, 45 insertions(+), 114 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index 207f627..ba85aa1 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -106,6 +106,12 @@ enum {
LAST_SIGNAL
};
+static GeglTileStorage *
+gegl_tile_storage_new_from_format (const void *babl_fmt,
+ gint tile_width,
+ gint tile_height,
+ gboolean use_ram);
+
static GeglBuffer *gegl_buffer_new_from_format (const void *babl_fmt,
gint x,
gint y,
@@ -1209,124 +1215,52 @@ gegl_buffer_create_sub_buffer (GeglBuffer *buffer,
NULL);
}
-
-typedef struct TileStorageCacheItem {
- GeglTileStorage *storage;
- gboolean ram;
- gint tile_width;
- gint tile_height;
- const void *babl_fmt;
-} TileStorageCacheItem;
-
-static GMutex storage_cache_mutex = { 0, };
-static GSList *storage_cache = NULL;
-
-/* returns TRUE if it could be done */
-gboolean gegl_tile_storage_cached_release (GeglTileStorage *storage);
-gboolean gegl_tile_storage_cached_release (GeglTileStorage *storage)
-{
- TileStorageCacheItem *item = g_object_get_data (G_OBJECT (storage), "storage-cache-item");
-
- if (!item)
- return FALSE;
- g_mutex_lock (&storage_cache_mutex);
- storage_cache = g_slist_prepend (storage_cache, item);
- g_mutex_unlock (&storage_cache_mutex);
- return TRUE;
-}
-
-void gegl_tile_storage_cache_cleanup (void);
-void gegl_tile_storage_cache_cleanup (void)
-{
- g_mutex_lock (&storage_cache_mutex);
- for (;storage_cache; storage_cache = g_slist_remove (storage_cache, storage_cache->data))
- {
- TileStorageCacheItem *item = storage_cache->data;
- g_object_unref (item->storage);
- }
- g_mutex_unlock (&storage_cache_mutex);
-}
-
static GeglTileStorage *
-gegl_tile_storage_new_cached (gint tile_width, gint tile_height,
- const void *babl_fmt, gboolean use_ram)
+gegl_tile_storage_new_from_format (const void *babl_fmt,
+ gint tile_width,
+ gint tile_height,
+ gboolean use_ram)
{
GeglTileStorage *storage = NULL;
- GSList *iter;
- g_mutex_lock (&storage_cache_mutex);
- for (iter = storage_cache; iter; iter = iter->next)
+
+ if (use_ram ||
+ !gegl_config()->swap ||
+ g_str_equal (gegl_config()->swap, "RAM") ||
+ g_str_equal (gegl_config()->swap, "ram"))
{
- TileStorageCacheItem *item = iter->data;
- if (item->babl_fmt == babl_fmt &&
- item->tile_width == tile_width &&
- item->tile_height == tile_height &&
- item->ram == use_ram)
- {
- storage = item->storage;
- storage_cache = g_slist_remove (storage_cache, item);
- break;
- }
+ GeglTileBackend *backend;
+ backend = g_object_new (GEGL_TYPE_TILE_BACKEND_RAM,
+ "tile-width", tile_width,
+ "tile-height", tile_height,
+ "format", babl_fmt,
+ NULL);
+ storage = gegl_tile_storage_new (backend);
+ g_object_unref (backend);
}
-
- if (!storage)
+ else
{
- TileStorageCacheItem *item = g_new0 (TileStorageCacheItem, 1);
-
- item->tile_width = tile_width;
- item->tile_height = tile_height;
- item->babl_fmt = babl_fmt;
-
- if (use_ram ||
- !gegl_config()->swap ||
- g_str_equal (gegl_config()->swap, "RAM") ||
- g_str_equal (gegl_config()->swap, "ram"))
- {
- GeglTileBackend *backend;
- item->ram = TRUE;
- backend = g_object_new (GEGL_TYPE_TILE_BACKEND_RAM,
- "tile-width", tile_width,
- "tile-height", tile_height,
- "format", babl_fmt,
- NULL);
- storage = gegl_tile_storage_new (backend);
- g_object_unref (backend);
- }
- else
- {
- static gint no = 1;
- GeglTileBackend *backend;
-
- gchar *filename;
- gchar *path;
- item->ram = FALSE;
-
-#if 0
- filename = g_strdup_printf ("GEGL-%i-%s-%i.swap",
- getpid (),
- babl_name ((Babl *) babl_fmt),
- no++);
-#endif
-
- filename = g_strdup_printf ("%i-%i", getpid(), no);
- g_atomic_int_inc (&no);
- path = g_build_filename (gegl_config()->swap, filename, NULL);
- g_free (filename);
-
- backend = g_object_new (GEGL_TYPE_TILE_BACKEND_FILE,
- "tile-width", tile_width,
- "tile-height", tile_height,
- "format", babl_fmt,
- "path", path,
- NULL);
- storage = gegl_tile_storage_new (backend);
- g_object_unref (backend);
- g_free (path);
- }
- item->storage = storage;
- g_object_set_data_full (G_OBJECT (storage), "storage-cache-item", item, g_free);
+ static gint no = 1;
+ GeglTileBackend *backend;
+
+ gchar *filename;
+ gchar *path;
+
+ filename = g_strdup_printf ("%i-%i", getpid(), no);
+ g_atomic_int_inc (&no);
+ path = g_build_filename (gegl_config()->swap, filename, NULL);
+ g_free (filename);
+
+ backend = g_object_new (GEGL_TYPE_TILE_BACKEND_FILE,
+ "tile-width", tile_width,
+ "tile-height", tile_height,
+ "format", babl_fmt,
+ "path", path,
+ NULL);
+ storage = gegl_tile_storage_new (backend);
+ g_object_unref (backend);
+ g_free (path);
}
- g_mutex_unlock (&storage_cache_mutex);
return storage;
}
@@ -1343,7 +1277,7 @@ gegl_buffer_new_from_format (const void *babl_fmt,
GeglTileStorage *tile_storage;
GeglBuffer *buffer;
- tile_storage = gegl_tile_storage_new_cached (tile_width, tile_height, babl_fmt, use_ram);
+ tile_storage = gegl_tile_storage_new_from_format (babl_fmt, tile_width, tile_height, use_ram);
buffer = g_object_new (GEGL_TYPE_BUFFER,
"source", tile_storage,
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index 733a7dc..86a377b 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -351,8 +351,6 @@ static void swap_clean (void)
}
}
-void gegl_tile_storage_cache_cleanup (void);
-
void
gegl_exit (void)
{
@@ -366,7 +364,6 @@ gegl_exit (void)
timing = gegl_ticks ();
- gegl_tile_storage_cache_cleanup ();
gegl_tile_cache_destroy ();
gegl_operation_gtype_cleanup ();
gegl_extension_handler_cleanup ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]