summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerd Moellmann <gerd@gnu.org>2001-04-03 15:31:08 +0000
committerGerd Moellmann <gerd@gnu.org>2001-04-03 15:31:08 +0000
commitad18ffb15b8e9290c4ef52c2d0436be10cc89911 (patch)
treee3af2dd73a7626559f4f09cb689e567da15d2d92
parent24d451c54138183d78966e7e77f6c2f3e57b2751 (diff)
downloademacs-ad18ffb15b8e9290c4ef52c2d0436be10cc89911.tar.gz
(postprocess_image): New function.
(lookup_image): Call it for all image types except PostScript. (x_kill_gs_process): Call postprocess_image.
-rw-r--r--src/ChangeLog4
-rw-r--r--src/xfns.c153
2 files changed, 92 insertions, 65 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6555aca1264..28515da69a9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
2001-04-03 Gerd Moellmann <gerd@gnu.org>
+ * xfns.c (postprocess_image): New function.
+ (lookup_image): Call it for all image types except PostScript.
+ (x_kill_gs_process): Call postprocess_image.
+
* xterm.c (x_use_underline_position_properties): New variable.
(x_draw_glyph_string): Use it.
(syms_of_xterm): DEFVAR_BOOL it.
diff --git a/src/xfns.c b/src/xfns.c
index ddd158ed98a..37663e35e09 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5788,6 +5788,7 @@ x_alloc_image_color (f, img, color_name, dflt)
***********************************************************************/
static void cache_image P_ ((struct frame *f, struct image *img));
+static void postprocess_image P_ ((struct frame *, struct image *));
/* Return a new, initialized image cache that is allocated from the
@@ -5919,6 +5920,81 @@ FRAME t means clear the image caches of all frames.")
}
+/* Compute masks and transform image IMG on frame F, as specified
+ by the image's specification, */
+
+static void
+postprocess_image (f, img)
+ struct frame *f;
+ struct image *img;
+{
+ /* Manipulation of the image's mask. */
+ if (img->pixmap)
+ {
+ Lisp_Object conversion, spec;
+ Lisp_Object mask;
+
+ spec = img->spec;
+
+ /* `:heuristic-mask t'
+ `:mask heuristic'
+ means build a mask heuristically.
+ `:heuristic-mask (R G B)'
+ `:mask (heuristic (R G B))'
+ means build a mask from color (R G B) in the
+ image.
+ `:mask nil'
+ means remove a mask, if any. */
+
+ mask = image_spec_value (spec, QCheuristic_mask, NULL);
+ if (!NILP (mask))
+ x_build_heuristic_mask (f, img, mask);
+ else
+ {
+ int found_p;
+
+ mask = image_spec_value (spec, QCmask, &found_p);
+
+ if (EQ (mask, Qheuristic))
+ x_build_heuristic_mask (f, img, Qt);
+ else if (CONSP (mask)
+ && EQ (XCAR (mask), Qheuristic))
+ {
+ if (CONSP (XCDR (mask)))
+ x_build_heuristic_mask (f, img, XCAR (XCDR (mask)));
+ else
+ x_build_heuristic_mask (f, img, XCDR (mask));
+ }
+ else if (NILP (mask) && found_p && img->mask)
+ {
+ XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
+ img->mask = None;
+ }
+ }
+
+
+ /* Should we apply an image transformation algorithm? */
+ conversion = image_spec_value (spec, QCconversion, NULL);
+ if (EQ (conversion, Qdisabled))
+ x_disable_image (f, img);
+ else if (EQ (conversion, Qlaplace))
+ x_laplace (f, img);
+ else if (EQ (conversion, Qemboss))
+ x_emboss (f, img);
+ else if (CONSP (conversion)
+ && EQ (XCAR (conversion), Qedge_detection))
+ {
+ Lisp_Object tem;
+ tem = XCDR (conversion);
+ if (CONSP (tem))
+ x_edge_detection (f, img,
+ Fplist_get (tem, QCmatrix),
+ Fplist_get (tem, QCcolor_adjustment));
+ }
+ }
+}
+
+
/* Return the id of image with Lisp specification SPEC on frame F.
SPEC must be a valid Lisp image specification (see valid_image_p). */
@@ -5952,6 +6028,8 @@ lookup_image (f, spec)
/* If not found, create a new image and cache it. */
if (img == NULL)
{
+ extern Lisp_Object Qpostscript;
+
BLOCK_INPUT;
img = make_image (spec, hash);
cache_image (f, img);
@@ -6003,71 +6081,10 @@ lookup_image (f, spec)
img->vmargin += abs (img->relief);
}
- /* Manipulation of the image's mask. */
- if (img->pixmap)
- {
- /* `:heuristic-mask t'
- `:mask heuristic'
- means build a mask heuristically.
- `:heuristic-mask (R G B)'
- `:mask (heuristic (R G B))'
- means build a mask from color (R G B) in the
- image.
- `:mask nil'
- means remove a mask, if any. */
-
- Lisp_Object mask;
-
- mask = image_spec_value (spec, QCheuristic_mask, NULL);
- if (!NILP (mask))
- x_build_heuristic_mask (f, img, mask);
- else
- {
- int found_p;
-
- mask = image_spec_value (spec, QCmask, &found_p);
-
- if (EQ (mask, Qheuristic))
- x_build_heuristic_mask (f, img, Qt);
- else if (CONSP (mask)
- && EQ (XCAR (mask), Qheuristic))
- {
- if (CONSP (XCDR (mask)))
- x_build_heuristic_mask (f, img, XCAR (XCDR (mask)));
- else
- x_build_heuristic_mask (f, img, XCDR (mask));
- }
- else if (NILP (mask) && found_p && img->mask)
- {
- XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
- img->mask = None;
- }
- }
- }
-
- /* Should we apply an image transformation algorithm? */
- if (img->pixmap)
- {
- Lisp_Object conversion;
-
- conversion = image_spec_value (spec, QCconversion, NULL);
- if (EQ (conversion, Qdisabled))
- x_disable_image (f, img);
- else if (EQ (conversion, Qlaplace))
- x_laplace (f, img);
- else if (EQ (conversion, Qemboss))
- x_emboss (f, img);
- else if (CONSP (conversion)
- && EQ (XCAR (conversion), Qedge_detection))
- {
- Lisp_Object tem;
- tem = XCDR (conversion);
- if (CONSP (tem))
- x_edge_detection (f, img,
- Fplist_get (tem, QCmatrix),
- Fplist_get (tem, QCcolor_adjustment));
- }
- }
+ /* Do image transformations and compute masks, unless we
+ don't have the image yet. */
+ if (!EQ (*img->type->type, Qpostscript))
+ postprocess_image (f, img);
}
UNBLOCK_INPUT;
@@ -10092,6 +10109,12 @@ x_kill_gs_process (pixmap, f)
UNBLOCK_INPUT;
}
+
+ /* Now that we have the pixmap, compute mask and transform the
+ image if requested. */
+ BLOCK_INPUT;
+ postprocess_image (f, img);
+ UNBLOCK_INPUT;
}