Commit fcf431dc authored by Gerd Moellmann's avatar Gerd Moellmann
Browse files

(x_build_heuristic_mask): Accept a list `(R G B)'

as background color specification instead of an integer.
(image-cache-eviction-delay): Replaces image-eviction-seconds.
(Vimage_cache_eviction_delay): Replaces Vimage_eviction_seconds.
(clear_image_cache, syms_of_xfns): Use it.
(Qpostscript): Replaces Qghostscript.
(gs_type): Use it.
(gs_image_p): Ditto.
(syms_of_xfns): Initialize Qpostscript.
parent 61e59c1d
...@@ -5460,7 +5460,7 @@ Lisp_Object Qlaplace; ...@@ -5460,7 +5460,7 @@ Lisp_Object Qlaplace;
/* Time in seconds after which images should be removed from the cache /* Time in seconds after which images should be removed from the cache
if not displayed. */ if not displayed. */
Lisp_Object Vimage_eviction_seconds; Lisp_Object Vimage_cache_eviction_delay;
/* Function prototypes. */ /* Function prototypes. */
...@@ -5989,14 +5989,14 @@ clear_image_cache (f, force_p) ...@@ -5989,14 +5989,14 @@ clear_image_cache (f, force_p)
{ {
struct image_cache *c = FRAME_X_IMAGE_CACHE (f); struct image_cache *c = FRAME_X_IMAGE_CACHE (f);
if (c && INTEGERP (Vimage_eviction_seconds)) if (c && INTEGERP (Vimage_cache_eviction_delay))
{ {
EMACS_TIME t; EMACS_TIME t;
unsigned long old; unsigned long old;
int i, any_freed_p = 0; int i, any_freed_p = 0;
EMACS_GET_TIME (t); EMACS_GET_TIME (t);
old = EMACS_SECS (t) - XFASTINT (Vimage_eviction_seconds); old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);
for (i = 0; i < c->used; ++i) for (i = 0; i < c->used; ++i)
{ {
...@@ -7516,10 +7516,10 @@ x_laplace (f, img) ...@@ -7516,10 +7516,10 @@ x_laplace (f, img)
/* Build a mask for image IMG which is used on frame F. FILE is the /* Build a mask for image IMG which is used on frame F. FILE is the
name of an image file, for error messages. HOW determines how to name of an image file, for error messages. HOW determines how to
determine the background color of IMG. If it is an integer, take determine the background color of IMG. If it is a list '(R G B)',
that as the pixel value of the background. Otherwise, determine with R, G, and B being integers >= 0, take that as the color of the
the background color of IMG heuristically. Value is non-zero background. Otherwise, determine the background color of IMG
if successful. */ heuristically. Value is non-zero if successful. */
static int static int
x_build_heuristic_mask (f, file, img, how) x_build_heuristic_mask (f, file, img, how)
...@@ -7531,7 +7531,7 @@ x_build_heuristic_mask (f, file, img, how) ...@@ -7531,7 +7531,7 @@ x_build_heuristic_mask (f, file, img, how)
Display *dpy = FRAME_X_DISPLAY (f); Display *dpy = FRAME_X_DISPLAY (f);
Window win = FRAME_X_WINDOW (f); Window win = FRAME_X_WINDOW (f);
XImage *ximg, *mask_img; XImage *ximg, *mask_img;
int x, y, rc; int x, y, rc, look_at_corners_p;
unsigned long bg; unsigned long bg;
BLOCK_INPUT; BLOCK_INPUT;
...@@ -7549,12 +7549,41 @@ x_build_heuristic_mask (f, file, img, how) ...@@ -7549,12 +7549,41 @@ x_build_heuristic_mask (f, file, img, how)
ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height, ximg = XGetImage (dpy, img->pixmap, 0, 0, img->width, img->height,
~0, ZPixmap); ~0, ZPixmap);
/* Determine the background color of ximg. If HOW is an integer, /* Determine the background color of ximg. If HOW is `(R G B)'
take that as a pixel color. Otherwise, try to determine the take that as color. Otherwise, try to determine the color
color heuristically. */ heuristically. */
if (NATNUMP (how)) look_at_corners_p = 1;
bg = XFASTINT (how);
else if (CONSP (how))
{
int rgb[3], i = 0;
while (i < 3
&& CONSP (how)
&& NATNUMP (XCAR (how)))
{
rgb[i] = XFASTINT (XCAR (how)) & 0xffff;
how = XCDR (how);
}
if (i == 3 && NILP (how))
{
char color_name[30];
XColor exact, color;
Colormap cmap;
sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
if (XLookupColor (dpy, cmap, color_name, &exact, &color))
{
bg = color.pixel;
look_at_corners_p = 0;
}
}
}
if (look_at_corners_p)
{ {
unsigned long corners[4]; unsigned long corners[4];
int i, best_count; int i, best_count;
...@@ -8990,9 +9019,9 @@ static int gs_image_p P_ ((Lisp_Object object)); ...@@ -8990,9 +9019,9 @@ static int gs_image_p P_ ((Lisp_Object object));
static int gs_load P_ ((struct frame *f, struct image *img)); static int gs_load P_ ((struct frame *f, struct image *img));
static void gs_clear_image P_ ((struct frame *f, struct image *img)); static void gs_clear_image P_ ((struct frame *f, struct image *img));
/* The symbol `ghostscript' identifying images of this type. */ /* The symbol `postscript' identifying images of this type. */
Lisp_Object Qghostscript; Lisp_Object Qpostscript;
/* Keyword symbols. */ /* Keyword symbols. */
...@@ -9038,7 +9067,7 @@ static struct image_keyword gs_format[GS_LAST] = ...@@ -9038,7 +9067,7 @@ static struct image_keyword gs_format[GS_LAST] =
static struct image_type gs_type = static struct image_type gs_type =
{ {
&Qghostscript, &Qpostscript,
gs_image_p, gs_image_p,
gs_load, gs_load,
gs_clear_image, gs_clear_image,
...@@ -9072,7 +9101,7 @@ gs_image_p (object) ...@@ -9072,7 +9101,7 @@ gs_image_p (object)
bcopy (gs_format, fmt, sizeof fmt); bcopy (gs_format, fmt, sizeof fmt);
if (!parse_image_spec (object, fmt, GS_LAST, Qghostscript, 1) if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript, 1)
|| (fmt[GS_ASCENT].count || (fmt[GS_ASCENT].count
&& XFASTINT (fmt[GS_ASCENT].value) > 100)) && XFASTINT (fmt[GS_ASCENT].value) > 100))
return 0; return 0;
...@@ -10289,12 +10318,12 @@ such a font. This is especially effective for such large fonts as\n\ ...@@ -10289,12 +10318,12 @@ such a font. This is especially effective for such large fonts as\n\
Chinese, Japanese, and Korean."); Chinese, Japanese, and Korean.");
Vx_pixel_size_width_font_regexp = Qnil; Vx_pixel_size_width_font_regexp = Qnil;
DEFVAR_LISP ("image-eviction-seconds", &Vimage_eviction_seconds, DEFVAR_LISP ("image-cache-eviction-delay", &Vimage_cache_eviction_delay,
"Time after which cached images are removed from the cache.\n\ "Time after which cached images are removed from the cache.\n\
When an image has not been displayed this many seconds, remove it\n\ When an image has not been displayed this many seconds, remove it\n\
from the image cache. Value must be an integer or nil with nil\n\ from the image cache. Value must be an integer or nil with nil\n\
meaning don't clear the cache."); meaning don't clear the cache.");
Vimage_eviction_seconds = make_number (30 * 60); Vimage_cache_eviction_delay = make_number (30 * 60);
DEFVAR_LISP ("image-types", &Vimage_types, DEFVAR_LISP ("image-types", &Vimage_types,
"List of supported image types.\n\ "List of supported image types.\n\
...@@ -10390,8 +10419,8 @@ Each element of the list is a symbol for a supported image type."); ...@@ -10390,8 +10419,8 @@ Each element of the list is a symbol for a supported image type.");
staticpro (&QCmargin); staticpro (&QCmargin);
QCrelief = intern (":relief"); QCrelief = intern (":relief");
staticpro (&QCrelief); staticpro (&QCrelief);
Qghostscript = intern ("ghostscript"); Qpostscript = intern ("postscript");
staticpro (&Qghostscript); staticpro (&Qpostscript);
QCloader = intern (":loader"); QCloader = intern (":loader");
staticpro (&QCloader); staticpro (&QCloader);
QCbounding_box = intern (":bounding-box"); QCbounding_box = intern (":bounding-box");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment