1 #include "evas_common.h"
2 #include "evas_engine.h"
7 evas_software_x11_x_write_mask_line(Outbuf *buf, X_Output_Buffer *xob, DATA32 *src, int w, int y)
15 dst_ptr = evas_software_x11_x_output_buffer_data(xob, &bpl);
16 dst_ptr = dst_ptr + (bpl * y);
18 if (buf->priv.x.bit_swap)
20 for (x = 0; x < w; x += 8)
23 ((A_VAL(&(src_ptr[0])) >> 7) << 7) |
24 ((A_VAL(&(src_ptr[1])) >> 7) << 6) |
25 ((A_VAL(&(src_ptr[2])) >> 7) << 5) |
26 ((A_VAL(&(src_ptr[3])) >> 7) << 4) |
27 ((A_VAL(&(src_ptr[4])) >> 7) << 3) |
28 ((A_VAL(&(src_ptr[5])) >> 7) << 2) |
29 ((A_VAL(&(src_ptr[6])) >> 7) << 1) |
30 ((A_VAL(&(src_ptr[7])) >> 7) << 0);
37 for (x = 0; x < w; x += 8)
40 ((A_VAL(&(src_ptr[0])) >> 7) << 0) |
41 ((A_VAL(&(src_ptr[1])) >> 7) << 1) |
42 ((A_VAL(&(src_ptr[2])) >> 7) << 2) |
43 ((A_VAL(&(src_ptr[3])) >> 7) << 3) |
44 ((A_VAL(&(src_ptr[4])) >> 7) << 4) |
45 ((A_VAL(&(src_ptr[5])) >> 7) << 5) |
46 ((A_VAL(&(src_ptr[6])) >> 7) << 6) |
47 ((A_VAL(&(src_ptr[7])) >> 7) << 7);
55 XPutPixel(xob->xim, x, y, A_VAL(src_ptr) >> 7);
61 evas_software_x11_x_can_do_shm(Display *d)
63 static Display *cached_d = NULL;
64 static int cached_result = 0;
66 if (d == cached_d) return cached_result;
68 if (XShmQueryExtension(d))
72 xob = evas_software_x11_x_output_buffer_new
73 (d, DefaultVisual(d, DefaultScreen(d)),
74 DefaultDepth(d, DefaultScreen(d)), 16, 16, 2, NULL);
80 evas_software_x11_x_output_buffer_free(xob, 1);
89 x_output_tmp_x_err(Display * d, XErrorEvent * ev)
95 //static int creates = 0;
98 evas_software_x11_x_output_buffer_new(Display *d, Visual *v, int depth, int w, int h, int try_shm, void *data)
100 X_Output_Buffer *xob;
102 xob = calloc(1, sizeof(X_Output_Buffer));
103 if (!xob) return NULL;
108 xob->shm_info = NULL;
114 xob->shm_info = malloc(sizeof(XShmSegmentInfo));
117 xob->xim = XShmCreateImage(d, v, depth, ZPixmap, NULL,
118 xob->shm_info, w, h);
121 xob->shm_info->shmid = shmget(IPC_PRIVATE,
122 xob->xim->bytes_per_line *
125 if (xob->shm_info->shmid >= 0)
127 xob->shm_info->readOnly = False;
128 xob->shm_info->shmaddr = xob->xim->data =
129 shmat(xob->shm_info->shmid, 0, 0);
130 if (xob->shm_info->shmaddr != NULL)
136 ph = XSetErrorHandler((XErrorHandler)
138 XShmAttach(d, xob->shm_info);
140 XSetErrorHandler((XErrorHandler)ph);
143 // printf("SHM++ ID=%i -> %i bytes [%i creates]\n",
144 // xob->shm_info->shmid,
145 // xob->xim->bytes_per_line * xob->xim->height,
148 xob->bpl = xob->xim->bytes_per_line;
149 xob->psize = xob->bpl * xob->h;
153 shmdt(xob->shm_info->shmaddr);
154 shmctl(xob->shm_info->shmid, IPC_RMID, 0);
156 if (xob->xim) XDestroyImage(xob->xim);
159 if (xob->shm_info) free(xob->shm_info);
160 xob->shm_info = NULL;
164 if (try_shm > 1) return NULL;
166 xob->xim = XCreateImage(d, v, depth, ZPixmap, 0, data, w, h, 32, 0);
177 xob->xim->data = malloc(xob->xim->bytes_per_line * xob->xim->height);
180 XDestroyImage(xob->xim);
185 xob->bpl = xob->xim->bytes_per_line;
186 xob->psize = xob->bpl * xob->h;
191 evas_software_x11_x_output_buffer_free(X_Output_Buffer *xob, int sync)
195 // printf("SHM-- ID=%i -> %i bytes, [sync=%i]\n",
196 // xob->shm_info->shmid,
197 // xob->xim->bytes_per_line * xob->xim->height,
199 if (sync) XSync(xob->display, False);
200 XShmDetach(xob->display, xob->shm_info);
201 XDestroyImage(xob->xim);
202 shmdt(xob->shm_info->shmaddr);
203 shmctl(xob->shm_info->shmid, IPC_RMID, 0);
208 if (xob->data) xob->xim->data = NULL;
209 XDestroyImage(xob->xim);
215 evas_software_x11_x_output_buffer_paste(X_Output_Buffer *xob, Drawable d, GC gc, int x, int y, int sync)
220 XShmPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y,
221 xob->w, xob->h, False);
222 if (sync) XSync(xob->display, False);
226 // printf("NO! shm\n");
227 XPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y,
233 evas_software_x11_x_output_buffer_data(X_Output_Buffer *xob, int *bytes_per_line_ret)
235 if (bytes_per_line_ret) *bytes_per_line_ret = xob->xim->bytes_per_line;
236 return xob->xim->data;
240 evas_software_x11_x_output_buffer_depth(X_Output_Buffer *xob)
242 return xob->xim->bits_per_pixel;
246 evas_software_x11_x_output_buffer_byte_order(X_Output_Buffer *xob)
248 return xob->xim->byte_order;
252 evas_software_x11_x_output_buffer_bit_order(X_Output_Buffer *xob)
254 return xob->xim->bitmap_bit_order;