| 1 | /*********************************************************** |
| 2 | |
| 3 | Copyright 1987, 1998 The Open Group |
| 4 | |
| 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 |
| 9 | documentation. |
| 10 | |
| 11 | The above copyright notice and this permission notice shall be included in |
| 12 | all copies or substantial portions of the Software. |
| 13 | |
| 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. |
| 20 | |
| 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. |
| 24 | |
| 25 | Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. |
| 26 | |
| 27 | All Rights Reserved |
| 28 | |
| 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. |
| 36 | |
| 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 |
| 43 | SOFTWARE. |
| 44 | |
| 45 | ******************************************************************/ |
| 46 | |
| 47 | #ifndef SERVERMD_H |
| 48 | #define SERVERMD_H 1 |
| 49 | |
| 50 | /* |
| 51 | * Note: much of this is vestigial from mfb/cfb times. This should |
| 52 | * really be simplified even further. |
| 53 | */ |
| 54 | |
| 55 | /* |
| 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. |
| 68 | */ |
| 69 | |
| 70 | #ifdef __avr32__ |
| 71 | |
| 72 | #define IMAGE_BYTE_ORDER MSBFirst |
| 73 | #define BITMAP_BIT_ORDER MSBFirst |
| 74 | #define GLYPHPADBYTES 4 |
| 75 | |
| 76 | #endif /* __avr32__ */ |
| 77 | |
| 78 | #ifdef __arm32__ |
| 79 | |
| 80 | #define IMAGE_BYTE_ORDER LSBFirst |
| 81 | #define BITMAP_BIT_ORDER LSBFirst |
| 82 | #define GLYPHPADBYTES 4 |
| 83 | |
| 84 | #endif /* __arm32__ */ |
| 85 | |
| 86 | #if defined(__nds32__) |
| 87 | |
| 88 | #define IMAGE_BYTE_ORDER LSBFirst |
| 89 | |
| 90 | #if defined(XF86MONOVGA) || defined(XF86VGA16) || defined(XF86MONO) |
| 91 | #define BITMAP_BIT_ORDER MSBFirst |
| 92 | #else |
| 93 | #define BITMAP_BIT_ORDER LSBFirst |
| 94 | #endif |
| 95 | |
| 96 | #if defined(XF86MONOVGA) || defined(XF86VGA16) |
| 97 | #define BITMAP_SCANLINE_UNIT 8 |
| 98 | #endif |
| 99 | |
| 100 | #define GLYPHPADBYTES 4 |
| 101 | #define GETLEFTBITS_ALIGNMENT 1 |
| 102 | #define LARGE_INSTRUCTION_CACHE |
| 103 | #define AVOID_MEMORY_READ |
| 104 | |
| 105 | #endif /* __nds32__ */ |
| 106 | |
| 107 | #if defined __hppa__ |
| 108 | |
| 109 | #define IMAGE_BYTE_ORDER MSBFirst |
| 110 | #define BITMAP_BIT_ORDER MSBFirst |
| 111 | #define GLYPHPADBYTES 4 /* to make fb work */ |
| 112 | /* byte boundries */ |
| 113 | #endif /* hpux || __hppa__ */ |
| 114 | |
| 115 | #if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) |
| 116 | |
| 117 | #define IMAGE_BYTE_ORDER MSBFirst |
| 118 | #define BITMAP_BIT_ORDER MSBFirst |
| 119 | #define GLYPHPADBYTES 4 |
| 120 | |
| 121 | #endif /* PowerPC */ |
| 122 | |
| 123 | #if defined(__sh__) |
| 124 | |
| 125 | #if defined(__BIG_ENDIAN__) |
| 126 | #define IMAGE_BYTE_ORDER MSBFirst |
| 127 | #define BITMAP_BIT_ORDER MSBFirst |
| 128 | #define GLYPHPADBYTES 4 |
| 129 | #else |
| 130 | #define IMAGE_BYTE_ORDER LSBFirst |
| 131 | #define BITMAP_BIT_ORDER LSBFirst |
| 132 | #define GLYPHPADBYTES 4 |
| 133 | #endif |
| 134 | |
| 135 | #endif /* SuperH */ |
| 136 | |
| 137 | #if defined(__m32r__) |
| 138 | |
| 139 | #if defined(__BIG_ENDIAN__) |
| 140 | #define IMAGE_BYTE_ORDER MSBFirst |
| 141 | #define BITMAP_BIT_ORDER MSBFirst |
| 142 | #define GLYPHPADBYTES 4 |
| 143 | #else |
| 144 | #define IMAGE_BYTE_ORDER LSBFirst |
| 145 | #define BITMAP_BIT_ORDER LSBFirst |
| 146 | #define GLYPHPADBYTES 4 |
| 147 | #endif |
| 148 | |
| 149 | #endif /* __m32r__ */ |
| 150 | |
| 151 | #if (defined(sun) && (defined(__sparc) || defined(sparc))) || \ |
| 152 | (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \ |
| 153 | defined(__sparc__) || defined(__mc68000__) |
| 154 | |
| 155 | #if defined(__sparc) || defined(__sparc__) |
| 156 | #if !defined(sparc) |
| 157 | #define sparc 1 |
| 158 | #endif |
| 159 | #endif |
| 160 | |
| 161 | #if defined(sun386) || defined(sun5) |
| 162 | #define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */ |
| 163 | #define BITMAP_BIT_ORDER LSBFirst |
| 164 | #else |
| 165 | #define IMAGE_BYTE_ORDER MSBFirst /* Values for the SUN only */ |
| 166 | #define BITMAP_BIT_ORDER MSBFirst |
| 167 | #endif |
| 168 | |
| 169 | #define GLYPHPADBYTES 4 |
| 170 | |
| 171 | #endif /* sun && !(i386 && SVR4) */ |
| 172 | |
| 173 | #if defined(ibm032) || defined (ibm) |
| 174 | |
| 175 | #ifdef __i386__ |
| 176 | #define IMAGE_BYTE_ORDER LSBFirst /* Value for PS/2 only */ |
| 177 | #else |
| 178 | #define IMAGE_BYTE_ORDER MSBFirst /* Values for the RT only */ |
| 179 | #endif |
| 180 | #define BITMAP_BIT_ORDER MSBFirst |
| 181 | #define GLYPHPADBYTES 1 |
| 182 | /* ibm pcc doesn't understand pragmas. */ |
| 183 | |
| 184 | #ifdef __i386__ |
| 185 | #define BITMAP_SCANLINE_UNIT 8 |
| 186 | #endif |
| 187 | |
| 188 | #endif /* ibm */ |
| 189 | |
| 190 | #if (defined(mips) || defined(__mips)) |
| 191 | |
| 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 |
| 196 | #else |
| 197 | #define IMAGE_BYTE_ORDER MSBFirst /* Values for the MIPS only */ |
| 198 | #define BITMAP_BIT_ORDER MSBFirst |
| 199 | #define GLYPHPADBYTES 4 |
| 200 | #endif |
| 201 | |
| 202 | #endif /* mips */ |
| 203 | |
| 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 |
| 208 | |
| 209 | #endif /* alpha */ |
| 210 | |
| 211 | #if defined (linux) && defined (__s390__) |
| 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/s390 */ |
| 221 | |
| 222 | #if defined (linux) && defined (__s390x__) |
| 223 | |
| 224 | #define IMAGE_BYTE_ORDER MSBFirst |
| 225 | #define BITMAP_BIT_ORDER MSBFirst |
| 226 | #define GLYPHPADBYTES 4 |
| 227 | |
| 228 | #define BITMAP_SCANLINE_UNIT 8 |
| 229 | #define FAST_UNALIGNED_READ |
| 230 | |
| 231 | #endif /* linux/s390x */ |
| 232 | |
| 233 | #if defined(__ia64__) || defined(ia64) |
| 234 | |
| 235 | #define IMAGE_BYTE_ORDER LSBFirst |
| 236 | #define BITMAP_BIT_ORDER LSBFirst |
| 237 | #define GLYPHPADBYTES 4 |
| 238 | |
| 239 | #endif /* ia64 */ |
| 240 | |
| 241 | #if defined(__amd64__) || defined(amd64) || defined(__amd64) |
| 242 | #define IMAGE_BYTE_ORDER LSBFirst |
| 243 | #define BITMAP_BIT_ORDER LSBFirst |
| 244 | #define GLYPHPADBYTES 4 |
| 245 | /* ???? */ |
| 246 | #endif /* AMD64 */ |
| 247 | |
| 248 | #if defined(SVR4) && (defined(__i386__) || defined(__i386) ) || \ |
| 249 | defined(__alpha__) || defined(__alpha) || \ |
| 250 | defined(__i386__) || \ |
| 251 | defined(__s390x__) || defined(__s390__) |
| 252 | |
| 253 | #ifndef IMAGE_BYTE_ORDER |
| 254 | #define IMAGE_BYTE_ORDER LSBFirst |
| 255 | #endif |
| 256 | |
| 257 | #ifndef BITMAP_BIT_ORDER |
| 258 | #define BITMAP_BIT_ORDER LSBFirst |
| 259 | #endif |
| 260 | |
| 261 | #ifndef GLYPHPADBYTES |
| 262 | #define GLYPHPADBYTES 4 |
| 263 | #endif |
| 264 | |
| 265 | #endif /* SVR4 / BSD / i386 */ |
| 266 | |
| 267 | #if defined (linux) && defined (__mc68000__) |
| 268 | |
| 269 | #define IMAGE_BYTE_ORDER MSBFirst |
| 270 | #define BITMAP_BIT_ORDER MSBFirst |
| 271 | #define GLYPHPADBYTES 4 |
| 272 | |
| 273 | #endif /* linux/m68k */ |
| 274 | |
| 275 | /* linux on ARM */ |
| 276 | #if defined(linux) && defined(__arm__) |
| 277 | #define IMAGE_BYTE_ORDER LSBFirst |
| 278 | #define BITMAP_BIT_ORDER LSBFirst |
| 279 | #define GLYPHPADBYTES 4 |
| 280 | #endif |
| 281 | |
| 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 */ |
| 288 | |
| 289 | #ifdef __aarch64__ |
| 290 | |
| 291 | #ifdef __AARCH64EL__ |
| 292 | #define IMAGE_BYTE_ORDER LSBFirst |
| 293 | #define BITMAP_BIT_ORDER LSBFirst |
| 294 | #endif |
| 295 | #ifdef __AARCH64EB__ |
| 296 | #define IMAGE_BYTE_ORDER MSBFirst |
| 297 | #define BITMAP_BIT_ORDER MSBFirst |
| 298 | #endif |
| 299 | #define GLYPHPADBYTES 4 |
| 300 | |
| 301 | #endif /* __aarch64__ */ |
| 302 | |
| 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. |
| 306 | */ |
| 307 | #ifndef IMAGE_BUFSIZE |
| 308 | #define IMAGE_BUFSIZE (64*1024) |
| 309 | #endif |
| 310 | |
| 311 | /* pad scanline to a longword */ |
| 312 | #ifndef BITMAP_SCANLINE_UNIT |
| 313 | #define BITMAP_SCANLINE_UNIT 32 |
| 314 | #endif |
| 315 | |
| 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 |
| 320 | #endif |
| 321 | |
| 322 | #include <X11/Xfuncproto.h> |
| 323 | /* |
| 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. |
| 328 | */ |
| 329 | |
| 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 */ |
| 337 | } PaddingInfo; |
| 338 | extern _X_EXPORT PaddingInfo PixmapWidthPaddingInfo[]; |
| 339 | |
| 340 | /* The only portable way to get the bpp from the depth is to look it up */ |
| 341 | #define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel) |
| 342 | |
| 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)) |
| 350 | |
| 351 | /* |
| 352 | * Return the number of bytes to which a scanline of the given |
| 353 | * depth and width will be padded. |
| 354 | */ |
| 355 | #define PixmapBytePad(w, d) \ |
| 356 | (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2) |
| 357 | |
| 358 | #define BitmapBytePad(w) \ |
| 359 | (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD) |
| 360 | |
| 361 | #define PixmapWidthInPadUnitsProto(w, d) PixmapWidthInPadUnits(w, d) |
| 362 | #define PixmapBytePadProto(w, d) PixmapBytePad(w, d) |
| 363 | #define BitmapBytePadProto(w) BitmapBytePad(w) |
| 364 | |
| 365 | #endif /* SERVERMD_H */ |