summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2020-12-12 13:12:57 +0200
committerEli Zaretskii <eliz@gnu.org>2020-12-12 13:12:57 +0200
commit61b6cc401a9adf7f718c1c9c4350181ecd413f1c (patch)
tree040ecf4857da1fa148fa0191db004a437e12f07e /src
parentdba74cb5ec1c1abfbee236bbcf811b023bb19d4f (diff)
downloademacs-61b6cc401a9adf7f718c1c9c4350181ecd413f1c.tar.gz
emacs-61b6cc401a9adf7f718c1c9c4350181ecd413f1c.tar.bz2
emacs-61b6cc401a9adf7f718c1c9c4350181ecd413f1c.zip
Improve support for 'memory-report' on MS-Windows
* src/w32term.c (w32_image_size): New function. * src/image.c (image_frame_cache_size) [HAVE_NTGUI]: Support reporting the size of frame image cache. (image_frame_cache_size, Fimage_cache_size): The total size is now of the type 'size_t', not 'int'.
Diffstat (limited to 'src')
-rw-r--r--src/image.c21
-rw-r--r--src/w32gui.h1
-rw-r--r--src/w32term.c11
3 files changed, 29 insertions, 4 deletions
diff --git a/src/image.c b/src/image.c
index 79b275cba94..63033572ed4 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1792,11 +1792,11 @@ which is then usually a filename. */)
return Qnil;
}
-static int
+static size_t
image_frame_cache_size (struct frame *f)
{
- int total = 0;
-#ifdef USE_CAIRO
+ size_t total = 0;
+#if defined USE_CAIRO
struct image_cache *c = FRAME_IMAGE_CACHE (f);
if (!c)
@@ -1810,6 +1810,19 @@ image_frame_cache_size (struct frame *f)
total += img->pixmap->width * img->pixmap->height *
img->pixmap->bits_per_pixel / 8;
}
+#elif defined HAVE_NTGUI
+ struct image_cache *c = FRAME_IMAGE_CACHE (f);
+
+ if (!c)
+ return 0;
+
+ for (ptrdiff_t i = 0; i < c->used; ++i)
+ {
+ struct image *img = c->images[i];
+
+ if (img && img->pixmap && img->pixmap != NO_PIXMAP)
+ total += w32_image_size (img);
+ }
#endif
return total;
}
@@ -1819,7 +1832,7 @@ DEFUN ("image-cache-size", Fimage_cache_size, Simage_cache_size, 0, 0, 0,
(void)
{
Lisp_Object tail, frame;
- int total = 0;
+ size_t total = 0;
FOR_EACH_FRAME (tail, frame)
if (FRAME_WINDOW_P (XFRAME (frame)))
diff --git a/src/w32gui.h b/src/w32gui.h
index dfec1f08617..fc8131130fb 100644
--- a/src/w32gui.h
+++ b/src/w32gui.h
@@ -46,6 +46,7 @@ extern int w32_load_image (struct frame *f, struct image *img,
Lisp_Object spec_file, Lisp_Object spec_data);
extern bool w32_can_use_native_image_api (Lisp_Object);
extern void w32_gdiplus_shutdown (void);
+extern size_t w32_image_size (struct image *);
#define FACE_DEFAULT (~0)
diff --git a/src/w32term.c b/src/w32term.c
index 23cb380040b..dc5cd1f6997 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1991,6 +1991,17 @@ w32_draw_image_foreground (struct glyph_string *s)
RestoreDC (s->hdc ,-1);
}
+size_t
+w32_image_size (struct image *img)
+{
+ BITMAP bm_info;
+ size_t rv = 0;
+
+ if (GetObject (img->pixmap, sizeof (BITMAP), &bm_info))
+ rv = bm_info.bmWidth * bm_info.bmHeight * bm_info.bmBitsPixel / 8;
+ return rv;
+}
+
/* Draw a relief around the image glyph string S. */