summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-03-26 15:54:40 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-03-26 15:54:40 +0900
commit5cdbcceccbb539065ffa7fc2d8b42ff3fdac3e09 (patch)
tree00e0ee2925aa25059f4678d8381e14b90232b712 /src
parent0a6d2e6b292b12f721002aa391f09ccbb18e29aa (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_image.c93
1 files changed, 72 insertions, 21 deletions
diff --git a/src/lib/ecore_x/xlib/ecore_x_image.c b/src/lib/ecore_x/xlib/ecore_x_image.c
index d72f38d..a496dcf 100644
--- a/src/lib/ecore_x/xlib/ecore_x_image.c
+++ b/src/lib/ecore_x/xlib/ecore_x_image.c
@@ -96,6 +96,12 @@ _ecore_x_image_shm_check(void)
96 if (_ecore_x_image_shm_can != -1) 96 if (_ecore_x_image_shm_can != -1)
97 return; 97 return;
98 98
99 if (!XShmQueryExtension(_ecore_x_disp))
100 {
101 _ecore_x_image_shm_can = 0;
102 return;
103 }
104
99 XSync(_ecore_x_disp, False); 105 XSync(_ecore_x_disp, False);
100 _ecore_x_image_err = 0; 106 _ecore_x_image_err = 0;
101 107
@@ -217,6 +223,18 @@ ecore_x_image_free(Ecore_X_Image *im)
217} 223}
218 224
219static void 225static void
226_ecore_x_image_finalize(Ecore_X_Image *im)
227{
228 im->data = (unsigned char *)im->xim->data;
229 im->bpl = im->xim->bytes_per_line;
230 im->rows = im->xim->height;
231 if (im->xim->bits_per_pixel <= 8) im->bpp = 1;
232 else if (im->xim->bits_per_pixel <= 16) im->bpp = 2;
233 else if (im->xim->bits_per_pixel <= 24) im->bpp = 3;
234 else im->bpp = 4;
235}
236
237static void
220_ecore_x_image_shm_create(Ecore_X_Image *im) 238_ecore_x_image_shm_create(Ecore_X_Image *im)
221{ 239{
222 im->xim = XShmCreateImage(_ecore_x_disp, im->vis, im->depth, 240 im->xim = XShmCreateImage(_ecore_x_disp, im->vis, im->depth,
@@ -249,19 +267,23 @@ _ecore_x_image_shm_create(Ecore_X_Image *im)
249 } 267 }
250 268
251 XShmAttach(_ecore_x_disp, &im->shminfo); 269 XShmAttach(_ecore_x_disp, &im->shminfo);
270 _ecore_x_image_finalize(im);
271}
252 272
253 im->data = (unsigned char *)im->xim->data; 273static void
254 274_ecore_x_image_create(Ecore_X_Image *im)
255 im->bpl = im->xim->bytes_per_line; 275{
256 im->rows = im->xim->height; 276 im->xim = XCreateImage(_ecore_x_disp, im->vis, im->depth,
257 if (im->xim->bits_per_pixel <= 8) 277 ZPixmap, 0, NULL, im->w, im->h, 32, 0);
258 im->bpp = 1; 278 if (!im->xim) return;
259 else if (im->xim->bits_per_pixel <= 16) 279 im->xim->data = malloc(im->xim->bytes_per_line * im->h);
260 im->bpp = 2; 280 if (!im->xim->data)
261 else if (im->xim->bits_per_pixel <= 24) 281 {
262 im->bpp = 3; 282 XDestroyImage(im->xim);
263 else 283 im->xim = NULL;
264 im->bpp = 4; 284 return;
285 }
286 _ecore_x_image_finalize(im);
265} 287}
266 288
267EAPI Eina_Bool 289EAPI Eina_Bool
@@ -280,11 +302,16 @@ ecore_x_image_get(Ecore_X_Image *im,
280 LOGFN(__FILE__, __LINE__, __FUNCTION__); 302 LOGFN(__FILE__, __LINE__, __FUNCTION__);
281 if (im->shm) 303 if (im->shm)
282 { 304 {
305
283 if (!im->xim) 306 if (!im->xim)
284 _ecore_x_image_shm_create(im); 307 _ecore_x_image_shm_create(im);
285 308
286 if (!im->xim) 309 if (!im->xim)
287 return 0; 310 {
311 fprintf(stderr, "BLAAAAAAAAAAAAH\n");
312 abort();
313 return EINA_FALSE;
314 }
288 315
289 _ecore_x_image_err = 0; 316 _ecore_x_image_err = 0;
290 317
@@ -345,8 +372,15 @@ ecore_x_image_get(Ecore_X_Image *im,
345 } 372 }
346 else 373 else
347 { 374 {
348 printf("currently unimplemented ecore_x_image_get without shm\n"); 375 if (!im->xim)
349 ret = EINA_FALSE; 376 _ecore_x_image_create(im);
377
378 if (!im->xim)
379 return EINA_FALSE;
380
381 if (XGetSubImage(_ecore_x_disp, draw, sx, sy, w, h,
382 0xffffffff, ZPixmap, im->xim, x, y) != im->xim)
383 ret = EINA_FALSE;
350 } 384 }
351 385
352 return ret; 386 return ret;
@@ -375,10 +409,19 @@ ecore_x_image_put(Ecore_X_Image *im,
375 if (_ecore_xlib_sync) ecore_x_sync(); 409 if (_ecore_xlib_sync) ecore_x_sync();
376 gc = tgc; 410 gc = tgc;
377 } 411 }
378 if (!im->xim) _ecore_x_image_shm_create(im); 412 if (!im->xim)
413 {
414 if (im->shm) _ecore_x_image_shm_create(im);
415 else _ecore_x_image_create(im);
416 }
379 if (im->xim) 417 if (im->xim)
380 { 418 {
381 XShmPutImage(_ecore_x_disp, draw, gc, im->xim, sx, sy, x, y, w, h, False); 419 if (im->shm)
420 XShmPutImage(_ecore_x_disp, draw, gc, im->xim,
421 sx, sy, x, y, w, h, False);
422 else
423 XPutImage(_ecore_x_disp, draw, gc, im->xim,
424 sx, sy, x, y, w, h);
382 if (_ecore_xlib_sync) ecore_x_sync(); 425 if (_ecore_xlib_sync) ecore_x_sync();
383 } 426 }
384 if (tgc) ecore_x_gc_free(tgc); 427 if (tgc) ecore_x_gc_free(tgc);
@@ -391,8 +434,12 @@ ecore_x_image_data_get(Ecore_X_Image *im,
391 int *bpp) 434 int *bpp)
392{ 435{
393 LOGFN(__FILE__, __LINE__, __FUNCTION__); 436 LOGFN(__FILE__, __LINE__, __FUNCTION__);
394 if (!im->xim) _ecore_x_image_shm_create(im); 437 if (!im->xim)
395 if (!im->xim) return NULL; 438 {
439 if (im->shm) _ecore_x_image_shm_create(im);
440 else _ecore_x_image_create(im);
441 if (!im->xim) return NULL;
442 }
396 if (bpl) *bpl = im->bpl; 443 if (bpl) *bpl = im->bpl;
397 if (rows) *rows = im->rows; 444 if (rows) *rows = im->rows;
398 if (bpp) *bpp = im->bpp; 445 if (bpp) *bpp = im->bpp;
@@ -403,7 +450,12 @@ EAPI Eina_Bool
403ecore_x_image_is_argb32_get(Ecore_X_Image *im) 450ecore_x_image_is_argb32_get(Ecore_X_Image *im)
404{ 451{
405 Visual *vis = im->vis; 452 Visual *vis = im->vis;
406 if (!im->xim) _ecore_x_image_shm_create(im); 453 if (!im->xim)
454 {
455 if (im->shm) _ecore_x_image_shm_create(im);
456 else _ecore_x_image_create(im);
457 if (!im->xim) return EINA_FALSE;
458 }
407 if (((vis->class == TrueColor) || 459 if (((vis->class == TrueColor) ||
408 (vis->class == DirectColor)) && 460 (vis->class == DirectColor)) &&
409 (im->bpp == 4) && 461 (im->bpp == 4) &&
@@ -711,4 +763,3 @@ ecore_x_image_to_argb_convert(void *src,
711 } 763 }
712 return EINA_TRUE; 764 return EINA_TRUE;
713} 765}
714