servermd.h revision 637ac9ab
1/*********************************************************** 2 3Copyright 1987, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included in 12all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 21Except as contained in this notice, the name of The Open Group shall not be 22used in advertising or otherwise to promote the sale, use or other dealings 23in this Software without prior written authorization from The Open Group. 24 25 26Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 27 28 All Rights Reserved 29 30Permission to use, copy, modify, and distribute this software and its 31documentation for any purpose and without fee is hereby granted, 32provided that the above copyright notice appear in all copies and that 33both that copyright notice and this permission notice appear in 34supporting documentation, and that the name of Digital not be 35used in advertising or publicity pertaining to distribution of the 36software without specific, written prior permission. 37 38DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 39ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 40DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 41ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 42WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 43ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 44SOFTWARE. 45 46******************************************************************/ 47 48#ifndef SERVERMD_H 49#define SERVERMD_H 1 50 51/* 52 * Note: much of this is vestigial from mfb/cfb times. This should 53 * really be simplified even further. 54 */ 55 56/* 57 * Machine dependent values: 58 * GLYPHPADBYTES should be chosen with consideration for the space-time 59 * trade-off. Padding to 0 bytes means that there is no wasted space 60 * in the font bitmaps (both on disk and in memory), but that access of 61 * the bitmaps will cause odd-address memory references. Padding to 62 * 2 bytes would ensure even address memory references and would 63 * be suitable for a 68010-class machine, but at the expense of wasted 64 * space in the font bitmaps. Padding to 4 bytes would be good 65 * for real 32 bit machines, etc. Be sure that you tell the font 66 * compiler what kind of padding you want because its defines are 67 * kept separate from this. See server/include/font.h for how 68 * GLYPHPADBYTES is used. 69 */ 70 71#if defined(vax) || defined(__vax__) 72#define IMAGE_BYTE_ORDER LSBFirst /* Values for the VAX only */ 73#define BITMAP_BIT_ORDER LSBFirst 74#define GLYPHPADBYTES 4 75#define GETLEFTBITS_ALIGNMENT 1 76#define FAST_UNALIGNED_READS 77#endif /* __vax__ */ 78 79#ifdef __avr32__ 80#define IMAGE_BYTE_ORDER MSBFirst 81#define BITMAP_BIT_ORDER MSBFirst 82#define GLYPHPADBYTES 4 83 84#endif /* __avr32__ */ 85 86/* XXX arm is not always LE */ 87#if defined(__arm32__) || defined(__arm__) 88 89#define IMAGE_BYTE_ORDER LSBFirst 90#define BITMAP_BIT_ORDER LSBFirst 91#define GLYPHPADBYTES 4 92 93#endif /* __arm32__ */ 94 95#if defined __hppa__ 96 97#define IMAGE_BYTE_ORDER MSBFirst 98#define BITMAP_BIT_ORDER MSBFirst 99#define GLYPHPADBYTES 4 /* to make fb work */ 100 /* byte boundries */ 101#endif /* hpux || __hppa__ */ 102 103#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) 104 105#define IMAGE_BYTE_ORDER MSBFirst 106#define BITMAP_BIT_ORDER MSBFirst 107#define GLYPHPADBYTES 4 108 109#endif /* PowerPC */ 110 111#if defined(__sh__) 112 113#if defined(__BIG_ENDIAN__) 114# define IMAGE_BYTE_ORDER MSBFirst 115# define BITMAP_BIT_ORDER MSBFirst 116# define GLYPHPADBYTES 4 117#else 118# define IMAGE_BYTE_ORDER LSBFirst 119# define BITMAP_BIT_ORDER LSBFirst 120# define GLYPHPADBYTES 4 121#endif 122 123#endif /* SuperH */ 124 125#if defined(__m32r__) 126 127#if defined(__BIG_ENDIAN__) 128# define IMAGE_BYTE_ORDER MSBFirst 129# define BITMAP_BIT_ORDER MSBFirst 130# define GLYPHPADBYTES 4 131#else 132# define IMAGE_BYTE_ORDER LSBFirst 133# define BITMAP_BIT_ORDER LSBFirst 134# define GLYPHPADBYTES 4 135#endif 136 137#endif /* __m32r__ */ 138 139#if (defined(sun) && (defined(__sparc) || defined(sparc))) || \ 140 (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \ 141 defined(__sparc__) || defined(__mc68000__) 142 143#if defined(__sparc) || defined(__sparc__) 144# if !defined(sparc) 145# define sparc 1 146# endif 147#endif 148 149#if defined(sun386) || defined(sun5) 150# define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */ 151# define BITMAP_BIT_ORDER LSBFirst 152#else 153# define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */ 154# define BITMAP_BIT_ORDER MSBFirst 155#endif 156 157#define GLYPHPADBYTES 4 158 159#endif /* sun && !(i386 && SVR4) */ 160 161 162#if defined(ibm032) || defined (ibm) 163 164#ifdef __i386__ 165# define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */ 166#else 167# define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only*/ 168#endif 169#define BITMAP_BIT_ORDER MSBFirst 170#define GLYPHPADBYTES 1 171/* ibm pcc doesn't understand pragmas. */ 172 173#ifdef __i386__ 174#define BITMAP_SCANLINE_UNIT 8 175#endif 176 177#endif /* ibm */ 178 179#if (defined(mips) || defined(__mips)) 180 181#if defined(MIPSEL) || defined(__MIPSEL__) 182# define IMAGE_BYTE_ORDER LSBFirst /* Values for the PMAX only */ 183# define BITMAP_BIT_ORDER LSBFirst 184# define GLYPHPADBYTES 4 185#else 186# define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */ 187# define BITMAP_BIT_ORDER MSBFirst 188# define GLYPHPADBYTES 4 189#endif 190 191#endif /* mips */ 192 193#if defined(__alpha) || defined(__alpha__) 194# define IMAGE_BYTE_ORDER LSBFirst /* Values for the Alpha only */ 195# define BITMAP_BIT_ORDER LSBFirst 196# define GLYPHPADBYTES 4 197 198#endif /* alpha */ 199 200#if defined (linux) && defined (__s390__) 201 202#define IMAGE_BYTE_ORDER MSBFirst 203#define BITMAP_BIT_ORDER MSBFirst 204#define GLYPHPADBYTES 4 205 206#define BITMAP_SCANLINE_UNIT 8 207#define FAST_UNALIGNED_READ 208 209#endif /* linux/s390 */ 210 211#if defined (linux) && defined (__s390x__) 212 213#define IMAGE_BYTE_ORDER MSBFirst 214#define BITMAP_BIT_ORDER MSBFirst 215#define GLYPHPADBYTES 4 216 217#define BITMAP_SCANLINE_UNIT 8 218#define FAST_UNALIGNED_READ 219 220#endif /* linux/s390x */ 221 222 223#if defined(__ia64__) || defined(ia64) 224 225# define IMAGE_BYTE_ORDER LSBFirst 226# define BITMAP_BIT_ORDER LSBFirst 227# define GLYPHPADBYTES 4 228 229#endif /* ia64 */ 230 231#if defined(__amd64__) || defined(amd64) || defined(__amd64) 232# define IMAGE_BYTE_ORDER LSBFirst 233# define BITMAP_BIT_ORDER LSBFirst 234# define GLYPHPADBYTES 4 235/* ???? */ 236#endif /* AMD64 */ 237 238#if defined(SVR4) && (defined(__i386__) || defined(__i386) ) || \ 239 defined(__alpha__) || defined(__alpha) || \ 240 defined(__i386__) || \ 241 defined(__s390x__) || defined(__s390__) 242 243#ifndef IMAGE_BYTE_ORDER 244#define IMAGE_BYTE_ORDER LSBFirst 245#endif 246 247#ifndef BITMAP_BIT_ORDER 248# define BITMAP_BIT_ORDER LSBFirst 249#endif 250 251#ifndef GLYPHPADBYTES 252#define GLYPHPADBYTES 4 253#endif 254 255#endif /* SVR4 / BSD / i386 */ 256 257#if defined (linux) && defined (__mc68000__) 258 259#define IMAGE_BYTE_ORDER MSBFirst 260#define BITMAP_BIT_ORDER MSBFirst 261#define GLYPHPADBYTES 4 262 263#endif /* linux/m68k */ 264 265 266/* linux on ARM */ 267#if defined(linux) && defined(__arm__) 268#define IMAGE_BYTE_ORDER LSBFirst 269#define BITMAP_BIT_ORDER LSBFirst 270#define GLYPHPADBYTES 4 271#endif 272 273/* linux on IBM S/390 */ 274#if defined (linux) && defined (__s390__) 275#define IMAGE_BYTE_ORDER MSBFirst 276#define BITMAP_BIT_ORDER MSBFirst 277#define GLYPHPADBYTES 4 278#endif /* linux/s390 */ 279 280/* size of buffer to use with GetImage, measured in bytes. There's obviously 281 * a trade-off between the amount of heap used and the number of times the 282 * ddx routine has to be called. 283 */ 284#ifndef IMAGE_BUFSIZE 285#define IMAGE_BUFSIZE (64*1024) 286#endif 287 288/* pad scanline to a longword */ 289#ifndef BITMAP_SCANLINE_UNIT 290#define BITMAP_SCANLINE_UNIT 32 291#endif 292 293#ifndef BITMAP_SCANLINE_PAD 294#define BITMAP_SCANLINE_PAD 32 295#define LOG2_BITMAP_PAD 5 296#define LOG2_BYTES_PER_SCANLINE_PAD 2 297#endif 298 299/* 300 * This returns the number of padding units, for depth d and width w. 301 * For bitmaps this can be calculated with the macros above. 302 * Other depths require either grovelling over the formats field of the 303 * screenInfo or hardwired constants. 304 */ 305 306typedef struct _PaddingInfo { 307 int padRoundUp; /* pixels per pad unit - 1 */ 308 int padPixelsLog2; /* log 2 (pixels per pad unit) */ 309 int padBytesLog2; /* log 2 (bytes per pad unit) */ 310 int notPower2; /* bitsPerPixel not a power of 2 */ 311 int bytesPerPixel; /* only set when notPower2 is TRUE */ 312 int bitsPerPixel; /* bits per pixel */ 313} PaddingInfo; 314extern PaddingInfo PixmapWidthPaddingInfo[]; 315 316/* The only portable way to get the bpp from the depth is to look it up */ 317#define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel) 318 319#define PixmapWidthInPadUnits(w, d) \ 320 (PixmapWidthPaddingInfo[d].notPower2 ? \ 321 (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \ 322 PixmapWidthPaddingInfo[d].bytesPerPixel) >> \ 323 PixmapWidthPaddingInfo[d].padBytesLog2) : \ 324 ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \ 325 PixmapWidthPaddingInfo[d].padPixelsLog2)) 326 327/* 328 * Return the number of bytes to which a scanline of the given 329 * depth and width will be padded. 330 */ 331#define PixmapBytePad(w, d) \ 332 (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2) 333 334#define BitmapBytePad(w) \ 335 (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD) 336 337#define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d) 338#define PixmapBytePadProto(w, d) PixmapBytePad(w, d) 339#define BitmapBytePadProto(w) BitmapBytePad(w) 340 341#endif /* SERVERMD_H */ 342