Mercurial > hg > xemacs-beta
comparison src/glyphs-x.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 2e6f5e180fb8 |
children | 54cc21c15cbb |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
55 #include "insdel.h" | 55 #include "insdel.h" |
56 #include "opaque.h" | 56 #include "opaque.h" |
57 | 57 |
58 #include "sysfile.h" | 58 #include "sysfile.h" |
59 | 59 |
60 #ifdef HAVE_PNG | |
61 #include <png.h> | |
62 #else | |
63 #include <setjmp.h> | 60 #include <setjmp.h> |
64 #endif | |
65 | 61 |
66 #define LISP_DEVICE_TO_X_SCREEN(dev) \ | 62 #define LISP_DEVICE_TO_X_SCREEN(dev) \ |
67 XDefaultScreenOfDisplay (DEVICE_X_DISPLAY (XDEVICE (dev))) | 63 XDefaultScreenOfDisplay (DEVICE_X_DISPLAY (XDEVICE (dev))) |
68 | 64 |
69 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xbm); | 65 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xbm); |
112 | 108 |
113 static void cursor_font_instantiate (Lisp_Object image_instance, | 109 static void cursor_font_instantiate (Lisp_Object image_instance, |
114 Lisp_Object instantiator, | 110 Lisp_Object instantiator, |
115 Lisp_Object pointer_fg, | 111 Lisp_Object pointer_fg, |
116 Lisp_Object pointer_bg, | 112 Lisp_Object pointer_bg, |
117 int dest_mask, | 113 int dest_mask); |
118 Lisp_Object domain); | |
119 | 114 |
120 #include "bitmaps.h" | 115 #include "bitmaps.h" |
121 | 116 |
122 | 117 |
123 /************************************************************************/ | 118 /************************************************************************/ |
143 sprintf (buf, "/0x%lx", (unsigned long) IMAGE_INSTANCE_X_MASK (p)); | 138 sprintf (buf, "/0x%lx", (unsigned long) IMAGE_INSTANCE_X_MASK (p)); |
144 write_c_string (buf, printcharfun); | 139 write_c_string (buf, printcharfun); |
145 } | 140 } |
146 write_c_string (")", printcharfun); | 141 write_c_string (")", printcharfun); |
147 break; | 142 break; |
148 #if HAVE_SUBWINDOWS | |
149 case IMAGE_SUBWINDOW: | 143 case IMAGE_SUBWINDOW: |
150 /* #### implement me */ | 144 /* #### implement me */ |
151 #endif | |
152 default: | 145 default: |
153 break; | 146 break; |
154 } | 147 } |
155 } | 148 } |
156 | 149 |
207 case IMAGE_COLOR_PIXMAP: | 200 case IMAGE_COLOR_PIXMAP: |
208 case IMAGE_POINTER: | 201 case IMAGE_POINTER: |
209 if (IMAGE_INSTANCE_X_NPIXELS (p1) != IMAGE_INSTANCE_X_NPIXELS (p2)) | 202 if (IMAGE_INSTANCE_X_NPIXELS (p1) != IMAGE_INSTANCE_X_NPIXELS (p2)) |
210 return 0; | 203 return 0; |
211 break; | 204 break; |
212 #if HAVE_SUBWINDOWS | |
213 case IMAGE_SUBWINDOW: | 205 case IMAGE_SUBWINDOW: |
214 /* #### implement me */ | 206 /* #### implement me */ |
215 break; | 207 break; |
216 #endif | |
217 default: | 208 default: |
218 break; | 209 break; |
219 } | 210 } |
220 | 211 |
221 return 1; | 212 return 1; |
228 { | 219 { |
229 case IMAGE_MONO_PIXMAP: | 220 case IMAGE_MONO_PIXMAP: |
230 case IMAGE_COLOR_PIXMAP: | 221 case IMAGE_COLOR_PIXMAP: |
231 case IMAGE_POINTER: | 222 case IMAGE_POINTER: |
232 return IMAGE_INSTANCE_X_NPIXELS (p); | 223 return IMAGE_INSTANCE_X_NPIXELS (p); |
233 #if HAVE_SUBWINDOWS | |
234 case IMAGE_SUBWINDOW: | 224 case IMAGE_SUBWINDOW: |
235 /* #### implement me */ | 225 /* #### implement me */ |
236 return 0; | 226 return 0; |
237 #endif | |
238 default: | 227 default: |
239 return 0; | 228 return 0; |
240 } | 229 } |
241 } | 230 } |
242 | 231 |
285 Display *display; | 274 Display *display; |
286 | 275 |
287 /* Check non-absolute pathnames with a directory component relative to | 276 /* Check non-absolute pathnames with a directory component relative to |
288 the search path; that's the way Xt does it. */ | 277 the search path; that's the way Xt does it. */ |
289 /* #### Unix-specific */ | 278 /* #### Unix-specific */ |
290 if (XSTRING_BYTE (name, 0) == '/' || | 279 if (string_byte (XSTRING (name), 0) == '/' || |
291 (XSTRING_BYTE (name, 0) == '.' && | 280 (string_byte (XSTRING (name), 0) == '.' && |
292 (XSTRING_BYTE (name, 1) == '/' || | 281 (string_byte (XSTRING (name), 1) == '/' || |
293 (XSTRING_BYTE (name, 1) == '.' && | 282 (string_byte (XSTRING (name), 1) == '.' && |
294 (XSTRING_BYTE (name, 2) == '/'))))) | 283 (string_byte (XSTRING (name), 2) == '/'))))) |
295 { | 284 { |
296 if (!NILP (Ffile_readable_p (name))) | 285 if (!NILP (Ffile_readable_p (name))) |
297 return name; | 286 return name; |
298 else | 287 else |
299 return Qnil; | 288 return Qnil; |
390 | 379 |
391 static Lisp_Object | 380 static Lisp_Object |
392 simple_image_type_normalize (Lisp_Object inst, Lisp_Object console_type, | 381 simple_image_type_normalize (Lisp_Object inst, Lisp_Object console_type, |
393 Lisp_Object image_type_tag) | 382 Lisp_Object image_type_tag) |
394 { | 383 { |
395 /* This function can call lisp */ | |
396 Lisp_Object file = Qnil; | 384 Lisp_Object file = Qnil; |
397 struct gcpro gcpro1, gcpro2; | 385 struct gcpro gcpro1, gcpro2; |
398 Lisp_Object alist = Qnil; | 386 Lisp_Object alist = Qnil; |
399 | 387 |
400 GCPRO2 (file, alist); | 388 GCPRO2 (file, alist); |
994 abort (); | 982 abort (); |
995 } | 983 } |
996 } | 984 } |
997 | 985 |
998 static int | 986 static int |
999 xbm_possible_dest_types (void) | 987 xbm_possible_dest_types () |
1000 { | 988 { |
1001 return | 989 return IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK | |
1002 IMAGE_MONO_PIXMAP_MASK | | |
1003 IMAGE_COLOR_PIXMAP_MASK | | |
1004 IMAGE_POINTER_MASK; | 990 IMAGE_POINTER_MASK; |
1005 } | 991 } |
1006 | 992 |
1007 static void | 993 static void |
1008 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, | 994 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, |
1037 /* Instantiate method for XBM's. */ | 1023 /* Instantiate method for XBM's. */ |
1038 | 1024 |
1039 static void | 1025 static void |
1040 xbm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1026 xbm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1041 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1027 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1042 int dest_mask, Lisp_Object domain) | 1028 int dest_mask) |
1043 { | 1029 { |
1044 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1030 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1045 CONST char *gcc_go_home; | 1031 CONST char *gcc_go_home; |
1046 | 1032 |
1047 assert (!NILP (data)); | 1033 assert (!NILP (data)); |
1062 **********************************************************************/ | 1048 **********************************************************************/ |
1063 | 1049 |
1064 #include "jpeglib.h" | 1050 #include "jpeglib.h" |
1065 #include "jerror.h" | 1051 #include "jerror.h" |
1066 | 1052 |
1067 /* The in-core jpeg code doesn't work, so I'm avoiding it for now. -sb */ | |
1068 /* Late-breaking update, we're going to give it a try, I think it's */ | |
1069 /* fixed now -sb */ | |
1070 /* #define USE_TEMP_FILES_FOR_JPEG_IMAGES 1 */ | |
1071 | |
1072 static void | 1053 static void |
1073 jpeg_validate (Lisp_Object instantiator) | 1054 jpeg_validate (Lisp_Object instantiator) |
1074 { | 1055 { |
1075 file_or_data_must_be_present (instantiator); | 1056 file_or_data_must_be_present (instantiator); |
1076 } | 1057 } |
1080 { | 1061 { |
1081 return simple_image_type_normalize (inst, console_type, Qjpeg); | 1062 return simple_image_type_normalize (inst, console_type, Qjpeg); |
1082 } | 1063 } |
1083 | 1064 |
1084 static int | 1065 static int |
1085 jpeg_possible_dest_types (void) | 1066 jpeg_possible_dest_types () |
1086 { | 1067 { |
1087 return IMAGE_COLOR_PIXMAP_MASK; | 1068 return IMAGE_COLOR_PIXMAP_MASK; |
1088 } | 1069 } |
1089 | 1070 |
1090 /* To survive the otherwise baffling complexity of making sure | 1071 /* To survive the otherwise baffling complexity of making sure |
1186 METHODDEF(boolean) | 1167 METHODDEF(boolean) |
1187 #else | 1168 #else |
1188 METHODDEF boolean | 1169 METHODDEF boolean |
1189 #endif | 1170 #endif |
1190 our_fill_input_buffer (j_decompress_ptr cinfo) { | 1171 our_fill_input_buffer (j_decompress_ptr cinfo) { |
1191 /* Insert a fake EOI marker */ | 1172 ERREXIT(cinfo,JERR_INPUT_EOF); |
1192 struct jpeg_source_mgr *src = (struct jpeg_source_mgr *) cinfo->src; | 1173 return FALSE; |
1193 static JOCTET buffer[2]; | |
1194 | |
1195 buffer[0] = (JOCTET) 0xFF; | |
1196 buffer[1] = (JOCTET) JPEG_EOI; | |
1197 | |
1198 src->next_input_byte = buffer; | |
1199 src->bytes_in_buffer = 2; | |
1200 return TRUE; | |
1201 } | 1174 } |
1202 | 1175 |
1203 #if defined(JPEG_LIB_VERSION) && (JPEG_LIB_VERSION >= 61) | 1176 #if defined(JPEG_LIB_VERSION) && (JPEG_LIB_VERSION >= 61) |
1204 METHODDEF(void) | 1177 METHODDEF(void) |
1205 #else | 1178 #else |
1206 METHODDEF void | 1179 METHODDEF void |
1207 #endif | 1180 #endif |
1208 our_skip_input_data (j_decompress_ptr cinfo, long num_bytes) { | 1181 our_skip_input_data (j_decompress_ptr cinfo, long num_bytes) { |
1209 struct jpeg_source_mgr *src = NULL; | |
1210 | |
1211 src = (struct jpeg_source_mgr *) cinfo->src; | |
1212 | |
1213 if (!src) { | |
1214 return; | |
1215 } else if (num_bytes > src->bytes_in_buffer) { | |
1216 ERREXIT(cinfo, JERR_INPUT_EOF); | |
1217 /*NOTREACHED*/ | |
1218 } | |
1219 | |
1220 src->bytes_in_buffer -= num_bytes; | |
1221 src->next_input_byte += num_bytes; | |
1222 } | 1182 } |
1223 | 1183 |
1224 #if defined(JPEG_LIB_VERSION) && (JPEG_LIB_VERSION >= 61) | 1184 #if defined(JPEG_LIB_VERSION) && (JPEG_LIB_VERSION >= 61) |
1225 METHODDEF(void) | 1185 METHODDEF(void) |
1226 #else | 1186 #else |
1272 /* The code in this routine is based on example.c from the JPEG library | 1232 /* The code in this routine is based on example.c from the JPEG library |
1273 source code and from gif_instantiate() */ | 1233 source code and from gif_instantiate() */ |
1274 static void | 1234 static void |
1275 jpeg_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1235 jpeg_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1276 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1236 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1277 int dest_mask, Lisp_Object domain) | 1237 int dest_mask) |
1278 { | 1238 { |
1279 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1239 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1280 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1240 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1281 Display *dpy; | 1241 Display *dpy; |
1282 Screen *scr; | 1242 Screen *scr; |
1307 | 1267 |
1308 memset (&unwind, 0, sizeof (unwind)); | 1268 memset (&unwind, 0, sizeof (unwind)); |
1309 unwind.dpy = dpy; | 1269 unwind.dpy = dpy; |
1310 record_unwind_protect (jpeg_instantiate_unwind, make_opaque_ptr (&unwind)); | 1270 record_unwind_protect (jpeg_instantiate_unwind, make_opaque_ptr (&unwind)); |
1311 | 1271 |
1312 #ifdef USE_TEMP_FILES_FOR_JPEG_IMAGES | 1272 #ifdef USE_TEMP_FILES_FOR_IMAGES |
1313 /* Step 0: Write out to a temp file. | 1273 /* Step 0: Write out to a temp file. |
1314 | 1274 |
1315 The JPEG routines require you to read from a file unless | 1275 The JPEG routines require you to read from a file unless |
1316 you provide your own special input handlers, which I don't | 1276 you provide your own special input handlers, which I don't |
1317 feel like doing. */ | 1277 feel like doing. */ |
1363 jpeg_create_decompress (&cinfo); | 1323 jpeg_create_decompress (&cinfo); |
1364 unwind.cinfo_ptr = &cinfo; | 1324 unwind.cinfo_ptr = &cinfo; |
1365 | 1325 |
1366 /* Step 2: specify data source (eg, a file) */ | 1326 /* Step 2: specify data source (eg, a file) */ |
1367 | 1327 |
1368 #ifdef USE_TEMP_FILES_FOR_JPEG_IMAGES | 1328 #ifdef USE_FILEIO_FOR_IMAGES |
1369 jpeg_stdio_src (&cinfo, unwind.instream); | 1329 jpeg_stdio_src (&cinfo, unwind.instream); |
1370 #else | 1330 #else |
1371 { | 1331 { |
1372 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1332 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1373 Extbyte *bytes; | 1333 Extbyte *bytes; |
1582 { | 1542 { |
1583 return simple_image_type_normalize (inst, console_type, Qgif); | 1543 return simple_image_type_normalize (inst, console_type, Qgif); |
1584 } | 1544 } |
1585 | 1545 |
1586 static int | 1546 static int |
1587 gif_possible_dest_types (void) | 1547 gif_possible_dest_types () |
1588 { | 1548 { |
1589 return IMAGE_COLOR_PIXMAP_MASK; | 1549 return IMAGE_COLOR_PIXMAP_MASK; |
1590 } | 1550 } |
1591 | 1551 |
1592 /* To survive the otherwise baffling complexity of making sure | 1552 /* To survive the otherwise baffling complexity of making sure |
1637 } | 1597 } |
1638 | 1598 |
1639 return Qnil; | 1599 return Qnil; |
1640 } | 1600 } |
1641 | 1601 |
1642 #if 0 | |
1643 /* We provide our own version of DGifSlurp() because the standardly | 1602 /* We provide our own version of DGifSlurp() because the standardly |
1644 provided one doesn't handle interlaced GIFs. This is based on | 1603 provided one doesn't handle interlaced GIFs. This is based on |
1645 code in gif2x11.c. */ | 1604 code in gif2x11.c. */ |
1646 | 1605 |
1647 /* Return value is GIF_ERROR, GIF_OK, or -1. | 1606 /* Return value is GIF_ERROR, GIF_OK, or -1. |
1711 &sp->RasterBits[(Row++) * Width + Col], | 1670 &sp->RasterBits[(Row++) * Width + Col], |
1712 Width) == GIF_ERROR) | 1671 Width) == GIF_ERROR) |
1713 return GIF_ERROR; | 1672 return GIF_ERROR; |
1714 } | 1673 } |
1715 } | 1674 } |
1716 | |
1717 /* Only get 1 image from animated gifs. */ | |
1718 /* #### if the rest of the file was bad, we still return | |
1719 GIF_OK, since we don't even bother looking at it. Should | |
1720 probably check for ImageCount == 1 above too, hmm. */ | |
1721 goto done; | |
1722 break; | 1675 break; |
1723 | 1676 |
1724 case EXTENSION_RECORD_TYPE: | 1677 case EXTENSION_RECORD_TYPE: |
1725 /* Skip any extension blocks in file: */ | 1678 /* Skip any extension blocks in file: */ |
1726 if (DGifGetExtension (GifFile, &ExtCode, &Extension) == GIF_ERROR) | 1679 if (DGifGetExtension (GifFile, &ExtCode, &Extension) == GIF_ERROR) |
1740 break; | 1693 break; |
1741 } | 1694 } |
1742 } | 1695 } |
1743 while (RecordType != TERMINATE_RECORD_TYPE); | 1696 while (RecordType != TERMINATE_RECORD_TYPE); |
1744 | 1697 |
1745 done: | |
1746 | |
1747 return GIF_OK; | 1698 return GIF_OK; |
1748 } | 1699 } |
1749 #endif | |
1750 | 1700 |
1751 static void | 1701 static void |
1752 gif_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1702 gif_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1753 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1703 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1754 int dest_mask, Lisp_Object domain) | 1704 int dest_mask) |
1755 { | 1705 { |
1756 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1706 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1757 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1707 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1758 Display *dpy; | 1708 Display *dpy; |
1759 Screen *scr; | 1709 Screen *scr; |
1794 { | 1744 { |
1795 gif_decode_error: | 1745 gif_decode_error: |
1796 signal_simple_error ("Unable to decode GIF", | 1746 signal_simple_error ("Unable to decode GIF", |
1797 build_string (EmacsPrintGifError ())); | 1747 build_string (EmacsPrintGifError ())); |
1798 } | 1748 } |
1799 #if 0 | 1749 #if 1 |
1800 if (our_own_dgif_slurp_from_gif2x11_c(unwind.giffile) != GIF_OK) | 1750 if (our_own_dgif_slurp_from_gif2x11_c(unwind.giffile) != GIF_OK) |
1801 #else | 1751 #else |
1802 /* DGifSlurp() doesn't handle interlaced files. */ | 1752 /* DGifSlurp() doesn't handle interlaced files. */ |
1803 /* Actually, it does, sort of. It just sets the Interlace flag | |
1804 and stores RasterBits in interlaced order. We handle that below. */ | |
1805 if (DGifSlurp (unwind.giffile) != GIF_OK) | 1753 if (DGifSlurp (unwind.giffile) != GIF_OK) |
1806 #endif | 1754 #endif |
1807 goto gif_decode_error; | 1755 goto gif_decode_error; |
1808 } | 1756 } |
1809 | 1757 |
1838 { | 1786 { |
1839 int height = unwind.giffile->SHeight; | 1787 int height = unwind.giffile->SHeight; |
1840 int width = unwind.giffile->SWidth; | 1788 int width = unwind.giffile->SWidth; |
1841 int depth; | 1789 int depth; |
1842 int bitmap_pad; | 1790 int bitmap_pad; |
1843 int i, j, row, pass, interlace; | 1791 int i, j; |
1844 /* interlaced gifs have rows in this order: | |
1845 0, 8, 16, ..., 4, 12, 20, ..., 2, 6, 10, ..., 1, 3, 5, ... */ | |
1846 static int InterlacedOffset[] = { 0, 4, 2, 1 }; | |
1847 static int InterlacedJumps[] = { 8, 8, 4, 2 }; | |
1848 | |
1849 | 1792 |
1850 depth = DefaultDepthOfScreen (scr); | 1793 depth = DefaultDepthOfScreen (scr); |
1851 | 1794 |
1852 /* first get bitmap_pad (from XPM) */ | 1795 /* first get bitmap_pad (from XPM) */ |
1853 if (depth > 16) | 1796 if (depth > 16) |
1876 long run, what with all the XPM overhead. If this proves | 1819 long run, what with all the XPM overhead. If this proves |
1877 to be a bottleneck here, maybe we should just copy the | 1820 to be a bottleneck here, maybe we should just copy the |
1878 optimization routines from XPM (they're in turn mostly | 1821 optimization routines from XPM (they're in turn mostly |
1879 copied from the Xlib source code). */ | 1822 copied from the Xlib source code). */ |
1880 | 1823 |
1881 /* Note: We just use the first image in the file and ignore the rest. | |
1882 We check here that that image covers the full "screen" size. | |
1883 I don't know whether that's always the case. | |
1884 -dkindred@cs.cmu.edu */ | |
1885 if (unwind.giffile->SavedImages[0].ImageDesc.Height != height | |
1886 || unwind.giffile->SavedImages[0].ImageDesc.Width != width | |
1887 || unwind.giffile->SavedImages[0].ImageDesc.Left != 0 | |
1888 || unwind.giffile->SavedImages[0].ImageDesc.Top != 0) | |
1889 signal_simple_error ("First image in GIF file is not full size", | |
1890 instantiator); | |
1891 | |
1892 interlace = unwind.giffile->SavedImages[0].ImageDesc.Interlace; | |
1893 pass = 0; | |
1894 row = interlace ? InterlacedOffset[pass] : 0; | |
1895 for (i = 0; i < height; i++) | 1824 for (i = 0; i < height; i++) |
1896 { | 1825 for (j = 0; j < width; j++) |
1897 if (interlace && row >= height) | 1826 XPutPixel (unwind.ximage, j, i, |
1898 row = InterlacedOffset[++pass]; | 1827 unwind.pixels[(unsigned char) |
1899 | 1828 /* incorrect signed declaration |
1900 for (j = 0; j < width; j++) | 1829 of RasterBits[] */ |
1901 XPutPixel (unwind.ximage, j, row, | 1830 (unwind.giffile->SavedImages-> |
1902 unwind.pixels[(unsigned char) | 1831 RasterBits[i * width + j])]); |
1903 /* incorrect signed declaration | |
1904 of RasterBits[] */ | |
1905 (unwind.giffile->SavedImages[0]. | |
1906 RasterBits[i * width + j])]); | |
1907 | |
1908 row += interlace ? InterlacedJumps[pass] : 1; | |
1909 } | |
1910 } | 1832 } |
1911 | 1833 |
1912 /* 4. Now create the pixmap and set up the image instance */ | 1834 /* 4. Now create the pixmap and set up the image instance */ |
1913 init_image_instance_from_x_image (ii, unwind.ximage, dest_mask, | 1835 init_image_instance_from_x_image (ii, unwind.ximage, dest_mask, |
1914 unwind.pixels, unwind.npixels, | 1836 unwind.pixels, unwind.npixels, |
1923 #endif /* HAVE_GIF */ | 1845 #endif /* HAVE_GIF */ |
1924 | 1846 |
1925 | 1847 |
1926 #ifdef HAVE_PNG | 1848 #ifdef HAVE_PNG |
1927 | 1849 |
1850 #include <png.h> | |
1851 | |
1928 /********************************************************************** | 1852 /********************************************************************** |
1929 * PNG * | 1853 * PNG * |
1930 **********************************************************************/ | 1854 **********************************************************************/ |
1931 static void | 1855 static void |
1932 png_validate (Lisp_Object instantiator) | 1856 png_validate (Lisp_Object instantiator) |
1939 { | 1863 { |
1940 return simple_image_type_normalize (inst, console_type, Qpng); | 1864 return simple_image_type_normalize (inst, console_type, Qpng); |
1941 } | 1865 } |
1942 | 1866 |
1943 static int | 1867 static int |
1944 png_possible_dest_types (void) | 1868 png_possible_dest_types () |
1945 { | 1869 { |
1946 return IMAGE_COLOR_PIXMAP_MASK; | 1870 return IMAGE_COLOR_PIXMAP_MASK; |
1947 } | 1871 } |
1948 | 1872 |
1949 #if !defined (USE_TEMP_FILES_FOR_IMAGES) && (PNG_LIBPNG_VER >= 87) | 1873 #if !defined (USE_TEMP_FILES_FOR_IMAGES) && (PNG_LIBPNG_VER >= 87) |
2032 #endif | 1956 #endif |
2033 | 1957 |
2034 static void | 1958 static void |
2035 png_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1959 png_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2036 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1960 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2037 int dest_mask, Lisp_Object domain) | 1961 int dest_mask) |
2038 { | 1962 { |
2039 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1963 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2040 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1964 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
2041 Display *dpy; | 1965 Display *dpy; |
2042 Screen *scr; | 1966 Screen *scr; |
2318 signal_simple_error ("No TIFF support yet", inst); | 2242 signal_simple_error ("No TIFF support yet", inst); |
2319 return Qnil; | 2243 return Qnil; |
2320 } | 2244 } |
2321 | 2245 |
2322 static int | 2246 static int |
2323 tiff_possible_dest_types (void) | 2247 tiff_possible_dest_types () |
2324 { | 2248 { |
2325 return IMAGE_COLOR_PIXMAP_MASK; | 2249 return IMAGE_COLOR_PIXMAP_MASK; |
2326 } | 2250 } |
2327 | 2251 |
2328 static void | 2252 static void |
2329 tiff_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2253 tiff_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2330 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2254 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2331 int dest_mask, Lisp_Object domain) | 2255 int dest_mask) |
2332 { | 2256 { |
2333 abort (); | 2257 abort (); |
2334 } | 2258 } |
2335 | 2259 |
2336 #endif /* HAVE_TIFF */ | 2260 #endif /* HAVE_TIFF */ |
2534 RETURN_UNGCPRO (result); | 2458 RETURN_UNGCPRO (result); |
2535 } | 2459 } |
2536 } | 2460 } |
2537 | 2461 |
2538 static int | 2462 static int |
2539 xpm_possible_dest_types (void) | 2463 xpm_possible_dest_types () |
2540 { | 2464 { |
2541 return | 2465 return IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK | |
2542 IMAGE_MONO_PIXMAP_MASK | | |
2543 IMAGE_COLOR_PIXMAP_MASK | | |
2544 IMAGE_POINTER_MASK; | 2466 IMAGE_POINTER_MASK; |
2545 } | 2467 } |
2546 | 2468 |
2547 /* xpm 3.2g and better has XpmCreatePixmapFromBuffer()... | 2469 /* xpm 3.2g and better has XpmCreatePixmapFromBuffer()... |
2548 There was no version number in xpm.h before 3.3, but this should do. | 2470 There was no version number in xpm.h before 3.3, but this should do. |
2556 Upgrade to version 3.2g or better or compile with --with-xpm=no. | 2478 Upgrade to version 3.2g or better or compile with --with-xpm=no. |
2557 #endif /* !XPM_DOES_BUFFERS */ | 2479 #endif /* !XPM_DOES_BUFFERS */ |
2558 | 2480 |
2559 static XpmColorSymbol * | 2481 static XpmColorSymbol * |
2560 extract_xpm_color_names (XpmAttributes *xpmattrs, Lisp_Object device, | 2482 extract_xpm_color_names (XpmAttributes *xpmattrs, Lisp_Object device, |
2561 Lisp_Object domain, | |
2562 Lisp_Object color_symbol_alist) | 2483 Lisp_Object color_symbol_alist) |
2563 { | 2484 { |
2564 /* This function can GC */ | 2485 /* This function can GC */ |
2565 Screen *xs = LISP_DEVICE_TO_X_SCREEN (device); | 2486 Screen *xs = LISP_DEVICE_TO_X_SCREEN (device); |
2566 Display *dpy = DisplayOfScreen (xs); | 2487 Display *dpy = DisplayOfScreen (xs); |
2590 Fmake_color_instance | 2511 Fmake_color_instance |
2591 (value, device, encode_error_behavior_flag (ERROR_ME_NOT)); | 2512 (value, device, encode_error_behavior_flag (ERROR_ME_NOT)); |
2592 else | 2513 else |
2593 { | 2514 { |
2594 assert (COLOR_SPECIFIERP (value)); | 2515 assert (COLOR_SPECIFIERP (value)); |
2595 value = Fspecifier_instance (value, domain, Qnil, Qnil); | 2516 value = Fspecifier_instance (value, device, Qnil, Qnil); |
2596 } | 2517 } |
2597 if (NILP (value)) | 2518 if (NILP (value)) |
2598 continue; | 2519 continue; |
2599 results = noseeum_cons (noseeum_cons (name, value), results); | 2520 results = noseeum_cons (noseeum_cons (name, value), results); |
2600 i++; | 2521 i++; |
2639 } | 2560 } |
2640 | 2561 |
2641 static void | 2562 static void |
2642 xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2563 xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2643 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2564 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2644 int dest_mask, Lisp_Object domain) | 2565 int dest_mask) |
2645 { | 2566 { |
2646 /* This function can GC */ | 2567 /* This function can GC */ |
2647 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2568 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2648 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 2569 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
2649 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 2570 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
2700 { | 2621 { |
2701 xpmattrs.closeness = 65535; | 2622 xpmattrs.closeness = 65535; |
2702 xpmattrs.valuemask |= XpmCloseness; | 2623 xpmattrs.valuemask |= XpmCloseness; |
2703 } | 2624 } |
2704 | 2625 |
2705 color_symbols = extract_xpm_color_names (&xpmattrs, device, domain, | 2626 color_symbols = extract_xpm_color_names (&xpmattrs, device, |
2706 color_symbol_alist); | 2627 color_symbol_alist); |
2707 | 2628 |
2708 result = XpmCreatePixmapFromBuffer (dpy, | 2629 result = XpmCreatePixmapFromBuffer (dpy, |
2709 RootWindowOfScreen (xs), | 2630 RootWindowOfScreen (xs), |
2710 (char *) XSTRING_DATA (data), | 2631 (char *) XSTRING_DATA (data), |
2978 } | 2899 } |
2979 | 2900 |
2980 static Lisp_Object | 2901 static Lisp_Object |
2981 xface_normalize (Lisp_Object inst, Lisp_Object console_type) | 2902 xface_normalize (Lisp_Object inst, Lisp_Object console_type) |
2982 { | 2903 { |
2983 /* This funcation can call lisp */ | |
2984 Lisp_Object file = Qnil, mask_file = Qnil; | 2904 Lisp_Object file = Qnil, mask_file = Qnil; |
2985 struct gcpro gcpro1, gcpro2, gcpro3; | 2905 struct gcpro gcpro1, gcpro2, gcpro3; |
2986 Lisp_Object alist = Qnil; | 2906 Lisp_Object alist = Qnil; |
2987 | 2907 |
2988 GCPRO3 (file, mask_file, alist); | 2908 GCPRO3 (file, mask_file, alist); |
3026 RETURN_UNGCPRO (result); | 2946 RETURN_UNGCPRO (result); |
3027 } | 2947 } |
3028 } | 2948 } |
3029 | 2949 |
3030 static int | 2950 static int |
3031 xface_possible_dest_types (void) | 2951 xface_possible_dest_types () |
3032 { | 2952 { |
3033 return | 2953 return IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK | |
3034 IMAGE_MONO_PIXMAP_MASK | | |
3035 IMAGE_COLOR_PIXMAP_MASK | | |
3036 IMAGE_POINTER_MASK; | 2954 IMAGE_POINTER_MASK; |
3037 } | 2955 } |
3038 | 2956 |
3039 #if defined(EXTERN) | 2957 #if defined(EXTERN) |
3040 /* This is about to get redefined! */ | 2958 /* This is about to get redefined! */ |
3051 #undef SYSV32 | 2969 #undef SYSV32 |
3052 | 2970 |
3053 static void | 2971 static void |
3054 xface_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2972 xface_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
3055 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2973 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
3056 int dest_mask, Lisp_Object domain) | 2974 int dest_mask) |
3057 { | 2975 { |
3058 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 2976 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
3059 int i, stattis; | 2977 int i, stattis; |
3060 char *p, *bits, *bp; | 2978 char *p, *bits, *bp; |
3061 CONST char * volatile emsg = 0; | 2979 CONST char * volatile emsg = 0; |
3204 RETURN_UNGCPRO (result); | 3122 RETURN_UNGCPRO (result); |
3205 } | 3123 } |
3206 } | 3124 } |
3207 | 3125 |
3208 static int | 3126 static int |
3209 autodetect_possible_dest_types (void) | 3127 autodetect_possible_dest_types () |
3210 { | 3128 { |
3211 return | 3129 return IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK | |
3212 IMAGE_MONO_PIXMAP_MASK | | 3130 IMAGE_POINTER_MASK | IMAGE_TEXT_MASK; |
3213 IMAGE_COLOR_PIXMAP_MASK | | |
3214 IMAGE_POINTER_MASK | | |
3215 IMAGE_TEXT_MASK; | |
3216 } | 3131 } |
3217 | 3132 |
3218 static void | 3133 static void |
3219 autodetect_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 3134 autodetect_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
3220 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 3135 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
3221 int dest_mask, Lisp_Object domain) | 3136 int dest_mask) |
3222 { | 3137 { |
3223 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 3138 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
3224 struct gcpro gcpro1, gcpro2, gcpro3; | 3139 struct gcpro gcpro1, gcpro2, gcpro3; |
3225 Lisp_Object alist = Qnil; | 3140 Lisp_Object alist = Qnil; |
3226 Lisp_Object result = Qnil; | 3141 Lisp_Object result = Qnil; |
3244 result = alist_to_tagged_vector (Qstring, alist); | 3159 result = alist_to_tagged_vector (Qstring, alist); |
3245 free_alist (alist); | 3160 free_alist (alist); |
3246 | 3161 |
3247 if (is_cursor_font) | 3162 if (is_cursor_font) |
3248 cursor_font_instantiate (image_instance, result, pointer_fg, | 3163 cursor_font_instantiate (image_instance, result, pointer_fg, |
3249 pointer_bg, dest_mask, domain); | 3164 pointer_bg, dest_mask); |
3250 else | 3165 else |
3251 string_instantiate (image_instance, result, pointer_fg, | 3166 string_instantiate (image_instance, result, pointer_fg, |
3252 pointer_bg, dest_mask, domain); | 3167 pointer_bg, dest_mask); |
3253 | 3168 |
3254 UNGCPRO; | 3169 UNGCPRO; |
3255 } | 3170 } |
3256 | 3171 |
3257 | 3172 |
3305 if (XLoadFont_got_error) return 0; | 3220 if (XLoadFont_got_error) return 0; |
3306 return font; | 3221 return font; |
3307 } | 3222 } |
3308 | 3223 |
3309 static int | 3224 static int |
3310 font_possible_dest_types (void) | 3225 font_possible_dest_types () |
3311 { | 3226 { |
3312 return IMAGE_POINTER_MASK; | 3227 return IMAGE_POINTER_MASK; |
3313 } | 3228 } |
3314 | 3229 |
3315 static void | 3230 static void |
3316 font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 3231 font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
3317 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 3232 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
3318 int dest_mask, Lisp_Object domain) | 3233 int dest_mask) |
3319 { | 3234 { |
3320 /* This function can GC */ | 3235 /* This function can GC */ |
3321 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 3236 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
3322 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 3237 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
3323 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 3238 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
3403 { | 3318 { |
3404 data_must_be_present (instantiator); | 3319 data_must_be_present (instantiator); |
3405 } | 3320 } |
3406 | 3321 |
3407 static int | 3322 static int |
3408 cursor_font_possible_dest_types (void) | 3323 cursor_font_possible_dest_types () |
3409 { | 3324 { |
3410 return IMAGE_POINTER_MASK; | 3325 return IMAGE_POINTER_MASK; |
3411 } | 3326 } |
3412 | 3327 |
3413 static void | 3328 static void |
3414 cursor_font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 3329 cursor_font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
3415 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 3330 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
3416 int dest_mask, Lisp_Object domain) | 3331 int dest_mask) |
3417 { | 3332 { |
3418 /* This function can GC */ | 3333 /* This function can GC */ |
3419 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 3334 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
3420 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 3335 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
3421 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 3336 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
3495 return 1; | 3410 return 1; |
3496 } | 3411 } |
3497 } | 3412 } |
3498 | 3413 |
3499 | 3414 |
3500 #if HAVE_SUBWINDOWS | |
3501 /************************************************************************/ | 3415 /************************************************************************/ |
3502 /* subwindows */ | 3416 /* subwindows */ |
3503 /************************************************************************/ | 3417 /************************************************************************/ |
3504 | 3418 |
3505 Lisp_Object Qsubwindowp; | 3419 Lisp_Object Qsubwindowp; |
3585 /* #### PROBLEM: The display routines assume that the glyph is only | 3499 /* #### PROBLEM: The display routines assume that the glyph is only |
3586 being displayed in one buffer. If it is in two different buffers | 3500 being displayed in one buffer. If it is in two different buffers |
3587 which are both being displayed simultaneously you will lose big time. | 3501 which are both being displayed simultaneously you will lose big time. |
3588 This can be dealt with in the new redisplay. */ | 3502 This can be dealt with in the new redisplay. */ |
3589 | 3503 |
3590 /* #### These are completely un-re-implemented in 19.16. Get it done | 3504 /* #### These are completely un-re-implemented in 19.14. Get it done |
3591 for 20.3. */ | 3505 for 19.15. */ |
3592 | 3506 |
3593 DEFUN ("make-subwindow", Fmake_subwindow, 0, 3, 0, /* | 3507 DEFUN ("make-subwindow", Fmake_subwindow, 0, 3, 0, /* |
3594 Creates a new `subwindow' object of size WIDTH x HEIGHT. | 3508 Creates a new `subwindow' object of size WIDTH x HEIGHT. |
3595 The default is a window of size 1x1, which is also the minimum allowed | 3509 The default is a window of size 1x1, which is also the minimum allowed |
3596 window size. Subwindows are per-frame. A buffer being shown in two | 3510 window size. Subwindows are per-frame. A buffer being shown in two |
3610 struct frame *f; | 3524 struct frame *f; |
3611 unsigned int iw, ih; | 3525 unsigned int iw, ih; |
3612 XSetWindowAttributes xswa; | 3526 XSetWindowAttributes xswa; |
3613 Mask valueMask = 0; | 3527 Mask valueMask = 0; |
3614 | 3528 |
3615 error ("subwindows are not functional in 19.16; perhaps some day ..."); | 3529 error ("subwindows are not functional in 19.14; they will be in 19.15"); |
3616 | 3530 |
3617 f = decode_x_frame (frame); | 3531 f = decode_x_frame (frame); |
3618 | 3532 |
3619 xs = LISP_DEVICE_TO_X_SCREEN (FRAME_DEVICE (f)); | 3533 xs = LISP_DEVICE_TO_X_SCREEN (FRAME_DEVICE (f)); |
3620 dpy = DisplayOfScreen (xs); | 3534 dpy = DisplayOfScreen (xs); |
3771 XMapWindow (DisplayOfScreen (XSUBWINDOW (subwindow)->xscreen), | 3685 XMapWindow (DisplayOfScreen (XSUBWINDOW (subwindow)->xscreen), |
3772 XSUBWINDOW (subwindow)->subwindow); | 3686 XSUBWINDOW (subwindow)->subwindow); |
3773 | 3687 |
3774 return subwindow; | 3688 return subwindow; |
3775 } | 3689 } |
3776 #endif | 3690 |
3777 | 3691 |
3778 /************************************************************************/ | 3692 /************************************************************************/ |
3779 /* initialization */ | 3693 /* initialization */ |
3780 /************************************************************************/ | 3694 /************************************************************************/ |
3781 | 3695 |
3782 void | 3696 void |
3783 syms_of_glyphs_x (void) | 3697 syms_of_glyphs_x (void) |
3784 { | 3698 { |
3785 #if HAVE_SUBWINDOWS | |
3786 defsymbol (&Qsubwindowp, "subwindowp"); | 3699 defsymbol (&Qsubwindowp, "subwindowp"); |
3787 | 3700 |
3788 DEFSUBR (Fmake_subwindow); | 3701 DEFSUBR (Fmake_subwindow); |
3789 DEFSUBR (Fchange_subwindow_property); | 3702 DEFSUBR (Fchange_subwindow_property); |
3790 DEFSUBR (Fsubwindowp); | 3703 DEFSUBR (Fsubwindowp); |
3791 DEFSUBR (Fsubwindow_width); | 3704 DEFSUBR (Fsubwindow_width); |
3792 DEFSUBR (Fsubwindow_height); | 3705 DEFSUBR (Fsubwindow_height); |
3793 DEFSUBR (Fsubwindow_xid); | 3706 DEFSUBR (Fsubwindow_xid); |
3794 DEFSUBR (Fresize_subwindow); | 3707 DEFSUBR (Fresize_subwindow); |
3795 DEFSUBR (Fforce_subwindow_map); | 3708 DEFSUBR (Fforce_subwindow_map); |
3796 #endif | |
3797 | 3709 |
3798 defkeyword (&Q_mask_file, ":mask-file"); | 3710 defkeyword (&Q_mask_file, ":mask-file"); |
3799 defkeyword (&Q_mask_data, ":mask-data"); | 3711 defkeyword (&Q_mask_data, ":mask-data"); |
3800 defkeyword (&Q_hotspot_x, ":hotspot-x"); | 3712 defkeyword (&Q_hotspot_x, ":hotspot-x"); |
3801 defkeyword (&Q_hotspot_y, ":hotspot-y"); | 3713 defkeyword (&Q_hotspot_y, ":hotspot-y"); |
4011 Qglobal, Qx, Qnil) | 3923 Qglobal, Qx, Qnil) |
4012 | 3924 |
4013 BUILD_GLYPH_INST (Vtruncation_glyph, truncator); | 3925 BUILD_GLYPH_INST (Vtruncation_glyph, truncator); |
4014 BUILD_GLYPH_INST (Vcontinuation_glyph, continuer); | 3926 BUILD_GLYPH_INST (Vcontinuation_glyph, continuer); |
4015 BUILD_GLYPH_INST (Vxemacs_logo, xemacs); | 3927 BUILD_GLYPH_INST (Vxemacs_logo, xemacs); |
4016 BUILD_GLYPH_INST (Vhscroll_glyph, hscroll); | |
4017 | 3928 |
4018 #undef BUILD_GLYPH_INST | 3929 #undef BUILD_GLYPH_INST |
4019 } | 3930 } |