aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c')
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c100
1 files changed, 51 insertions, 49 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c
index 2de5319..b8e720c 100644
--- a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c
@@ -1,26 +1,28 @@
1#ifdef HAVE_CONFIG_H 1#ifdef HAVE_CONFIG_H
2# include <config.h> 2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */ 3#endif
4
5#include <stdlib.h>
6#include <string.h>
7#include <sys/ipc.h>
8#include <sys/shm.h>
4 9
5#include "ecore_x_private.h" 10#include "ecore_x_private.h"
6#include "Ecore_X.h" 11#include "Ecore_X.h"
7 12
8#include <X11/extensions/XShm.h> 13#include <X11/extensions/XShm.h>
9#include <X11/Xutil.h> 14#include <X11/Xutil.h>
10#include <sys/ipc.h>
11#include <sys/shm.h>
12#include <string.h>
13 15
14static int _ecore_x_image_shm_can = -1; 16static int _ecore_x_image_shm_can = -1;
15static int _ecore_x_image_err = 0; 17static int _ecore_x_image_err = 0;
16 18
17static int 19static int
18_ecore_x_image_error_handler(Display *d __UNUSED__, 20_ecore_x_image_error_handler(Display *d __UNUSED__,
19 XErrorEvent *ev __UNUSED__) 21 XErrorEvent *ev __UNUSED__)
20{ 22{
21 _ecore_x_image_err = 1; 23 _ecore_x_image_err = 1;
22 return 0; 24 return 0;
23} /* _ecore_x_image_error_handler */ 25}
24 26
25static void 27static void
26_ecore_x_image_shm_check(void) 28_ecore_x_image_shm_check(void)
@@ -90,7 +92,7 @@ _ecore_x_image_shm_check(void)
90 shmctl(shminfo.shmid, IPC_RMID, 0); 92 shmctl(shminfo.shmid, IPC_RMID, 0);
91 93
92 _ecore_x_image_shm_can = 1; 94 _ecore_x_image_shm_can = 1;
93} /* _ecore_x_image_shm_check */ 95}
94 96
95struct _Ecore_X_Image 97struct _Ecore_X_Image
96{ 98{
@@ -105,10 +107,10 @@ struct _Ecore_X_Image
105}; 107};
106 108
107EAPI Ecore_X_Image * 109EAPI Ecore_X_Image *
108ecore_x_image_new(int w, 110ecore_x_image_new(int w,
109 int h, 111 int h,
110 Ecore_X_Visual vis, 112 Ecore_X_Visual vis,
111 int depth) 113 int depth)
112{ 114{
113 Ecore_X_Image *im; 115 Ecore_X_Image *im;
114 116
@@ -124,7 +126,7 @@ ecore_x_image_new(int w,
124 _ecore_x_image_shm_check(); 126 _ecore_x_image_shm_check();
125 im->shm = _ecore_x_image_shm_can; 127 im->shm = _ecore_x_image_shm_can;
126 return im; 128 return im;
127} /* ecore_x_image_new */ 129}
128 130
129EAPI void 131EAPI void
130ecore_x_image_free(Ecore_X_Image *im) 132ecore_x_image_free(Ecore_X_Image *im)
@@ -148,7 +150,7 @@ ecore_x_image_free(Ecore_X_Image *im)
148 } 150 }
149 151
150 free(im); 152 free(im);
151} /* ecore_x_image_free */ 153}
152 154
153static void 155static void
154_ecore_x_image_shm_create(Ecore_X_Image *im) 156_ecore_x_image_shm_create(Ecore_X_Image *im)
@@ -192,17 +194,17 @@ _ecore_x_image_shm_create(Ecore_X_Image *im)
192 im->bpp = 2; 194 im->bpp = 2;
193 else 195 else
194 im->bpp = 4; 196 im->bpp = 4;
195} /* _ecore_x_image_shm_create */ 197}
196 198
197EAPI Eina_Bool 199EAPI Eina_Bool
198ecore_x_image_get(Ecore_X_Image *im, 200ecore_x_image_get(Ecore_X_Image *im,
199 Ecore_X_Drawable draw, 201 Ecore_X_Drawable draw,
200 int x, 202 int x,
201 int y, 203 int y,
202 int sx, 204 int sx,
203 int sy, 205 int sy,
204 int w, 206 int w,
205 int h) 207 int h)
206{ 208{
207 Eina_Bool ret = EINA_TRUE; 209 Eina_Bool ret = EINA_TRUE;
208 XErrorHandler ph; 210 XErrorHandler ph;
@@ -278,18 +280,18 @@ ecore_x_image_get(Ecore_X_Image *im,
278 } 280 }
279 281
280 return ret; 282 return ret;
281} /* ecore_x_image_get */ 283}
282 284
283EAPI void 285EAPI void
284ecore_x_image_put(Ecore_X_Image *im, 286ecore_x_image_put(Ecore_X_Image *im,
285 Ecore_X_Drawable draw, 287 Ecore_X_Drawable draw,
286 Ecore_X_GC gc, 288 Ecore_X_GC gc,
287 int x, 289 int x,
288 int y, 290 int y,
289 int sx, 291 int sx,
290 int sy, 292 int sy,
291 int w, 293 int w,
292 int h) 294 int h)
293{ 295{
294 Ecore_X_GC tgc = 0; 296 Ecore_X_GC tgc = 0;
295 297
@@ -306,13 +308,13 @@ ecore_x_image_put(Ecore_X_Image *im,
306 if (im->xim) 308 if (im->xim)
307 XShmPutImage(_ecore_x_disp, draw, gc, im->xim, sx, sy, x, y, w, h, False); 309 XShmPutImage(_ecore_x_disp, draw, gc, im->xim, sx, sy, x, y, w, h, False);
308 if (tgc) ecore_x_gc_free(tgc); 310 if (tgc) ecore_x_gc_free(tgc);
309} /* ecore_x_image_put */ 311}
310 312
311EAPI void * 313EAPI void *
312ecore_x_image_data_get(Ecore_X_Image *im, 314ecore_x_image_data_get(Ecore_X_Image *im,
313 int *bpl, 315 int *bpl,
314 int *rows, 316 int *rows,
315 int *bpp) 317 int *bpp)
316{ 318{
317 LOGFN(__FILE__, __LINE__, __FUNCTION__); 319 LOGFN(__FILE__, __LINE__, __FUNCTION__);
318 if (!im->xim) _ecore_x_image_shm_create(im); 320 if (!im->xim) _ecore_x_image_shm_create(im);
@@ -321,7 +323,7 @@ ecore_x_image_data_get(Ecore_X_Image *im,
321 if (rows) *rows = im->rows; 323 if (rows) *rows = im->rows;
322 if (bpp) *bpp = im->bpp; 324 if (bpp) *bpp = im->bpp;
323 return im->data; 325 return im->data;
324} /* ecore_x_image_data_get */ 326}
325 327
326EAPI Eina_Bool 328EAPI Eina_Bool
327ecore_x_image_is_argb32_get(Ecore_X_Image *im) 329ecore_x_image_is_argb32_get(Ecore_X_Image *im)
@@ -345,19 +347,19 @@ ecore_x_image_is_argb32_get(Ecore_X_Image *im)
345} 347}
346 348
347EAPI Eina_Bool 349EAPI Eina_Bool
348ecore_x_image_to_argb_convert(void *src, 350ecore_x_image_to_argb_convert(void *src,
349 int sbpp, 351 int sbpp,
350 int sbpl, 352 int sbpl,
351 Ecore_X_Colormap c, 353 Ecore_X_Colormap c,
352 Ecore_X_Visual v, 354 Ecore_X_Visual v,
353 int x, 355 int x,
354 int y, 356 int y,
355 int w, 357 int w,
356 int h, 358 int h,
357 unsigned int *dst, 359 unsigned int *dst,
358 int dbpl, 360 int dbpl,
359 int dx, 361 int dx,
360 int dy) 362 int dy)
361{ 363{
362 Visual *vis = v; 364 Visual *vis = v;
363 XColor *cols = NULL; 365 XColor *cols = NULL;
@@ -411,9 +413,9 @@ ecore_x_image_to_argb_convert(void *src,
411 else if ((vis->class == TrueColor) || 413 else if ((vis->class == TrueColor) ||
412 (vis->class == DirectColor)) 414 (vis->class == DirectColor))
413 { 415 {
414 if ((vis->red_mask == 0x00ff0000) && 416 if ((vis->red_mask == 0x00ff0000) &&
415 (vis->green_mask == 0x0000ff00) && 417 (vis->green_mask == 0x0000ff00) &&
416 (vis->blue_mask == 0x000000ff)) 418 (vis->blue_mask == 0x000000ff))
417 mode = argbx888; 419 mode = argbx888;
418 else if ((vis->red_mask == 0x000000ff) && 420 else if ((vis->red_mask == 0x000000ff) &&
419 (vis->green_mask == 0x0000ff00) && 421 (vis->green_mask == 0x0000ff00) &&