mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-18 18:05:07 +00:00
Add new function 'image-cache-size'
* src/image.c (Fimage_cache_size): New defun. (image_frame_cache_size): New function.
This commit is contained in:
parent
14ffab8263
commit
9d598ef93c
@ -6577,6 +6577,12 @@ except when you explicitly clear it. This mode can be useful for
|
||||
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
|
||||
|
4
etc/NEWS
4
etc/NEWS
@ -1089,6 +1089,10 @@ If 'shr-width' is non-nil, it overrides this variable.
|
||||
|
||||
** 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
|
||||
|
35
src/image.c
35
src/image.c
@ -1792,6 +1792,40 @@ which is then usually a filename. */)
|
||||
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,
|
||||
@ -10703,6 +10737,7 @@ non-numeric, there is no explicit limit on the size of images. */);
|
||||
defsubr (&Simage_size);
|
||||
defsubr (&Simage_mask_p);
|
||||
defsubr (&Simage_metadata);
|
||||
defsubr (&Simage_cache_size);
|
||||
|
||||
#ifdef GLYPH_DEBUG
|
||||
defsubr (&Simagep);
|
||||
|
Loading…
Reference in New Issue
Block a user