diff options
| author | Stefan Monnier | 2008-02-22 17:42:09 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-02-22 17:42:09 +0000 |
| commit | 354884c46ee708a22b0372d2092256408b485c8d (patch) | |
| tree | 03802c0c4e44d3ecd4b096cada74b8abf811ce29 /src/image.c | |
| parent | c2e426903cfd93202e302471a6e1b265a08e8368 (diff) | |
| download | emacs-354884c46ee708a22b0372d2092256408b485c8d.tar.gz emacs-354884c46ee708a22b0372d2092256408b485c8d.zip | |
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.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/src/image.c b/src/image.c index 04fda4f88a8..7833b8473d6 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -1207,7 +1207,7 @@ free_image (f, img) | |||
| 1207 | { | 1207 | { |
| 1208 | if (img) | 1208 | if (img) |
| 1209 | { | 1209 | { |
| 1210 | struct image_cache *c = FRAME_X_IMAGE_CACHE (f); | 1210 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 1211 | 1211 | ||
| 1212 | /* Remove IMG from the hash table of its cache. */ | 1212 | /* Remove IMG from the hash table of its cache. */ |
| 1213 | if (img->prev) | 1213 | if (img->prev) |
| @@ -1642,7 +1642,7 @@ search_image_cache (f, spec, hash) | |||
| 1642 | unsigned hash; | 1642 | unsigned hash; |
| 1643 | { | 1643 | { |
| 1644 | struct image *img; | 1644 | struct image *img; |
| 1645 | struct image_cache *c = FRAME_X_IMAGE_CACHE (f); | 1645 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 1646 | int i = hash % IMAGE_CACHE_BUCKETS_SIZE; | 1646 | int i = hash % IMAGE_CACHE_BUCKETS_SIZE; |
| 1647 | 1647 | ||
| 1648 | if (!c) return NULL; | 1648 | if (!c) return NULL; |
| @@ -1689,7 +1689,7 @@ void | |||
| 1689 | free_image_cache (f) | 1689 | free_image_cache (f) |
| 1690 | struct frame *f; | 1690 | struct frame *f; |
| 1691 | { | 1691 | { |
| 1692 | struct image_cache *c = FRAME_X_IMAGE_CACHE (f); | 1692 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 1693 | if (c) | 1693 | if (c) |
| 1694 | { | 1694 | { |
| 1695 | int i; | 1695 | int i; |
| @@ -1702,7 +1702,7 @@ free_image_cache (f) | |||
| 1702 | xfree (c->images); | 1702 | xfree (c->images); |
| 1703 | xfree (c->buckets); | 1703 | xfree (c->buckets); |
| 1704 | xfree (c); | 1704 | xfree (c); |
| 1705 | FRAME_X_IMAGE_CACHE (f) = NULL; | 1705 | FRAME_IMAGE_CACHE (f) = NULL; |
| 1706 | } | 1706 | } |
| 1707 | } | 1707 | } |
| 1708 | 1708 | ||
| @@ -1719,7 +1719,7 @@ clear_image_cache (f, force_p) | |||
| 1719 | struct frame *f; | 1719 | struct frame *f; |
| 1720 | int force_p; | 1720 | int force_p; |
| 1721 | { | 1721 | { |
| 1722 | struct image_cache *c = FRAME_X_IMAGE_CACHE (f); | 1722 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 1723 | 1723 | ||
| 1724 | if (c && INTEGERP (Vimage_cache_eviction_delay)) | 1724 | if (c && INTEGERP (Vimage_cache_eviction_delay)) |
| 1725 | { | 1725 | { |
| @@ -1756,8 +1756,7 @@ clear_image_cache (f, force_p) | |||
| 1756 | FOR_EACH_FRAME (tail, frame) | 1756 | FOR_EACH_FRAME (tail, frame) |
| 1757 | { | 1757 | { |
| 1758 | struct frame *f = XFRAME (frame); | 1758 | struct frame *f = XFRAME (frame); |
| 1759 | if (FRAME_WINDOW_P (f) | 1759 | if (FRAME_IMAGE_CACHE (f) == c) |
| 1760 | && FRAME_X_IMAGE_CACHE (f) == c) | ||
| 1761 | clear_current_matrices (f); | 1760 | clear_current_matrices (f); |
| 1762 | } | 1761 | } |
| 1763 | 1762 | ||
| @@ -1768,6 +1767,18 @@ clear_image_cache (f, force_p) | |||
| 1768 | } | 1767 | } |
| 1769 | } | 1768 | } |
| 1770 | 1769 | ||
| 1770 | void | ||
| 1771 | clear_image_caches (int force_p) | ||
| 1772 | { | ||
| 1773 | /* FIXME: We want to do | ||
| 1774 | * struct terminal *t; | ||
| 1775 | * for (t = terminal_list; t; t = t->next_terminal) | ||
| 1776 | * clear_image_cache (t, filter); */ | ||
| 1777 | Lisp_Object tail, frame; | ||
| 1778 | FOR_EACH_FRAME (tail, frame) | ||
| 1779 | if (FRAME_WINDOW_P (XFRAME (frame))) | ||
| 1780 | clear_image_cache (XFRAME (frame), force_p); | ||
| 1781 | } | ||
| 1771 | 1782 | ||
| 1772 | DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache, | 1783 | DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache, |
| 1773 | 0, 1, 0, | 1784 | 0, 1, 0, |
| @@ -1778,13 +1789,7 @@ FRAME t means clear the image caches of all frames. */) | |||
| 1778 | Lisp_Object frame; | 1789 | Lisp_Object frame; |
| 1779 | { | 1790 | { |
| 1780 | if (EQ (frame, Qt)) | 1791 | if (EQ (frame, Qt)) |
| 1781 | { | 1792 | clear_image_caches (1); |
| 1782 | Lisp_Object tail; | ||
| 1783 | |||
| 1784 | FOR_EACH_FRAME (tail, frame) | ||
| 1785 | if (FRAME_WINDOW_P (XFRAME (frame))) | ||
| 1786 | clear_image_cache (XFRAME (frame), 1); | ||
| 1787 | } | ||
| 1788 | else | 1793 | else |
| 1789 | clear_image_cache (check_x_frame (frame), 1); | 1794 | clear_image_cache (check_x_frame (frame), 1); |
| 1790 | 1795 | ||
| @@ -1916,7 +1921,7 @@ lookup_image (f, spec) | |||
| 1916 | xassert (FRAME_WINDOW_P (f)); | 1921 | xassert (FRAME_WINDOW_P (f)); |
| 1917 | xassert (valid_image_p (spec)); | 1922 | xassert (valid_image_p (spec)); |
| 1918 | 1923 | ||
| 1919 | c = FRAME_X_IMAGE_CACHE (f); | 1924 | c = FRAME_IMAGE_CACHE (f); |
| 1920 | 1925 | ||
| 1921 | GCPRO1 (spec); | 1926 | GCPRO1 (spec); |
| 1922 | 1927 | ||
| @@ -2027,7 +2032,7 @@ cache_image (f, img) | |||
| 2027 | struct frame *f; | 2032 | struct frame *f; |
| 2028 | struct image *img; | 2033 | struct image *img; |
| 2029 | { | 2034 | { |
| 2030 | struct image_cache *c = FRAME_X_IMAGE_CACHE (f); | 2035 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 2031 | int i; | 2036 | int i; |
| 2032 | 2037 | ||
| 2033 | /* Find a free slot in c->images. */ | 2038 | /* Find a free slot in c->images. */ |
| @@ -2062,21 +2067,28 @@ cache_image (f, img) | |||
| 2062 | /* Call FN on every image in the image cache of frame F. Used to mark | 2067 | /* Call FN on every image in the image cache of frame F. Used to mark |
| 2063 | Lisp Objects in the image cache. */ | 2068 | Lisp Objects in the image cache. */ |
| 2064 | 2069 | ||
| 2070 | /* Mark Lisp objects in image IMG. */ | ||
| 2071 | |||
| 2072 | static void | ||
| 2073 | mark_image (img) | ||
| 2074 | struct image *img; | ||
| 2075 | { | ||
| 2076 | mark_object (img->spec); | ||
| 2077 | |||
| 2078 | if (!NILP (img->data.lisp_val)) | ||
| 2079 | mark_object (img->data.lisp_val); | ||
| 2080 | } | ||
| 2081 | |||
| 2082 | |||
| 2065 | void | 2083 | void |
| 2066 | forall_images_in_image_cache (f, fn) | 2084 | mark_image_cache (struct image_cache *c) |
| 2067 | struct frame *f; | ||
| 2068 | void (*fn) P_ ((struct image *img)); | ||
| 2069 | { | 2085 | { |
| 2070 | if (FRAME_LIVE_P (f) && FRAME_WINDOW_P (f)) | 2086 | if (c) |
| 2071 | { | 2087 | { |
| 2072 | struct image_cache *c = FRAME_X_IMAGE_CACHE (f); | 2088 | int i; |
| 2073 | if (c) | 2089 | for (i = 0; i < c->used; ++i) |
| 2074 | { | 2090 | if (c->images[i]) |
| 2075 | int i; | 2091 | mark_image (c->images[i]); |
| 2076 | for (i = 0; i < c->used; ++i) | ||
| 2077 | if (c->images[i]) | ||
| 2078 | fn (c->images[i]); | ||
| 2079 | } | ||
| 2080 | } | 2092 | } |
| 2081 | } | 2093 | } |
| 2082 | 2094 | ||
| @@ -8856,7 +8868,7 @@ x_kill_gs_process (pixmap, f) | |||
| 8856 | Pixmap pixmap; | 8868 | Pixmap pixmap; |
| 8857 | struct frame *f; | 8869 | struct frame *f; |
| 8858 | { | 8870 | { |
| 8859 | struct image_cache *c = FRAME_X_IMAGE_CACHE (f); | 8871 | struct image_cache *c = FRAME_IMAGE_CACHE (f); |
| 8860 | int class, i; | 8872 | int class, i; |
| 8861 | struct image *img; | 8873 | struct image *img; |
| 8862 | 8874 | ||