Mercurial > emacs
changeset 92109:4d9fc08769fa
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.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 22 Feb 2008 17:42:09 +0000 |
parents | fc5344b71cdb |
children | 458c8171667a |
files | src/ChangeLog src/alloc.c src/dispextern.h src/frame.h src/image.c src/macfns.c src/macterm.c src/macterm.h src/termhooks.h src/w32fns.c src/w32term.c src/w32term.h src/xdisp.c src/xfaces.c src/xfns.c src/xterm.c src/xterm.h |
diffstat | 17 files changed, 103 insertions(+), 123 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Fri Feb 22 17:27:17 2008 +0000 +++ b/src/ChangeLog Fri Feb 22 17:42:09 2008 +0000 @@ -1,5 +1,34 @@ 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)
--- a/src/alloc.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/alloc.c Fri Feb 22 17:42:09 2008 +0000 @@ -353,8 +353,6 @@ #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)); @@ -5324,34 +5322,6 @@ } -#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 */ - - /* Mark reference to a Lisp_Object. If the object referred to has not been seen yet, recursively mark @@ -5520,12 +5490,7 @@ { 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)) { @@ -5760,6 +5725,9 @@ 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); } }
--- a/src/dispextern.h Fri Feb 22 17:27:17 2008 +0000 +++ b/src/dispextern.h Fri Feb 22 17:42:09 2008 +0000 @@ -2547,8 +2547,8 @@ 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. */ @@ -2818,9 +2818,8 @@ 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));
--- a/src/frame.h Fri Feb 22 17:27:17 2008 +0000 +++ b/src/frame.h Fri Feb 22 17:42:09 2008 +0000 @@ -484,6 +484,9 @@ #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))
--- a/src/image.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/image.c Fri Feb 22 17:42:09 2008 +0000 @@ -1207,7 +1207,7 @@ { 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) @@ -1642,7 +1642,7 @@ 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; @@ -1689,7 +1689,7 @@ 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; @@ -1702,7 +1702,7 @@ xfree (c->images); xfree (c->buckets); xfree (c); - FRAME_X_IMAGE_CACHE (f) = NULL; + FRAME_IMAGE_CACHE (f) = NULL; } } @@ -1719,7 +1719,7 @@ 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)) { @@ -1756,8 +1756,7 @@ 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); } @@ -1768,6 +1767,18 @@ } } +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, @@ -1778,13 +1789,7 @@ 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); @@ -1916,7 +1921,7 @@ xassert (FRAME_WINDOW_P (f)); xassert (valid_image_p (spec)); - c = FRAME_X_IMAGE_CACHE (f); + c = FRAME_IMAGE_CACHE (f); GCPRO1 (spec); @@ -2027,7 +2032,7 @@ 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. */ @@ -2062,21 +2067,28 @@ /* 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)); -{ - if (FRAME_LIVE_P (f) && FRAME_WINDOW_P (f)) - { - 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]); - } +mark_image_cache (struct image_cache *c) +{ + if (c) + { + int i; + for (i = 0; i < c->used; ++i) + if (c->images[i]) + mark_image (c->images[i]); } } @@ -8856,7 +8868,7 @@ 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;
--- a/src/macfns.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/macfns.c Fri Feb 22 17:42:09 2008 +0000 @@ -2608,7 +2608,7 @@ /* 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; @@ -3846,7 +3846,7 @@ 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;
--- a/src/macterm.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/macterm.c Fri Feb 22 17:42:09 2008 +0000 @@ -12624,7 +12624,7 @@ 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;
--- a/src/macterm.h Fri Feb 22 17:27:17 2008 +0000 +++ b/src/macterm.h Fri Feb 22 17:42:09 2008 +0000 @@ -185,9 +185,6 @@ 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. */ @@ -394,11 +391,6 @@ #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 - /* Mac-specific scroll bar stuff. */
--- a/src/termhooks.h Fri Feb 22 17:27:17 2008 +0000 +++ b/src/termhooks.h Fri Feb 22 17:42:09 2008 +0000 @@ -24,11 +24,6 @@ struct glyph; struct frame; - -/* Only use prototypes when lisp.h has been included. */ -#ifndef P_ -#define P_(X) () -#endif enum scroll_bar_part { @@ -363,6 +358,11 @@ 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 {
--- a/src/w32fns.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/w32fns.c Fri Feb 22 17:42:09 2008 +0000 @@ -7476,7 +7476,7 @@ 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
--- a/src/w32term.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/w32term.c Fri Feb 22 17:42:09 2008 +0000 @@ -7033,7 +7033,7 @@ 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);
--- a/src/w32term.h Fri Feb 22 17:27:17 2008 +0000 +++ b/src/w32term.h Fri Feb 22 17:42:09 2008 +0000 @@ -233,9 +233,6 @@ 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. */ @@ -443,11 +440,6 @@ #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 - /* W32-specific scroll bar stuff. */
--- a/src/xdisp.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/xdisp.c Fri Feb 22 17:42:09 2008 +0000 @@ -11797,13 +11797,7 @@ #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 */
--- a/src/xfaces.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/xfaces.c Fri Feb 22 17:42:09 2008 +0000 @@ -894,9 +894,10 @@ /* 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 */ @@ -933,7 +934,7 @@ #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; @@ -1008,11 +1009,9 @@ { 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 */ }
--- a/src/xfns.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/xfns.c Fri Feb 22 17:42:09 2008 +0000 @@ -3326,7 +3326,7 @@ /* 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 */ @@ -4930,7 +4930,7 @@ 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;
--- a/src/xterm.c Fri Feb 22 17:27:17 2008 +0000 +++ b/src/xterm.c Fri Feb 22 17:42:09 2008 +0000 @@ -11395,7 +11395,7 @@ 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. */
--- a/src/xterm.h Fri Feb 22 17:27:17 2008 +0000 +++ b/src/xterm.h Fri Feb 22 17:42:09 2008 +0000 @@ -330,9 +330,6 @@ /* The gray pixmap. */ Pixmap gray; - /* Cache of images. */ - struct image_cache *image_cache; - #ifdef HAVE_X_I18N /* XIM (X Input method). */ XIM xim; @@ -737,11 +734,6 @@ #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 - /* X-specific scroll bar stuff. */