1 /***********************************************************
3 Copyright 1987, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
25 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29 Permission to use, copy, modify, and distribute this software and its
30 documentation for any purpose and without fee is hereby granted,
31 provided that the above copyright notice appear in all copies and that
32 both that copyright notice and this permission notice appear in
33 supporting documentation, and that the name of Digital not be
34 used in advertising or publicity pertaining to distribution of the
35 software without specific, written prior permission.
37 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45 ******************************************************************/
51 * Note: much of this is vestigial from mfb/cfb times. This should
52 * really be simplified even further.
56 * Machine dependent values:
57 * GLYPHPADBYTES should be chosen with consideration for the space-time
58 * trade-off. Padding to 0 bytes means that there is no wasted space
59 * in the font bitmaps (both on disk and in memory), but that access of
60 * the bitmaps will cause odd-address memory references. Padding to
61 * 2 bytes would ensure even address memory references and would
62 * be suitable for a 68010-class machine, but at the expense of wasted
63 * space in the font bitmaps. Padding to 4 bytes would be good
64 * for real 32 bit machines, etc. Be sure that you tell the font
65 * compiler what kind of padding you want because its defines are
66 * kept separate from this. See server/include/font.h for how
67 * GLYPHPADBYTES is used.
72 #define IMAGE_BYTE_ORDER MSBFirst
73 #define BITMAP_BIT_ORDER MSBFirst
74 #define GLYPHPADBYTES 4
76 #endif /* __avr32__ */
80 #define IMAGE_BYTE_ORDER LSBFirst
81 #define BITMAP_BIT_ORDER LSBFirst
82 #define GLYPHPADBYTES 4
84 #endif /* __arm32__ */
86 #if defined(__nds32__)
88 #define IMAGE_BYTE_ORDER LSBFirst
90 #if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO)
91 #define BITMAP_BIT_ORDER MSBFirst
93 #define BITMAP_BIT_ORDER LSBFirst
96 #if defined(XF86MONOVGA) || defined(XF86VGA16)
97 #define BITMAP_SCANLINE_UNIT 8
100 #define GLYPHPADBYTES 4
101 #define GETLEFTBITS_ALIGNMENT 1
102 #define LARGE_INSTRUCTION_CACHE
103 #define AVOID_MEMORY_READ
105 #endif /* __nds32__ */
109 #define IMAGE_BYTE_ORDER MSBFirst
110 #define BITMAP_BIT_ORDER MSBFirst
111 #define GLYPHPADBYTES 4 /* to make fb work */
113 #endif /* hpux || __hppa__ */
115 #if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__)
117 #define IMAGE_BYTE_ORDER MSBFirst
118 #define BITMAP_BIT_ORDER MSBFirst
119 #define GLYPHPADBYTES 4
125 #if defined(__BIG_ENDIAN__)
126 #define IMAGE_BYTE_ORDER MSBFirst
127 #define BITMAP_BIT_ORDER MSBFirst
128 #define GLYPHPADBYTES 4
130 #define IMAGE_BYTE_ORDER LSBFirst
131 #define BITMAP_BIT_ORDER LSBFirst
132 #define GLYPHPADBYTES 4
137 #if defined(__m32r__)
139 #if defined(__BIG_ENDIAN__)
140 #define IMAGE_BYTE_ORDER MSBFirst
141 #define BITMAP_BIT_ORDER MSBFirst
142 #define GLYPHPADBYTES 4
144 #define IMAGE_BYTE_ORDER LSBFirst
145 #define BITMAP_BIT_ORDER LSBFirst
146 #define GLYPHPADBYTES 4
149 #endif /* __m32r__ */
151 #if (defined(sun) && (defined(__sparc) || defined(sparc))) || \
152 (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
153 defined(__sparc__) || defined(__mc68000__)
155 #if defined(__sparc) || defined(__sparc__)
161 #if defined(sun386) || defined(sun5)
162 #define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */
163 #define BITMAP_BIT_ORDER LSBFirst
165 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */
166 #define BITMAP_BIT_ORDER MSBFirst
169 #define GLYPHPADBYTES 4
171 #endif /* sun && !(i386 && SVR4) */
173 #if defined(ibm032) || defined (ibm)
176 #define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */
178 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only */
180 #define BITMAP_BIT_ORDER MSBFirst
181 #define GLYPHPADBYTES 1
182 /* ibm pcc doesn't understand pragmas. */
185 #define BITMAP_SCANLINE_UNIT 8
190 #if (defined(mips) || defined(__mips))
192 #if defined(MIPSEL) || defined(__MIPSEL__)
193 #define IMAGE_BYTE_ORDER LSBFirst /* Values for the PMAX only */
194 #define BITMAP_BIT_ORDER LSBFirst
195 #define GLYPHPADBYTES 4
197 #define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */
198 #define BITMAP_BIT_ORDER MSBFirst
199 #define GLYPHPADBYTES 4
204 #if defined(__alpha) || defined(__alpha__)
205 #define IMAGE_BYTE_ORDER LSBFirst /* Values for the Alpha only */
206 #define BITMAP_BIT_ORDER LSBFirst
207 #define GLYPHPADBYTES 4
211 #if defined (linux) && defined (__s390__)
213 #define IMAGE_BYTE_ORDER MSBFirst
214 #define BITMAP_BIT_ORDER MSBFirst
215 #define GLYPHPADBYTES 4
217 #define BITMAP_SCANLINE_UNIT 8
218 #define FAST_UNALIGNED_READ
220 #endif /* linux/s390 */
222 #if defined (linux) && defined (__s390x__)
224 #define IMAGE_BYTE_ORDER MSBFirst
225 #define BITMAP_BIT_ORDER MSBFirst
226 #define GLYPHPADBYTES 4
228 #define BITMAP_SCANLINE_UNIT 8
229 #define FAST_UNALIGNED_READ
231 #endif /* linux/s390x */
233 #if defined(__ia64__) || defined(ia64)
235 #define IMAGE_BYTE_ORDER LSBFirst
236 #define BITMAP_BIT_ORDER LSBFirst
237 #define GLYPHPADBYTES 4
241 #if defined(__amd64__) || defined(amd64) || defined(__amd64)
242 #define IMAGE_BYTE_ORDER LSBFirst
243 #define BITMAP_BIT_ORDER LSBFirst
244 #define GLYPHPADBYTES 4
248 #if defined(SVR4) && (defined(__i386__) || defined(__i386) ) || \
249 defined(__alpha__) || defined(__alpha) || \
250 defined(__i386__) || \
251 defined(__s390x__) || defined(__s390__)
253 #ifndef IMAGE_BYTE_ORDER
254 #define IMAGE_BYTE_ORDER LSBFirst
257 #ifndef BITMAP_BIT_ORDER
258 #define BITMAP_BIT_ORDER LSBFirst
261 #ifndef GLYPHPADBYTES
262 #define GLYPHPADBYTES 4
265 #endif /* SVR4 / BSD / i386 */
267 #if defined (linux) && defined (__mc68000__)
269 #define IMAGE_BYTE_ORDER MSBFirst
270 #define BITMAP_BIT_ORDER MSBFirst
271 #define GLYPHPADBYTES 4
273 #endif /* linux/m68k */
276 #if defined(linux) && defined(__arm__)
277 #define IMAGE_BYTE_ORDER LSBFirst
278 #define BITMAP_BIT_ORDER LSBFirst
279 #define GLYPHPADBYTES 4
282 /* linux on IBM S/390 */
283 #if defined (linux) && defined (__s390__)
284 #define IMAGE_BYTE_ORDER MSBFirst
285 #define BITMAP_BIT_ORDER MSBFirst
286 #define GLYPHPADBYTES 4
287 #endif /* linux/s390 */
292 #define IMAGE_BYTE_ORDER LSBFirst
293 #define BITMAP_BIT_ORDER LSBFirst
296 #define IMAGE_BYTE_ORDER MSBFirst
297 #define BITMAP_BIT_ORDER MSBFirst
299 #define GLYPHPADBYTES 4
301 #endif /* __aarch64__ */
303 /* size of buffer to use with GetImage, measured in bytes. There's obviously
304 * a trade-off between the amount of heap used and the number of times the
305 * ddx routine has to be called.
307 #ifndef IMAGE_BUFSIZE
308 #define IMAGE_BUFSIZE (64*1024)
311 /* pad scanline to a longword */
312 #ifndef BITMAP_SCANLINE_UNIT
313 #define BITMAP_SCANLINE_UNIT 32
316 #ifndef BITMAP_SCANLINE_PAD
317 #define BITMAP_SCANLINE_PAD 32
318 #define LOG2_BITMAP_PAD 5
319 #define LOG2_BYTES_PER_SCANLINE_PAD 2
322 #include <X11/Xfuncproto.h>
324 * This returns the number of padding units, for depth d and width w.
325 * For bitmaps this can be calculated with the macros above.
326 * Other depths require either grovelling over the formats field of the
327 * screenInfo or hardwired constants.
330 typedef struct _PaddingInfo
{
331 int padRoundUp
; /* pixels per pad unit - 1 */
332 int padPixelsLog2
; /* log 2 (pixels per pad unit) */
333 int padBytesLog2
; /* log 2 (bytes per pad unit) */
334 int notPower2
; /* bitsPerPixel not a power of 2 */
335 int bytesPerPixel
; /* only set when notPower2 is TRUE */
336 int bitsPerPixel
; /* bits per pixel */
338 extern _X_EXPORT PaddingInfo PixmapWidthPaddingInfo
[];
340 /* The only portable way to get the bpp from the depth is to look it up */
341 #define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel)
343 #define PixmapWidthInPadUnits(w, d) \
344 (PixmapWidthPaddingInfo[d].notPower2 ? \
345 (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \
346 PixmapWidthPaddingInfo[d].bytesPerPixel) >> \
347 PixmapWidthPaddingInfo[d].padBytesLog2) : \
348 ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \
349 PixmapWidthPaddingInfo[d].padPixelsLog2))
352 * Return the number of bytes to which a scanline of the given
353 * depth and width will be padded.
355 #define PixmapBytePad(w, d) \
356 (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2)
358 #define BitmapBytePad(w) \
359 (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD)
361 #define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d)
362 #define PixmapBytePadProto(w, d) PixmapBytePad(w, d)
363 #define BitmapBytePadProto(w) BitmapBytePad(w)
365 #endif /* SERVERMD_H */