x11: Pass X11 context around by struct

A bit nicer, I think.
This commit is contained in:
Kim Woelders 2023-02-17 08:59:41 +01:00
parent 51d74520fc
commit 3ab9498777
17 changed files with 411 additions and 405 deletions

View File

@ -74,7 +74,7 @@ EXTRA_DIST = $(MMX_SRCS) $(AMD64_SRCS) asm_loadimmq.S
if BUILD_X11
libImlib2_la_SOURCES += \
api_x11.c \
api_x11.c x11_types.h \
x11_color.c x11_color.h \
x11_context.c x11_context.h \
x11_grab.c x11_grab.h \

View File

@ -1,5 +1,8 @@
#include "rgbadraw.h"
#ifdef BUILD_X11
#include "x11_types.h"
#endif
/* convenience macros */
#define CAST_IMAGE(im, image) (im) = (ImlibImage *)(image)
@ -34,10 +37,7 @@ typedef void (*Imlib_Internal_Data_Destructor_Function)(void *, void *);
typedef struct {
#ifdef BUILD_X11
Display *display;
Visual *visual;
Colormap colormap;
int depth;
ImlibContextX11 x11;
Drawable drawable;
Pixmap mask;
#endif

View File

@ -18,47 +18,47 @@
EAPI void
imlib_context_set_display(Display * display)
{
ctx->display = display;
ctx->x11.dpy = display;
}
EAPI Display *
imlib_context_get_display(void)
{
return ctx->display;
return ctx->x11.dpy;
}
EAPI void
imlib_context_disconnect_display(void)
{
if (!ctx->display)
if (!ctx->x11.dpy)
return;
__imlib_RenderDisconnect(ctx->display);
ctx->display = NULL;
__imlib_RenderDisconnect(ctx->x11.dpy);
ctx->x11.dpy = NULL;
}
EAPI void
imlib_context_set_visual(Visual * visual)
{
ctx->visual = visual;
ctx->depth = imlib_get_visual_depth(ctx->display, ctx->visual);
ctx->x11.vis = visual;
ctx->x11.depth = imlib_get_visual_depth(ctx->x11.dpy, ctx->x11.vis);
}
EAPI Visual *
imlib_context_get_visual(void)
{
return ctx->visual;
return ctx->x11.vis;
}
EAPI void
imlib_context_set_colormap(Colormap colormap)
{
ctx->colormap = colormap;
ctx->x11.cmap = colormap;
}
EAPI Colormap
imlib_context_get_colormap(void)
{
return ctx->colormap;
return ctx->x11.cmap;
}
EAPI void
@ -112,37 +112,37 @@ imlib_context_get_mask_alpha_threshold(void)
EAPI int
imlib_get_ximage_cache_count_used(void)
{
return __imlib_GetXImageCacheCountUsed(ctx->display);
return __imlib_GetXImageCacheCountUsed(&ctx->x11);
}
EAPI int
imlib_get_ximage_cache_count_max(void)
{
return __imlib_GetXImageCacheCountMax(ctx->display);
return __imlib_GetXImageCacheCountMax(&ctx->x11);
}
EAPI void
imlib_set_ximage_cache_count_max(int count)
{
__imlib_SetXImageCacheCountMax(ctx->display, count);
__imlib_SetXImageCacheCountMax(&ctx->x11, count);
}
EAPI int
imlib_get_ximage_cache_size_used(void)
{
return __imlib_GetXImageCacheSizeUsed(ctx->display);
return __imlib_GetXImageCacheSizeUsed(&ctx->x11);
}
EAPI int
imlib_get_ximage_cache_size_max(void)
{
return __imlib_GetXImageCacheSizeMax(ctx->display);
return __imlib_GetXImageCacheSizeMax(&ctx->x11);
}
EAPI void
imlib_set_ximage_cache_size_max(int bytes)
{
__imlib_SetXImageCacheSizeMax(ctx->display, bytes);
__imlib_SetXImageCacheSizeMax(&ctx->x11, bytes);
}
EAPI int
@ -189,10 +189,9 @@ imlib_render_pixmaps_for_whole_image(Pixmap * pixmap_return,
ctx->error = __imlib_LoadImageData(im);
if (ctx->error)
return;
__imlib_CreatePixmapsForImage(ctx->display, ctx->drawable, ctx->visual,
ctx->depth, ctx->colormap, im, pixmap_return,
mask_return, 0, 0, im->w, im->h, im->w,
im->h, 0, ctx->dither, ctx->dither_mask,
__imlib_CreatePixmapsForImage(&ctx->x11, ctx->drawable, im, pixmap_return,
mask_return, 0, 0, im->w, im->h, im->w, im->h,
0, ctx->dither, ctx->dither_mask,
ctx->mask_alpha_threshold,
ctx->color_modifier);
}
@ -210,8 +209,7 @@ imlib_render_pixmaps_for_whole_image_at_size(Pixmap * pixmap_return,
ctx->error = __imlib_LoadImageData(im);
if (ctx->error)
return;
__imlib_CreatePixmapsForImage(ctx->display, ctx->drawable, ctx->visual,
ctx->depth, ctx->colormap, im, pixmap_return,
__imlib_CreatePixmapsForImage(&ctx->x11, ctx->drawable, im, pixmap_return,
mask_return, 0, 0, im->w, im->h, width,
height, ctx->anti_alias, ctx->dither,
ctx->dither_mask, ctx->mask_alpha_threshold,
@ -221,7 +219,7 @@ imlib_render_pixmaps_for_whole_image_at_size(Pixmap * pixmap_return,
EAPI void
imlib_free_pixmap_and_mask(Pixmap pixmap)
{
__imlib_FreePixmap(ctx->display, pixmap);
__imlib_FreePixmap(ctx->x11.dpy, pixmap);
}
EAPI void
@ -234,9 +232,9 @@ imlib_render_image_on_drawable(int x, int y)
ctx->error = __imlib_LoadImageData(im);
if (ctx->error)
return;
__imlib_RenderImage(ctx->display, im, ctx->drawable, ctx->mask,
ctx->visual, ctx->colormap, ctx->depth, 0, 0, im->w,
im->h, x, y, im->w, im->h, 0, ctx->dither, ctx->blend,
__imlib_RenderImage(&ctx->x11, im, ctx->drawable, ctx->mask,
0, 0, im->w, im->h, x, y, im->w, im->h,
0, ctx->dither, ctx->blend,
ctx->dither_mask, ctx->mask_alpha_threshold,
ctx->color_modifier, ctx->operation);
}
@ -251,8 +249,7 @@ imlib_render_image_on_drawable_at_size(int x, int y, int width, int height)
ctx->error = __imlib_LoadImageData(im);
if (ctx->error)
return;
__imlib_RenderImage(ctx->display, im, ctx->drawable, ctx->mask,
ctx->visual, ctx->colormap, ctx->depth,
__imlib_RenderImage(&ctx->x11, im, ctx->drawable, ctx->mask,
0, 0, im->w, im->h, x, y, width, height,
ctx->anti_alias, ctx->dither, ctx->blend,
ctx->dither_mask, ctx->mask_alpha_threshold,
@ -272,8 +269,7 @@ imlib_render_image_part_on_drawable_at_size(int src_x, int src_y,
ctx->error = __imlib_LoadImageData(im);
if (ctx->error)
return;
__imlib_RenderImage(ctx->display, im, ctx->drawable, 0,
ctx->visual, ctx->colormap, ctx->depth,
__imlib_RenderImage(&ctx->x11, im, ctx->drawable, 0,
src_x, src_y, src_width, src_height,
dst_x, dst_y, dst_width, dst_height,
ctx->anti_alias, ctx->dither, ctx->blend, 0, 0,
@ -283,8 +279,7 @@ imlib_render_image_part_on_drawable_at_size(int src_x, int src_y,
EAPI uint32_t
imlib_render_get_pixel_color(void)
{
return __imlib_RenderGetPixel(ctx->display, ctx->drawable, ctx->visual,
ctx->colormap, ctx->depth,
return __imlib_RenderGetPixel(&ctx->x11, ctx->drawable,
(uint8_t) ctx->color.red,
(uint8_t) ctx->color.green,
(uint8_t) ctx->color.blue);
@ -309,9 +304,8 @@ imlib_create_image_from_drawable(Pixmap mask, int x, int y, int width,
if (!im)
return NULL;
err = __imlib_GrabDrawableToRGBA(im->data, 0, 0, width, height,
ctx->display, ctx->drawable, mask,
ctx->visual, ctx->colormap, ctx->depth,
err = __imlib_GrabDrawableToRGBA(&ctx->x11, im->data, 0, 0, width, height,
ctx->drawable, mask,
x, y, width, height,
&domask, need_to_grab_x);
if (err)
@ -335,9 +329,8 @@ imlib_create_image_from_ximage(XImage * image, XImage * mask, int x, int y,
if (!im)
return NULL;
__imlib_GrabXImageToRGBA(im->data, 0, 0, width, height,
ctx->display, image, mask, ctx->visual,
ctx->depth, x, y, width, height, need_to_grab_x);
__imlib_GrabXImageToRGBA(&ctx->x11, im->data, 0, 0, width, height,
image, mask, x, y, width, height, need_to_grab_x);
return im;
}
@ -362,19 +355,15 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, int src_x, int src_y,
domask = mask != 0 || get_mask_from_shape;
if (src_width == dst_width && src_height == dst_height)
err = __imlib_GrabDrawableToRGBA(im->data,
err = __imlib_GrabDrawableToRGBA(&ctx->x11, im->data,
0, 0, dst_width, dst_height,
ctx->display, ctx->drawable, mask,
ctx->visual, ctx->colormap,
ctx->depth,
ctx->drawable, mask,
src_x, src_y, src_width, src_height,
&domask, need_to_grab_x);
else
err = __imlib_GrabDrawableScaledToRGBA(im->data,
err = __imlib_GrabDrawableScaledToRGBA(&ctx->x11, im->data,
0, 0, dst_width, dst_height,
ctx->display, ctx->drawable, mask,
ctx->visual, ctx->colormap,
ctx->depth,
ctx->drawable, mask,
src_x, src_y,
src_width, src_height,
&domask, need_to_grab_x);
@ -450,9 +439,10 @@ imlib_copy_drawable_to_image(Pixmap mask, int src_x, int src_y, int src_width,
if ((src_width <= 0) || (src_height <= 0))
return 0;
__imlib_DirtyImage(im);
return !__imlib_GrabDrawableToRGBA(im->data, dst_x, dst_y, im->w, im->h,
ctx->display, ctx->drawable, mask,
ctx->visual, ctx->colormap, ctx->depth,
return !__imlib_GrabDrawableToRGBA(&ctx->x11, im->data,
dst_x, dst_y, im->w, im->h,
ctx->drawable, mask,
src_x, src_y, src_width, src_height,
&domask, need_to_grab_x);
}
@ -472,18 +462,18 @@ imlib_render_image_updates_on_drawable(Imlib_Updates updates, int x, int y)
ctx->error = __imlib_LoadImageData(im);
if (ctx->error)
return;
ximcs = __imlib_GetXImageCacheCountMax(ctx->display); /* Save */
ximcs = __imlib_GetXImageCacheCountMax(&ctx->x11); /* Save */
if (ximcs == 0) /* Only if we don't set this up elsewhere */
__imlib_SetXImageCacheCountMax(ctx->display, 10);
__imlib_SetXImageCacheCountMax(&ctx->x11, 10);
for (; u; u = u->next)
{
__imlib_RenderImage(ctx->display, im, ctx->drawable, 0, ctx->visual,
ctx->colormap, ctx->depth, u->x, u->y, u->w, u->h,
__imlib_RenderImage(&ctx->x11, im, ctx->drawable, 0,
u->x, u->y, u->w, u->h,
x + u->x, y + u->y, u->w, u->h, 0, ctx->dither, 0,
0, 0, ctx->color_modifier, OP_COPY);
}
if (ximcs == 0)
__imlib_SetXImageCacheCountMax(ctx->display, ximcs);
__imlib_SetXImageCacheCountMax(&ctx->x11, ximcs);
}
EAPI void
@ -500,12 +490,11 @@ imlib_render_image_on_drawable_skewed(int src_x, int src_y,
ctx->error = __imlib_LoadImageData(im);
if (ctx->error)
return;
__imlib_RenderImageSkewed(ctx->display, im, ctx->drawable, ctx->mask,
ctx->visual, ctx->colormap, ctx->depth, src_x,
src_y, src_width, src_height,
dst_x, dst_y, h_angle_x,
h_angle_y, v_angle_x, v_angle_y, ctx->anti_alias,
ctx->dither, ctx->blend, ctx->dither_mask,
__imlib_RenderImageSkewed(&ctx->x11, im, ctx->drawable, ctx->mask,
src_x, src_y, src_width, src_height,
dst_x, dst_y, h_angle_x, h_angle_y, v_angle_x,
v_angle_y, ctx->anti_alias, ctx->dither,
ctx->blend, ctx->dither_mask,
ctx->mask_alpha_threshold, ctx->color_modifier,
ctx->operation);
}
@ -523,9 +512,8 @@ imlib_render_image_on_drawable_at_angle(int src_x, int src_y,
ctx->error = __imlib_LoadImageData(im);
if (ctx->error)
return;
__imlib_RenderImageSkewed(ctx->display, im, ctx->drawable, ctx->mask,
ctx->visual, ctx->colormap, ctx->depth, src_x,
src_y, src_width, src_height,
__imlib_RenderImageSkewed(&ctx->x11, im, ctx->drawable, ctx->mask,
src_x, src_y, src_width, src_height,
dst_x, dst_y, angle_x, angle_y,
0, 0, ctx->anti_alias, ctx->dither, ctx->blend,
ctx->dither_mask, ctx->mask_alpha_threshold,

View File

@ -87,15 +87,15 @@ _free_colors(Display * d, Colormap cmap, uint8_t * lut, int num)
}
static uint8_t *
__imlib_AllocColors332(Display * d, Colormap cmap, Visual * v)
__imlib_AllocColors332(const ImlibContextX11 * x11)
{
int r, g, b, i;
uint8_t *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb; i++)
for (i = 0; i < x11->vis->bits_per_rgb; i++)
sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
sig_mask <<= (16 - x11->vis->bits_per_rgb);
i = 0;
color_lut = malloc(256 * sizeof(uint8_t));
if (!color_lut)
@ -118,13 +118,13 @@ __imlib_AllocColors332(Display * d, Colormap cmap, Visual * v)
val = (b << 6) | (b << 4) | (b << 2) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
xcl_in = xcl;
ret = XAllocColor(d, cmap, &xcl);
ret = XAllocColor(x11->dpy, x11->cmap, &xcl);
if ((ret == 0) ||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
{
_free_colors(d, cmap, color_lut, i);
_free_colors(x11->dpy, x11->cmap, color_lut, i);
return NULL;
}
color_lut[i] = xcl.pixel;
@ -136,15 +136,15 @@ __imlib_AllocColors332(Display * d, Colormap cmap, Visual * v)
}
static uint8_t *
__imlib_AllocColors666(Display * d, Colormap cmap, Visual * v)
__imlib_AllocColors666(const ImlibContextX11 * x11)
{
int r, g, b, i;
uint8_t *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb; i++)
for (i = 0; i < x11->vis->bits_per_rgb; i++)
sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
sig_mask <<= (16 - x11->vis->bits_per_rgb);
i = 0;
color_lut = malloc(256 * sizeof(uint8_t));
if (!color_lut)
@ -167,13 +167,13 @@ __imlib_AllocColors666(Display * d, Colormap cmap, Visual * v)
val = (int)((((double)b) / 5.0) * 65535);
xcl.blue = (unsigned short)(val);
xcl_in = xcl;
ret = XAllocColor(d, cmap, &xcl);
ret = XAllocColor(x11->dpy, x11->cmap, &xcl);
if ((ret == 0) ||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
{
_free_colors(d, cmap, color_lut, i);
_free_colors(x11->dpy, x11->cmap, color_lut, i);
return NULL;
}
color_lut[i] = xcl.pixel;
@ -185,15 +185,15 @@ __imlib_AllocColors666(Display * d, Colormap cmap, Visual * v)
}
static uint8_t *
__imlib_AllocColors232(Display * d, Colormap cmap, Visual * v)
__imlib_AllocColors232(const ImlibContextX11 * x11)
{
int r, g, b, i;
uint8_t *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb; i++)
for (i = 0; i < x11->vis->bits_per_rgb; i++)
sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
sig_mask <<= (16 - x11->vis->bits_per_rgb);
i = 0;
color_lut = malloc(128 * sizeof(uint8_t));
if (!color_lut)
@ -216,13 +216,13 @@ __imlib_AllocColors232(Display * d, Colormap cmap, Visual * v)
val = (b << 6) | (b << 4) | (b << 2) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
xcl_in = xcl;
ret = XAllocColor(d, cmap, &xcl);
ret = XAllocColor(x11->dpy, x11->cmap, &xcl);
if ((ret == 0) ||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
{
_free_colors(d, cmap, color_lut, i);
_free_colors(x11->dpy, x11->cmap, color_lut, i);
return NULL;
}
color_lut[i] = xcl.pixel;
@ -234,15 +234,15 @@ __imlib_AllocColors232(Display * d, Colormap cmap, Visual * v)
}
static uint8_t *
__imlib_AllocColors222(Display * d, Colormap cmap, Visual * v)
__imlib_AllocColors222(const ImlibContextX11 * x11)
{
int r, g, b, i;
uint8_t *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb; i++)
for (i = 0; i < x11->vis->bits_per_rgb; i++)
sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
sig_mask <<= (16 - x11->vis->bits_per_rgb);
i = 0;
color_lut = malloc(64 * sizeof(uint8_t));
if (!color_lut)
@ -265,13 +265,13 @@ __imlib_AllocColors222(Display * d, Colormap cmap, Visual * v)
val = (b << 6) | (b << 4) | (b << 2) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
xcl_in = xcl;
ret = XAllocColor(d, cmap, &xcl);
ret = XAllocColor(x11->dpy, x11->cmap, &xcl);
if ((ret == 0) ||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
{
_free_colors(d, cmap, color_lut, i);
_free_colors(x11->dpy, x11->cmap, color_lut, i);
return NULL;
}
color_lut[i] = xcl.pixel;
@ -283,15 +283,15 @@ __imlib_AllocColors222(Display * d, Colormap cmap, Visual * v)
}
static uint8_t *
__imlib_AllocColors221(Display * d, Colormap cmap, Visual * v)
__imlib_AllocColors221(const ImlibContextX11 * x11)
{
int r, g, b, i;
uint8_t *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb; i++)
for (i = 0; i < x11->vis->bits_per_rgb; i++)
sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
sig_mask <<= (16 - x11->vis->bits_per_rgb);
i = 0;
color_lut = malloc(32 * sizeof(uint8_t));
if (!color_lut)
@ -315,13 +315,13 @@ __imlib_AllocColors221(Display * d, Colormap cmap, Visual * v)
(b << 3) | (b << 2) | (b << 1) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
xcl_in = xcl;
ret = XAllocColor(d, cmap, &xcl);
ret = XAllocColor(x11->dpy, x11->cmap, &xcl);
if ((ret == 0) ||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
{
_free_colors(d, cmap, color_lut, i);
_free_colors(x11->dpy, x11->cmap, color_lut, i);
return NULL;
}
color_lut[i] = xcl.pixel;
@ -333,15 +333,15 @@ __imlib_AllocColors221(Display * d, Colormap cmap, Visual * v)
}
static uint8_t *
__imlib_AllocColors121(Display * d, Colormap cmap, Visual * v)
__imlib_AllocColors121(const ImlibContextX11 * x11)
{
int r, g, b, i;
uint8_t *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb; i++)
for (i = 0; i < x11->vis->bits_per_rgb; i++)
sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
sig_mask <<= (16 - x11->vis->bits_per_rgb);
i = 0;
color_lut = malloc(16 * sizeof(uint8_t));
if (!color_lut)
@ -366,13 +366,13 @@ __imlib_AllocColors121(Display * d, Colormap cmap, Visual * v)
(b << 3) | (b << 2) | (b << 1) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
xcl_in = xcl;
ret = XAllocColor(d, cmap, &xcl);
ret = XAllocColor(x11->dpy, x11->cmap, &xcl);
if ((ret == 0) ||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
{
_free_colors(d, cmap, color_lut, i);
_free_colors(x11->dpy, x11->cmap, color_lut, i);
return NULL;
}
color_lut[i] = xcl.pixel;
@ -384,15 +384,15 @@ __imlib_AllocColors121(Display * d, Colormap cmap, Visual * v)
}
static uint8_t *
__imlib_AllocColors111(Display * d, Colormap cmap, Visual * v)
__imlib_AllocColors111(const ImlibContextX11 * x11)
{
int r, g, b, i;
uint8_t *color_lut;
int sig_mask = 0;
for (i = 0; i < v->bits_per_rgb; i++)
for (i = 0; i < x11->vis->bits_per_rgb; i++)
sig_mask |= (0x1 << i);
sig_mask <<= (16 - v->bits_per_rgb);
sig_mask <<= (16 - x11->vis->bits_per_rgb);
i = 0;
color_lut = malloc(8 * sizeof(uint8_t));
if (!color_lut)
@ -418,13 +418,13 @@ __imlib_AllocColors111(Display * d, Colormap cmap, Visual * v)
(b << 3) | (b << 2) | (b << 1) | (b);
xcl.blue = (unsigned short)((val << 8) | (val));
xcl_in = xcl;
ret = XAllocColor(d, cmap, &xcl);
ret = XAllocColor(x11->dpy, x11->cmap, &xcl);
if ((ret == 0) ||
((xcl_in.red & sig_mask) != (xcl.red & sig_mask)) ||
((xcl_in.green & sig_mask) != (xcl.green & sig_mask)) ||
((xcl_in.blue & sig_mask) != (xcl.blue & sig_mask)))
{
_free_colors(d, cmap, color_lut, i);
_free_colors(x11->dpy, x11->cmap, color_lut, i);
return NULL;
}
color_lut[i] = xcl.pixel;
@ -436,7 +436,7 @@ __imlib_AllocColors111(Display * d, Colormap cmap, Visual * v)
}
static uint8_t *
__imlib_AllocColors1(Display * d, Colormap cmap, Visual * v)
__imlib_AllocColors1(const ImlibContextX11 * x11)
{
XColor xcl;
uint8_t *color_lut;
@ -450,77 +450,70 @@ __imlib_AllocColors1(Display * d, Colormap cmap, Visual * v)
xcl.red = (unsigned short)(0x0000);
xcl.green = (unsigned short)(0x0000);
xcl.blue = (unsigned short)(0x0000);
if (!XAllocColor(d, cmap, &xcl))
if (!XAllocColor(x11->dpy, x11->cmap, &xcl))
goto bail;
color_lut[i++] = xcl.pixel;
xcl.red = (unsigned short)(0xffff);
xcl.green = (unsigned short)(0xffff);
xcl.blue = (unsigned short)(0xffff);
if (!XAllocColor(d, cmap, &xcl))
if (!XAllocColor(x11->dpy, x11->cmap, &xcl))
goto bail;
color_lut[i] = xcl.pixel;
return color_lut;
bail:
_free_colors(d, cmap, color_lut, i);
_free_colors(x11->dpy, x11->cmap, color_lut, i);
return NULL;
}
uint8_t *
__imlib_AllocColorTable(Display * d, Colormap cmap,
unsigned char *type_return, Visual * v)
__imlib_AllocColorTable(const ImlibContextX11 * x11, unsigned char *type_return)
{
uint8_t *color_lut = NULL;
if (v->bits_per_rgb > 1)
if (x11->vis->bits_per_rgb > 1)
{
if ((_max_colors >= 256)
&& (color_lut = __imlib_AllocColors332(d, cmap, v)))
if ((_max_colors >= 256) && (color_lut = __imlib_AllocColors332(x11)))
{
*type_return = PAL_TYPE_332;
return color_lut;
}
if ((_max_colors >= 216)
&& (color_lut = __imlib_AllocColors666(d, cmap, v)))
if ((_max_colors >= 216) && (color_lut = __imlib_AllocColors666(x11)))
{
*type_return = PAL_TYPE_666;
return color_lut;
}
if ((_max_colors >= 128)
&& (color_lut = __imlib_AllocColors232(d, cmap, v)))
if ((_max_colors >= 128) && (color_lut = __imlib_AllocColors232(x11)))
{
*type_return = PAL_TYPE_232;
return color_lut;
}
if ((_max_colors >= 64)
&& (color_lut = __imlib_AllocColors222(d, cmap, v)))
if ((_max_colors >= 64) && (color_lut = __imlib_AllocColors222(x11)))
{
*type_return = PAL_TYPE_222;
return color_lut;
}
if ((_max_colors >= 32)
&& (color_lut = __imlib_AllocColors221(d, cmap, v)))
if ((_max_colors >= 32) && (color_lut = __imlib_AllocColors221(x11)))
{
*type_return = PAL_TYPE_221;
return color_lut;
}
if ((_max_colors >= 16)
&& (color_lut = __imlib_AllocColors121(d, cmap, v)))
if ((_max_colors >= 16) && (color_lut = __imlib_AllocColors121(x11)))
{
*type_return = PAL_TYPE_121;
return color_lut;
}
}
if ((_max_colors >= 8) && (color_lut = __imlib_AllocColors111(d, cmap, v)))
if ((_max_colors >= 8) && (color_lut = __imlib_AllocColors111(x11)))
{
*type_return = PAL_TYPE_111;
return color_lut;
}
color_lut = __imlib_AllocColors1(d, cmap, v);
color_lut = __imlib_AllocColors1(x11);
*type_return = PAL_TYPE_1;
return color_lut;
}

View File

@ -1,8 +1,7 @@
#ifndef X11_COLOR_H
#define X11_COLOR_H 1
#include <X11/Xlib.h>
#include "types.h"
#include "x11_types.h"
typedef enum {
PAL_TYPE_332, /* 0 */
@ -21,8 +20,7 @@ int __imlib_XActualDepth(Display * d, Visual * v);
Visual *__imlib_BestVisual(Display * d, int screen,
int *depth_return);
uint8_t *__imlib_AllocColorTable(Display * d, Colormap cmap,
unsigned char *type_return,
Visual * v);
uint8_t *__imlib_AllocColorTable(const ImlibContextX11 * x11,
unsigned char *type_return);
#endif /* X11_COLOR_H */

View File

@ -48,7 +48,7 @@ __imlib_FlushContexts(void)
for (i = 0; i < num[ct->palette_type]; i++)
pixels[i] = (unsigned long)ct->palette[i];
XFreeColors(ct->display, ct->colormap, pixels,
XFreeColors(ct->x11.dpy, ct->x11.cmap, pixels,
num[ct->palette_type], 0);
free(ct->palette);
@ -72,14 +72,14 @@ __imlib_FlushContexts(void)
}
Context *
__imlib_FindContext(Display * d, Visual * v, Colormap c, int depth)
__imlib_FindContext(const ImlibContextX11 * x11)
{
Context *ct, *ct_prev;
for (ct = context, ct_prev = NULL; ct; ct_prev = ct, ct = ct->next)
{
if ((ct->display == d) && (ct->visual == v) &&
(ct->colormap == c) && (ct->depth == depth))
if ((ct->x11.dpy == x11->dpy) && (ct->x11.vis == x11->vis) &&
(ct->x11.cmap == x11->cmap) && (ct->x11.depth == x11->depth))
{
if (ct_prev)
{
@ -94,39 +94,36 @@ __imlib_FindContext(Display * d, Visual * v, Colormap c, int depth)
}
Context *
__imlib_NewContext(Display * d, Visual * v, Colormap c, int depth)
__imlib_NewContext(const ImlibContextX11 * x11)
{
Context *ct;
context_counter++;
ct = malloc(sizeof(Context));
ct->last_use = context_counter;
ct->display = d;
ct->visual = v;
ct->colormap = c;
ct->depth = depth;
ct->x11 = *x11;
ct->next = NULL;
if (depth <= 8)
if (x11->depth <= 8)
{
ct->palette = __imlib_AllocColorTable(d, c, &(ct->palette_type), v);
ct->palette = __imlib_AllocColorTable(x11, &ct->palette_type);
ct->r_dither = malloc(sizeof(uint8_t) * DM_X * DM_Y * 256);
ct->g_dither = malloc(sizeof(uint8_t) * DM_X * DM_Y * 256);
ct->b_dither = malloc(sizeof(uint8_t) * DM_X * DM_Y * 256);
__imlib_RGBA_init((void *)ct->r_dither, (void *)ct->g_dither,
(void *)ct->b_dither, depth, ct->palette_type);
(void *)ct->b_dither, x11->depth, ct->palette_type);
}
else
{
ct->palette = NULL;
ct->palette_type = 0;
if ((depth > 8) && (depth <= 16))
if ((x11->depth > 8) && (x11->depth <= 16))
{
ct->r_dither = malloc(sizeof(uint16_t) * 4 * 4 * 256);
ct->g_dither = malloc(sizeof(uint16_t) * 4 * 4 * 256);
ct->b_dither = malloc(sizeof(uint16_t) * 4 * 4 * 256);
__imlib_RGBA_init((void *)ct->r_dither, (void *)ct->g_dither,
(void *)ct->b_dither, depth, 0);
(void *)ct->b_dither, x11->depth, 0);
}
else
{
@ -134,7 +131,7 @@ __imlib_NewContext(Display * d, Visual * v, Colormap c, int depth)
ct->g_dither = NULL;
ct->b_dither = NULL;
__imlib_RGBA_init((void *)ct->r_dither, (void *)ct->g_dither,
(void *)ct->b_dither, depth, 0);
(void *)ct->b_dither, x11->depth, 0);
}
}
@ -142,11 +139,11 @@ __imlib_NewContext(Display * d, Visual * v, Colormap c, int depth)
}
Context *
__imlib_GetContext(Display * d, Visual * v, Colormap c, int depth)
__imlib_GetContext(const ImlibContextX11 * x11)
{
Context *ct;
ct = __imlib_FindContext(d, v, c, depth);
ct = __imlib_FindContext(x11);
if (ct)
{
ct->last_use = context_counter;
@ -155,7 +152,7 @@ __imlib_GetContext(Display * d, Visual * v, Colormap c, int depth)
__imlib_FlushContexts();
ct = __imlib_NewContext(d, v, c, depth);
ct = __imlib_NewContext(x11);
ct->next = context;
context = ct;

View File

@ -1,15 +1,12 @@
#ifndef X11_CONTEXT_H
#define X11_CONTEXT_H 1
#include <X11/Xlib.h>
#include "types.h"
#include "x11_types.h"
typedef struct _Context {
int last_use;
Display *display;
Visual *visual;
Colormap colormap;
int depth;
ImlibContextX11 x11;
struct _Context *next;
uint8_t *palette;
@ -22,11 +19,8 @@ typedef struct _Context {
void __imlib_SetMaxContexts(int num);
int __imlib_GetMaxContexts(void);
void __imlib_FlushContexts(void);
Context *__imlib_FindContext(Display * d, Visual * v, Colormap c,
int depth);
Context *__imlib_NewContext(Display * d, Visual * v, Colormap c,
int depth);
Context *__imlib_GetContext(Display * d, Visual * v, Colormap c,
int depth);
Context *__imlib_FindContext(const ImlibContextX11 * x11);
Context *__imlib_NewContext(const ImlibContextX11 * x11);
Context *__imlib_GetContext(const ImlibContextX11 * x11);
#endif /* X11_CONTEXT_H */

View File

@ -24,13 +24,13 @@ Tmp_HandleXError(Display * d, XErrorEvent * ev)
#define PTR(T, im_, y_) (T*)(void*)(im_->data + (im_->bytes_per_line * y_))
void
__imlib_GrabXImageToRGBA(uint32_t * data,
__imlib_GrabXImageToRGBA(const ImlibContextX11 * x11, uint32_t * data,
int x_dst, int y_dst, int w_dst, int h_dst,
Display * d, XImage * xim, XImage * mxim, Visual * v,
int depth,
XImage * xim, XImage * mxim,
int x_src, int y_src, int w_src, int h_src, int grab)
{
int x, y, inx, iny;
int depth;
const uint32_t *src;
const uint16_t *s16;
uint32_t *ptr;
@ -42,9 +42,9 @@ __imlib_GrabXImageToRGBA(uint32_t * data,
return;
if (grab)
XGrabServer(d); /* This may prevent the image to be changed under our feet */
XGrabServer(x11->dpy); /* This may prevent the image to be changed under our feet */
if (v->blue_mask > v->red_mask)
if (x11->vis->blue_mask > x11->vis->red_mask)
bgr = 1;
if (x_src < 0)
@ -58,6 +58,7 @@ __imlib_GrabXImageToRGBA(uint32_t * data,
/* go thru the XImage and convert */
depth = x11->depth;
if ((depth == 24) && (xim->bits_per_pixel == 32))
depth = 25; /* fake depth meaning 24 bit in 32 bpp ximage */
@ -533,7 +534,7 @@ __imlib_GrabXImageToRGBA(uint32_t * data,
}
if (grab)
XUngrabServer(d);
XUngrabServer(x11->dpy);
}
static Pixmap
@ -580,11 +581,12 @@ _WindowGetShapeMask(Display * d, Window p,
}
int
__imlib_GrabDrawableToRGBA(uint32_t * 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)
__imlib_GrabDrawableToRGBA(const ImlibContextX11 * x11, uint32_t * data,
int x_dst, int y_dst,
int w_dst, int h_dst,
Drawable draw, Pixmap mask_,
int x_src, int y_src, int w_src, int h_src,
char *pdomask, int grab)
{
XErrorHandler prev_erh = NULL;
XWindowAttributes xatt, ratt;
@ -593,7 +595,7 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
int i;
int src_x, src_y, src_w, src_h;
int width, height, clipx, clipy;
Pixmap m = m_;
Pixmap mask = mask_;
XShmSegmentInfo shminfo, mshminfo;
XImage *xim, *mxim;
XColor cols[256];
@ -603,14 +605,14 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
h_dst = 0; /* h_dst is not used */
if (grab)
XGrabServer(d);
XSync(d, False);
XGrabServer(x11->dpy);
XSync(x11->dpy, False);
prev_erh = XSetErrorHandler(Tmp_HandleXError);
_x_err = 0;
/* lets see if its a pixmap or not */
XGetWindowAttributes(d, p, &xatt);
XSync(d, False);
XGetWindowAttributes(x11->dpy, draw, &xatt);
XSync(x11->dpy, False);
if (_x_err)
is_pixmap = 1;
/* reset our error handler */
@ -620,7 +622,7 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
{
Window dw;
XGetGeometry(d, p, &dw, &src_x, &src_y,
XGetGeometry(x11->dpy, draw, &dw, &src_x, &src_y,
(unsigned int *)&src_w, (unsigned int *)&src_h,
(unsigned int *)&src_x, (unsigned int *)&xatt.depth);
src_x = 0;
@ -630,8 +632,9 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
{
Window dw;
XGetWindowAttributes(d, xatt.root, &ratt);
XTranslateCoordinates(d, p, xatt.root, 0, 0, &src_x, &src_y, &dw);
XGetWindowAttributes(x11->dpy, xatt.root, &ratt);
XTranslateCoordinates(x11->dpy, draw, xatt.root,
0, 0, &src_x, &src_y, &dw);
src_w = xatt.width;
src_h = xatt.height;
if ((xatt.map_state != IsViewable) && (xatt.backing_store == NotUseful))
@ -692,40 +695,44 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
w_src = width;
h_src = height;
if ((!is_pixmap) && (domask) && (m == None))
m = _WindowGetShapeMask(d, p, x_src, y_src, w_src, h_src,
xatt.width, xatt.height);
if ((!is_pixmap) && (domask) && (mask == None))
mask = _WindowGetShapeMask(x11->dpy, draw,
x_src, y_src, w_src, h_src,
xatt.width, xatt.height);
/* Create an Ximage (shared or not) */
xim = __imlib_ShmGetXImage(d, v, p, xatt.depth, x_src, y_src, w_src, h_src,
&shminfo);
xim = __imlib_ShmGetXImage(x11, draw, xatt.depth,
x_src, y_src, w_src, h_src, &shminfo);
is_shm = !!xim;
if (!xim)
xim = XGetImage(d, p, x_src, y_src, w_src, h_src, 0xffffffff, ZPixmap);
xim = XGetImage(x11->dpy, draw, x_src, y_src,
w_src, h_src, 0xffffffff, ZPixmap);
if (!xim)
goto bail;
mxim = NULL;
if ((m) && (domask))
if ((mask) && (domask))
{
mxim = __imlib_ShmGetXImage(d, v, m, 1, 0, 0, w_src, h_src, &mshminfo);
mxim = __imlib_ShmGetXImage(x11, mask, 1, 0, 0, w_src, h_src,
&mshminfo);
is_mshm = !!mxim;
if (!mxim)
mxim = XGetImage(d, m, 0, 0, w_src, h_src, 0xffffffff, ZPixmap);
mxim = XGetImage(x11->dpy, mask, 0, 0, w_src, h_src,
0xffffffff, ZPixmap);
}
if ((is_shm) || (is_mshm))
{
XSync(d, False);
XSync(x11->dpy, False);
if (grab)
XUngrabServer(d);
XSync(d, False);
XUngrabServer(x11->dpy);
XSync(x11->dpy, False);
}
else if (grab)
XUngrabServer(d);
XUngrabServer(x11->dpy);
if ((xatt.depth == 1) && (!cm) && (is_pixmap))
if ((xatt.depth == 1) && (!x11->cmap) && (is_pixmap))
{
rtab[0] = 255;
gtab[0] = 255;
@ -736,17 +743,19 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
}
else if (xatt.depth <= 8)
{
if (!cm)
Colormap cmap = x11->cmap;
if (!cmap)
{
if (is_pixmap)
{
cm = DefaultColormap(d, DefaultScreen(d));
cmap = DefaultColormap(x11->dpy, DefaultScreen(x11->dpy));
}
else
{
cm = xatt.colormap;
if (cm == None)
cm = ratt.colormap;
cmap = xatt.colormap;
if (cmap == None)
cmap = ratt.colormap;
}
}
@ -755,7 +764,7 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
cols[i].pixel = i;
cols[i].flags = DoRed | DoGreen | DoBlue;
}
XQueryColors(d, cm, cols, 1 << xatt.depth);
XQueryColors(x11->dpy, cmap, cols, 1 << xatt.depth);
for (i = 0; i < (1 << xatt.depth); i++)
{
rtab[i] = cols[i].red >> 8;
@ -764,33 +773,33 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
}
}
__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);
__imlib_GrabXImageToRGBA(x11, data,
x_dst + clipx, y_dst + clipy, w_dst, h_dst,
xim, mxim, x_src, y_src, w_src, h_src, 0);
/* destroy the Ximage */
if (is_shm)
__imlib_ShmDestroyXImage(d, xim, &shminfo);
__imlib_ShmDestroyXImage(x11, xim, &shminfo);
else
XDestroyImage(xim);
if (mxim)
{
if (is_mshm)
__imlib_ShmDestroyXImage(d, mxim, &mshminfo);
__imlib_ShmDestroyXImage(x11, mxim, &mshminfo);
else
XDestroyImage(mxim);
}
if (m != None && m != m_)
XFreePixmap(d, m);
if (mask != None && mask != mask_)
XFreePixmap(x11->dpy, mask);
if (pdomask)
{
/* Set domask according to whether or not we have useful alpha data */
if (xatt.depth == 32)
*pdomask = 1;
else if (m == None)
else if (mask == None)
*pdomask = 0;
}
@ -798,15 +807,15 @@ __imlib_GrabDrawableToRGBA(uint32_t * data, int x_dst, int y_dst, int w_dst,
bail:
if (grab)
XUngrabServer(d);
XUngrabServer(x11->dpy);
return 1;
}
int
__imlib_GrabDrawableScaledToRGBA(uint32_t * data, int nu_x_dst, int nu_y_dst,
__imlib_GrabDrawableScaledToRGBA(const ImlibContextX11 * x11, uint32_t * 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,
Drawable draw, Pixmap mask_,
int x_src, int y_src, int w_src, int h_src,
char *pdomask, int grab)
{
@ -814,7 +823,7 @@ __imlib_GrabDrawableScaledToRGBA(uint32_t * data, int nu_x_dst, int nu_y_dst,
int h_tmp, i, xx;
XGCValues gcv;
GC gc, mgc = NULL;
Pixmap m = m_;
Pixmap mask = mask_;
Pixmap psc, msc;
h_tmp = h_dst > h_src ? h_dst : h_src;
@ -822,21 +831,23 @@ __imlib_GrabDrawableScaledToRGBA(uint32_t * data, int nu_x_dst, int nu_y_dst,
gcv.foreground = 0;
gcv.subwindow_mode = IncludeInferiors;
gcv.graphics_exposures = False;
gc = XCreateGC(d, p, GCSubwindowMode | GCGraphicsExposures, &gcv);
gc = XCreateGC(x11->dpy, draw, GCSubwindowMode | GCGraphicsExposures, &gcv);
if (*pdomask && m == None)
if (*pdomask && mask == None)
{
m = _WindowGetShapeMask(d, p, 0, 0, w_src, h_src, w_src, h_src);
if (m == None)
mask = _WindowGetShapeMask(x11->dpy, draw,
0, 0, w_src, h_src, w_src, h_src);
if (mask == None)
*pdomask = 0;
}
psc = XCreatePixmap(d, p, w_dst, h_tmp, depth);
psc = XCreatePixmap(x11->dpy, draw, w_dst, h_tmp, x11->depth);
if (*pdomask)
{
msc = XCreatePixmap(d, p, w_dst, h_tmp, 1);
mgc = XCreateGC(d, msc, GCForeground | GCGraphicsExposures, &gcv);
msc = XCreatePixmap(x11->dpy, draw, w_dst, h_tmp, 1);
mgc =
XCreateGC(x11->dpy, msc, GCForeground | GCGraphicsExposures, &gcv);
}
else
msc = None;
@ -844,9 +855,9 @@ __imlib_GrabDrawableScaledToRGBA(uint32_t * data, int nu_x_dst, int nu_y_dst,
for (i = 0; i < w_dst; i++)
{
xx = (w_src * i) / w_dst;
XCopyArea(d, p, psc, gc, x_src + xx, y_src, 1, h_src, i, 0);
XCopyArea(x11->dpy, draw, psc, gc, x_src + xx, y_src, 1, h_src, i, 0);
if (msc != None)
XCopyArea(d, m, msc, mgc, xx, 0, 1, h_src, i, 0);
XCopyArea(x11->dpy, mask, msc, mgc, xx, 0, 1, h_src, i, 0);
}
if (h_dst > h_src)
{
@ -855,9 +866,9 @@ __imlib_GrabDrawableScaledToRGBA(uint32_t * data, int nu_x_dst, int nu_y_dst,
xx = (h_src * i) / h_dst;
if (xx == i)
continue; /* Don't copy onto self */
XCopyArea(d, psc, psc, gc, 0, xx, w_dst, 1, 0, i);
XCopyArea(x11->dpy, psc, psc, gc, 0, xx, w_dst, 1, 0, i);
if (msc != None)
XCopyArea(d, msc, msc, mgc, 0, xx, w_dst, 1, 0, i);
XCopyArea(x11->dpy, msc, msc, mgc, 0, xx, w_dst, 1, 0, i);
}
}
else
@ -867,25 +878,24 @@ __imlib_GrabDrawableScaledToRGBA(uint32_t * data, int nu_x_dst, int nu_y_dst,
xx = (h_src * i) / h_dst;
if (xx == i)
continue; /* Don't copy onto self */
XCopyArea(d, psc, psc, gc, 0, xx, w_dst, 1, 0, i);
XCopyArea(x11->dpy, psc, psc, gc, 0, xx, w_dst, 1, 0, i);
if (msc != None)
XCopyArea(d, msc, msc, mgc, 0, xx, w_dst, 1, 0, i);
XCopyArea(x11->dpy, msc, msc, mgc, 0, xx, w_dst, 1, 0, i);
}
}
rc = __imlib_GrabDrawableToRGBA(data, 0, 0, w_dst, h_dst, d, psc, msc,
v, cm, depth, 0, 0, w_dst, h_dst,
pdomask, grab);
rc = __imlib_GrabDrawableToRGBA(x11, data, 0, 0, w_dst, h_dst, psc, msc,
0, 0, w_dst, h_dst, pdomask, grab);
if (mgc)
XFreeGC(d, mgc);
if (msc != None && msc != m)
XFreePixmap(d, msc);
if (m != None && m != m_)
XFreePixmap(d, m);
XFreeGC(d, gc);
if (psc != p)
XFreePixmap(d, psc);
XFreeGC(x11->dpy, mgc);
if (msc != None && msc != mask)
XFreePixmap(x11->dpy, msc);
if (mask != None && mask != mask_)
XFreePixmap(x11->dpy, mask);
XFreeGC(x11->dpy, gc);
if (psc != draw)
XFreePixmap(x11->dpy, psc);
return rc;
}

View File

@ -1,33 +1,33 @@
#ifndef X11_GRAB_H
#define X11_GRAB_H 1
#include <X11/Xlib.h>
#include "types.h"
#include "x11_types.h"
int __imlib_GrabDrawableToRGBA(uint32_t * 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_GrabDrawableToRGBA(const ImlibContextX11 * x11,
uint32_t * data,