summaryrefslogtreecommitdiff
path: root/src/image.c
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2008-02-24 13:36:39 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2008-02-24 13:36:39 +0000
commita2bc5bdd7db3f708b7489d91919336e775c3e6ca (patch)
treeca7e9efac023071ffcbeb514ab66fc4c0d76a8b9 /src/image.c
parent01dcf28448dab12ad7160942323144836467dd65 (diff)
downloademacs-a2bc5bdd7db3f708b7489d91919336e775c3e6ca.tar.gz
Allow fine-grained image-cache flushing.
* dispextern.h (struct image): Add `dependencies' field. (clear_image_caches): Change arg to Lisp_Object. * image.c (make_image): Initialize `dependencies' field. (clear_image_cache): Change arg to allow fine-grained flushing. Perform the flush even if image-cache-eviction-delay is nil. (clear_image_caches): Change arg to Lisp_Object. (Fclear_image_cache): Expand meaning of the argument. (mark_image): Mark `dependencies' field. * xfaces.c (clear_face_cache): Adapt arg to call to clear_image_caches. (lface_hash): Use XHASH rather than XFASTINT. (face_at_buffer_position): Fix int -> EMACS_INT position. * xdisp.c (next_overlay_change): Fix int -> EMACS_INT position. (select_frame_for_redisplay): Remove code duplication. (redisplay_internal): Adapt arg to call to clear_image_caches.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/image.c b/src/image.c
index cce0024e835..81754ca68d2 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1184,9 +1184,11 @@ make_image (spec, hash)
unsigned hash;
{
struct image *img = (struct image *) xmalloc (sizeof *img);
+ Lisp_Object file = image_spec_value (spec, QCfile, NULL);
xassert (valid_image_p (spec));
bzero (img, sizeof *img);
+ img->dependencies = NILP (file) ? Qnil : list1 (file);
img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
xassert (img->type != NULL);
img->spec = spec;
@@ -1707,21 +1709,20 @@ free_image_cache (f)
}
-/* Clear image cache of frame F. FORCE_P non-zero means free all
- images. FORCE_P zero means clear only images that haven't been
- displayed for some time. Should be called from time to time to
- reduce the number of loaded images. If image-cache-eviction-delay
- is non-nil, this frees images in the cache which weren't displayed
- for at least that many seconds. */
+/* Clear image cache of frame F. FILTER=t means free all images.
+ FILTER=nil means clear only images that haven't been
+ displayed for some time.
+ Else, only free the images which have FILTER in their `dependencies'.
+ Should be called from time to time to reduce the number of loaded images.
+ If image-cache-eviction-delay is non-nil, this frees images in the cache
+ which weren't displayed for at least that many seconds. */
void
-clear_image_cache (f, force_p)
- struct frame *f;
- int force_p;
+clear_image_cache (struct frame *f, Lisp_Object filter)
{
struct image_cache *c = FRAME_IMAGE_CACHE (f);
- if (c && INTEGERP (Vimage_cache_eviction_delay))
+ if (c && (!NILP (filter) || INTEGERP (Vimage_cache_eviction_delay)))
{
EMACS_TIME t;
unsigned long old;
@@ -1738,7 +1739,9 @@ clear_image_cache (f, force_p)
{
struct image *img = c->images[i];
if (img != NULL
- && (force_p || img->timestamp < old))
+ && (NILP (filter) ? img->timestamp < old
+ : (EQ (Qt, filter)
+ || !NILP (Fmember (filter, img->dependencies)))))
{
free_image (f, img);
++nfreed;
@@ -1768,7 +1771,7 @@ clear_image_cache (f, force_p)
}
void
-clear_image_caches (int force_p)
+clear_image_caches (Lisp_Object filter)
{
/* FIXME: We want to do
* struct terminal *t;
@@ -1777,21 +1780,23 @@ clear_image_caches (int force_p)
Lisp_Object tail, frame;
FOR_EACH_FRAME (tail, frame)
if (FRAME_WINDOW_P (XFRAME (frame)))
- clear_image_cache (XFRAME (frame), force_p);
+ clear_image_cache (XFRAME (frame), filter);
}
DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache,
0, 1, 0,
- doc: /* Clear the image cache of FRAME.
-FRAME nil or omitted means use the selected frame.
-FRAME t means clear the image caches of all frames. */)
- (frame)
- Lisp_Object frame;
-{
- if (EQ (frame, Qt))
- clear_image_caches (1);
+ doc: /* Clear the image cache.
+FILTER nil or a frame means clear all images in the selected frame.
+FILTER t means clear the image caches of all frames.
+Anything else, means only clear those images which refer to FILTER,
+which is then usually a filename. */)
+ (filter)
+ Lisp_Object filter;
+{
+ if (!(EQ (filter, Qnil) || FRAMEP (filter)))
+ clear_image_caches (filter);
else
- clear_image_cache (check_x_frame (frame), 1);
+ clear_image_cache (check_x_frame (filter), Qt);
return Qnil;
}
@@ -2074,6 +2079,7 @@ mark_image (img)
struct image *img;
{
mark_object (img->spec);
+ mark_object (img->dependencies);
if (!NILP (img->data.lisp_val))
mark_object (img->data.lisp_val);