Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/imlib2
Dir : e17/libs/imlib2/src
Modified Files:
grab.c
Log Message:
kwo's patch
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/imlib2/src/grab.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- grab.c 5 Apr 2004 02:55:29 -0000 1.9
+++ grab.c 14 Apr 2004 08:24:25 -0000 1.10
@@ -27,7 +27,7 @@
{
int inx, iny;
DATA32 *src, *ptr;
- int pixel, mpixel;
+ int pixel;
int origx, origy;
int bgr = 0;
@@ -72,12 +72,12 @@
for (x = 0; x < w; x++)
{
pixel = XGetPixel(xim, x, y);
- mpixel = XGetPixel(mxim, x, y);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- (btab[pixel & 0xff]) |
- (gtab[pixel & 0xff] << 8) |
- (rtab[pixel & 0xff] << 16);
-
+ pixel = (btab[pixel & 0xff]) |
+ (gtab[pixel & 0xff] << 8) |
+ (rtab[pixel & 0xff] << 16);
+ if (XGetPixel(mxim, x, y))
+ pixel |= 0xff000000;
+ *ptr++ = pixel;
}
}
}
@@ -110,7 +110,7 @@
#undef B2SH
#undef P1
#undef P2
-#define MP(x, y) (0xff000000 >> (XGetPixel(mxim, (x), (y)) << 31))
+#define MP(x, y) ((XGetPixel(mxim, (x), (y))) ? 0xff000000 : 0)
#define RMSK 0xf80000
#define GMSK 0x00fc00
#define BMSK 0x0000f8
@@ -186,7 +186,7 @@
#undef B2SH
#undef P1
#undef P2
-#define MP(x, y) (0xff000000 >> (XGetPixel(mxim, (x), (y)) << 31))
+#define MP(x, y) ((XGetPixel(mxim, (x), (y))) ? 0xff000000 : 0)
#define RMSK 0xf80000
#define GMSK 0x00f800
#define BMSK 0x0000f8
@@ -260,13 +260,12 @@
for (x = 0; x < w; x++)
{
pixel = XGetPixel(xim, x, y);
- pixel =
- ((pixel << 16) & 0xff0000) |
- ((pixel) & 0x00ff00) |
- ((pixel >> 16) & 0x0000ff);
- mpixel = XGetPixel(mxim, x, y);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- (pixel & 0x00ffffff);
+ pixel = ((pixel << 16) & 0xff0000) |
+ ((pixel) & 0x00ff00) |
+ ((pixel >> 16) & 0x0000ff);
+ if (XGetPixel(mxim, x, y))
+ pixel |= 0xff000000;
+ *ptr++ = pixel;
}
}
}
@@ -295,10 +294,10 @@
ptr = data + ((y + iny) * ow) + inx;
for (x = 0; x < w; x++)
{
- pixel = XGetPixel(xim, x, y);
- mpixel = XGetPixel(mxim, x, y);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- (pixel & 0x00ffffff);
+ pixel = XGetPixel(xim, x, y) & 0x00ffffff;
+ if (XGetPixel(mxim, x, y))
+ pixel |= 0xff000000;
+ *ptr++ = pixel;
}
}
}
@@ -328,13 +327,12 @@
ptr = data + ((y + iny) * ow) + inx;
for (x = 0; x < w; x++)
{
- mpixel = XGetPixel(mxim, x, y);
- pixel =
- ((*src << 16) & 0xff0000) |
- ((*src) & 0x00ff00) |
- ((*src >> 16) & 0x0000ff);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- ((pixel) & 0x00ffffff);
+ pixel = ((*src << 16) & 0xff0000) |
+ ((*src) & 0x00ff00) |
+ ((*src >> 16) & 0x0000ff);
+ if (XGetPixel(mxim, x, y))
+ pixel |= 0xff000000;
+ *ptr++ = pixel;
src++;
}
}
@@ -368,9 +366,10 @@
ptr = data + ((y + iny) * ow) + inx;
for (x = 0; x < w; x++)
{
- mpixel = XGetPixel(mxim, x, y);
- *ptr++ = (0xff000000 >> (mpixel << 31)) |
- ((*src) & 0x00ffffff);
+ pixel = (*src) & 0x00ffffff;
+ if (XGetPixel(mxim, x, y))
+ pixel |= 0xff000000;
+ *ptr++ = pixel;
src++;
}
}
@@ -394,7 +393,9 @@
default:
break;
}
- XUngrabServer(d);
+
+ if (grab)
+ XUngrabServer(d);
}
char
@@ -538,6 +539,7 @@
XFree(r);
}
}
+
/* Create an Ximage (shared or not) */
if (x_does_shm < 0)
{
@@ -546,21 +548,19 @@
else
x_does_shm = 0;
}
+
prev_erh = XSetErrorHandler((XErrorHandler) Tmp_HandleXError);
- _x_err = 0;
+
if (x_does_shm)
{
+ _x_err = 0;
xim = XShmCreateImage(d, v, xatt.depth, ZPixmap, NULL, &shminfo, w, h);
- if (!xim)
- xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
- else
+ if (xim)
{
XSync(d, False);
if (_x_err)
{
XDestroyImage(xim);
- xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
- _x_err = 0;
}
else
{
@@ -569,7 +569,6 @@
if (shminfo.shmid < 0)
{
XDestroyImage(xim);
- xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
}
else
{
@@ -579,52 +578,40 @@
shminfo.readOnly = False;
XShmAttach(d, &shminfo);
is_shm = 1;
+ XShmGetImage(d, p, xim, x, y, 0xffffffff);
+ XSync(d, False);
+ if (_x_err)
+ {
+ shmdt(shminfo.shmaddr);
+ shmctl(shminfo.shmid, IPC_RMID, 0);
+ XDestroyImage(xim);
+ is_shm = 0;
+ }
}
else
{
shmctl(shminfo.shmid, IPC_RMID, 0);
XDestroyImage(xim);
- xim = XGetImage(d, p, x, y, w, h,
- 0xffffffff, ZPixmap);
}
}
}
}
}
- else
+ if (!is_shm)
xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
- if (is_shm)
- {
- XShmGetImage(d, p, xim, x, y, 0xffffffff);
- XSync(d, False);
- if (_x_err)
- {
- shmdt(shminfo.shmaddr);
- shmctl(shminfo.shmid, IPC_RMID, 0);
- XDestroyImage(xim);
- xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
- is_shm = 0;
- }
- }
- XSetErrorHandler((XErrorHandler) prev_erh);
if ((m) && (domask))
{
- prev_erh = XSetErrorHandler((XErrorHandler) Tmp_HandleXError);
_x_err = 0;
if (x_does_shm)
{
mxim = XShmCreateImage(d, v, 1, ZPixmap, NULL, &mshminfo, w, h);
- if (!mxim)
- mxim = XGetImage(d, p, 0, 0, w, h, 0xffffffff, ZPixmap);
- else
+ if (mxim)
{
XSync(d, False);
if (_x_err)
{
XDestroyImage(mxim);
- xim = XGetImage(d, p, 0, 0, w, h, 0xffffffff, ZPixmap);
- _x_err = 0;
}
else
{
@@ -634,47 +621,41 @@
if (mshminfo.shmid < 0)
{
XDestroyImage(mxim);
- mxim = XGetImage(d, p, 0, 0, w, h,
- 0xffffffff, ZPixmap);
}
else
{
- mshminfo.shmaddr = xim->data =
+ mshminfo.shmaddr = mxim->data =
shmat(mshminfo.shmid, 0, 0);
if (mxim->data != (char *)-1)
{
mshminfo.readOnly = False;
XShmAttach(d, &mshminfo);
is_mshm = 1;
+ XShmGetImage(d, m, mxim, 0, 0, 0xffffffff);
+ XSync(d, False);
+ if (_x_err)
+ {
+ shmdt(mshminfo.shmaddr);
+ shmctl(mshminfo.shmid, IPC_RMID, 0);
+ XDestroyImage(mxim);
+ is_mshm = 0;
+ }
}
else
{
shmctl(mshminfo.shmid, IPC_RMID, 0);
XDestroyImage(mxim);
- mxim = XGetImage(d, p, x, y, w, h,
- 0xffffffff, ZPixmap);
}
}
}
}
}
- else
+ if (!is_mshm)
mxim = XGetImage(d, m, 0, 0, w, h, 0xffffffff, ZPixmap);
- if (is_mshm)
- {
- XShmGetImage(d, p, mxim, 0, 0, 0xffffffff);
- XSync(d, False);
- if (_x_err)
- {
- shmdt(mshminfo.shmaddr);
- shmctl(mshminfo.shmid, IPC_RMID, 0);
- XDestroyImage(mxim);
- mxim = XGetImage(d, p, 0, 0, w, h, 0xffffffff, ZPixmap);
- is_mshm = 0;
- }
- XSetErrorHandler((XErrorHandler) prev_erh);
- }
}
+
+ XSetErrorHandler((XErrorHandler) prev_erh);
+
if ((is_shm) || (is_mshm))
{
XSync(d, False);
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs