1
/* $Xorg: Pixmap.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
4
Copyright 1993 by Davor Matic
6
Permission to use, copy, modify, distribute, and sell this software
7
and its documentation for any purpose is hereby granted without fee,
8
provided that the above copyright notice appear in all copies and that
9
both that copyright notice and this permission notice appear in
10
supporting documentation. Davor Matic makes no representations about
11
the suitability of this software for any purpose. It is provided "as
12
is" without express or implied warranty.
15
/* $XFree86: xc/programs/Xserver/hw/xnest/Pixmap.c,v 3.6 2003/01/10 13:29:40 eich Exp $ */
19
#include "miscstruct.h"
20
#include "pixmapstr.h"
21
#include "scrnintstr.h"
22
#include "regionstr.h"
34
int xnestPixmapPrivateIndex;
37
PixmapPtr xnestCreatePixmap(pScreen, width, height, depth)
45
pPixmap = AllocatePixmap(pScreen, sizeof(xnestPrivPixmap));
48
pPixmap->drawable.type = DRAWABLE_PIXMAP;
49
pPixmap->drawable.class = 0;
50
pPixmap->drawable.depth = depth;
51
pPixmap->drawable.bitsPerPixel = depth;
52
pPixmap->drawable.id = 0;
53
pPixmap->drawable.x = 0;
54
pPixmap->drawable.y = 0;
55
pPixmap->drawable.width = width;
56
pPixmap->drawable.height = height;
57
pPixmap->drawable.pScreen = pScreen;
58
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
60
pPixmap->devKind = PixmapBytePad(width, depth);
62
pPixmap->devPrivates[xnestPixmapPrivateIndex].ptr =
63
(pointer)((char *)pPixmap + pScreen->totalPixmapSize);
65
pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
68
xnestPixmapPriv(pPixmap)->pixmap =
69
XCreatePixmap(xnestDisplay,
70
xnestDefaultWindows[pScreen->myNum],
71
width, height, depth);
73
xnestPixmapPriv(pPixmap)->pixmap = 0;
78
Bool xnestDestroyPixmap(pPixmap)
83
XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
88
RegionPtr xnestPixmapToRegion(pPixmap)
92
register RegionPtr pReg, pTmpReg;
94
unsigned long previousPixel, currentPixel;
98
ximage = XGetImage(xnestDisplay, xnestPixmap(pPixmap), 0, 0,
99
pPixmap->drawable.width, pPixmap->drawable.height,
102
pReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
103
pTmpReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
104
if(!pReg || !pTmpReg) return NullRegion;
106
for (y = 0; y < pPixmap->drawable.height; y++) {
110
for (x = 0; x < pPixmap->drawable.width; x++) {
111
currentPixel = XGetPixel(ximage, x, y);
112
if (previousPixel != currentPixel) {
113
if (previousPixel == 0L) {
117
else if (currentPixel == 0L) {
120
REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
121
REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
123
previousPixel = currentPixel;
126
if (previousPixel != 0L) {
127
/* right edge because of the end of pixmap */
128
Box.x2 = pPixmap->drawable.width;
129
REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
130
REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
134
REGION_DESTROY(pPixmap->drawable.pScreen, pTmpReg);
135
XDestroyImage(ximage);
137
REGION_VALIDATE(pPixmap->drawable.pScreen, pReg, &overlap);