forked from enlightenment/efl
fixes enlightenment working over non-shm paths.
this technically adds a feature - it adds non-mitshm support for ecore_x image grabbing, but that fixes a bug. it doesn't touch xcb support though. this fixes T1127 andshould probably be backported.
This commit is contained in:
parent
0a6d2e6b29
commit
5cdbcceccb
|
@ -96,6 +96,12 @@ _ecore_x_image_shm_check(void)
|
||||||
if (_ecore_x_image_shm_can != -1)
|
if (_ecore_x_image_shm_can != -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!XShmQueryExtension(_ecore_x_disp))
|
||||||
|
{
|
||||||
|
_ecore_x_image_shm_can = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
XSync(_ecore_x_disp, False);
|
XSync(_ecore_x_disp, False);
|
||||||
_ecore_x_image_err = 0;
|
_ecore_x_image_err = 0;
|
||||||
|
|
||||||
|
@ -216,6 +222,18 @@ ecore_x_image_free(Ecore_X_Image *im)
|
||||||
free(im);
|
free(im);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ecore_x_image_finalize(Ecore_X_Image *im)
|
||||||
|
{
|
||||||
|
im->data = (unsigned char *)im->xim->data;
|
||||||
|
im->bpl = im->xim->bytes_per_line;
|
||||||
|
im->rows = im->xim->height;
|
||||||
|
if (im->xim->bits_per_pixel <= 8) im->bpp = 1;
|
||||||
|
else if (im->xim->bits_per_pixel <= 16) im->bpp = 2;
|
||||||
|
else if (im->xim->bits_per_pixel <= 24) im->bpp = 3;
|
||||||
|
else im->bpp = 4;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ecore_x_image_shm_create(Ecore_X_Image *im)
|
_ecore_x_image_shm_create(Ecore_X_Image *im)
|
||||||
{
|
{
|
||||||
|
@ -249,19 +267,23 @@ _ecore_x_image_shm_create(Ecore_X_Image *im)
|
||||||
}
|
}
|
||||||
|
|
||||||
XShmAttach(_ecore_x_disp, &im->shminfo);
|
XShmAttach(_ecore_x_disp, &im->shminfo);
|
||||||
|
_ecore_x_image_finalize(im);
|
||||||
|
}
|
||||||
|
|
||||||
im->data = (unsigned char *)im->xim->data;
|
static void
|
||||||
|
_ecore_x_image_create(Ecore_X_Image *im)
|
||||||
im->bpl = im->xim->bytes_per_line;
|
{
|
||||||
im->rows = im->xim->height;
|
im->xim = XCreateImage(_ecore_x_disp, im->vis, im->depth,
|
||||||
if (im->xim->bits_per_pixel <= 8)
|
ZPixmap, 0, NULL, im->w, im->h, 32, 0);
|
||||||
im->bpp = 1;
|
if (!im->xim) return;
|
||||||
else if (im->xim->bits_per_pixel <= 16)
|
im->xim->data = malloc(im->xim->bytes_per_line * im->h);
|
||||||
im->bpp = 2;
|
if (!im->xim->data)
|
||||||
else if (im->xim->bits_per_pixel <= 24)
|
{
|
||||||
im->bpp = 3;
|
XDestroyImage(im->xim);
|
||||||
else
|
im->xim = NULL;
|
||||||
im->bpp = 4;
|
return;
|
||||||
|
}
|
||||||
|
_ecore_x_image_finalize(im);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
|
@ -280,11 +302,16 @@ ecore_x_image_get(Ecore_X_Image *im,
|
||||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||||
if (im->shm)
|
if (im->shm)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!im->xim)
|
if (!im->xim)
|
||||||
_ecore_x_image_shm_create(im);
|
_ecore_x_image_shm_create(im);
|
||||||
|
|
||||||
if (!im->xim)
|
if (!im->xim)
|
||||||
return 0;
|
{
|
||||||
|
fprintf(stderr, "BLAAAAAAAAAAAAH\n");
|
||||||
|
abort();
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
_ecore_x_image_err = 0;
|
_ecore_x_image_err = 0;
|
||||||
|
|
||||||
|
@ -345,8 +372,15 @@ ecore_x_image_get(Ecore_X_Image *im,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("currently unimplemented ecore_x_image_get without shm\n");
|
if (!im->xim)
|
||||||
ret = EINA_FALSE;
|
_ecore_x_image_create(im);
|
||||||
|
|
||||||
|
if (!im->xim)
|
||||||
|
return EINA_FALSE;
|
||||||
|
|
||||||
|
if (XGetSubImage(_ecore_x_disp, draw, sx, sy, w, h,
|
||||||
|
0xffffffff, ZPixmap, im->xim, x, y) != im->xim)
|
||||||
|
ret = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -375,10 +409,19 @@ ecore_x_image_put(Ecore_X_Image *im,
|
||||||
if (_ecore_xlib_sync) ecore_x_sync();
|
if (_ecore_xlib_sync) ecore_x_sync();
|
||||||
gc = tgc;
|
gc = tgc;
|
||||||
}
|
}
|
||||||
if (!im->xim) _ecore_x_image_shm_create(im);
|
if (!im->xim)
|
||||||
|
{
|
||||||
|
if (im->shm) _ecore_x_image_shm_create(im);
|
||||||
|
else _ecore_x_image_create(im);
|
||||||
|
}
|
||||||
if (im->xim)
|
if (im->xim)
|
||||||
{
|
{
|
||||||
XShmPutImage(_ecore_x_disp, draw, gc, im->xim, sx, sy, x, y, w, h, False);
|
if (im->shm)
|
||||||
|
XShmPutImage(_ecore_x_disp, draw, gc, im->xim,
|
||||||
|
sx, sy, x, y, w, h, False);
|
||||||
|
else
|
||||||
|
XPutImage(_ecore_x_disp, draw, gc, im->xim,
|
||||||
|
sx, sy, x, y, w, h);
|
||||||
if (_ecore_xlib_sync) ecore_x_sync();
|
if (_ecore_xlib_sync) ecore_x_sync();
|
||||||
}
|
}
|
||||||
if (tgc) ecore_x_gc_free(tgc);
|
if (tgc) ecore_x_gc_free(tgc);
|
||||||
|
@ -391,8 +434,12 @@ ecore_x_image_data_get(Ecore_X_Image *im,
|
||||||
int *bpp)
|
int *bpp)
|
||||||
{
|
{
|
||||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||||
if (!im->xim) _ecore_x_image_shm_create(im);
|
if (!im->xim)
|
||||||
if (!im->xim) return NULL;
|
{
|
||||||
|
if (im->shm) _ecore_x_image_shm_create(im);
|
||||||
|
else _ecore_x_image_create(im);
|
||||||
|
if (!im->xim) return NULL;
|
||||||
|
}
|
||||||
if (bpl) *bpl = im->bpl;
|
if (bpl) *bpl = im->bpl;
|
||||||
if (rows) *rows = im->rows;
|
if (rows) *rows = im->rows;
|
||||||
if (bpp) *bpp = im->bpp;
|
if (bpp) *bpp = im->bpp;
|
||||||
|
@ -403,7 +450,12 @@ EAPI Eina_Bool
|
||||||
ecore_x_image_is_argb32_get(Ecore_X_Image *im)
|
ecore_x_image_is_argb32_get(Ecore_X_Image *im)
|
||||||
{
|
{
|
||||||
Visual *vis = im->vis;
|
Visual *vis = im->vis;
|
||||||
if (!im->xim) _ecore_x_image_shm_create(im);
|
if (!im->xim)
|
||||||
|
{
|
||||||
|
if (im->shm) _ecore_x_image_shm_create(im);
|
||||||
|
else _ecore_x_image_create(im);
|
||||||
|
if (!im->xim) return EINA_FALSE;
|
||||||
|
}
|
||||||
if (((vis->class == TrueColor) ||
|
if (((vis->class == TrueColor) ||
|
||||||
(vis->class == DirectColor)) &&
|
(vis->class == DirectColor)) &&
|
||||||
(im->bpp == 4) &&
|
(im->bpp == 4) &&
|
||||||
|
@ -711,4 +763,3 @@ ecore_x_image_to_argb_convert(void *src,
|
||||||
}
|
}
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue