summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Woelders <kim@woelders.dk>2021-11-25 06:16:47 +0100
committerKim Woelders <kim@woelders.dk>2021-11-25 09:17:50 +0100
commitadd72b4023735f67bce5c1e01f1c2198914d1b52 (patch)
tree20d8cfa48261305d682c85ece2a2b0a679ac8d2d
parent86a5a73b5e400538b63c9d5945925feea0a3eb5c (diff)
downloadimlib2-add72b4023735f67bce5c1e01f1c2198914d1b52.tar.gz
x11_grab.c: Rename source/destination variables for clarity
-rw-r--r--src/lib/x11_grab.c311
-rw-r--r--src/lib/x11_grab.h41
2 files changed, 183 insertions, 169 deletions
diff --git a/src/lib/x11_grab.c b/src/lib/x11_grab.c
index 24d4443..01170c9 100644
--- a/src/lib/x11_grab.c
+++ b/src/lib/x11_grab.c
@@ -21,15 +21,16 @@ Tmp_HandleXError(Display * d, XErrorEvent * ev)
}
void
-__imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
+__imlib_GrabXImageToRGBA(DATA32 * data,
+ int x_dst, int y_dst, int w_dst, int h_dst,
Display * d, XImage * xim, XImage * mxim, Visual * v,
- int depth, int x, int y, int w, int h, int grab)
+ int depth,
+ int x_src, int y_src, int w_src, int h_src, int grab)
{
- int inx, iny;
+ int x, y, inx, iny;
const DATA32 *src;
DATA32 *ptr;
int pixel;
- int origx, origy;
int bgr = 0;
if (!data)
@@ -37,25 +38,25 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
if (grab)
XGrabServer(d); /* This may prevent the image to be changed under our feet */
- origx = x;
- origy = y;
if (v->blue_mask > v->red_mask)
bgr = 1;
- if (origx < 0)
- inx = -origx;
+ if (x_src < 0)
+ inx = -x_src;
else
- inx = ox;
- if (origy < 0)
- iny = -origy;
+ inx = x_dst;
+ if (y_src < 0)
+ iny = -y_src;
else
- iny = oy;
+ iny = y_dst;
+
/* go thru the XImage and convert */
+
if ((depth == 24) && (xim->bits_per_pixel == 32))
depth = 25; /* fake depth meaning 24 bit in 32 bpp ximage */
- /* data needs swapping */
+ /* data needs swapping */
#ifdef WORDS_BIGENDIAN
if (xim->bitmap_bit_order == LSBFirst)
#else
@@ -76,13 +77,13 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
break;
case 15:
case 16:
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
unsigned short *tmp;
tmp =
(unsigned short *)(xim->data + (xim->bytes_per_line * y));
- for (x = 0; x < w; x++)
+ for (x = 0; x < w_src; x++)
{
*tmp = SWAP16(*tmp);
tmp++;
@@ -93,12 +94,12 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
case 25:
case 30:
case 32:
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
unsigned int *tmp;
tmp = (unsigned int *)(xim->data + (xim->bytes_per_line * y));
- for (x = 0; x < w; x++)
+ for (x = 0; x < w_src; x++)
{
*tmp = SWAP32(*tmp);
tmp++;
@@ -109,6 +110,7 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
break;
}
}
+
switch (depth)
{
case 0:
@@ -122,10 +124,10 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
case 8:
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = XGetPixel(xim, x, y);
pixel = (btab[pixel & 0xff]) |
@@ -139,10 +141,10 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = XGetPixel(xim, x, y);
*ptr++ = 0xff000000 |
@@ -180,11 +182,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
#define P2(p) (R2SH(p) & RMSK) | (G2SH(p) & GMSK) | (B2SH(p) & BMSK)
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < (w - 1); x += 2)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < (w_src - 1); x += 2)
{
#ifdef WORDS_BIGENDIAN
*ptr++ = MP(x + 1, y) | P2(*src);
@@ -195,7 +197,7 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
#endif
src++;
}
- if (x == (w - 1))
+ if (x == (w_src - 1))
{
pixel = XGetPixel(xim, x, y);
*ptr++ = MP(x, y) | P1(pixel);
@@ -206,11 +208,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
#define MP(x, y) (0xff000000)
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < (w - 1); x += 2)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < (w_src - 1); x += 2)
{
#ifdef WORDS_BIGENDIAN
*ptr++ = MP(x + 1, y) | P2(*src);
@@ -221,7 +223,7 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
#endif
src++;
}
- if (x == (w - 1))
+ if (x == (w_src - 1))
{
pixel = XGetPixel(xim, x, y);
*ptr++ = MP(x, y) | P1(pixel);
@@ -256,11 +258,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
#define P2(p) (R2SH(p) & RMSK) | (G2SH(p) & GMSK) | (B2SH(p) & BMSK)
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < (w - 1); x += 2)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < (w_src - 1); x += 2)
{
#ifdef WORDS_BIGENDIAN
*ptr++ = MP(x + 1, y) | P2(*src);
@@ -271,7 +273,7 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
#endif
src++;
}
- if (x == (w - 1))
+ if (x == (w_src - 1))
{
pixel = XGetPixel(xim, x, y);
*ptr++ = MP(x, y) | P1(pixel);
@@ -282,11 +284,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
#define MP(x, y) (0xff000000)
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < (w - 1); x += 2)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < (w_src - 1); x += 2)
{
#ifdef WORDS_BIGENDIAN
*ptr++ = MP(x + 1, y) | P2(*src);
@@ -297,7 +299,7 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
#endif
src++;
}
- if (x == (w - 1))
+ if (x == (w_src - 1))
{
pixel = XGetPixel(xim, x, y);
*ptr++ = MP(x, y) | P1(pixel);
@@ -310,10 +312,10 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
{
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = XGetPixel(xim, x, y);
pixel = ((pixel << 16) & 0xff0000) |
@@ -327,10 +329,10 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = XGetPixel(xim, x, y);
*ptr++ = 0xff000000 |
@@ -345,10 +347,10 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
{
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = XGetPixel(xim, x, y) & 0x00ffffff;
if (XGetPixel(mxim, x, y))
@@ -359,10 +361,10 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = XGetPixel(xim, x, y);
*ptr++ = 0xff000000 | (pixel & 0x00ffffff);
@@ -376,11 +378,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
{
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = ((*src << 16) & 0xff0000) |
((*src) & 0x00ff00) | ((*src >> 16) & 0x0000ff);
@@ -393,11 +395,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
*ptr++ = 0xff000000 |
((*src << 16) & 0xff0000) |
@@ -411,11 +413,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
{
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = (*src) & 0x00ffffff;
if (XGetPixel(mxim, x, y))
@@ -427,11 +429,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
*ptr++ = 0xff000000 | ((*src) & 0x00ffffff);
src++;
@@ -445,11 +447,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
{
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = (((*src) & 0x000003ff) << 14 & 0x00ff0000) |
(((*src) & 0x000ffc00) >> 4 & 0x0000ff00) |
@@ -463,11 +465,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
*ptr++ = 0xff000000 |
(((*src) & 0x000003ff) << 14 & 0x00ff0000) |
@@ -482,11 +484,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
{
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = (((*src) & 0x3ff00000) >> 6 & 0x00ff0000) |
(((*src) & 0x000ffc00) >> 4 & 0x0000ff00) |
@@ -500,11 +502,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
*ptr++ = 0xff000000 |
(((*src) & 0x3ff00000) >> 6 & 0x00ff0000) |
@@ -521,11 +523,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
{
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = SWAP32(*src);
if (!XGetPixel(mxim, x, y))
@@ -537,11 +539,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
*ptr++ = SWAP32(*src);
src++;
@@ -553,11 +555,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
{
if (mxim)
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
pixel = *src++;
if (!XGetPixel(mxim, x, y))
@@ -568,11 +570,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
else
{
- for (y = 0; y < h; y++)
+ for (y = 0; y < h_src; y++)
{
src = (DATA32 *) (xim->data + (xim->bytes_per_line * y));
- ptr = data + ((y + iny) * ow) + inx;
- for (x = 0; x < w; x++)
+ ptr = data + ((y + iny) * w_dst) + inx;
+ for (x = 0; x < w_src; x++)
{
*ptr++ = *src++;
}
@@ -589,10 +591,11 @@ __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
int
-__imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
- Display * d, Drawable p, Pixmap m, Visual * v,
- Colormap cm, int depth, int x, int y,
- int w, int h, char *pdomask, int grab)
+__imlib_GrabDrawableToRGBA(DATA32 * data, int x_dst, int y_dst, int w_dst,
+ int h_dst, Display * d, Drawable p, Pixmap m,
+ Visual * v, Colormap cm, int depth, int x_src,
+ int y_src, int w_src, int h_src, char *pdomask,
+ int grab)
{
XErrorHandler prev_erh = NULL;
XWindowAttributes xatt, ratt;
@@ -606,8 +609,8 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
XColor cols[256];
domask = (pdomask) ? *pdomask : 0;
- /* FIXME: oh isn't used - i wonder if there's a bug looming... */
- oh = 0;
+ /* FIXME: h_dst isn't used - i wonder if there's a bug looming... */
+ h_dst = 0;
if (grab)
XGrabServer(d);
XSync(d, False);
@@ -649,45 +652,45 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
/* clip to the drawable tree and screen */
clipx = 0;
clipy = 0;
- width = src_w - x;
- height = src_h - y;
- if (width > w)
- width = w;
- if (height > h)
- height = h;
+ width = src_w - x_src;
+ height = src_h - y_src;
+ if (width > w_src)
+ width = w_src;
+ if (height > h_src)
+ height = h_src;
if (!is_pixmap)
{
- if ((src_x + x + width) > ratt.width)
- width = ratt.width - (src_x + x);
- if ((src_y + y + height) > ratt.height)
- height = ratt.height - (src_y + y);
+ if ((src_x + x_src + width) > ratt.width)
+ width = ratt.width - (src_x + x_src);
+ if ((src_y + y_src + height) > ratt.height)
+ height = ratt.height - (src_y + y_src);
}
- if (x < 0)
+ if (x_src < 0)
{
- clipx = -x;
- width += x;
- x = 0;
+ clipx = -x_src;
+ width += x_src;
+ x_src = 0;
}
- if (y < 0)
+ if (y_src < 0)
{
- clipy = -y;
- height += y;
- y = 0;
+ clipy = -y_src;
+ height += y_src;
+ y_src = 0;
}
if (!is_pixmap)
{
- if ((src_x + x) < 0)
+ if ((src_x + x_src) < 0)
{
- clipx -= (src_x + x);
- width += (src_x + x);
- x = -src_x;
+ clipx -= (src_x + x_src);
+ width += (src_x + x_src);
+ x_src = -src_x;
}
- if ((src_y + y) < 0)
+ if ((src_y + y_src) < 0)
{
- clipy -= (src_y + y);
- height += (src_y + y);
- y = -src_y;
+ clipy -= (src_y + y_src);
+ height += (src_y + y_src);
+ y_src = -src_y;
}
}
if ((width <= 0) || (height <= 0))
@@ -696,8 +699,8 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
XUngrabServer(d);
return 0;
}
- w = width;
- h = height;
+ w_src = width;
+ h_src = height;
if ((!is_pixmap) && (domask) && (!m))
{
int ord, rect_no = 0;
@@ -714,14 +717,14 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
GC gc;
created_mask = 1;
- m = XCreatePixmap(d, p, w, h, 1);
+ m = XCreatePixmap(d, p, w_src, h_src, 1);
gcv.foreground = 0;
gc = XCreateGC(d, m, GCForeground, &gcv);
- XFillRectangle(d, m, gc, 0, 0, w, h);
+ XFillRectangle(d, m, gc, 0, 0, w_src, h_src);
XSetForeground(d, gc, 1);
for (i = 0; i < rect_no; i++)
XFillRectangle(d, m, gc,
- r[i].x - x, r[i].y - y,
+ r[i].x - x_src, r[i].y - y_src,
r[i].width, r[i].height);
XFreeGC(d, gc);
}
@@ -730,11 +733,13 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
/* Create an Ximage (shared or not) */
- xim = __imlib_ShmGetXImage(d, v, p, xatt.depth, x, y, w, h, &shminfo);
+ xim =
+ __imlib_ShmGetXImage(d, v, p, xatt.depth, x_src, y_src, w_src, h_src,
+ &shminfo);
is_shm = !!xim;
if (!xim)
- xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap);
+ xim = XGetImage(d, p, x_src, y_src, w_src, h_src, 0xffffffff, ZPixmap);
if (!xim)
{
if (grab)
@@ -745,10 +750,10 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
mxim = NULL;
if ((m) && (domask))
{
- mxim = __imlib_ShmGetXImage(d, v, m, 1, 0, 0, w, h, &mshminfo);
+ mxim = __imlib_ShmGetXImage(d, v, m, 1, 0, 0, w_src, h_src, &mshminfo);
is_mshm = !!mxim;
if (!mxim)
- mxim = XGetImage(d, m, 0, 0, w, h, 0xffffffff, ZPixmap);
+ mxim = XGetImage(d, m, 0, 0, w_src, h_src, 0xffffffff, ZPixmap);
}
if ((is_shm) || (is_mshm))
@@ -799,8 +804,9 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
btab[i] = cols[i].blue >> 8;
}
}
- __imlib_GrabXImageToRGBA(data, ox + clipx, oy + clipy, ow, oh,
- d, xim, mxim, v, xatt.depth, x, y, w, h, 0);
+ __imlib_GrabXImageToRGBA(data, x_dst + clipx, y_dst + clipy, w_dst, h_dst,
+ d, xim, mxim, v, xatt.depth, x_src, y_src, w_src,
+ h_src, 0);
/* destroy the Ximage */
if (is_shm)
@@ -831,10 +837,12 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
int
-__imlib_GrabDrawableScaledToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
- Display * d, Drawable p, Pixmap m, Visual * v,
- Colormap cm, int depth, int x, int y,
- int w, int h, char *pdomask, int grab)
+__imlib_GrabDrawableScaledToRGBA(DATA32 * data, int nu_x_dst, int nu_y_dst,
+ int w_dst, int h_dst,
+ Display * d, Drawable p, Pixmap m,
+ Visual * v, Colormap cm, int depth,
+ int x_src, int y_src, int w_src, int h_src,
+ char *pdomask, int grab)
{
int rc;
int tmpmask = 0;
@@ -843,7 +851,7 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
GC gc = 0, mgc = 0;
Pixmap psc, msc;
- psc = XCreatePixmap(d, p, ow, h, depth);
+ psc = XCreatePixmap(d, p, w_dst, h_src, depth);
gcv.foreground = 0;
gcv.subwindow_mode = IncludeInferiors;
@@ -858,7 +866,7 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
rect = XShapeGetRectangles(d, p, ShapeBounding, &rect_num, &rect_ord);
if (rect && (rect_num == 1 && rect[0].x == 0 && rect[0].y == 0 &&
- rect[0].width == w && rect[0].height == h))
+ rect[0].width == w_src && rect[0].height == h_src))
{
*pdomask = 0;
XFree(rect);
@@ -866,9 +874,9 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
else
{
tmpmask = 1;
- m = XCreatePixmap(d, p, w, h, 1);
+ m = XCreatePixmap(d, p, w_src, h_src, 1);
mgc = XCreateGC(d, m, GCForeground | GCGraphicsExposures, &gcv);
- XFillRectangle(d, m, mgc, 0, 0, w, h);
+ XFillRectangle(d, m, mgc, 0, 0, w_src, h_src);
if (rect)
{
XSetForeground(d, mgc, 1);
@@ -880,16 +888,16 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
}
}
- if (ow == w && oh == h)
+ if (w_dst == w_src && h_dst == h_src)
{
- XCopyArea(d, p, psc, gc, x, y, w, h, 0, 0);
+ XCopyArea(d, p, psc, gc, x_src, y_src, w_src, h_src, 0, 0);
msc = m;
}
else
{
if (*pdomask)
{
- msc = XCreatePixmap(d, p, ow, h, 1);
+ msc = XCreatePixmap(d, p, w_dst, h_src, 1);
if (!mgc)
mgc =
XCreateGC(d, msc, GCForeground | GCGraphicsExposures, &gcv);
@@ -897,24 +905,25 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int ox, int oy, int ow, int oh,
else
msc = None;
- for (i = 0; i < ow; i++)
+ for (i = 0; i < w_dst; i++)
{
- xx = (w * i) / ow;
- XCopyArea(d, p, psc, gc, x + xx, y, 1, h, i, 0);
+ xx = (w_src * i) / w_dst;
+ XCopyArea(d, p, psc, gc, x_src + xx, y_src, 1, h_src, i, 0);
if (msc != None)
- XCopyArea(d, m, msc, mgc, xx, 0, 1, h, i, 0);
+ XCopyArea(d, m, msc, mgc, xx, 0, 1, h_src, i, 0);
}
- for (i = 0; i < oh; i++)
+ for (i = 0; i < h_dst; i++)
{
- xx = (h * i) / oh;
- XCopyArea(d, psc, psc, gc, 0, xx, ow, 1, 0, i);
+ xx = (h_src * i) / h_dst;
+ XCopyArea(d, psc, psc, gc, 0, xx, w_dst, 1, 0, i);
if (msc != None)
- XCopyArea(d, msc, msc, mgc, 0, xx, ow, 1, 0, i);
+ XCopyArea(d, msc, msc, mgc, 0, xx, w_dst, 1, 0, i);
}
}
- rc = __imlib_GrabDrawableToRGBA(data, 0, 0, ow, h, d, psc, msc,
- v, cm, depth, 0, 0, ow, oh, pdomask, grab);
+ rc = __imlib_GrabDrawableToRGBA(data, 0, 0, w_dst, h_src, d, psc, msc,
+ v, cm, depth, 0, 0, w_dst, h_dst,
+ pdomask, grab);
if (mgc)
XFreeGC(d, mgc);
diff --git a/src/lib/x11_grab.h b/src/lib/x11_grab.h
index b6f3ad6..1e3e3dd 100644
--- a/src/lib/x11_grab.h
+++ b/src/lib/x11_grab.h
@@ -3,25 +3,30 @@
#include "common.h"
-int __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy,
- int ow, int oh, Display * d,
- Drawable p, Pixmap m, Visual * v,
- Colormap cm, int depth, int x,
- int y, int w, int h,
- char *domask, int grab);
+int __imlib_GrabDrawableToRGBA(DATA32 * data, int x_dst,
+ int y_dst, int w_dst, int h_dst,
+ Display * d, Drawable p,
+ Pixmap m, Visual * v,
+ Colormap cm, int depth,
+ int x_src, int y_src, int w_src,
+ int h_src, char *domask,
+ int grab);
-int __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int ox,
- int oy, int ow, int oh,
- Display * d, Drawable p,
- Pixmap m, Visual * v,
- Colormap cm, int depth,
- int x, int y, int w, int h,
- char *pdomask, int grab);
+int __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int x_dst,
+ int y_dst, int w_dst,
+ int h_dst, Display * d,
+ Drawable p, Pixmap m,
+ Visual * v, Colormap cm,
+ int depth, int x_src,
+ int y_src, int w_src,
+ int h_src, char *pdomask,
+ int grab);
-void __imlib_GrabXImageToRGBA(DATA32 * data, int ox, int oy,
- int ow, int oh, Display * d,
- XImage * xim, XImage * mxim,
- Visual * v, int depth, int x,
- int y, int w, int h, int grab);
+void __imlib_GrabXImageToRGBA(DATA32 * data, int x_dst,
+ int y_dst, int w_dst, int h_dst,
+ Display * d, XImage * xim,
+ XImage * mxim, Visual * v,
+ int depth, int x_src, int y_src,
+ int w_src, int h_src, int grab);
#endif /* X11_GRAB_H */