[gegl] buffer: don't damage pyramid when inserting new tile to cache
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: don't damage pyramid when inserting new tile to cache
- Date: Wed, 28 Nov 2018 14:22:58 +0000 (UTC)
commit 4aa710faa747c7a3885f607d6810ed3bded08057
Author: Ell <ell_se yahoo com>
Date: Wed Nov 28 09:08:38 2018 -0500
buffer: don't damage pyramid when inserting new tile to cache
In gegl_tile_handler_cache_insert(), when there's already a cached
tile at the same coordinates as the new tile, merely remove the old
tile from the cache, but don't damage the corresponding area of the
pyramid. We already explicitly damage the pyramid at all the
relevant points, so doing this again in cache_insert() is
superfluous. Moreover, the code in gegl_tile_handler_cache_void()
that is responsible for the damaging is erroneous, and fixing it
(as done in the next few commits) would make damaging the pyramid
in cache_insert() excessive, breaking a few tests.
.mtsync.log
gegl/buffer/gegl-tile-handler-cache.c | 57 ++++++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 17 deletions(-)
---
diff --git a/gegl/buffer/gegl-tile-handler-cache.c b/gegl/buffer/gegl-tile-handler-cache.c
index f57e5b65b..ce1395405 100644
--- a/gegl/buffer/gegl-tile-handler-cache.c
+++ b/gegl/buffer/gegl-tile-handler-cache.c
@@ -745,6 +745,44 @@ gegl_tile_handler_cache_copy (GeglTileHandlerCache *cache,
}
+static void
+gegl_tile_handler_cache_remove_item (GeglTileHandlerCache *cache,
+ CacheItem *item)
+{
+ if (g_atomic_int_dec_and_test (gegl_tile_n_cached_clones (item->tile)))
+ g_atomic_pointer_add (&cache_total, -item->tile->size);
+ g_atomic_pointer_add (&cache_total_uncloned, -item->tile->size);
+
+ g_queue_unlink (&cache->queue, &item->link);
+ g_hash_table_remove (cache->items, item);
+
+ if (g_queue_is_empty (&cache->queue))
+ cache->time = cache->stamp = 0;
+
+ item->tile->tile_storage = NULL;
+ gegl_tile_unref (item->tile);
+
+ g_slice_free (CacheItem, item);
+}
+
+static void
+gegl_tile_handler_cache_remove (GeglTileHandlerCache *cache,
+ gint x,
+ gint y,
+ gint z)
+{
+ CacheItem *item;
+
+ item = cache_lookup (cache, x, y, z);
+
+ if (item)
+ {
+ drop_hot_tile (item->tile);
+
+ gegl_tile_handler_cache_remove_item (cache, item);
+ }
+}
+
static void
gegl_tile_handler_cache_void (GeglTileHandlerCache *cache,
gint x,
@@ -760,22 +798,7 @@ gegl_tile_handler_cache_void (GeglTileHandlerCache *cache,
drop_hot_tile (item->tile);
if (gegl_tile_damage (item->tile, damage))
- {
- if (g_atomic_int_dec_and_test (gegl_tile_n_cached_clones (item->tile)))
- g_atomic_pointer_add (&cache_total, -item->tile->size);
- g_atomic_pointer_add (&cache_total_uncloned, -item->tile->size);
-
- g_queue_unlink (&cache->queue, &item->link);
- g_hash_table_remove (cache->items, item);
-
- if (g_queue_is_empty (&cache->queue))
- cache->time = cache->stamp = 0;
-
- item->tile->tile_storage = NULL;
- gegl_tile_unref (item->tile);
-
- g_slice_free (CacheItem, item);
- }
+ gegl_tile_handler_cache_remove_item (cache, item);
}
}
@@ -797,7 +820,7 @@ gegl_tile_handler_cache_insert (GeglTileHandlerCache *cache,
item->z = z;
// XXX : remove entry if it already exists
- gegl_tile_handler_cache_void (cache, x, y, z, ~(guint64) 0);
+ gegl_tile_handler_cache_remove (cache, x, y, z);
tile->x = x;
tile->y = y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]