diff options
| author | Lars Ingebrigtsen | 2020-12-11 14:30:44 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2020-12-11 14:30:44 +0100 |
| commit | 9d598ef93cbebe59f1d3a91f4fda35d3e00f36a9 (patch) | |
| tree | 7263ecbe937978a293dd9e3fe405d3b8941da6ba /src/image.c | |
| parent | 14ffab8263eb219fe0c49ad4e0a3476316c542c0 (diff) | |
| download | emacs-9d598ef93cbebe59f1d3a91f4fda35d3e00f36a9.tar.gz emacs-9d598ef93cbebe59f1d3a91f4fda35d3e00f36a9.zip | |
Add new function 'image-cache-size'
* src/image.c (Fimage_cache_size): New defun.
(image_frame_cache_size): New function.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/image.c b/src/image.c index 522a4cf7c0f..38887ced25b 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -1792,6 +1792,40 @@ which is then usually a filename. */) | |||
| 1792 | return Qnil; | 1792 | return Qnil; |
| 1793 | } | 1793 | } |
| 1794 | 1794 | ||
| 1795 | static int | ||
| 1796 | image_frame_cache_size (struct frame *f) | ||
| 1797 | { | ||
| 1798 | struct image_cache *c = FRAME_IMAGE_CACHE (f); | ||
| 1799 | int total = 0; | ||
| 1800 | |||
| 1801 | if (!c) | ||
| 1802 | return 0; | ||
| 1803 | |||
| 1804 | for (ptrdiff_t i = 0; i < c->used; ++i) | ||
| 1805 | { | ||
| 1806 | struct image *img = c->images[i]; | ||
| 1807 | |||
| 1808 | if (img) | ||
| 1809 | total += img->pixmap->width * img->pixmap->height * | ||
| 1810 | img->pixmap->bits_per_pixel / 8; | ||
| 1811 | } | ||
| 1812 | return total; | ||
| 1813 | } | ||
| 1814 | |||
| 1815 | DEFUN ("image-cache-size", Fimage_cache_size, Simage_cache_size, 0, 0, 0, | ||
| 1816 | doc: /* Return the size of the image cache. */) | ||
| 1817 | (void) | ||
| 1818 | { | ||
| 1819 | Lisp_Object tail, frame; | ||
| 1820 | int total = 0; | ||
| 1821 | |||
| 1822 | FOR_EACH_FRAME (tail, frame) | ||
| 1823 | if (FRAME_WINDOW_P (XFRAME (frame))) | ||
| 1824 | total += image_frame_cache_size (XFRAME (frame)); | ||
| 1825 | |||
| 1826 | return make_int (total); | ||
| 1827 | } | ||
| 1828 | |||
| 1795 | 1829 | ||
| 1796 | DEFUN ("image-flush", Fimage_flush, Simage_flush, | 1830 | DEFUN ("image-flush", Fimage_flush, Simage_flush, |
| 1797 | 1, 2, 0, | 1831 | 1, 2, 0, |
| @@ -10703,6 +10737,7 @@ non-numeric, there is no explicit limit on the size of images. */); | |||
| 10703 | defsubr (&Simage_size); | 10737 | defsubr (&Simage_size); |
| 10704 | defsubr (&Simage_mask_p); | 10738 | defsubr (&Simage_mask_p); |
| 10705 | defsubr (&Simage_metadata); | 10739 | defsubr (&Simage_metadata); |
| 10740 | defsubr (&Simage_cache_size); | ||
| 10706 | 10741 | ||
| 10707 | #ifdef GLYPH_DEBUG | 10742 | #ifdef GLYPH_DEBUG |
| 10708 | defsubr (&Simagep); | 10743 | defsubr (&Simagep); |