Mercurial > emacs
comparison src/image.c @ 109859:68616bb3ae25
merged from trunk
author | Joakim <joakim@localhost.localdomain> |
---|---|
date | Mon, 14 Jun 2010 11:48:51 +0200 |
parents | d7a20b755b64 24d486687f54 |
children | c92f5e6103a8 |
comparison
equal
deleted
inserted
replaced
109858:73108272ef0b | 109859:68616bb3ae25 |
---|---|
1580 void | 1580 void |
1581 clear_image_cache (struct frame *f, Lisp_Object filter) | 1581 clear_image_cache (struct frame *f, Lisp_Object filter) |
1582 { | 1582 { |
1583 struct image_cache *c = FRAME_IMAGE_CACHE (f); | 1583 struct image_cache *c = FRAME_IMAGE_CACHE (f); |
1584 | 1584 |
1585 if (c && (!NILP (filter) || INTEGERP (Vimage_cache_eviction_delay))) | 1585 if (c) |
1586 { | 1586 { |
1587 EMACS_TIME t; | 1587 int i, nfreed = 0; |
1588 unsigned long old; | |
1589 int i, nfreed; | |
1590 | |
1591 EMACS_GET_TIME (t); | |
1592 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay); | |
1593 | 1588 |
1594 /* Block input so that we won't be interrupted by a SIGIO | 1589 /* Block input so that we won't be interrupted by a SIGIO |
1595 while being in an inconsistent state. */ | 1590 while being in an inconsistent state. */ |
1596 BLOCK_INPUT; | 1591 BLOCK_INPUT; |
1597 | 1592 |
1598 for (i = nfreed = 0; i < c->used; ++i) | 1593 if (!NILP (filter)) |
1599 { | 1594 { |
1600 struct image *img = c->images[i]; | 1595 /* Filter image cache. */ |
1601 if (img != NULL | 1596 for (i = 0; i < c->used; ++i) |
1602 && (NILP (filter) ? img->timestamp < old | |
1603 : (EQ (Qt, filter) | |
1604 || !NILP (Fmember (filter, img->dependencies))))) | |
1605 { | 1597 { |
1606 free_image (f, img); | 1598 struct image *img = c->images[i]; |
1607 ++nfreed; | 1599 if (img && (EQ (Qt, filter) |
1600 || !NILP (Fmember (filter, img->dependencies)))) | |
1601 { | |
1602 free_image (f, img); | |
1603 ++nfreed; | |
1604 } | |
1605 } | |
1606 } | |
1607 else if (INTEGERP (Vimage_cache_eviction_delay)) | |
1608 { | |
1609 /* Free cache based on timestamp. */ | |
1610 EMACS_TIME t; | |
1611 unsigned long old; | |
1612 int delay, nimages = 0; | |
1613 | |
1614 for (i = 0; i < c->used; ++i) | |
1615 if (c->images[i]) | |
1616 nimages++; | |
1617 | |
1618 /* If the number of cached images has grown unusually large, | |
1619 decrease the cache eviction delay (Bug#6230). */ | |
1620 delay = XFASTINT (Vimage_cache_eviction_delay); | |
1621 if (nimages > 40) | |
1622 delay = max (1, 1600 * delay / (nimages*nimages)); | |
1623 | |
1624 EMACS_GET_TIME (t); | |
1625 old = EMACS_SECS (t) - delay; | |
1626 | |
1627 for (i = 0; i < c->used; ++i) | |
1628 { | |
1629 struct image *img = c->images[i]; | |
1630 if (img && img->timestamp < old) | |
1631 { | |
1632 free_image (f, img); | |
1633 ++nfreed; | |
1634 } | |
1608 } | 1635 } |
1609 } | 1636 } |
1610 | 1637 |
1611 /* We may be clearing the image cache because, for example, | 1638 /* We may be clearing the image cache because, for example, |
1612 Emacs was iconified for a longer period of time. In that | 1639 Emacs was iconified for a longer period of time. In that |
1660 | 1687 |
1661 return Qnil; | 1688 return Qnil; |
1662 } | 1689 } |
1663 | 1690 |
1664 | 1691 |
1665 DEFUN ("image-refresh", Fimage_refresh, Simage_refresh, | 1692 DEFUN ("image-flush", Fimage_flush, Simage_flush, |
1666 1, 2, 0, | 1693 1, 2, 0, |
1667 doc: /* Refresh the image with specification SPEC on frame FRAME. | 1694 doc: /* Fush the image with specification SPEC on frame FRAME. |
1668 If SPEC specifies an image file, the displayed image is updated with | 1695 This removes the image from the Emacs image cache. If SPEC specifies |
1669 the current contents of that file. | 1696 an image file, the next redisplay of this image will read from the |
1697 current contents of that file. | |
1698 | |
1670 FRAME nil or omitted means use the selected frame. | 1699 FRAME nil or omitted means use the selected frame. |
1671 FRAME t means refresh the image on all frames. */) | 1700 FRAME t means refresh the image on all frames. */) |
1672 (spec, frame) | 1701 (spec, frame) |
1673 Lisp_Object spec, frame; | 1702 Lisp_Object spec, frame; |
1674 { | 1703 { |
8977 defsubr (&Sinit_image_library); | 9006 defsubr (&Sinit_image_library); |
8978 #ifdef HAVE_IMAGEMAGICK | 9007 #ifdef HAVE_IMAGEMAGICK |
8979 defsubr (&Simagemagick_types); | 9008 defsubr (&Simagemagick_types); |
8980 #endif | 9009 #endif |
8981 defsubr (&Sclear_image_cache); | 9010 defsubr (&Sclear_image_cache); |
8982 defsubr (&Simage_refresh); | 9011 defsubr (&Simage_flush); |
8983 defsubr (&Simage_size); | 9012 defsubr (&Simage_size); |
8984 defsubr (&Simage_mask_p); | 9013 defsubr (&Simage_mask_p); |
8985 defsubr (&Simage_metadata); | 9014 defsubr (&Simage_metadata); |
8986 | 9015 |
8987 #if GLYPH_DEBUG | 9016 #if GLYPH_DEBUG |
8998 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path, | 9027 DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path, |
8999 doc: /* List of directories to search for window system bitmap files. */); | 9028 doc: /* List of directories to search for window system bitmap files. */); |
9000 Vx_bitmap_file_path = decode_env_path ((char *) 0, PATH_BITMAPS); | 9029 Vx_bitmap_file_path = decode_env_path ((char *) 0, PATH_BITMAPS); |
9001 | 9030 |
9002 DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay, | 9031 DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay, |
9003 doc: /* Time after which cached images are removed from the cache. | 9032 doc: /* Maximum time after which images are removed from the cache. |
9004 When an image has not been displayed this many seconds, remove it | 9033 When an image has not been displayed this many seconds, Emacs |
9005 from the image cache. Value must be an integer or nil with nil | 9034 automatically removes it from the image cache. If the cache contains |
9006 meaning don't clear the cache. */); | 9035 a large number of images, the actual eviction time may be shorter. |
9007 Vimage_cache_eviction_delay = make_number (30 * 60); | 9036 The value can also be nil, meaning the cache is never cleared. |
9037 The function `clear-image-cache' disregards this variable. */); | |
9038 Vimage_cache_eviction_delay = make_number (300); | |
9039 } | |
9008 | 9040 |
9009 #ifdef HAVE_IMAGEMAGICK | 9041 #ifdef HAVE_IMAGEMAGICK |
9010 DEFVAR_LISP ("imagemagick-render-type", &Vimagemagick_render_type, | 9042 DEFVAR_LISP ("imagemagick-render-type", &Vimagemagick_render_type, |
9011 doc: /* */); | 9043 doc: /* */); |
9012 #endif | 9044 #endif |
9013 } | |
9014 | 9045 |
9015 void | 9046 void |
9016 init_image () | 9047 init_image () |
9017 { | 9048 { |
9018 | 9049 |