changeset: 4362:600b94a559b0b289127e224ce93d7f4a783a72a7
tag: tip
user: Aidan Kehoe <kehoea(a)parhasard.net>
date: Tue Dec 25 16:59:41 2007 +0100
files: lisp/ChangeLog.carbon2 lisp/glyphs.el src/ChangeLog.carbon2
src/glyphs-carbon.c
description:
Support non-XPM image and text glyphs under Carbon.
lisp/ChangeLog addition:
2007-12-25 Aidan Kehoe <kehoea(a)parhasard.net>
* glyphs.el (init-glyphs):
Initialise image-conversion-list correctly for carbon.
src/ChangeLog addition:
2007-12-25 Aidan Kehoe <kehoea(a)parhasard.net>
glyphs-carbon.c:
Declare that Carbon consoles support the various common glyph
instantiators, if the appropriate libraries are available.
* glyphs-carbon.c (convert_EImage_to_image_ref):
Change to use the RGB format of real eimages.
* glyphs-carbon.c (convert_EImage_to_image_ref_with_alpha):
This is the old function; deals with RGBA data.
* glyphs-carbon.c (carbon_xpm_instantiate):
Call convert_EImage_to_image_ref_with_alpha, not
convert_EImage_to_image_ref, since the XPM data may have an alpha
channel.
diff -r 20b8c35ce0fd67c1ef15011f58d55003778f5f4d -r
600b94a559b0b289127e224ce93d7f4a783a72a7 lisp/ChangeLog.carbon2
--- a/lisp/ChangeLog.carbon2 Sun Dec 23 18:05:26 2007 +0100
+++ b/lisp/ChangeLog.carbon2 Tue Dec 25 16:59:41 2007 +0100
@@ -1,3 +1,8 @@ 2007-12-23 Aidan Kehoe <kehoea@parhasa
+2007-12-25 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * glyphs.el (init-glyphs):
+ Initialise image-conversion-list correctly for carbon.
+
2007-12-23 Aidan Kehoe <kehoea(a)parhasard.net>
* mule/mule-cmds.el (init-locale-at-early-startup):
diff -r 20b8c35ce0fd67c1ef15011f58d55003778f5f4d -r
600b94a559b0b289127e224ce93d7f4a783a72a7 lisp/glyphs.el
--- a/lisp/glyphs.el Sun Dec 23 18:05:26 2007 +0100
+++ b/lisp/glyphs.el Tue Dec 25 16:59:41 2007 +0100
@@ -1227,6 +1227,23 @@ If unspecified in a particular domain, `
;; finish initializing hscroll glyph -- created internally
;; because it has a built-in bitmap
(set-glyph-image hscroll-glyph "$" 'global 'tty)))
+ (if (featurep 'carbon)
+ (set-console-type-image-conversion-list 'carbon
+ `(,@(if (featurep 'xpm) '(("\\.xpm\\'" [xpm :file nil] 2)))
+ ("\\.xbm\\'" [xbm :file nil] 2)
+ ,@(if (featurep 'xpm) '(("\\`/\\* XPM \\*/" [xpm :data nil]
2)))
+ ,@(if (featurep 'xface) '(("\\`X-Face:" [xface :data nil] 2)))
+ ,@(if (featurep 'gif) '(("\\.gif\\'" [gif :file nil] 2)
+ ("\\`GIF8[79]" [gif :data nil] 2)))
+ ,@(if (featurep 'jpeg) '(("\\.jpe?g\\'" [jpeg :file nil]
2)))
+ ;; all of the JFIF-format JPEG's that I've seen begin with
+ ;; the following. I have no idea if this is standard.
+ ,@(if (featurep 'jpeg) '(("\\`\377\330\377\340\000\020JFIF"
+ [jpeg :data nil] 2)))
+ ,@(if (featurep 'png) '(("\\.png\\'" [png :file nil] 2)))
+ ,@(if (featurep 'png) '(("\\`\211PNG" [png :data nil] 2)))
+ ("" [string :data nil] 2)
+ ("" [nothing]))))
;; For streams, we don't want images at all -- dvl
(set-console-type-image-conversion-list 'stream '(("" [nothing])))
diff -r 20b8c35ce0fd67c1ef15011f58d55003778f5f4d -r
600b94a559b0b289127e224ce93d7f4a783a72a7 src/ChangeLog.carbon2
--- a/src/ChangeLog.carbon2 Sun Dec 23 18:05:26 2007 +0100
+++ b/src/ChangeLog.carbon2 Tue Dec 25 16:59:41 2007 +0100
@@ -1,3 +1,17 @@ 2007-12-23 Aidan Kehoe <kehoea@parhasa
+2007-12-25 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ glyphs-carbon.c:
+ Declare that Carbon consoles support the various common glyph
+ instantiators, if the appropriate libraries are available.
+ * glyphs-carbon.c (convert_EImage_to_image_ref):
+ Change to use the RGB format of real eimages.
+ * glyphs-carbon.c (convert_EImage_to_image_ref_with_alpha):
+ This is the old function; deals with RGBA data.
+ * glyphs-carbon.c (carbon_xpm_instantiate):
+ Call convert_EImage_to_image_ref_with_alpha, not
+ convert_EImage_to_image_ref, since the XPM data may have an alpha
+ channel.
+
2007-12-23 Aidan Kehoe <kehoea(a)parhasard.net>
* intl-carbon.c:
diff -r 20b8c35ce0fd67c1ef15011f58d55003778f5f4d -r
600b94a559b0b289127e224ce93d7f4a783a72a7 src/glyphs-carbon.c
--- a/src/glyphs-carbon.c Sun Dec 23 18:05:26 2007 +0100
+++ b/src/glyphs-carbon.c Tue Dec 25 16:59:41 2007 +0100
@@ -35,6 +35,23 @@ static CGColorRef transparent_color;
#ifdef HAVE_XPM
DEFINE_DEVICE_IIFORMAT (carbon, xpm);
+#endif
+
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing);
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (string);
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string);
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit);
+#ifdef HAVE_JPEG
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg);
+#endif
+#ifdef HAVE_TIFF
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff);
+#endif
+#ifdef HAVE_PNG
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (png);
+#endif
+#ifdef HAVE_GIF
+DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif);
#endif
/* Taken from glyphs-msw.c. */
@@ -136,6 +153,26 @@ convert_EImage_to_image_ref (int width,
convert_EImage_to_image_ref (int width, int height, Binbyte *pic)
{
/* Need to make a copy because data providers don't really /hold/ any data within
them, and contents of "pic" aren't guaranteed to hang around. */
+ unsigned int data_len = width * height * 3;
+ Binbyte *data = (Binbyte *) xmalloc (data_len);
+ memcpy (data, pic, data_len);
+
+ CGDataProviderRef provider = CGDataProviderCreateWithData (data, data, data_len,
data_provider_release_data);
+ CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB ();
+
+ CGImageRef image = CGImageCreate (width, height, 8, 24, width * 3, cs, 0, provider,
NULL, TRUE, kCGRenderingIntentDefault);
+
+ CGDataProviderRelease (provider);
+ CGColorSpaceRelease (cs);
+
+ /* Image retains provider, data should freed when image is freed. */
+ return image;
+}
+
+static CGImageRef
+convert_EImage_to_image_ref_with_alpha (int width, int height, Binbyte *pic)
+{
+ /* Need to make a copy because data providers don't really /hold/ any data within
them, and contents of "pic" aren't guaranteed to hang around. */
unsigned int data_len = width * height * 4;
Binbyte *data = (Binbyte *) xmalloc (data_len);
memcpy (data, pic, data_len);
@@ -225,7 +262,7 @@ carbon_init_image_instance_from_eimage (
for (slice = 0; slice < slices; slice++)
{
/* build a Quartz 2D image from the eimage */
- if (!(image_ref = convert_EImage_to_image_ref (width, height, eimage + (width *
height * 4 * slice))))
+ if (!(image_ref = convert_EImage_to_image_ref (width, height, eimage + (width *
height * 3 * slice))))
{
signal_image_error ("EImage to Quartz 2D image conversion failed",
instantiator);
}
@@ -578,7 +615,8 @@ carbon_xpm_instantiate (Lisp_Object imag
}
/* build a bitmap from the eimage */
- if (!(image_ref = convert_EImage_to_image_ref (width, height, eimage)))
+ if (!(image_ref = convert_EImage_to_image_ref_with_alpha
+ (width, height, eimage)))
{
signal_image_error ("XPM to EImage conversion failed",
image_instance);
@@ -607,9 +645,25 @@ void
void
image_instantiator_format_create_glyphs_carbon (void)
{
+ IIFORMAT_VALID_CONSOLE (carbon, nothing);
+ IIFORMAT_VALID_CONSOLE (carbon, string);
+ IIFORMAT_VALID_CONSOLE (carbon, formatted_string);
+ IIFORMAT_VALID_CONSOLE (carbon, inherit);
#ifdef HAVE_XPM
INITIALIZE_DEVICE_IIFORMAT (carbon, xpm);
IIFORMAT_HAS_DEVMETHOD (carbon, xpm, instantiate);
+#endif
+#ifdef HAVE_JPEG
+ IIFORMAT_VALID_CONSOLE (carbon, jpeg);
+#endif
+#ifdef HAVE_TIFF
+ IIFORMAT_VALID_CONSOLE (carbon, tiff);
+#endif
+#ifdef HAVE_PNG
+ IIFORMAT_VALID_CONSOLE (carbon, png);
+#endif
+#ifdef HAVE_GIF
+ IIFORMAT_VALID_CONSOLE (carbon, gif);
#endif
}
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches