3 Copyright 1993, 1998 The Open Group
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
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
29 #ifdef HAVE_DIX_CONFIG_H
30 #include <dix-config.h>
34 #include "scrnintstr.h"
37 #include "windowstr.h"
39 #include "dixstruct.h"
46 * Scratch pixmap management and device independent pixmap allocation
53 GetScratchPixmapHeader(ScreenPtr pScreen
, int width
, int height
, int depth
,
54 int bitsPerPixel
, int devKind
, pointer pPixData
)
56 PixmapPtr pPixmap
= pScreen
->pScratchPixmap
;
59 pScreen
->pScratchPixmap
= NULL
;
61 /* width and height of 0 means don't allocate any pixmap data */
62 pPixmap
= (*pScreen
->CreatePixmap
)(pScreen
, 0, 0, depth
);
65 if ((*pScreen
->ModifyPixmapHeader
)(pPixmap
, width
, height
, depth
,
66 bitsPerPixel
, devKind
, pPixData
))
68 (*pScreen
->DestroyPixmap
)(pPixmap
);
76 FreeScratchPixmapHeader(PixmapPtr pPixmap
)
80 ScreenPtr pScreen
= pPixmap
->drawable
.pScreen
;
82 pPixmap
->devPrivate
.ptr
= NULL
; /* lest ddx chases bad ptr */
83 if (pScreen
->pScratchPixmap
)
84 (*pScreen
->DestroyPixmap
)(pPixmap
);
86 pScreen
->pScratchPixmap
= pPixmap
;
92 CreateScratchPixmapsForScreen(int scrnum
)
94 /* let it be created on first use */
95 screenInfo
.screens
[scrnum
]->pScratchPixmap
= NULL
;
101 FreeScratchPixmapsForScreen(int scrnum
)
103 FreeScratchPixmapHeader(screenInfo
.screens
[scrnum
]->pScratchPixmap
);
107 /* callable by ddx */
109 AllocatePixmap(ScreenPtr pScreen
, int pixDataSize
)
118 if (pScreen
->totalPixmapSize
> ((size_t)-1) - pixDataSize
)
121 pPixmap
= (PixmapPtr
)xalloc(pScreen
->totalPixmapSize
+ pixDataSize
);
124 ppriv
= (DevUnion
*)(pPixmap
+ 1);
125 pPixmap
->devPrivates
= ppriv
;
126 sizes
= pScreen
->PixmapPrivateSizes
;
127 ptr
= (char *)(ppriv
+ pScreen
->PixmapPrivateLen
);
128 for (i
= pScreen
->PixmapPrivateLen
; --i
>= 0; ppriv
++, sizes
++)
130 if ((size
= *sizes
) != 0)
132 ppriv
->ptr
= (pointer
)ptr
;
136 ppriv
->ptr
= (pointer
)NULL
;
141 pPixmap
->drawable
.pad0
= 0;
142 pPixmap
->drawable
.pad1
= 0;