comparison src/glyphs-x.c @ 36:c53a95d3c46d r19-15b101

Import from CVS: tag r19-15b101
author cvs
date Mon, 13 Aug 2007 08:53:38 +0200
parents d620409f5eb8
children 1a767b41a199
comparison
equal deleted inserted replaced
35:279432d5c479 36:c53a95d3c46d
56 #include "opaque.h" 56 #include "opaque.h"
57 57
58 #include "sysfile.h" 58 #include "sysfile.h"
59 59
60 #include <setjmp.h> 60 #include <setjmp.h>
61
62 /* Set to 1 if you wish to implement this feature */
63 # define HAVE_SUBWINDOWS 0
61 64
62 #define LISP_DEVICE_TO_X_SCREEN(dev) \ 65 #define LISP_DEVICE_TO_X_SCREEN(dev) \
63 XDefaultScreenOfDisplay (DEVICE_X_DISPLAY (XDEVICE (dev))) 66 XDefaultScreenOfDisplay (DEVICE_X_DISPLAY (XDEVICE (dev)))
64 67
65 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xbm); 68 DEFINE_IMAGE_INSTANTIATOR_FORMAT (xbm);
138 sprintf (buf, "/0x%lx", (unsigned long) IMAGE_INSTANCE_X_MASK (p)); 141 sprintf (buf, "/0x%lx", (unsigned long) IMAGE_INSTANCE_X_MASK (p));
139 write_c_string (buf, printcharfun); 142 write_c_string (buf, printcharfun);
140 } 143 }
141 write_c_string (")", printcharfun); 144 write_c_string (")", printcharfun);
142 break; 145 break;
146 #if HAVE_SUBWINDOWS
143 case IMAGE_SUBWINDOW: 147 case IMAGE_SUBWINDOW:
144 /* #### implement me */ 148 /* #### implement me */
149 #endif
145 default: 150 default:
146 break; 151 break;
147 } 152 }
148 } 153 }
149 154
200 case IMAGE_COLOR_PIXMAP: 205 case IMAGE_COLOR_PIXMAP:
201 case IMAGE_POINTER: 206 case IMAGE_POINTER:
202 if (IMAGE_INSTANCE_X_NPIXELS (p1) != IMAGE_INSTANCE_X_NPIXELS (p2)) 207 if (IMAGE_INSTANCE_X_NPIXELS (p1) != IMAGE_INSTANCE_X_NPIXELS (p2))
203 return 0; 208 return 0;
204 break; 209 break;
210 #if HAVE_SUBWINDOWS
205 case IMAGE_SUBWINDOW: 211 case IMAGE_SUBWINDOW:
206 /* #### implement me */ 212 /* #### implement me */
213 #endif
207 break; 214 break;
208 default: 215 default:
209 break; 216 break;
210 } 217 }
211 218
219 { 226 {
220 case IMAGE_MONO_PIXMAP: 227 case IMAGE_MONO_PIXMAP:
221 case IMAGE_COLOR_PIXMAP: 228 case IMAGE_COLOR_PIXMAP:
222 case IMAGE_POINTER: 229 case IMAGE_POINTER:
223 return IMAGE_INSTANCE_X_NPIXELS (p); 230 return IMAGE_INSTANCE_X_NPIXELS (p);
231 #if HAVE_SUBWINDOWS
224 case IMAGE_SUBWINDOW: 232 case IMAGE_SUBWINDOW:
225 /* #### implement me */ 233 /* #### implement me */
234 #endif
226 return 0; 235 return 0;
227 default: 236 default:
228 return 0; 237 return 0;
229 } 238 }
230 } 239 }
1602 } 1611 }
1603 1612
1604 return Qnil; 1613 return Qnil;
1605 } 1614 }
1606 1615
1616 #if 0
1607 /* We provide our own version of DGifSlurp() because the standardly 1617 /* We provide our own version of DGifSlurp() because the standardly
1608 provided one doesn't handle interlaced GIFs. This is based on 1618 provided one doesn't handle interlaced GIFs. This is based on
1609 code in gif2x11.c. */ 1619 code in gif2x11.c. */
1610 1620
1611 /* Return value is GIF_ERROR, GIF_OK, or -1. 1621 /* Return value is GIF_ERROR, GIF_OK, or -1.
1708 1718
1709 done: 1719 done:
1710 1720
1711 return GIF_OK; 1721 return GIF_OK;
1712 } 1722 }
1723 #endif
1713 1724
1714 static void 1725 static void
1715 gif_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1726 gif_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1716 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1727 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1717 int dest_mask) 1728 int dest_mask)
1757 { 1768 {
1758 gif_decode_error: 1769 gif_decode_error:
1759 signal_simple_error ("Unable to decode GIF", 1770 signal_simple_error ("Unable to decode GIF",
1760 build_string (EmacsPrintGifError ())); 1771 build_string (EmacsPrintGifError ()));
1761 } 1772 }
1762 #if 1 1773 #if 0
1763 if (our_own_dgif_slurp_from_gif2x11_c(unwind.giffile) != GIF_OK) 1774 if (our_own_dgif_slurp_from_gif2x11_c(unwind.giffile) != GIF_OK)
1764 #else 1775 #else
1765 /* DGifSlurp() doesn't handle interlaced files. */ 1776 /* DGifSlurp() doesn't handle interlaced files. */
1777 /* Actually, it does, sort of. It just sets the Interlace flag
1778 and stores RasterBits in interlaced order. We handle that below. */
1766 if (DGifSlurp (unwind.giffile) != GIF_OK) 1779 if (DGifSlurp (unwind.giffile) != GIF_OK)
1767 #endif 1780 #endif
1768 goto gif_decode_error; 1781 goto gif_decode_error;
1769 } 1782 }
1770 1783
1799 { 1812 {
1800 int height = unwind.giffile->SHeight; 1813 int height = unwind.giffile->SHeight;
1801 int width = unwind.giffile->SWidth; 1814 int width = unwind.giffile->SWidth;
1802 int depth; 1815 int depth;
1803 int bitmap_pad; 1816 int bitmap_pad;
1804 int i, j; 1817 int i, j, row, pass, interlace;
1818 /* interlaced gifs have rows in this order:
1819 0, 8, 16, ..., 4, 12, 20, ..., 2, 6, 10, ..., 1, 3, 5, ... */
1820 static int InterlacedOffset[] = { 0, 4, 2, 1 };
1821 static int InterlacedJumps[] = { 8, 8, 4, 2 };
1822
1805 1823
1806 depth = DefaultDepthOfScreen (scr); 1824 depth = DefaultDepthOfScreen (scr);
1807 1825
1808 /* first get bitmap_pad (from XPM) */ 1826 /* first get bitmap_pad (from XPM) */
1809 if (depth > 16) 1827 if (depth > 16)
1832 long run, what with all the XPM overhead. If this proves 1850 long run, what with all the XPM overhead. If this proves
1833 to be a bottleneck here, maybe we should just copy the 1851 to be a bottleneck here, maybe we should just copy the
1834 optimization routines from XPM (they're in turn mostly 1852 optimization routines from XPM (they're in turn mostly
1835 copied from the Xlib source code). */ 1853 copied from the Xlib source code). */
1836 1854
1855 /* Note: We just use the first image in the file and ignore the rest.
1856 We check here that that image covers the full "screen" size.
1857 I don't know whether that's always the case.
1858 -dkindred@cs.cmu.edu */
1859 if (unwind.giffile->SavedImages[0].ImageDesc.Height != height
1860 || unwind.giffile->SavedImages[0].ImageDesc.Width != width
1861 || unwind.giffile->SavedImages[0].ImageDesc.Left != 0
1862 || unwind.giffile->SavedImages[0].ImageDesc.Top != 0)
1863 signal_simple_error ("First image in GIF file is not full size",
1864 instantiator);
1865
1866 interlace = unwind.giffile->SavedImages[0].ImageDesc.Interlace;
1867 pass = 0;
1868 row = interlace ? InterlacedOffset[pass] : 0;
1837 for (i = 0; i < height; i++) 1869 for (i = 0; i < height; i++)
1838 for (j = 0; j < width; j++) 1870 {
1839 XPutPixel (unwind.ximage, j, i, 1871 if (interlace && row >= height)
1840 unwind.pixels[(unsigned char) 1872 row = InterlacedOffset[++pass];
1841 /* incorrect signed declaration 1873
1842 of RasterBits[] */ 1874 for (j = 0; j < width; j++)
1843 (unwind.giffile->SavedImages-> 1875 XPutPixel (unwind.ximage, j, row,
1844 RasterBits[i * width + j])]); 1876 unwind.pixels[(unsigned char)
1877 /* incorrect signed declaration
1878 of RasterBits[] */
1879 (unwind.giffile->SavedImages[0].
1880 RasterBits[i * width + j])]);
1881
1882 row += interlace ? InterlacedJumps[pass] : 1;
1883 }
1845 } 1884 }
1846 1885
1847 /* 4. Now create the pixmap and set up the image instance */ 1886 /* 4. Now create the pixmap and set up the image instance */
1848 init_image_instance_from_x_image (ii, unwind.ximage, dest_mask, 1887 init_image_instance_from_x_image (ii, unwind.ximage, dest_mask,
1849 unwind.pixels, unwind.npixels, 1888 unwind.pixels, unwind.npixels,
3430 return 1; 3469 return 1;
3431 } 3470 }
3432 } 3471 }
3433 3472
3434 3473
3474 #if HAVE_SUBWINDOWS
3435 /************************************************************************/ 3475 /************************************************************************/
3436 /* subwindows */ 3476 /* subwindows */
3437 /************************************************************************/ 3477 /************************************************************************/
3438 3478
3439 Lisp_Object Qsubwindowp; 3479 Lisp_Object Qsubwindowp;
3705 XMapWindow (DisplayOfScreen (XSUBWINDOW (subwindow)->xscreen), 3745 XMapWindow (DisplayOfScreen (XSUBWINDOW (subwindow)->xscreen),
3706 XSUBWINDOW (subwindow)->subwindow); 3746 XSUBWINDOW (subwindow)->subwindow);
3707 3747
3708 return subwindow; 3748 return subwindow;
3709 } 3749 }
3710 3750 #endif
3711 3751
3712 /************************************************************************/ 3752 /************************************************************************/
3713 /* initialization */ 3753 /* initialization */
3714 /************************************************************************/ 3754 /************************************************************************/
3715 3755
3716 void 3756 void
3717 syms_of_glyphs_x (void) 3757 syms_of_glyphs_x (void)
3718 { 3758 {
3759 #if HAVE_SUBWINDOWS
3719 defsymbol (&Qsubwindowp, "subwindowp"); 3760 defsymbol (&Qsubwindowp, "subwindowp");
3720 3761
3721 DEFSUBR (Fmake_subwindow); 3762 DEFSUBR (Fmake_subwindow);
3722 DEFSUBR (Fchange_subwindow_property); 3763 DEFSUBR (Fchange_subwindow_property);
3723 DEFSUBR (Fsubwindowp); 3764 DEFSUBR (Fsubwindowp);
3724 DEFSUBR (Fsubwindow_width); 3765 DEFSUBR (Fsubwindow_width);
3725 DEFSUBR (Fsubwindow_height); 3766 DEFSUBR (Fsubwindow_height);
3726 DEFSUBR (Fsubwindow_xid); 3767 DEFSUBR (Fsubwindow_xid);
3727 DEFSUBR (Fresize_subwindow); 3768 DEFSUBR (Fresize_subwindow);
3728 DEFSUBR (Fforce_subwindow_map); 3769 DEFSUBR (Fforce_subwindow_map);
3770 #endif
3729 3771
3730 defkeyword (&Q_mask_file, ":mask-file"); 3772 defkeyword (&Q_mask_file, ":mask-file");
3731 defkeyword (&Q_mask_data, ":mask-data"); 3773 defkeyword (&Q_mask_data, ":mask-data");
3732 defkeyword (&Q_hotspot_x, ":hotspot-x"); 3774 defkeyword (&Q_hotspot_x, ":hotspot-x");
3733 defkeyword (&Q_hotspot_y, ":hotspot-y"); 3775 defkeyword (&Q_hotspot_y, ":hotspot-y");