debugging.
@end defvar
+@defun image-cache-size
+This function returns the total size of the current image cache, in
+bytes. An image of size 200x100 with 24 bits per color will have a
+cache size of 60000 bytes, for instance.
+@end defun
+
@node Xwidgets
@section Embedded Native Widgets
@cindex xwidget
** Images
++++
+*** New function 'image-cache-size'.
+This function returns the size of the current image cache, in bytes.
+
---
*** Animated images stop automatically under high CPU pressure sooner.
Previously, an animated image would stop animating if any single image
return Qnil;
}
+static int
+image_frame_cache_size (struct frame *f)
+{
+ struct image_cache *c = FRAME_IMAGE_CACHE (f);
+ int total = 0;
+
+ if (!c)
+ return 0;
+
+ for (ptrdiff_t i = 0; i < c->used; ++i)
+ {
+ struct image *img = c->images[i];
+
+ if (img)
+ total += img->pixmap->width * img->pixmap->height *
+ img->pixmap->bits_per_pixel / 8;
+ }
+ return total;
+}
+
+DEFUN ("image-cache-size", Fimage_cache_size, Simage_cache_size, 0, 0, 0,
+ doc: /* Return the size of the image cache. */)
+ (void)
+{
+ Lisp_Object tail, frame;
+ int total = 0;
+
+ FOR_EACH_FRAME (tail, frame)
+ if (FRAME_WINDOW_P (XFRAME (frame)))
+ total += image_frame_cache_size (XFRAME (frame));
+
+ return make_int (total);
+}
+
DEFUN ("image-flush", Fimage_flush, Simage_flush,
1, 2, 0,
defsubr (&Simage_size);
defsubr (&Simage_mask_p);
defsubr (&Simage_metadata);
+ defsubr (&Simage_cache_size);
#ifdef GLYPH_DEBUG
defsubr (&Simagep);