a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/***********************************************************
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncCopyright 1987, 1998 The Open Group
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncdocumentation for any purpose is hereby granted without fee, provided that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncthe above copyright notice appear in all copies and that both that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynccopyright notice and this permission notice appear in supporting
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncdocumentation.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncThe above copyright notice and this permission notice shall be included in
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncall copies or substantial portions of the Software.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncExcept as contained in this notice, the name of The Open Group shall not be
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncused in advertising or otherwise to promote the sale, use or other dealings
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncin this Software without prior written authorization from The Open Group.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync All Rights Reserved
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncPermission to use, copy, modify, and distribute this software and its
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncdocumentation for any purpose and without fee is hereby granted,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncprovided that the above copyright notice appear in all copies and that
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncboth that copyright notice and this permission notice appear in
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncsupporting documentation, and that the name of Digital not be
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncused in advertising or publicity pertaining to distribution of the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncsoftware without specific, written prior permission.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncSOFTWARE.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync******************************************************************/
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#ifndef SERVERMD_H
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define SERVERMD_H 1
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#if !defined(_DIX_CONFIG_H_) && !defined(_XORG_SERVER_H_)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#error Drivers must include xorg-server.h before any other xserver headers
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#error xserver code must include dix-config.h before any other headers
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#if X_BYTE_ORDER == X_LITTLE_ENDIAN
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define IMAGE_BYTE_ORDER LSBFirst
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define BITMAP_BIT_ORDER LSBFirst
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#elif X_BYTE_ORDER == X_BIG_ENDIAN
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define IMAGE_BYTE_ORDER MSBFirst
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define BITMAP_BIT_ORDER MSBFirst
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#else
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#error "Too weird to live."
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#ifndef GLYPHPADBYTES
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define GLYPHPADBYTES 4
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* size of buffer to use with GetImage, measured in bytes. There's obviously
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * a trade-off between the amount of heap used and the number of times the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * ddx routine has to be called.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#ifndef IMAGE_BUFSIZE
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define IMAGE_BUFSIZE (64*1024)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* pad scanline to a longword */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#ifndef BITMAP_SCANLINE_UNIT
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define BITMAP_SCANLINE_UNIT 32
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#ifndef BITMAP_SCANLINE_PAD
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define BITMAP_SCANLINE_PAD 32
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define LOG2_BITMAP_PAD 5
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define LOG2_BYTES_PER_SCANLINE_PAD 2
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#include <X11/Xfuncproto.h>
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * This returns the number of padding units, for depth d and width w.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * For bitmaps this can be calculated with the macros above.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Other depths require either grovelling over the formats field of the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * screenInfo or hardwired constants.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsynctypedef struct _PaddingInfo {
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int padRoundUp; /* pixels per pad unit - 1 */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int padPixelsLog2; /* log 2 (pixels per pad unit) */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int padBytesLog2; /* log 2 (bytes per pad unit) */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int notPower2; /* bitsPerPixel not a power of 2 */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int bytesPerPixel; /* only set when notPower2 is TRUE */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync int bitsPerPixel; /* bits per pixel */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync} PaddingInfo;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsyncextern _X_EXPORT PaddingInfo PixmapWidthPaddingInfo[];
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/* The only portable way to get the bpp from the depth is to look it up */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define BitsPerPixel(d) (PixmapWidthPaddingInfo[d].bitsPerPixel)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define PixmapWidthInPadUnits(w, d) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync (PixmapWidthPaddingInfo[d].notPower2 ? \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync (((int)(w) * PixmapWidthPaddingInfo[d].bytesPerPixel + \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync PixmapWidthPaddingInfo[d].bytesPerPixel) >> \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync PixmapWidthPaddingInfo[d].padBytesLog2) : \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync ((int)((w) + PixmapWidthPaddingInfo[d].padRoundUp) >> \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync PixmapWidthPaddingInfo[d].padPixelsLog2))
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Return the number of bytes to which a scanline of the given
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * depth and width will be padded.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync */
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define PixmapBytePad(w, d) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync (PixmapWidthInPadUnits(w, d) << PixmapWidthPaddingInfo[d].padBytesLog2)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#define BitmapBytePad(w) \
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync (((int)((w) + BITMAP_SCANLINE_PAD - 1) >> LOG2_BITMAP_PAD) << LOG2_BYTES_PER_SCANLINE_PAD)
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync#endif /* SERVERMD_H */