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 25Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 26 27 All Rights Reserved 28 29Permission to use, copy, modify, and distribute this software and its 30documentation for any purpose and without fee is hereby granted, 31provided that the above copyright notice appear in all copies and that 32both that copyright notice and this permission notice appear in 33supporting documentation, and that the name of Digital not be 34used in advertising or publicity pertaining to distribution of the 35software without specific, written prior permission. 36 37DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 38ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 39DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 40ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 41WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 42ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 43SOFTWARE. 44 45******************************************************************/ 46 47#ifndef SERVERMD_H 48#define SERVERMD_H 1 49 50#if !defined(_DIX_CONFIG_H_) && !defined(_XORG_SERVER_H_) 51#error Drivers must include xorg-server.h before any other xserver headers 52#error xserver code must include dix-config.h before any other headers 53#endif 54 55#include <X11/Xarch.h> /* for X_LITTLE_ENDIAN/X_BIG_ENDIAN */ 56 57#if X_BYTE_ORDER == X_LITTLE_ENDIAN 58#define IMAGE_BYTE_ORDER LSBFirst 59#define BITMAP_BIT_ORDER LSBFirst 60#elif X_BYTE_ORDER == X_BIG_ENDIAN 61#define IMAGE_BYTE_ORDER MSBFirst 62#define BITMAP_BIT_ORDER MSBFirst 63#else 64#error "Too weird to live." 65#endif 66 67#ifndef GLYPHPADBYTES 68#define GLYPHPADBYTES 4 69#endif 70 71/* size of buffer to use with GetImage, measured in bytes. There's obviously 72 * a trade-off between the amount of heap used and the number of times the 73 * ddx routine has to be called. 74 */ 75#ifndef IMAGE_BUFSIZE 76#define IMAGE_BUFSIZE (64*1024) 77#endif 78 79/* pad scanline to a longword */ 80#ifndef BITMAP_SCANLINE_UNIT 81#define BITMAP_SCANLINE_UNIT 32 82#endif 83 84#ifndef BITMAP_SCANLINE_PAD 85#define BITMAP_SCANLINE_PAD 32 86#define LOG2_BITMAP_PAD 5 87#define LOG2_BYTES_PER_SCANLINE_PAD 2 88#endif 89 90#include <X11/Xfuncproto.h> 91/* 92 * This returns the number of padding units, for depth d and width w. 93 * For bitmaps this can be calculated with the macros above. 94 * Other depths require either grovelling over the formats field of the 95 * screenInfo or hardwired constants. 96 */ 97 98typedef struct _PaddingInfo { 99 int padRoundUp; /* pixels per pad unit - 1 */ 100 int padPixelsLog2; /* log 2 (pixels per pad unit) */ 101 int padBytesLog2; /* log 2 (bytes per pad unit) */ 102 int notPower2; /* bitsPerPixel not a power of 2 */ 103 int bytesPerPixel; /* only set when notPower2 is TRUE */ 104 int bitsPerPixel; /* bits per pixel */ 105} PaddingInfo; 106extern _X_EXPORT PaddingInfo PixmapWidthPaddingInfo[]; 107 108/* The only portable way to get the bpp from the depth is to look it up */ 109#define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel) 110 111#define PixmapWidthInPadUnits(w, d) \ 112 (PixmapWidthPaddingInfo[d].notPower2 ? \ 113 (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \ 114 PixmapWidthPaddingInfo[d].bytesPerPixel) >> \ 115 PixmapWidthPaddingInfo[d].padBytesLog2) : \ 116 ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \ 117 PixmapWidthPaddingInfo[d].padPixelsLog2)) 118 119/* 120 * Return the number of bytes to which a scanline of the given 121 * depth and width will be padded. 122 */ 123#define PixmapBytePad(w, d) \ 124 (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2) 125 126#define BitmapBytePad(w) \ 127 (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD) 128 129#endif /* SERVERMD_H */ 130