1
/* $Xorg: pixmap.c,v 1.4 2001/02/09 02:04:40 xorgcvs Exp $ */
4
Copyright 1993, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
12
The above copyright notice and this permission notice shall be included
13
in all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall
24
not be used in advertising or otherwise to promote the sale, use or
25
other dealings in this Software without prior written authorization
29
/* $XFree86: xc/programs/Xserver/dix/pixmap.c,v 3.4 2001/01/17 22:36:44 dawes Exp $ */
31
#ifdef HAVE_DIX_CONFIG_H
32
#include <dix-config.h>
36
#include "scrnintstr.h"
39
#include "windowstr.h"
41
#include "dixstruct.h"
48
* Scratch pixmap management and device independent pixmap allocation
55
GetScratchPixmapHeader(ScreenPtr pScreen, int width, int height, int depth,
56
int bitsPerPixel, int devKind, pointer pPixData)
58
PixmapPtr pPixmap = pScreen->pScratchPixmap;
61
pScreen->pScratchPixmap = NULL;
63
/* width and height of 0 means don't allocate any pixmap data */
64
pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth);
67
if ((*pScreen->ModifyPixmapHeader)(pPixmap, width, height, depth,
68
bitsPerPixel, devKind, pPixData))
70
(*pScreen->DestroyPixmap)(pPixmap);
78
FreeScratchPixmapHeader(PixmapPtr pPixmap)
82
ScreenPtr pScreen = pPixmap->drawable.pScreen;
84
pPixmap->devPrivate.ptr = NULL; /* lest ddx chases bad ptr */
85
if (pScreen->pScratchPixmap)
86
(*pScreen->DestroyPixmap)(pPixmap);
88
pScreen->pScratchPixmap = pPixmap;
94
CreateScratchPixmapsForScreen(int scrnum)
96
/* let it be created on first use */
97
screenInfo.screens[scrnum]->pScratchPixmap = NULL;
103
FreeScratchPixmapsForScreen(int scrnum)
105
FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap);
109
/* callable by ddx */
111
AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
121
if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
124
pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize);
127
ppriv = (DevUnion *)(pPixmap + 1);
128
pPixmap->devPrivates = ppriv;
129
sizes = pScreen->PixmapPrivateSizes;
130
ptr = (char *)(ppriv + pScreen->PixmapPrivateLen);
131
for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++)
133
if ((size = *sizes) != 0)
135
ppriv->ptr = (pointer)ptr;
139
ppriv->ptr = (pointer)NULL;
142
pPixmap = (PixmapPtr)xalloc(sizeof(PixmapRec) + pixDataSize);