x11: Pass X11 context around by struct
A bit nicer, I think.
This commit is contained in:
parent
51d74520fc
commit
3ab9498777
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
int x_dst, int y_dst,
|
||||
int w_dst, int h_dst,
|
||||
Drawable p, Pixmap m,
|
||||
int x_src, int y_src,
|
||||
int w_src, int h_src,
|
||||
char *domask, int grab);
|
||||
|
||||
int __imlib_GrabDrawableScaledToRGBA(uint32_t * data, int x_dst,
|
||||
int y_dst, int w_dst,
|
||||
int h_dst, Display * d,
|
||||
int __imlib_GrabDrawableScaledToRGBA(const ImlibContextX11 *
|
||||
x11, uint32_t * data,
|
||||
int x_dst, int y_dst,
|
||||
int w_dst, int h_dst,
|
||||
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 x_src, int y_src,
|
||||
int w_src, int h_src,
|
||||
char *domask, int grab);
|
||||
|
||||
void __imlib_GrabXImageToRGBA(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, int x_src, int y_src,
|
||||
void __imlib_GrabXImageToRGBA(const ImlibContextX11 * x11,
|
||||
uint32_t * data,
|
||||
int x_dst, int y_dst,
|
||||
int w_dst, int h_dst,
|
||||
XImage * xim, XImage * mxim,
|
||||
int x_src, int y_src,
|
||||
int w_src, int h_src, int grab);
|
||||
|
||||
#endif /* X11_GRAB_H */
|
||||
|
|
|
@ -59,9 +59,9 @@ __imlib_ConsumeImagePixmap(ImlibImagePixmap * ip)
|
|||
}
|
||||
|
||||
static ImlibImagePixmap *
|
||||
__imlib_FindCachedImagePixmap(ImlibImage * im, int w, int h, Display * d,
|
||||
Visual * v, int depth, int sx, int sy, int sw,
|
||||
int sh, Colormap cm, char aa, char hiq,
|
||||
__imlib_FindCachedImagePixmap(const ImlibContextX11 * x11, ImlibImage * im,
|
||||
int w, int h, int sx, int sy, int sw, int sh,
|
||||
char aa, char hiq,
|
||||
char dmask, uint64_t modification_count)
|
||||
{
|
||||
ImlibImagePixmap *ip, *ip_prev;
|
||||
|
@ -69,19 +69,20 @@ __imlib_FindCachedImagePixmap(ImlibImage * im, int w, int h, Display * d,
|
|||
for (ip = pixmaps, ip_prev = NULL; ip; ip_prev = ip, ip = ip->next)
|
||||
{
|
||||
/* if all the pixmap attributes match */
|
||||
if ((ip->w == w) && (ip->h == h) && (ip->depth == depth) && (!ip->dirty)
|
||||
&& (ip->visual == v) && (ip->display == d)
|
||||
&& (ip->source_x == sx) && (ip->source_x == sy)
|
||||
&& (ip->source_w == sw) && (ip->source_h == sh)
|
||||
&& (ip->colormap == cm) && (ip->antialias == aa)
|
||||
if ((ip->w == w) && (ip->h == h) && (ip->depth == x11->depth)
|
||||
&& (!ip->dirty) && (ip->visual == x11->vis)
|
||||
&& (ip->display == x11->dpy) && (ip->source_x == sx)
|
||||
&& (ip->source_x == sy) && (ip->source_w == sw)
|
||||
&& (ip->source_h == sh) && (ip->colormap == x11->cmap)
|
||||
&& (ip->antialias == aa)
|
||||
&& (ip->modification_count == modification_count)
|
||||
&& (ip->dither_mask == dmask)
|
||||
&& (ip->border.left == im->border.left)
|
||||
&& (ip->border.right == im->border.right)
|
||||
&& (ip->border.top == im->border.top)
|
||||
&& (ip->border.bottom == im->border.bottom) &&
|
||||
(((im->file) && (ip->file) && !strcmp(im->file, ip->file)) ||
|
||||
((!im->file) && (!ip->file) && (im == ip->image))))
|
||||
&& (ip->border.bottom == im->border.bottom)
|
||||
&& (((im->file) && (ip->file) && !strcmp(im->file, ip->file))
|
||||
|| ((!im->file) && (!ip->file) && (im == ip->image))))
|
||||
{
|
||||
/* move the pixmap to the head of the pixmap list */
|
||||
if (ip_prev)
|
||||
|
@ -98,18 +99,17 @@ __imlib_FindCachedImagePixmap(ImlibImage * im, int w, int h, Display * d,
|
|||
|
||||
/* add a pixmap cahce struct to the pixmap cache (at the start of course */
|
||||
static ImlibImagePixmap *
|
||||
__imlib_AddImagePixmapToCache(ImlibImage * im, Pixmap pmap, Pixmap mask,
|
||||
int w, int h,
|
||||
Display * d, Visual * v, int depth,
|
||||
__imlib_AddImagePixmapToCache(const ImlibContextX11 * x11, ImlibImage * im,
|
||||
Pixmap pmap, Pixmap mask, int w, int h,
|
||||
int sx, int sy, int sw, int sh,
|
||||
Colormap cm, char aa, char hiq, char dmask,
|
||||
char aa, char hiq, char dmask,
|
||||
uint64_t modification_count)
|
||||
{
|
||||
ImlibImagePixmap *ip;
|
||||
|
||||
ip = __imlib_ProduceImagePixmap();
|
||||
ip->visual = v;
|
||||
ip->depth = depth;
|
||||
ip->visual = x11->vis;
|
||||
ip->depth = x11->depth;
|
||||
ip->image = im;
|
||||
if (im->file)
|
||||
ip->file = strdup(im->file);
|
||||
|
@ -117,8 +117,8 @@ __imlib_AddImagePixmapToCache(ImlibImage * im, Pixmap pmap, Pixmap mask,
|
|||
ip->border.right = im->border.right;
|
||||
ip->border.top = im->border.top;
|
||||
ip->border.bottom = im->border.bottom;
|
||||
ip->colormap = cm;
|
||||
ip->display = d;
|
||||
ip->colormap = x11->cmap;
|
||||
ip->display = x11->dpy;
|
||||
ip->w = w;
|
||||
ip->h = h;
|
||||
ip->source_x = sx;
|
||||
|
@ -326,13 +326,12 @@ __imlib_PixmapCacheSize(void)
|
|||
return current_cache;
|
||||
}
|
||||
|
||||
char
|
||||
__imlib_CreatePixmapsForImage(Display * d, Drawable w, Visual * v, int depth,
|
||||
Colormap cm, ImlibImage * im, Pixmap * p,
|
||||
Mask * m, int sx, int sy, int sw, int sh, int dw,
|
||||
int dh, char antialias, char hiq,
|
||||
char dither_mask, int mat,
|
||||
ImlibColorModifier * cmod)
|
||||
int
|
||||
__imlib_CreatePixmapsForImage(const ImlibContextX11 * x11, Drawable w,
|
||||
ImlibImage * im, Pixmap * p, Mask * m,
|
||||
int sx, int sy, int sw, int sh, int dw, int dh,
|
||||
char antialias, char hiq, char dither_mask,
|
||||
int mat, ImlibColorModifier * cmod)
|
||||
{
|
||||
ImlibImagePixmap *ip = NULL;
|
||||
Pixmap pmap = 0;
|
||||
|
@ -341,9 +340,9 @@ __imlib_CreatePixmapsForImage(Display * d, Drawable w, Visual * v, int depth,
|
|||
|
||||
if (cmod)
|
||||
mod_count = cmod->modification_count;
|
||||
ip = __imlib_FindCachedImagePixmap(im, dw, dh, d, v, depth, sx, sy,
|
||||
sw, sh, cm, antialias, hiq, dither_mask,
|
||||
mod_count);
|
||||
ip =
|
||||
__imlib_FindCachedImagePixmap(x11, im, dw, dh, sx, sy, sw, sh,
|
||||
antialias, hiq, dither_mask, mod_count);
|
||||
if (ip)
|
||||
{
|
||||
if (p)
|
||||
|
@ -360,22 +359,21 @@ __imlib_CreatePixmapsForImage(Display * d, Drawable w, Visual * v, int depth,
|
|||
}
|
||||
if (p)
|
||||
{
|
||||
pmap = XCreatePixmap(d, w, dw, dh, depth);
|
||||
pmap = XCreatePixmap(x11->dpy, w, dw, dh, x11->depth);
|
||||
*p = pmap;
|
||||
}
|
||||
if (m)
|
||||
{
|
||||
if (im->has_alpha)
|
||||
mask = XCreatePixmap(d, w, dw, dh, 1);
|
||||
mask = XCreatePixmap(x11->dpy, w, dw, dh, 1);
|
||||
*m = mask;
|
||||
}
|
||||
__imlib_RenderImage(d, im, pmap, mask, v, cm, depth, sx, sy, sw, sh, 0, 0,
|
||||
__imlib_RenderImage(x11, im, pmap, mask, sx, sy, sw, sh, 0, 0,
|
||||
dw, dh, antialias, hiq, 0, dither_mask, mat, cmod,
|
||||
OP_COPY);
|
||||
ip = __imlib_AddImagePixmapToCache(im, pmap, mask,
|
||||
dw, dh, d, v, depth, sx, sy,
|
||||
sw, sh, cm, antialias, hiq, dither_mask,
|
||||
mod_count);
|
||||
ip = __imlib_AddImagePixmapToCache(x11, im, pmap, mask,
|
||||
dw, dh, sx, sy, sw, sh,
|
||||
antialias, hiq, dither_mask, mod_count);
|
||||
#ifdef DEBUG_CACHE
|
||||
fprintf(stderr,
|
||||
"[Imlib2] Created pixmap. Reference count is %d, pixmap 0x%08lx, mask 0x%08lx\n",
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#ifndef X11_PIXMAP_H
|
||||
#define X11_PIXMAP_H 1
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "x11_types.h"
|
||||
|
||||
void __imlib_CleanupImagePixmapCache(void);
|
||||
int __imlib_PixmapCacheSize(void);
|
||||
|
@ -12,11 +11,11 @@ void __imlib_FreePixmap(Display * d, Pixmap p);
|
|||
void __imlib_DirtyPixmapsForImage(const ImlibImage * im);
|
||||
void __imlib_PixmapUnrefImage(const ImlibImage * im);
|
||||
|
||||
char __imlib_CreatePixmapsForImage(Display * d, Drawable w,
|
||||
Visual * v, int depth,
|
||||
Colormap cm, ImlibImage * im,
|
||||
Pixmap * p, Mask * m, int sx,
|
||||
int sy, int sw, int sh,
|
||||
int __imlib_CreatePixmapsForImage(const ImlibContextX11 * x11,
|
||||
Drawable w, ImlibImage * im,
|
||||
Pixmap * p, Mask * m,
|
||||
int sx, int sy,
|
||||
int sw, int sh,
|
||||
int dw, int dh,
|
||||
char anitalias, char hiq,
|
||||
char dither_mask, int mat,
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
#define LINESIZE 16
|
||||
|
||||
uint32_t
|
||||
__imlib_RenderGetPixel(Display * d, Drawable w, Visual * v, Colormap cm,
|
||||
int depth, uint8_t r, uint8_t g, uint8_t b)
|
||||
__imlib_RenderGetPixel(const ImlibContextX11 * x11, Drawable w,
|
||||
uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
Context *ct;
|
||||
|
||||
ct = __imlib_GetContext(d, v, cm, depth);
|
||||
ct = __imlib_GetContext(x11);
|
||||
|
||||
if (ct->palette)
|
||||
{
|
||||
|
@ -76,9 +76,9 @@ __imlib_RenderGetPixel(Display * d, Drawable w, Visual * v, Colormap cm,
|
|||
int i, rshift = 0, gshift = 0, bshift = 0;
|
||||
uint32_t val;
|
||||
|
||||
rm = v->red_mask;
|
||||
gm = v->green_mask;
|
||||
bm = v->blue_mask;
|
||||
rm = x11->vis->red_mask;
|
||||
gm = x11->vis->green_mask;
|
||||
bm = x11->vis->blue_mask;
|
||||
if ((rm == 0xf800) && (gm == 0x7e0) && (bm == 0x1f)) /* 565 */
|
||||
{
|
||||
return (((r << 8) & 0xf800) |
|
||||
|
@ -247,13 +247,13 @@ __imlib_RenderDisconnect(Display * d)
|
|||
}
|
||||
|
||||
void
|
||||
__imlib_RenderImage(Display * d, ImlibImage * im,
|
||||
__imlib_RenderImage(const ImlibContextX11 * x11, ImlibImage * im,
|
||||
Drawable w, Drawable m,
|
||||
Visual * v, Colormap cm, int depth,
|
||||
int sx, int sy, int sw, int sh,
|
||||
int dx, int dy, int dw, int dh,
|
||||
char antialias, char hiq, char blend, char dither_mask,
|
||||
int mat, ImlibColorModifier * cmod, ImlibOp op)
|
||||
char antialias, char hiq, char blend,
|
||||
char dither_mask, int mat,
|
||||
ImlibColorModifier * cmod, ImlibOp op)
|
||||
{
|
||||
XImage *xim = NULL, *mxim = NULL;
|
||||
Context *ct;
|
||||
|
@ -313,20 +313,20 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
/* Sign not needed anymore */
|
||||
dw = abs(dw);
|
||||
dh = abs(dh);
|
||||
ct = __imlib_GetContext(d, v, cm, depth);
|
||||
ct = __imlib_GetContext(x11);
|
||||
__imlib_RGBASetupContext(ct);
|
||||
if (blend && im->has_alpha)
|
||||
{
|
||||
back = malloc(dw * dh * sizeof(uint32_t));
|
||||
if (__imlib_GrabDrawableToRGBA
|
||||
(back, 0, 0, dw, dh, d, w, 0, v, cm, depth, dx, dy, dw, dh, 0, 1))
|
||||
if (__imlib_GrabDrawableToRGBA(x11, back, 0, 0, dw, dh,
|
||||
w, 0, dx, dy, dw, dh, 0, 1))
|
||||
{
|
||||
free(back);
|
||||
back = NULL;
|
||||
}
|
||||
}
|
||||
/* get a new XImage - or get one from the cached list */
|
||||
xim = __imlib_ProduceXImage(d, v, depth, dw, dh, &shm);
|
||||
xim = __imlib_ProduceXImage(x11, x11->depth, dw, dh, &shm);
|
||||
if (!xim)
|
||||
{
|
||||
__imlib_FreeScaleInfo(scaleinfo);
|
||||
|
@ -335,10 +335,10 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
}
|
||||
if (m)
|
||||
{
|
||||
mxim = __imlib_ProduceXImage(d, v, 1, dw, dh, &shm);
|
||||
mxim = __imlib_ProduceXImage(x11, 1, dw, dh, &shm);
|
||||
if (!mxim)
|
||||
{
|
||||
__imlib_ConsumeXImage(d, xim);
|
||||
__imlib_ConsumeXImage(x11, xim);
|
||||
__imlib_FreeScaleInfo(scaleinfo);
|
||||
free(back);
|
||||
return;
|
||||
|
@ -352,9 +352,9 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
buf = malloc(dw * LINESIZE * sizeof(uint32_t));
|
||||
if (!buf)
|
||||
{
|
||||
__imlib_ConsumeXImage(d, xim);
|
||||
__imlib_ConsumeXImage(x11, xim);
|
||||
if (m)
|
||||
__imlib_ConsumeXImage(d, mxim);
|
||||
__imlib_ConsumeXImage(x11, mxim);
|
||||
__imlib_FreeScaleInfo(scaleinfo);
|
||||
free(back);
|
||||
return;
|
||||
|
@ -365,8 +365,8 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
/* scale in LINESIZE Y chunks and convert to depth */
|
||||
/* Get rgba and mask functions for XImage rendering */
|
||||
rgbaer = __imlib_GetRGBAFunction(xim->bits_per_pixel,
|
||||
v->red_mask, v->green_mask, v->blue_mask,
|
||||
hiq, ct->palette_type);
|
||||
x11->vis->red_mask, x11->vis->green_mask,
|
||||
x11->vis->blue_mask, hiq, ct->palette_type);
|
||||
if (m)
|
||||
masker = __imlib_GetMaskFunction(dither_mask);
|
||||
for (y = 0; y < dh; y += LINESIZE)
|
||||
|
@ -405,9 +405,9 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
buf = malloc(im->w * LINESIZE * sizeof(uint32_t));
|
||||
if (!buf)
|
||||
{
|
||||
__imlib_ConsumeXImage(d, xim);
|
||||
__imlib_ConsumeXImage(x11, xim);
|
||||
if (m)
|
||||
__imlib_ConsumeXImage(d, mxim);
|
||||
__imlib_ConsumeXImage(x11, mxim);
|
||||
__imlib_FreeScaleInfo(scaleinfo);
|
||||
free(back);
|
||||
return;
|
||||
|
@ -437,7 +437,8 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
((uint8_t *) xim->data) + (y * (xim->bytes_per_line)),
|
||||
xim->bytes_per_line, dw, hh, dx, dy + y);
|
||||
else
|
||||
__imlib_generic_render(pointer, jump, dw, hh, 0, y, xim, v, ct);
|
||||
__imlib_generic_render(pointer, jump, dw, hh, 0, y, xim, x11->vis,
|
||||
ct);
|
||||
if (m)
|
||||
masker(pointer, jump,
|
||||
((uint8_t *) mxim->data) + (y * (mxim->bytes_per_line)),
|
||||
|
@ -450,7 +451,7 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
__imlib_FreeScaleInfo(scaleinfo);
|
||||
free(back);
|
||||
/* if we changed diplays or depth since last time... free old gc */
|
||||
if ((gc) && ((last_depth != depth) || (disp != d)))
|
||||
if ((gc) && ((last_depth != x11->depth) || (disp != x11->dpy)))
|
||||
{
|
||||
XFreeGC(disp, gc);
|
||||
gc = 0;
|
||||
|
@ -458,15 +459,15 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
/* if we didn't have a gc... create it */
|
||||
if (!gc)
|
||||
{
|
||||
disp = d;
|
||||
last_depth = depth;
|
||||
disp = x11->dpy;
|
||||
last_depth = x11->depth;
|
||||
gcv.graphics_exposures = False;
|
||||
gc = XCreateGC(d, w, GCGraphicsExposures, &gcv);
|
||||
gc = XCreateGC(x11->dpy, w, GCGraphicsExposures, &gcv);
|
||||
}
|
||||
if (m)
|
||||
{
|
||||
/* if we changed diplays since last time... free old gc */
|
||||
if ((gcm) && (disp != d))
|
||||
if ((gcm) && (disp != x11->dpy))
|
||||
{
|
||||
XFreeGC(disp, gcm);
|
||||
gcm = 0;
|
||||
|
@ -474,40 +475,41 @@ __imlib_RenderImage(Display * d, ImlibImage * im,
|
|||
if (!gcm)
|
||||
{
|
||||
gcv.graphics_exposures = False;
|
||||
gcm = XCreateGC(d, m, GCGraphicsExposures, &gcv);
|
||||
gcm = XCreateGC(x11->dpy, m, GCGraphicsExposures, &gcv);
|
||||
}
|
||||
/* write the mask */
|
||||
if (shm)
|
||||
/* write shm XImage */
|
||||
XShmPutImage(d, m, gcm, mxim, 0, 0, dx, dy, dw, dh, False);
|
||||
XShmPutImage(x11->dpy, m, gcm, mxim, 0, 0, dx, dy, dw, dh, False);
|
||||
/* write regular XImage */
|
||||
else
|
||||
XPutImage(d, m, gcm, mxim, 0, 0, dx, dy, dw, dh);
|
||||
XPutImage(x11->dpy, m, gcm, mxim, 0, 0, dx, dy, dw, dh);
|
||||
}
|
||||
/* write the image */
|
||||
if (shm)
|
||||
/* write shm XImage */
|
||||
XShmPutImage(d, w, gc, xim, 0, 0, dx, dy, dw, dh, False);
|
||||
XShmPutImage(x11->dpy, w, gc, xim, 0, 0, dx, dy, dw, dh, False);
|
||||
/* write regular XImage */
|
||||
else
|
||||
XPutImage(d, w, gc, xim, 0, 0, dx, dy, dw, dh);
|
||||
XPutImage(x11->dpy, w, gc, xim, 0, 0, dx, dy, dw, dh);
|
||||
/* free the XImage and put onto our free list */
|
||||
/* wait for the write to be done */
|
||||
if (shm)
|
||||
XSync(d, False);
|
||||
__imlib_ConsumeXImage(d, xim);
|
||||
XSync(x11->dpy, False);
|
||||
__imlib_ConsumeXImage(x11, xim);
|
||||
if (m)
|
||||
__imlib_ConsumeXImage(d, mxim);
|
||||
__imlib_ConsumeXImage(x11, mxim);
|
||||
}
|
||||
|
||||
void
|
||||
__imlib_RenderImageSkewed(Display * d, ImlibImage * im, Drawable w, Drawable m,
|
||||
Visual * v, Colormap cm, int depth,
|
||||
int sx, int sy, int sw, int sh, int dx, int dy,
|
||||
__imlib_RenderImageSkewed(const ImlibContextX11 * x11, ImlibImage * im,
|
||||
Drawable w, Drawable m,
|
||||
int sx, int sy, int sw,
|
||||
int sh, int dx, int dy,
|
||||
int hsx, int hsy, int vsx, int vsy,
|
||||
char antialias, char hiq, char blend,
|
||||
char dither_mask, int mat, ImlibColorModifier * cmod,
|
||||
ImlibOp op)
|
||||
char antialias, char hiq,
|
||||
char blend, char dither_mask,
|
||||
int mat, ImlibColorModifier * cmod, ImlibOp op)
|
||||
{
|
||||
int dx1, dy1, dx2, dy2, dw, dh, tsx, tsy;
|
||||
ImlibImage *back;
|
||||
|
@ -563,16 +565,16 @@ __imlib_RenderImageSkewed(Display * d, ImlibImage * im, Drawable w, Drawable m,
|
|||
if (!back)
|
||||
return;
|
||||
|
||||
__imlib_GetContext(d, v, cm, depth);
|
||||
__imlib_GetContext(x11);
|
||||
|
||||
__imlib_GrabDrawableToRGBA(back->data, 0, 0, dw, dh, d, w, 0, v, cm,
|
||||
depth, dx1, dy1, dw, dh, 0, 1);
|
||||
__imlib_GrabDrawableToRGBA(x11, back->data, 0, 0, dw, dh,
|
||||
w, 0, dx1, dy1, dw, dh, 0, 1);
|
||||
|
||||
__imlib_BlendImageToImageSkewed(im, back, antialias, 1, 0, sx, sy, sw, sh,
|
||||
dx - dx1, dy - dy1, hsx, hsy, vsx, vsy,
|
||||
cmod, op, 0, 0, 0, 0);
|
||||
|
||||
__imlib_RenderImage(d, back, w, m, v, cm, depth, 0, 0, dw, dh,
|
||||
__imlib_RenderImage(x11, back, w, m, 0, 0, dw, dh,
|
||||
dx1, dy1, dw, dh, 0, hiq, 0, dither_mask, mat, 0,
|
||||
OP_COPY);
|
||||
|
||||
|
|
|
@ -2,28 +2,29 @@
|
|||
#define X11_REND_H 1
|
||||
|
||||
#include "types.h"
|
||||
#include "x11_types.h"
|
||||
|
||||
uint32_t __imlib_RenderGetPixel(Display * d, Drawable w, Visual * v,
|
||||
Colormap cm, int depth, uint8_t r,
|
||||
uint8_t g, uint8_t b);
|
||||
uint32_t __imlib_RenderGetPixel(const ImlibContextX11 * x11,
|
||||
Drawable w, uint8_t r, uint8_t g,
|
||||
uint8_t b);
|
||||
|
||||
void __imlib_RenderDisconnect(Display * d);
|
||||
|
||||
void __imlib_RenderImage(Display * d, ImlibImage * im,
|
||||
Drawable w, Drawable m,
|
||||
Visual * v, Colormap cm, int depth,
|
||||
int sx, int sy, int sw, int sh,
|
||||
int dx, int dy, int dw, int dh,
|
||||
char anitalias, char hiq, char blend,
|
||||
char dither_mask, int mat,
|
||||
ImlibColorModifier * cmod, ImlibOp op);
|
||||
void __imlib_RenderImage(const ImlibContextX11 * ctx,
|
||||
ImlibImage * im, Drawable w, Drawable m,
|
||||
int sx, int sy, int sw, int sh, int dx,
|
||||
int dy, int dw, int dh, char antialias,
|
||||
char hiq, char blend, char dither_mask,
|
||||
int mat, ImlibColorModifier * cmod,
|
||||
ImlibOp op);
|
||||
|
||||
void __imlib_RenderImageSkewed(Display * d, ImlibImage * im,
|
||||
void __imlib_RenderImageSkewed(const ImlibContextX11 * x11,
|
||||
ImlibImage * im,
|
||||
Drawable w, Drawable m,
|
||||
Visual * v, Colormap cm,
|
||||
int depth, int sx, int sy, int sw,
|
||||
int sh, int dx, int dy, int hsx,
|
||||
int hsy, int vsx, int vsy,
|
||||
int sx, int sy, int sw, int sh,
|
||||
int dx, int dy,
|
||||
int hsx, int hsy,
|
||||
int vsx, int vsy,
|
||||
char antialias, char hiq,
|
||||
char blend, char dither_mask,
|
||||
int mat,
|
||||
|
|
|
@ -2412,13 +2412,13 @@ __imlib_RGBASetupContext(Context * ct)
|
|||
{
|
||||
_dither_color_lut = ct->palette;
|
||||
|
||||
if ((ct->depth == 16) || (ct->depth == 15))
|
||||
if ((ct->x11.depth == 16) || (ct->x11.depth == 15))
|
||||
{
|
||||
_dither_r16 = (uint16_t *) ct->r_dither;
|
||||
_dither_g16 = (uint16_t *) ct->g_dither;
|
||||
_dither_b16 = (uint16_t *) ct->b_dither;
|
||||
}
|
||||
else if (ct->depth <= 8)
|
||||
else if (ct->x11.depth <= 8)
|
||||
{
|
||||
switch (ct->palette_type)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef X11_TYPES_H
|
||||
#define X11_TYPES_H 1
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
typedef struct {
|
||||
Display *dpy;
|
||||
Visual *vis;
|
||||
Colormap cmap;
|
||||
int depth;
|
||||
} ImlibContextX11;
|
||||
|
||||
#endif /* X11_TYPES_H */
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include "x11_ximage.h"
|
||||
|
||||
static void __imlib_FlushXImage(const ImlibContextX11 * x11);
|
||||
|
||||
static signed char x_does_shm = -1;
|
||||
|
||||
#ifdef HAVE_X11_SHM_FD
|
||||
|
@ -107,19 +109,19 @@ ShmCheck(Display * d)
|
|||
}
|
||||
|
||||
XImage *
|
||||
__imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth,
|
||||
__imlib_ShmGetXImage(const ImlibContextX11 * x11, Drawable draw, int depth,
|
||||
int x, int y, int w, int h, XShmSegmentInfo * si)
|
||||
{
|
||||
XImage *xim;
|
||||
|
||||
if (x_does_shm < 0)
|
||||
ShmCheck(d);
|
||||
ShmCheck(x11->dpy);
|
||||
|
||||
if (!x_does_shm)
|
||||
return NULL;
|
||||
|
||||
/* try create an shm image */
|
||||
xim = XShmCreateImage(d, v, depth, ZPixmap, NULL, si, w, h);
|
||||
xim = XShmCreateImage(x11->dpy, x11->vis, depth, ZPixmap, NULL, si, w, h);
|
||||
if (!xim)
|
||||
return NULL;
|
||||
|
||||
|
@ -129,7 +131,7 @@ __imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth,
|
|||
xcb_generic_error_t *error = NULL;
|
||||
xcb_shm_create_segment_cookie_t cookie;
|
||||
xcb_shm_create_segment_reply_t *reply;
|
||||
xcb_connection_t *c = XGetXCBConnection(d);
|
||||
xcb_connection_t *c = XGetXCBConnection(x11->dpy);
|
||||
size_t segment_size = xim->bytes_per_line * xim->height;
|
||||
|
||||
si->shmaddr = NULL;
|
||||
|
@ -165,7 +167,7 @@ __imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth,
|
|||
{
|
||||
xim->data = si->shmaddr;
|
||||
if (draw != None)
|
||||
XShmGetImage(d, draw, xim, x, y, 0xffffffff);
|
||||
XShmGetImage(x11->dpy, draw, xim, x, y, 0xffffffff);
|
||||
|
||||
return xim;
|
||||
}
|
||||
|
@ -195,17 +197,17 @@ __imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth,
|
|||
{
|
||||
/* setup a temporary error handler */
|
||||
_x_err = 0;
|
||||
XSync(d, False);
|
||||
XSync(x11->dpy, False);
|
||||
ph = XSetErrorHandler(TmpXError);
|
||||
}
|
||||
/* ask X to attach to the shared mem segment */
|
||||
XShmAttach(d, si);
|
||||
XShmAttach(x11->dpy, si);
|
||||
if (draw != None)
|
||||
XShmGetImage(d, draw, xim, x, y, 0xffffffff);
|
||||
XShmGetImage(x11->dpy, draw, xim, x, y, 0xffffffff);
|
||||
if (x_does_shm == 2)
|
||||
{
|
||||
/* wait for X to reply and do this */
|
||||
XSync(d, False);
|
||||
XSync(x11->dpy, False);
|
||||
/* reset the error handler */
|
||||
XSetErrorHandler(ph);
|
||||
x_does_shm = 1;
|
||||
|
@ -237,10 +239,11 @@ __imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth,
|
|||
}
|
||||
|
||||
void
|
||||
__imlib_ShmDestroyXImage(Display * d, XImage * xim, XShmSegmentInfo * si)
|
||||
__imlib_ShmDestroyXImage(const ImlibContextX11 * x11, XImage * xim,
|
||||
XShmSegmentInfo * si)
|
||||
{
|
||||
XSync(d, False);
|
||||
XShmDetach(d, si);
|
||||
XSync(x11->dpy, False);
|
||||
XShmDetach(x11->dpy, si);
|
||||
#ifdef HAVE_X11_SHM_FD
|
||||
if (x_does_shm_fd)
|
||||
{
|
||||
|
@ -256,45 +259,45 @@ __imlib_ShmDestroyXImage(Display * d, XImage * xim, XShmSegmentInfo * si)
|
|||
}
|
||||
|
||||
void
|
||||
__imlib_SetXImageCacheCountMax(Display * d, int num)
|
||||
__imlib_SetXImageCacheCountMax(const ImlibContextX11 * x11, int num)
|
||||
{
|
||||
list_max_count = num;
|
||||
__imlib_FlushXImage(d);
|
||||
__imlib_FlushXImage(x11);
|
||||
}
|
||||
|
||||
int
|
||||
__imlib_GetXImageCacheCountMax(Display * d)
|
||||
__imlib_GetXImageCacheCountMax(const ImlibContextX11 * x11)
|
||||
{
|
||||
return list_max_count;
|
||||
}
|
||||
|
||||
int
|
||||
__imlib_GetXImageCacheCountUsed(Display * d)
|
||||
__imlib_GetXImageCacheCountUsed(const ImlibContextX11 * x11)
|
||||
{
|
||||
return list_num;
|
||||
}
|
||||
|
||||
void
|
||||
__imlib_SetXImageCacheSizeMax(Display * d, int num)
|
||||
__imlib_SetXImageCacheSizeMax(const ImlibContextX11 * x11, int num)
|
||||
{
|
||||
list_max_mem = num;
|
||||
__imlib_FlushXImage(d);
|
||||
__imlib_FlushXImage(x11);
|
||||
}
|
||||
|
||||
int
|
||||
__imlib_GetXImageCacheSizeMax(Display * d)
|
||||
__imlib_GetXImageCacheSizeMax(const ImlibContextX11 * x11)
|
||||
{
|
||||
return list_max_mem;
|
||||
}
|
||||
|
||||
int
|
||||
__imlib_GetXImageCacheSizeUsed(Display * d)
|
||||
__imlib_GetXImageCacheSizeUsed(const ImlibContextX11 * x11)
|
||||
{
|
||||
return list_mem_use;
|
||||
}
|
||||
|
||||
void
|
||||
__imlib_FlushXImage(Display * d)
|
||||
__imlib_FlushXImage(const ImlibContextX11 * x11)
|
||||
{
|
||||
int i, j;
|
||||
XImage *xim;
|
||||
|
@ -317,7 +320,7 @@ __imlib_FlushXImage(Display * d)
|
|||
|
||||
if (xim_cache[i].si)
|
||||
{
|
||||
__imlib_ShmDestroyXImage(d, xim, xim_cache[i].si);
|
||||
__imlib_ShmDestroyXImage(x11, xim, xim_cache[i].si);
|
||||
free(xim_cache[i].si);
|
||||
}
|
||||
else
|
||||
|
@ -349,7 +352,7 @@ __imlib_FlushXImage(Display * d)
|
|||
|
||||
/* free (consume == opposite of produce) the XImage (mark as unused) */
|
||||
void
|
||||
__imlib_ConsumeXImage(Display * d, XImage * xim)
|
||||
__imlib_ConsumeXImage(const ImlibContextX11 * x11, XImage * xim)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -362,7 +365,7 @@ __imlib_ConsumeXImage(Display * d, XImage * xim)
|
|||
/* we have a match = mark as unused */
|
||||
xim_cache[i].used = 0;
|
||||
/* flush the XImage list to get rud of stuff we dont want */
|
||||
__imlib_FlushXImage(d);
|
||||
__imlib_FlushXImage(x11);
|
||||
/* return */
|
||||
return;
|
||||
}
|
||||
|
@ -372,7 +375,7 @@ __imlib_ConsumeXImage(Display * d, XImage * xim)
|
|||
/* create a new XImage or find it on our list of currently available ones so */
|
||||
/* we dont need to create a new one */
|
||||
XImage *
|
||||
__imlib_ProduceXImage(Display * d, Visual * v, int depth, int w, int h,
|
||||
__imlib_ProduceXImage(const ImlibContextX11 * x11, int depth, int w, int h,
|
||||
char *shared)
|
||||
{
|
||||
XImage *xim;
|
||||
|
@ -423,7 +426,7 @@ __imlib_ProduceXImage(Display * d, Visual * v, int depth, int w, int h,
|
|||
}
|
||||
|
||||
/* work on making a shared image */
|
||||
xim = __imlib_ShmGetXImage(d, v, None, depth, 0, 0, w, h,
|
||||
xim = __imlib_ShmGetXImage(x11, None, depth, 0, 0, w, h,
|
||||
xim_cache[list_num - 1].si);
|
||||
/* ok if xim == NULL it all failed - fall back to XImages */
|
||||
if (xim)
|
||||
|
@ -437,7 +440,9 @@ __imlib_ProduceXImage(Display * d, Visual * v, int depth, int w, int h,
|
|||
/* flag it as NULL ot indicate a normal XImage */
|
||||
xim_cache[list_num - 1].si = NULL;
|
||||
/* create a normal ximage */
|
||||
xim = XCreateImage(d, v, depth, ZPixmap, 0, NULL, w, h, 32, 0);
|
||||
xim =
|
||||
XCreateImage(x11->dpy, x11->vis, depth, ZPixmap, 0, NULL, w, h, 32,
|
||||
0);
|
||||
/* allocate data for it */
|
||||
if (xim)
|
||||
xim->data = malloc(xim->bytes_per_line * xim->height);
|
||||
|
@ -457,10 +462,10 @@ __imlib_ProduceXImage(Display * d, Visual * v, int depth, int w, int h,
|
|||
/* mark image as used */
|
||||
xim_cache[list_num - 1].used = 1;
|
||||
/* remember what display that XImage was for */
|
||||
xim_cache[list_num - 1].dpy = d;
|
||||
xim_cache[list_num - 1].dpy = x11->dpy;
|
||||
|
||||
/* flush unused images from the image list */
|
||||
__imlib_FlushXImage(d);
|
||||
__imlib_FlushXImage(x11);
|
||||
|
||||
/* set the byte order of the XImage to the byte_order of the Xclient */
|
||||
/* (rather than the Xserver) */
|
||||
|
|
|
@ -4,20 +4,28 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
|
||||
void __imlib_SetXImageCacheCountMax(Display * d, int num);
|
||||
int __imlib_GetXImageCacheCountMax(Display * d);
|
||||
int __imlib_GetXImageCacheCountUsed(Display * d);
|
||||
void __imlib_SetXImageCacheSizeMax(Display * d, int num);
|
||||
int __imlib_GetXImageCacheSizeMax(Display * d);
|
||||
int __imlib_GetXImageCacheSizeUsed(Display * d);
|
||||
void __imlib_FlushXImage(Display * d);
|
||||
void __imlib_ConsumeXImage(Display * d, XImage * xim);
|
||||
XImage *__imlib_ProduceXImage(Display * d, Visual * v, int depth,
|
||||
int w, int h, char *shared);
|
||||
XImage *__imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw,
|
||||
int depth, int x, int y, int w, int h,
|
||||
#include "x11_types.h"
|
||||
|
||||
void __imlib_SetXImageCacheCountMax(const ImlibContextX11 * x11,
|
||||
int num);
|
||||
int __imlib_GetXImageCacheCountMax(const ImlibContextX11 * x11);
|
||||
int __imlib_GetXImageCacheCountUsed(const ImlibContextX11 *
|
||||
x11);
|
||||
void __imlib_SetXImageCacheSizeMax(const ImlibContextX11 * x11,
|
||||
int num);
|
||||
int __imlib_GetXImageCacheSizeMax(const ImlibContextX11 * x11);
|
||||
int __imlib_GetXImageCacheSizeUsed(const ImlibContextX11 * x11);
|
||||
void __imlib_ConsumeXImage(const ImlibContextX11 * x11,
|
||||
XImage * xim);
|
||||
XImage *__imlib_ProduceXImage(const ImlibContextX11 * x11,
|
||||
int depth, int w, int h,
|
||||
char *shared);
|
||||
XImage *__imlib_ShmGetXImage(const ImlibContextX11 * x11,
|
||||
Drawable draw, int depth,
|
||||
int x, int y, int w, int h,
|
||||
XShmSegmentInfo * si);
|
||||
void __imlib_ShmDestroyXImage(Display * d, XImage * xim,
|
||||
void __imlib_ShmDestroyXImage(const ImlibContextX11 * x11,
|
||||
XImage * xim,
|
||||
XShmSegmentInfo * si);
|
||||
|
||||
#endif /* X11_XIMAGE_H */
|
||||
|
|
Loading…
Reference in New Issue