aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorMiles Bader2007-06-11 01:00:07 +0000
committerMiles Bader2007-06-11 01:00:07 +0000
commit67f3ad67ee317226cb5d1bb139de0cfd883fdc5e (patch)
tree58a0e1bea7a1d8728fd32e6127a44434e7eac006 /src/image.c
parentd17cf4eb2024cf54e4a216312184665094ee3df4 (diff)
parent2d715b39ea1c89066f469405d065dd1a6631d28e (diff)
downloademacs-67f3ad67ee317226cb5d1bb139de0cfd883fdc5e.tar.gz
emacs-67f3ad67ee317226cb5d1bb139de0cfd883fdc5e.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 781-792) - Update from CVS - Merge from gnus--rel--5.10 - Merge from emacs--rel--22 * emacs--rel--22 (patch 33-41) * gnus--rel--5.10 (patch 226-228) - Update from CVS Revision: emacs@sv.gnu.org/emacs--multi-tty--0--patch-21
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c57
1 files changed, 36 insertions, 21 deletions
diff --git a/src/image.c b/src/image.c
index fbd2f4e6a51..b53fe01d7f9 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1609,6 +1609,7 @@ x_alloc_image_color (f, img, color_name, dflt)
1609 Image Cache 1609 Image Cache
1610 ***********************************************************************/ 1610 ***********************************************************************/
1611 1611
1612static struct image *search_image_cache P_ ((struct frame *, Lisp_Object, unsigned));
1612static void cache_image P_ ((struct frame *f, struct image *img)); 1613static void cache_image P_ ((struct frame *f, struct image *img));
1613static void postprocess_image P_ ((struct frame *, struct image *)); 1614static void postprocess_image P_ ((struct frame *, struct image *));
1614 1615
@@ -1631,24 +1632,47 @@ make_image_cache ()
1631} 1632}
1632 1633
1633 1634
1634/* Search frame F for an images with spec SPEC, and free it. */ 1635/* Find an image matching SPEC in the cache, and return it. If no
1635 1636 image is found, return NULL. */
1636static void 1637static struct image *
1637uncache_image (f, spec) 1638search_image_cache (f, spec, hash)
1638 struct frame *f; 1639 struct frame *f;
1639 Lisp_Object spec; 1640 Lisp_Object spec;
1641 unsigned hash;
1640{ 1642{
1641 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
1642 struct image *img; 1643 struct image *img;
1643 unsigned hash = sxhash (spec, 0); 1644 struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
1645 Lisp_Object specified_bg = image_spec_value (spec, QCbackground, NULL);
1644 int i = hash % IMAGE_CACHE_BUCKETS_SIZE; 1646 int i = hash % IMAGE_CACHE_BUCKETS_SIZE;
1645 1647
1648 /* If the image spec does not specify a background color, the cached
1649 image must have the same background color as the current frame.
1650 The following code be improved. For example, jpeg does not
1651 support transparency, but currently a jpeg image spec won't match
1652 a cached spec created with a different frame background. The
1653 extra memory usage is probably negligible in practice. */
1654 if (!c) return NULL;
1655
1646 for (img = c->buckets[i]; img; img = img->next) 1656 for (img = c->buckets[i]; img; img = img->next)
1647 if (img->hash == hash && !NILP (Fequal (img->spec, spec))) 1657 if (img->hash == hash
1648 { 1658 && !NILP (Fequal (img->spec, spec))
1649 free_image (f, img); 1659 && (STRINGP (specified_bg)
1650 break; 1660 || img->background == FRAME_BACKGROUND_PIXEL (f)))
1651 } 1661 break;
1662 return img;
1663}
1664
1665
1666/* Search frame F for an image with spec SPEC, and free it. */
1667
1668static void
1669uncache_image (f, spec)
1670 struct frame *f;
1671 Lisp_Object spec;
1672{
1673 struct image *img = search_image_cache (f, spec, sxhash (spec, 0));
1674 if (img)
1675 free_image (f, img);
1652} 1676}
1653 1677
1654 1678
@@ -1877,7 +1901,6 @@ lookup_image (f, spec)
1877{ 1901{
1878 struct image_cache *c; 1902 struct image_cache *c;
1879 struct image *img; 1903 struct image *img;
1880 int i;
1881 unsigned hash; 1904 unsigned hash;
1882 struct gcpro gcpro1; 1905 struct gcpro gcpro1;
1883 EMACS_TIME now; 1906 EMACS_TIME now;
@@ -1893,12 +1916,7 @@ lookup_image (f, spec)
1893 1916
1894 /* Look up SPEC in the hash table of the image cache. */ 1917 /* Look up SPEC in the hash table of the image cache. */
1895 hash = sxhash (spec, 0); 1918 hash = sxhash (spec, 0);
1896 i = hash % IMAGE_CACHE_BUCKETS_SIZE; 1919 img = search_image_cache (f, spec, hash);
1897
1898 for (img = c->buckets[i]; img; img = img->next)
1899 if (img->hash == hash && !NILP (Fequal (img->spec, spec)))
1900 break;
1901
1902 if (img && img->load_failed_p) 1920 if (img && img->load_failed_p)
1903 { 1921 {
1904 free_image (f, img); 1922 free_image (f, img);
@@ -3963,9 +3981,6 @@ xpm_load (f, img)
3963 attrs.valuemask |= XpmCloseness; 3981 attrs.valuemask |= XpmCloseness;
3964#endif /* not XpmAllocCloseColors */ 3982#endif /* not XpmAllocCloseColors */
3965#endif /* ALLOC_XPM_COLORS */ 3983#endif /* ALLOC_XPM_COLORS */
3966#ifdef ALLOC_XPM_COLORS
3967 xpm_init_color_cache (f, &attrs);
3968#endif
3969 3984
3970 /* If image specification contains symbolic color definitions, add 3985 /* If image specification contains symbolic color definitions, add
3971 these to `attrs'. */ 3986 these to `attrs'. */