void free_image_cache (struct frame *);
void clear_image_caches (Lisp_Object);
void mark_image_cache (struct image_cache *);
+void image_prune_animation_caches (bool);
bool valid_image_p (Lisp_Object);
void prepare_image_for_display (struct frame *, struct image *);
ptrdiff_t lookup_image (struct frame *, Lisp_Object, int);
else
clear_image_cache (decode_window_system_frame (filter), Qt);
+ /* Also clear the animation caches. */
+ image_prune_animation_caches (true);
+
return Qnil;
}
return cache;
}
-/* Discard cached images that haven't been used for a minute. */
+/* Discard cached images that haven't been used for a minute. If
+ CLEAR, remove all animation cache entries. */
static void
-anim_prune_animation_cache (void)
+anim_prune_animation_cache (bool clear)
{
struct anim_cache **pcache = &anim_cache;
struct timespec old = timespec_sub (current_timespec (),
while (*pcache)
{
struct anim_cache *cache = *pcache;
- if (timespec_cmp (old, cache->update_time) <= 0)
- pcache = &cache->next;
- else
+ if (clear || timespec_cmp (old, cache->update_time) > 0)
{
if (cache->handle)
cache->destructor (cache);
*pcache = cache->next;
xfree (cache);
}
+ else
+ pcache = &cache->next;
}
}
struct anim_cache *cache;
struct anim_cache **pcache = &anim_cache;
- anim_prune_animation_cache ();
+ anim_prune_animation_cache (false);
while (1)
{
return cache;
}
-/* Discard cached images that haven't been used for a minute. */
+/* Discard cached images that haven't been used for a minute. If
+ CLEAR, discard all cached animated images. */
static void
-imagemagick_prune_animation_cache (void)
+imagemagick_prune_animation_cache (bool clear)
{
struct animation_cache **pcache = &animation_cache;
struct timespec old = timespec_sub (current_timespec (),
while (*pcache)
{
struct animation_cache *cache = *pcache;
- if (timespec_cmp (old, cache->update_time) <= 0)
- pcache = &cache->next;
- else
+ if (clear || timespec_cmp (old, cache->update_time) > 0)
{
if (cache->wand)
DestroyMagickWand (cache->wand);
*pcache = cache->next;
xfree (cache);
}
+ else
+ pcache = &cache->next;
}
}
struct animation_cache *cache;
struct animation_cache **pcache = &animation_cache;
- imagemagick_prune_animation_cache ();
+ imagemagick_prune_animation_cache (false);
while (1)
{
return NULL;
}
+/* Prune the animation caches. If CLEAR, remove all animation cache
+ entries. */
+void
+image_prune_animation_caches (bool clear)
+{
+#if defined (HAVE_WEBP) || defined (HAVE_GIF)
+ anim_prune_animation_cache (clear);
+#endif
+#ifdef HAVE_IMAGEMAGICK
+ imagemagick_prune_animation_cache (clear);
+#endif
+}
void
syms_of_image (void)