1 /* $XConsortium: pixmap.c /main/4 1996/08/12 22:04:49 dpw $ */
2 /* $XFree86: xc/programs/Xserver/dix/pixmap.c,v 3.1 1996/12/23 06:29:47 dawes Exp $ */
5 Copyright (c) 1993 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 OTHER DEALINGS IN THE SOFTWARE.
26 Except as contained in this notice, the name of the X Consortium shall
27 not be used in advertising or otherwise to promote the sale, use or
28 other dealings in this Software without prior written authorization
29 from the X Consortium.
34 #include "scrnintstr.h"
37 #include "windowstr.h"
39 #include "dixstruct.h"
46 * Scratch pixmap management and device independent pixmap allocation
53 GetScratchPixmapHeader(pScreen, width, height, depth, bitsPerPixel, devKind,
63 PixmapPtr pPixmap = pScreen->pScratchPixmap;
66 pScreen->pScratchPixmap = NULL;
68 /* width and height of 0 means don't allocate any pixmap data */
69 pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth);
72 if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth,
73 bitsPerPixel, devKind, pPixData))
81 FreeScratchPixmapHeader(pPixmap)
86 ScreenPtr pScreen = pPixmap->drawable.pScreen;
88 pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */
89 if (pScreen->pScratchPixmap)
90 (*pScreen->DestroyPixmap)(pPixmap);
92 pScreen->pScratchPixmap = pPixmap;
98 CreateScratchPixmapsForScreen(scrnum)
101 /* let it be created on first use */
102 screenInfo.screens[scrnum]->pScratchPixmap = NULL;
108 FreeScratchPixmapsForScreen(scrnum)
111 FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap);
115 /* callable by ddx */
117 AllocatePixmap(pScreen, pixDataSize)
129 pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize);
132 ppriv = (DevUnion *)(pPixmap + 1);
133 pPixmap->devPrivates = ppriv;
134 sizes = pScreen->PixmapPrivateSizes;
135 ptr = (char *)(ppriv + pScreen->PixmapPrivateLen);
136 for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++)
138 if ((size = *sizes) != 0)
140 ppriv->ptr = (pointer)ptr;
144 ppriv->ptr = (pointer)NULL;
147 pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize);