Commit 4aa710fa authored by Ell's avatar Ell

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
parent f9df6a84
......@@ -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;
......
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