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.7 2003/07/16 01:38:51 dawes Exp $ */
17
#ifdef HAVE_XNEST_CONFIG_H
18
#include <xnest-config.h>
22
#include <X11/Xproto.h>
23
#include "regionstr.h"
24
#include "pixmapstr.h"
25
#include "scrnintstr.h"
26
#include "regionstr.h"
38
int xnestPixmapPrivateIndex;
42
xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth)
46
pPixmap = AllocatePixmap(pScreen, sizeof(xnestPrivPixmap));
49
pPixmap->drawable.type = DRAWABLE_PIXMAP;
50
pPixmap->drawable.class = 0;
51
pPixmap->drawable.depth = depth;
52
pPixmap->drawable.bitsPerPixel = depth;
53
pPixmap->drawable.id = 0;
54
pPixmap->drawable.x = 0;
55
pPixmap->drawable.y = 0;
56
pPixmap->drawable.width = width;
57
pPixmap->drawable.height = height;
58
pPixmap->drawable.pScreen = pScreen;
59
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
61
pPixmap->devKind = PixmapBytePad(width, depth);
63
pPixmap->devPrivates[xnestPixmapPrivateIndex].ptr =
64
(pointer)((char *)pPixmap + pScreen->totalPixmapSize);
66
pPixmap->devPrivate.ptr = (pointer)(pPixmap + 1);
69
xnestPixmapPriv(pPixmap)->pixmap =
70
XCreatePixmap(xnestDisplay,
71
xnestDefaultWindows[pScreen->myNum],
72
width, height, depth);
74
xnestPixmapPriv(pPixmap)->pixmap = 0;
80
xnestDestroyPixmap(PixmapPtr pPixmap)
84
XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
90
xnestPixmapToRegion(PixmapPtr pPixmap)
93
register RegionPtr pReg, pTmpReg;
95
unsigned long previousPixel, currentPixel;
99
ximage = XGetImage(xnestDisplay, xnestPixmap(pPixmap), 0, 0,
100
pPixmap->drawable.width, pPixmap->drawable.height,
103
pReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
104
pTmpReg = REGION_CREATE(pPixmap->drawable.pScreen, NULL, 1);
105
if(!pReg || !pTmpReg) return NullRegion;
107
for (y = 0; y < pPixmap->drawable.height; y++) {
111
for (x = 0; x < pPixmap->drawable.width; x++) {
112
currentPixel = XGetPixel(ximage, x, y);
113
if (previousPixel != currentPixel) {
114
if (previousPixel == 0L) {
118
else if (currentPixel == 0L) {
121
REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
122
REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
124
previousPixel = currentPixel;
127
if (previousPixel != 0L) {
128
/* right edge because of the end of pixmap */
129
Box.x2 = pPixmap->drawable.width;
130
REGION_RESET(pPixmap->drawable.pScreen, pTmpReg, &Box);
131
REGION_APPEND(pPixmap->drawable.pScreen, pReg, pTmpReg);
135
REGION_DESTROY(pPixmap->drawable.pScreen, pTmpReg);
136
XDestroyImage(ximage);
138
REGION_VALIDATE(pPixmap->drawable.pScreen, pReg, &overlap);