* termhooks.h (P_): Remove redundant def.
(struct terminal): New field `image_cache'.
* frame.h (FRAME_IMAGE_CACHE): New macro. Use it everywhere in place
of FRAME_X_IMAGE_CACHE.
* xterm.h (struct x_display_info): Remove image_cache field.
(FRAME_X_IMAGE_CACHE): Remove. Use FRAME_IMAGE_CACHE instead.
* w32term.h (struct w32_display_info): Remove image_cache field.
(FRAME_X_IMAGE_CACHE): Remove. Use FRAME_IMAGE_CACHE instead.
* macterm.h (struct mac_display_info): Remove image_cache field.
(FRAME_X_IMAGE_CACHE): Remove. Use FRAME_IMAGE_CACHE instead.
* xterm.c (x_term_init):
* w32term.c (w32_term_init):
* macterm.c (mac_term_init): Set the image_cache in the terminal.
* dispextern.h (clear_image_cache, forall_images_in_image_cache):
Remove declarations.
(clear_image_caches, mark_image_cache): New declarations.
* xfaces.c (clear_face_cache):
* xdisp.c (redisplay_internal): Use clear_image_caches.
* image.c (clear_image_cache): Don't check that a frame is on
a window-system before checking if it shares the same cache.
(clear_image_caches): New function.
(Fclear_image_cache): Use it.
(mark_image): Move from allo.c.
(mark_image_cache): Move from alloc.c and forall_images_in_image_cache.
* alloc.c (mark_image, mark_image_cache): Move to image.c.
(mark_object): Don't call mark_image_cache for frames.
(mark_terminals): Call mark_image_cache.
2008-02-22 Stefan Monnier <monnier@iro.umontreal.ca>
+ Consolidate the image_cache to the terminal struct.
+ * termhooks.h (P_): Remove redundant def.
+ (struct terminal): New field `image_cache'.
+ * frame.h (FRAME_IMAGE_CACHE): New macro. Use it everywhere in place
+ of FRAME_X_IMAGE_CACHE.
+ * xterm.h (struct x_display_info): Remove image_cache field.
+ (FRAME_X_IMAGE_CACHE): Remove. Use FRAME_IMAGE_CACHE instead.
+ * w32term.h (struct w32_display_info): Remove image_cache field.
+ (FRAME_X_IMAGE_CACHE): Remove. Use FRAME_IMAGE_CACHE instead.
+ * macterm.h (struct mac_display_info): Remove image_cache field.
+ (FRAME_X_IMAGE_CACHE): Remove. Use FRAME_IMAGE_CACHE instead.
+ * xterm.c (x_term_init):
+ * w32term.c (w32_term_init):
+ * macterm.c (mac_term_init): Set the image_cache in the terminal.
+ * dispextern.h (clear_image_cache, forall_images_in_image_cache):
+ Remove declarations.
+ (clear_image_caches, mark_image_cache): New declarations.
+ * xfaces.c (clear_face_cache):
+ * xdisp.c (redisplay_internal): Use clear_image_caches.
+ * image.c (clear_image_cache): Don't check that a frame is on
+ a window-system before checking if it shares the same cache.
+ (clear_image_caches): New function.
+ (Fclear_image_cache): Use it.
+ (mark_image): Move from allo.c.
+ (mark_image_cache): Move from alloc.c and forall_images_in_image_cache.
+ * alloc.c (mark_image, mark_image_cache): Move to image.c.
+ (mark_object): Don't call mark_image_cache for frames.
+ (mark_terminals): Call mark_image_cache.
+
* lisp.h (Fdelete_terminal): Declare.
* charset.h (CHECK_CHARSET, CHECK_CHARSET_GET_ID)
#ifdef HAVE_WINDOW_SYSTEM
extern void mark_fringe_data P_ ((void));
-static void mark_image P_ ((struct image *));
-static void mark_image_cache P_ ((struct frame *));
#endif /* HAVE_WINDOW_SYSTEM */
static struct Lisp_String *allocate_string P_ ((void));
}
-#ifdef HAVE_WINDOW_SYSTEM
-
-/* Mark Lisp objects in image IMG. */
-
-static void
-mark_image (img)
- struct image *img;
-{
- mark_object (img->spec);
-
- if (!NILP (img->data.lisp_val))
- mark_object (img->data.lisp_val);
-}
-
-
-/* Mark Lisp objects in image cache of frame F. It's done this way so
- that we don't have to include xterm.h here. */
-
-static void
-mark_image_cache (f)
- struct frame *f;
-{
- forall_images_in_image_cache (f, mark_image);
-}
-
-#endif /* HAVE_X_WINDOWS */
-
-
\f
/* Mark reference to a Lisp_Object.
If the object referred to has not been seen yet, recursively mark
{
register struct frame *ptr = XFRAME (obj);
if (mark_vectorlike (XVECTOR (obj)))
- {
- mark_face_cache (ptr->face_cache);
-#ifdef HAVE_WINDOW_SYSTEM
- mark_image_cache (ptr);
-#endif /* HAVE_WINDOW_SYSTEM */
- }
+ mark_face_cache (ptr->face_cache);
}
else if (WINDOWP (obj))
{
for (t = terminal_list; t; t = t->next_terminal)
{
eassert (t->name != NULL);
+#ifdef HAVE_WINDOW_SYSTEM
+ mark_image_cache (t->image_cache);
+#endif /* HAVE_WINDOW_SYSTEM */
mark_vectorlike ((struct Lisp_Vector *)t);
}
}
no image with that id exists. */
#define IMAGE_FROM_ID(F, ID) \
- (((ID) >= 0 && (ID) < (FRAME_X_IMAGE_CACHE (F)->used)) \
- ? FRAME_X_IMAGE_CACHE (F)->images[ID] \
+ (((ID) >= 0 && (ID) < (FRAME_IMAGE_CACHE (F)->used)) \
+ ? FRAME_IMAGE_CACHE (F)->images[ID] \
: NULL)
/* Size of bucket vector of image caches. Should be prime. */
void x_kill_gs_process P_ ((Pixmap, struct frame *));
struct image_cache *make_image_cache P_ ((void));
void free_image_cache P_ ((struct frame *));
-void clear_image_cache P_ ((struct frame *, int));
-void forall_images_in_image_cache P_ ((struct frame *,
- void (*) P_ ((struct image *))));
+void clear_image_caches P_ ((int));
+void mark_image_cache P_ ((struct image_cache *));
int valid_image_p P_ ((Lisp_Object));
void prepare_image_for_display P_ ((struct frame *, struct image *));
int lookup_image P_ ((struct frame *, Lisp_Object));
#define FRAME_KBOARD(f) (&the_only_kboard)
#endif
+/* Return a pointer to the image cache of frame F. */
+#define FRAME_IMAGE_CACHE(F) ((F)->terminal->image_cache)
+
typedef struct frame *FRAME_PTR;
#define XFRAME(p) (eassert (FRAMEP(p)),(struct frame *) XPNTR (p))
{
if (img)
{
- struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
+ struct image_cache *c = FRAME_IMAGE_CACHE (f);
/* Remove IMG from the hash table of its cache. */
if (img->prev)
unsigned hash;
{
struct image *img;
- struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
+ struct image_cache *c = FRAME_IMAGE_CACHE (f);
int i = hash % IMAGE_CACHE_BUCKETS_SIZE;
if (!c) return NULL;
free_image_cache (f)
struct frame *f;
{
- struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
+ struct image_cache *c = FRAME_IMAGE_CACHE (f);
if (c)
{
int i;
xfree (c->images);
xfree (c->buckets);
xfree (c);
- FRAME_X_IMAGE_CACHE (f) = NULL;
+ FRAME_IMAGE_CACHE (f) = NULL;
}
}
struct frame *f;
int force_p;
{
- struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
+ struct image_cache *c = FRAME_IMAGE_CACHE (f);
if (c && INTEGERP (Vimage_cache_eviction_delay))
{
FOR_EACH_FRAME (tail, frame)
{
struct frame *f = XFRAME (frame);
- if (FRAME_WINDOW_P (f)
- && FRAME_X_IMAGE_CACHE (f) == c)
+ if (FRAME_IMAGE_CACHE (f) == c)
clear_current_matrices (f);
}
}
}
+void
+clear_image_caches (int force_p)
+{
+ /* FIXME: We want to do
+ * struct terminal *t;
+ * for (t = terminal_list; t; t = t->next_terminal)
+ * clear_image_cache (t, filter); */
+ Lisp_Object tail, frame;
+ FOR_EACH_FRAME (tail, frame)
+ if (FRAME_WINDOW_P (XFRAME (frame)))
+ clear_image_cache (XFRAME (frame), force_p);
+}
DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache,
0, 1, 0,
Lisp_Object frame;
{
if (EQ (frame, Qt))
- {
- Lisp_Object tail;
-
- FOR_EACH_FRAME (tail, frame)
- if (FRAME_WINDOW_P (XFRAME (frame)))
- clear_image_cache (XFRAME (frame), 1);
- }
+ clear_image_caches (1);
else
clear_image_cache (check_x_frame (frame), 1);
xassert (FRAME_WINDOW_P (f));
xassert (valid_image_p (spec));
- c = FRAME_X_IMAGE_CACHE (f);
+ c = FRAME_IMAGE_CACHE (f);
GCPRO1 (spec);
struct frame *f;
struct image *img;
{
- struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
+ struct image_cache *c = FRAME_IMAGE_CACHE (f);
int i;
/* Find a free slot in c->images. */
/* Call FN on every image in the image cache of frame F. Used to mark
Lisp Objects in the image cache. */
+/* Mark Lisp objects in image IMG. */
+
+static void
+mark_image (img)
+ struct image *img;
+{
+ mark_object (img->spec);
+
+ if (!NILP (img->data.lisp_val))
+ mark_object (img->data.lisp_val);
+}
+
+
void
-forall_images_in_image_cache (f, fn)
- struct frame *f;
- void (*fn) P_ ((struct image *img));
+mark_image_cache (struct image_cache *c)
{
- if (FRAME_LIVE_P (f) && FRAME_WINDOW_P (f))
+ if (c)
{
- struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
- if (c)
- {
- int i;
- for (i = 0; i < c->used; ++i)
- if (c->images[i])
- fn (c->images[i]);
- }
+ int i;
+ for (i = 0; i < c->used; ++i)
+ if (c->images[i])
+ mark_image (c->images[i]);
}
}
Pixmap pixmap;
struct frame *f;
{
- struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
+ struct image_cache *c = FRAME_IMAGE_CACHE (f);
int class, i;
struct image *img;
/* With FRAME_MAC_DISPLAY_INFO set up, this unwind-protect is safe. */
#if GLYPH_DEBUG
- image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
+ image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */
FRAME_KBOARD (f) = kb;
f->icon_name = Qnil;
/* FRAME_X_DISPLAY_INFO (f) = dpyinfo; */
#if GLYPH_DEBUG
- image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
+ image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */
FRAME_KBOARD (f) = kb;
dpyinfo->grabbed = 0;
dpyinfo->root_window = NULL;
- dpyinfo->image_cache = make_image_cache ();
+ dpyinfo->terminal->image_cache = make_image_cache ();
dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
frame. It differs from x_focus_frame when we're using a global
minibuffer. */
struct frame *x_highlight_frame;
-
- /* Cache of images. */
- struct image_cache *image_cache;
};
/* This checks to make sure we have a display. */
#define FRAME_SMALLEST_FONT_HEIGHT(F) \
FRAME_MAC_DISPLAY_INFO(F)->smallest_font_height
-
-/* Return a pointer to the image cache of frame F. */
-
-#define FRAME_X_IMAGE_CACHE(F) FRAME_MAC_DISPLAY_INFO ((F))->image_cache
-
\f
/* Mac-specific scroll bar stuff. */
struct glyph;
struct frame;
-
-/* Only use prototypes when lisp.h has been included. */
-#ifndef P_
-#define P_(X) ()
-#endif
\f
enum scroll_bar_part {
struct kboard *kboard;
#endif
+#ifdef HAVE_WINDOW_SYSTEM
+ /* Cache of images. */
+ struct image_cache *image_cache;
+#endif /* HAVE_WINDOW_SYSTEM */
+
/* Device-type dependent data shared amongst all frames on this terminal. */
union display_info
{
f->icon_name = Qnil;
#if 0 /* GLYPH_DEBUG TODO: image support. */
- image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
+ image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */
#ifdef MULTI_KBOARD
dpyinfo->resx = GetDeviceCaps (hdc, LOGPIXELSX);
dpyinfo->resy = GetDeviceCaps (hdc, LOGPIXELSY);
dpyinfo->has_palette = GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE;
- dpyinfo->image_cache = make_image_cache ();
+ dpyinfo->terminal->image_cache = make_image_cache ();
dpyinfo->height_in = dpyinfo->height / dpyinfo->resx;
dpyinfo->width_in = dpyinfo->width / dpyinfo->resy;
ReleaseDC (GetDesktopWindow (), hdc);
frame. It differs from w32_focus_frame when we're using a global
minibuffer. */
struct frame *x_highlight_frame;
-
- /* Cache of images. */
- struct image_cache *image_cache;
};
/* This is a chain of structures for all the displays currently in use. */
#define FRAME_SMALLEST_FONT_HEIGHT(F) \
FRAME_W32_DISPLAY_INFO(F)->smallest_font_height
-
-/* Return a pointer to the image cache of frame F. */
-
-#define FRAME_X_IMAGE_CACHE(F) FRAME_W32_DISPLAY_INFO ((F))->image_cache
-
\f
/* W32-specific scroll bar stuff. */
#ifdef HAVE_WINDOW_SYSTEM
if (clear_image_cache_count > CLEAR_IMAGE_CACHE_COUNT)
{
- Lisp_Object tail, frame;
- FOR_EACH_FRAME (tail, frame)
- {
- struct frame *f = XFRAME (frame);
- if (FRAME_WINDOW_P (f))
- clear_image_cache (f, 0);
- }
+ clear_image_caches (0);
clear_image_cache_count = 0;
}
#endif /* HAVE_WINDOW_SYSTEM */
/* Make the image cache. */
if (FRAME_WINDOW_P (f))
{
- if (FRAME_X_IMAGE_CACHE (f) == NULL)
- FRAME_X_IMAGE_CACHE (f) = make_image_cache ();
- ++FRAME_X_IMAGE_CACHE (f)->refcount;
+ if (FRAME_IMAGE_CACHE (f) == NULL)
+ /* Is that ever possible?? --Stef */
+ FRAME_IMAGE_CACHE (f) = make_image_cache ();
+ ++FRAME_IMAGE_CACHE (f)->refcount;
}
#endif /* HAVE_WINDOW_SYSTEM */
#ifdef HAVE_WINDOW_SYSTEM
if (FRAME_WINDOW_P (f))
{
- struct image_cache *image_cache = FRAME_X_IMAGE_CACHE (f);
+ struct image_cache *image_cache = FRAME_IMAGE_CACHE (f);
if (image_cache)
{
--image_cache->refcount;
{
f = XFRAME (frame);
if (FRAME_WINDOW_P (f))
- {
clear_face_gcs (FRAME_FACE_CACHE (f));
- clear_image_cache (f, 0);
- }
}
+ clear_image_caches (0);
}
#endif /* HAVE_WINDOW_SYSTEM */
}
/* With FRAME_X_DISPLAY_INFO set up, this unwind-protect is safe. */
record_unwind_protect (unwind_create_frame, frame);
#if GLYPH_DEBUG
- image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
+ image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */
f->icon_name = Qnil;
FRAME_X_DISPLAY_INFO (f) = dpyinfo;
#if GLYPH_DEBUG
- image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
+ image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
#endif /* GLYPH_DEBUG */
f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
dpyinfo->x_focus_frame = 0;
dpyinfo->x_focus_event_frame = 0;
dpyinfo->x_highlight_frame = 0;
- dpyinfo->image_cache = make_image_cache ();
+ dpyinfo->terminal->image_cache = make_image_cache ();
dpyinfo->wm_type = X_WMTYPE_UNKNOWN;
/* See if we can construct pixel values from RGB values. */
/* The gray pixmap. */
Pixmap gray;
- /* Cache of images. */
- struct image_cache *image_cache;
-
#ifdef HAVE_X_I18N
/* XIM (X Input method). */
XIM xim;
#define FRAME_SMALLEST_FONT_HEIGHT(F) \
FRAME_X_DISPLAY_INFO(F)->smallest_font_height
-
-/* Return a pointer to the image cache of frame F. */
-
-#define FRAME_X_IMAGE_CACHE(F) FRAME_X_DISPLAY_INFO ((F))->image_cache
-
\f
/* X-specific scroll bar stuff. */