2 #include <sys/utsname.h>
4 #include "evas_common.h"
5 #include "evas_macros.h"
6 #include "evas_xlib_outbuf.h"
7 #include "evas_xlib_buffer.h"
8 #include "evas_xlib_color.h"
11 typedef struct _Outbuf_Region Outbuf_Region;
16 X_Output_Buffer *mxob;
23 static Eina_List *shmpool = NULL;
24 static int shmsize = 0;
25 static int shmmemlimit = 10 * 1024 * 1024;
26 static int shmcountlimit = 32;
28 #ifdef EVAS_FRAME_QUEUING
29 static LK(lock_shmpool);
30 #define SHMPOOL_LOCK() LKL(lock_shmpool)
31 #define SHMPOOL_UNLOCK() LKU(lock_shmpool)
33 #define SHMPOOL_LOCK()
34 #define SHMPOOL_UNLOCK()
37 static X_Output_Buffer *
38 _find_xob(Display *d, Visual *v, int depth, int w, int h, int shm, void *data)
40 Eina_List *l, *xl = NULL;
41 X_Output_Buffer *xob = NULL;
42 X_Output_Buffer *xob2;
43 int fitness = 0x7fffffff;
46 // return evas_software_xlib_x_output_buffer_new(d, v, depth, w, h, shm, data);
48 return evas_software_xlib_x_output_buffer_new(d, v, depth, w, h, shm, data);
52 if (bpp == 3) bpp = 4;
53 lbytes = (((w * bpp) + 3) / 4) * 4;
56 lbytes = ((w + 31) / 32) * 4;
59 EINA_LIST_FOREACH(shmpool, l, xob2)
63 if ((xob2->xim->depth != depth) || (xob2->visual != v) ||
66 szdif = xob2->psize - sz;
67 if (szdif < 0) continue;
81 if ((fitness > (100 * 100)) || (!xob))
84 xob = evas_software_xlib_x_output_buffer_new(d, v, depth, w, h, shm, data);
89 shmpool = eina_list_remove_list(shmpool, xl);
93 xob->xim->width = xob->w;
94 xob->xim->height = xob->h;
95 xob->xim->bytes_per_line = xob->bpl;
96 shmsize -= xob->psize * (xob->xim->depth / 8);
102 _unfind_xob(X_Output_Buffer *xob, int sync)
104 // evas_software_xlib_x_output_buffer_free(xob, sync); return;
108 shmpool = eina_list_prepend(shmpool, xob);
109 shmsize += xob->psize * xob->xim->depth / 8;
110 while ((shmsize > (shmmemlimit)) ||
111 (eina_list_count(shmpool) > shmcountlimit))
115 xl = eina_list_last(shmpool);
122 shmpool = eina_list_remove_list(shmpool, xl);
123 shmsize -= xob->psize * xob->xim->depth / 8;
124 evas_software_xlib_x_output_buffer_free(xob, sync);
129 evas_software_xlib_x_output_buffer_free(xob, sync);
138 X_Output_Buffer *xob;
141 shmpool = eina_list_remove_list(shmpool, shmpool);
142 evas_software_xlib_x_output_buffer_free(xob, sync);
149 evas_software_xlib_outbuf_init(void)
151 #ifdef EVAS_FRAME_QUEUING
157 evas_software_xlib_outbuf_free(Outbuf *buf)
159 #ifdef EVAS_FRAME_QUEUING
162 while (buf->priv.pending_writes)
167 im = buf->priv.pending_writes->data;
168 buf->priv.pending_writes = eina_list_remove_list(buf->priv.pending_writes, buf->priv.pending_writes);
169 obr = im->extended_info;
170 evas_cache_image_drop(&im->cache_entry);
171 if (obr->xob) _unfind_xob(obr->xob, 0);
172 if (obr->mxob) _unfind_xob(obr->mxob, 0);
175 #ifdef EVAS_FRAME_QUEUING
178 evas_software_xlib_outbuf_idle_flush(buf);
179 evas_software_xlib_outbuf_flush(buf);
180 if (buf->priv.x11.xlib.gc)
181 XFreeGC(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gc);
182 if (buf->priv.x11.xlib.gcm)
183 XFreeGC(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gcm);
185 evas_software_xlib_x_color_deallocate(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.cmap,
186 buf->priv.x11.xlib.vis, buf->priv.pal);
187 #ifdef EVAS_FRAME_QUEUING
195 evas_software_xlib_outbuf_setup_x(int w, int h, int rot, Outbuf_Depth depth,
196 Display *disp, Drawable draw, Visual *vis,
197 Colormap cmap, int x_depth,
198 int grayscale, int max_colors, Pixmap mask,
199 int shape_dither, int destination_alpha)
203 buf = calloc(1, sizeof(Outbuf));
212 buf->priv.x11.xlib.disp = disp;
213 buf->priv.x11.xlib.vis = vis;
214 buf->priv.x11.xlib.cmap = cmap;
215 buf->priv.x11.xlib.depth = x_depth;
217 buf->priv.mask_dither = shape_dither;
218 buf->priv.destination_alpha = destination_alpha;
221 Gfx_Func_Convert conv_func;
222 X_Output_Buffer *xob;
224 buf->priv.x11.xlib.shm = evas_software_xlib_x_can_do_shm(buf->priv.x11.xlib.disp);
225 xob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
226 buf->priv.x11.xlib.vis,
227 buf->priv.x11.xlib.depth,
228 1, 1, buf->priv.x11.xlib.shm, NULL);
233 #ifdef WORDS_BIGENDIAN
234 if (evas_software_xlib_x_output_buffer_byte_order(xob) == LSBFirst)
235 buf->priv.x11.xlib.swap = 1;
236 if (evas_software_xlib_x_output_buffer_bit_order(xob) == MSBFirst)
237 buf->priv.x11.xlib.bit_swap = 1;
239 if (evas_software_xlib_x_output_buffer_byte_order(xob) == MSBFirst)
240 buf->priv.x11.xlib.swap = 1;
241 if (evas_software_xlib_x_output_buffer_bit_order(xob) == MSBFirst)
242 buf->priv.x11.xlib.bit_swap = 1;
244 if (((vis->class == TrueColor) || (vis->class == DirectColor)) &&
247 buf->priv.mask.r = (DATA32) vis->red_mask;
248 buf->priv.mask.g = (DATA32) vis->green_mask;
249 buf->priv.mask.b = (DATA32) vis->blue_mask;
250 if (buf->priv.x11.xlib.swap)
252 SWAP32(buf->priv.mask.r);
253 SWAP32(buf->priv.mask.g);
254 SWAP32(buf->priv.mask.b);
257 else if ((vis->class == PseudoColor) ||
258 (vis->class == StaticColor) ||
259 (vis->class == GrayScale) ||
260 (vis->class == StaticGray) ||
263 Convert_Pal_Mode pm = PAL_MODE_RGB332;
265 if ((vis->class == GrayScale) || (vis->class == StaticGray))
269 if (max_colors >= 256)
270 pm = PAL_MODE_GRAY256;
271 else if (max_colors >= 64)
272 pm = PAL_MODE_GRAY64;
273 else if (max_colors >= 16)
274 pm = PAL_MODE_GRAY16;
275 else if (max_colors >= 4)
282 if (max_colors >= 256)
283 pm = PAL_MODE_RGB332;
284 else if (max_colors >= 216)
285 pm = PAL_MODE_RGB666;
286 else if (max_colors >= 128)
287 pm = PAL_MODE_RGB232;
288 else if (max_colors >= 64)
289 pm = PAL_MODE_RGB222;
290 else if (max_colors >= 32)
291 pm = PAL_MODE_RGB221;
292 else if (max_colors >= 16)
293 pm = PAL_MODE_RGB121;
294 else if (max_colors >= 8)
295 pm = PAL_MODE_RGB111;
296 else if (max_colors >= 4)
301 /* FIXME: only alloc once per display+cmap */
302 buf->priv.pal = evas_software_xlib_x_color_allocate(disp, cmap, vis,
312 if (buf->rot == 0 || buf->rot == 180)
313 conv_func = evas_common_convert_func_get(0, buf->w, buf->h,
314 evas_software_xlib_x_output_buffer_depth
315 (xob), buf->priv.mask.r,
318 buf->priv.pal->colors,
320 else if (buf->rot == 90 || buf->rot == 270)
321 conv_func = evas_common_convert_func_get(0, buf->h, buf->w,
322 evas_software_xlib_x_output_buffer_depth
323 (xob), buf->priv.mask.r,
326 buf->priv.pal->colors,
331 if (buf->rot == 0 || buf->rot == 180)
332 conv_func = evas_common_convert_func_get(0, buf->w, buf->h,
333 evas_software_xlib_x_output_buffer_depth
334 (xob), buf->priv.mask.r,
336 buf->priv.mask.b, PAL_MODE_NONE,
338 else if (buf->rot == 90 || buf->rot == 270)
339 conv_func = evas_common_convert_func_get(0, buf->h, buf->w,
340 evas_software_xlib_x_output_buffer_depth
341 (xob), buf->priv.mask.r,
343 buf->priv.mask.b, PAL_MODE_NONE,
346 evas_software_xlib_x_output_buffer_free(xob, 1);
349 printf(".[ Evas Error ].\n"
352 " RGB format mask: %08x, %08x, %08x\n"
353 " Palette mode: %i\n"
354 " Not supported by compiled in converters!\n"
356 buf->priv.x11.xlib.depth,
360 buf->priv.pal ? buf->priv.pal->colors : -1);
363 evas_software_xlib_outbuf_drawable_set(buf, draw);
364 evas_software_xlib_outbuf_mask_set(buf, mask);
366 #ifdef EVAS_FRAME_QUEUING
373 evas_software_xlib_outbuf_new_region_for_update(Outbuf *buf, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch)
381 if ((buf->onebuf) && (buf->priv.x11.xlib.shm))
383 Eina_Rectangle *rect;
385 RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, buf->w, buf->h);
386 rect = eina_rectangle_new(x, y, w, h);
387 if (!rect) return NULL;
389 buf->priv.onebuf_regions = eina_list_append(buf->priv.onebuf_regions, rect);
390 if (buf->priv.onebuf)
396 if (!buf->priv.synced)
398 XSync(buf->priv.x11.xlib.disp, False);
399 buf->priv.synced = 1;
401 return buf->priv.onebuf;
403 obr = calloc(1, sizeof(Outbuf_Region));
413 alpha = ((buf->priv.x11.xlib.mask) || (buf->priv.destination_alpha));
415 use_shm = buf->priv.x11.xlib.shm;
416 if ((buf->rot == 0) &&
417 (buf->priv.mask.r == 0xff0000) &&
418 (buf->priv.mask.g == 0x00ff00) &&
419 (buf->priv.mask.b == 0x0000ff))
421 obr->xob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
422 buf->priv.x11.xlib.vis,
423 buf->priv.x11.xlib.depth,
427 im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
429 (DATA32 *) evas_software_xlib_x_output_buffer_data(obr->xob, &bpl),
430 alpha, EVAS_COLORSPACE_ARGB8888);
431 im->extended_info = obr;
432 if (buf->priv.x11.xlib.mask)
433 obr->mxob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
434 buf->priv.x11.xlib.vis,
442 im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
443 im->cache_entry.flags.alpha |= alpha ? 1 : 0;
444 evas_cache_image_surface_alloc(&im->cache_entry, buf->w, buf->h);
445 im->extended_info = obr;
446 if ((buf->rot == 0) || (buf->rot == 180))
448 obr->xob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
449 buf->priv.x11.xlib.vis,
450 buf->priv.x11.xlib.depth,
454 if (buf->priv.x11.xlib.mask)
455 obr->mxob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
456 buf->priv.x11.xlib.vis,
461 else if ((buf->rot == 90) || (buf->rot == 270))
463 obr->xob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
464 buf->priv.x11.xlib.vis,
465 buf->priv.x11.xlib.depth,
469 if (buf->priv.x11.xlib.mask)
470 obr->mxob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
471 buf->priv.x11.xlib.vis,
477 /* FIXME: We should be able to remove this memset, but somewhere in the process
478 we copy too much to the destination surface and some area are not cleaned before copy. */
480 /* FIXME: faster memset! */
481 memset(im->image.data, 0, w * h * sizeof(DATA32));
483 buf->priv.onebuf = im;
487 obr = calloc(1, sizeof(Outbuf_Region));
497 use_shm = buf->priv.x11.xlib.shm;
498 /* FIXME: magic - i found if shm regions are smaller than 200x200 its
499 * faster to use ximages over unix sockets - trial and error
501 // use_shm = 0; /* 630 -> 1006 fps */
502 // if ((w * h) < (200 * 200)) use_shm = 0; /* 630 -> 962 fps */
504 alpha = ((buf->priv.x11.xlib.mask) || (buf->priv.destination_alpha));
506 if ((buf->rot == 0) &&
507 (buf->priv.mask.r == 0xff0000) &&
508 (buf->priv.mask.g == 0x00ff00) &&
509 (buf->priv.mask.b == 0x0000ff))
511 obr->xob = _find_xob(buf->priv.x11.xlib.disp,
512 buf->priv.x11.xlib.vis,
513 buf->priv.x11.xlib.depth,
517 /* obr->xob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp, */
518 /* buf->priv.x11.xlib.vis, */
519 /* buf->priv.x11.xlib.depth, */
523 im = (RGBA_Image *) evas_cache_image_data(evas_common_image_cache_get(),
525 (DATA32 *) evas_software_xlib_x_output_buffer_data(obr->xob, &bpl),
526 alpha, EVAS_COLORSPACE_ARGB8888);
527 im->extended_info = obr;
528 if (buf->priv.x11.xlib.mask)
529 obr->mxob = _find_xob(buf->priv.x11.xlib.disp,
530 buf->priv.x11.xlib.vis,
535 obr->mxob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
536 buf->priv.x11.xlib.vis,
544 im = (RGBA_Image *) evas_cache_image_empty(evas_common_image_cache_get());
545 im->cache_entry.flags.alpha |= alpha ? 1 : 0;
546 evas_cache_image_surface_alloc(&im->cache_entry, w, h);
547 im->extended_info = obr;
548 if ((buf->rot == 0) || (buf->rot == 180))
550 obr->xob = _find_xob(buf->priv.x11.xlib.disp,
551 buf->priv.x11.xlib.vis,
552 buf->priv.x11.xlib.depth,
556 if (buf->priv.x11.xlib.mask)
557 obr->mxob = _find_xob(buf->priv.x11.xlib.disp,
558 buf->priv.x11.xlib.vis,
564 obr->xob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
565 buf->priv.x11.xlib.vis,
566 buf->priv.x11.xlib.depth,
571 else if ((buf->rot == 90) || (buf->rot == 270))
573 obr->xob = _find_xob(buf->priv.x11.xlib.disp,
574 buf->priv.x11.xlib.vis,
575 buf->priv.x11.xlib.depth,
579 if (buf->priv.x11.xlib.mask)
580 obr->mxob = _find_xob(buf->priv.x11.xlib.disp,
581 buf->priv.x11.xlib.vis,
587 obr->xob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
588 buf->priv.x11.xlib.vis,
589 buf->priv.x11.xlib.depth,
595 if (buf->priv.x11.xlib.mask)
596 obr->mxob = _find_xob(buf->priv.x11.xlib.disp,
597 buf->priv.x11.xlib.vis,
603 obr->mxob = evas_software_xlib_x_output_buffer_new(buf->priv.x11.xlib.disp,
604 buf->priv.x11.xlib.vis,
610 /* FIXME: We should be able to remove this memset, but somewhere in the process
611 we copy too much to the destination surface and some area are not cleaned before copy. */
612 if ((buf->priv.x11.xlib.mask) || (buf->priv.destination_alpha))
613 /* FIXME: faster memset! */
614 memset(im->image.data, 0, w * h * sizeof(DATA32));
616 #ifdef EVAS_FRAME_QUEUING
617 if (!evas_common_frameq_enabled())
619 buf->priv.pending_writes = eina_list_append(buf->priv.pending_writes, im);
624 evas_software_xlib_outbuf_free_region_for_update(Outbuf *buf __UNUSED__, RGBA_Image *update __UNUSED__)
626 /* no need to do anything - they are cleaned up on flush */
630 evas_software_xlib_outbuf_flush(Outbuf *buf)
636 if ((buf->priv.onebuf) && (buf->priv.onebuf_regions))
640 im = buf->priv.onebuf;
641 obr = im->extended_info;
642 tmpr = XCreateRegion();
643 while (buf->priv.onebuf_regions)
645 Eina_Rectangle *rect;
648 rect = buf->priv.onebuf_regions->data;
649 buf->priv.onebuf_regions = eina_list_remove_list(buf->priv.onebuf_regions, buf->priv.onebuf_regions);
654 XUnionRectWithRegion(&xr, tmpr, tmpr);
656 evas_software_xlib_outbuf_debug_show(buf, buf->priv.x11.xlib.win,
657 rect->x, rect->y, rect->w, rect->h);
658 eina_rectangle_free(rect);
660 XSetRegion(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gc, tmpr);
661 evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
662 buf->priv.x11.xlib.gc,
666 XSetRegion(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gcm, tmpr);
667 evas_software_xlib_x_output_buffer_paste(obr->mxob,
668 buf->priv.x11.xlib.mask,
669 buf->priv.x11.xlib.gcm,
672 XDestroyRegion(tmpr);
673 buf->priv.synced = 0;
678 XSync(buf->priv.x11.xlib.disp, False);
679 EINA_LIST_FOREACH(buf->priv.pending_writes, l, im)
681 obr = im->extended_info;
683 evas_software_xlib_outbuf_debug_show(buf, buf->priv.x11.xlib.win,
684 obr->x, obr->y, obr->w, obr->h);
685 evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
686 buf->priv.x11.xlib.gc,
689 evas_software_xlib_x_output_buffer_paste(obr->mxob,
690 buf->priv.x11.xlib.mask,
691 buf->priv.x11.xlib.gcm,
694 #ifdef EVAS_FRAME_QUEUING
697 while (buf->priv.prev_pending_writes)
699 im = buf->priv.prev_pending_writes->data;
700 buf->priv.prev_pending_writes =
701 eina_list_remove_list(buf->priv.prev_pending_writes,
702 buf->priv.prev_pending_writes);
703 obr = im->extended_info;
704 evas_cache_image_drop(&im->cache_entry);
705 if (obr->xob) _unfind_xob(obr->xob, 0);
706 if (obr->mxob) _unfind_xob(obr->mxob, 0);
708 if (obr->xob) evas_software_xlib_x_output_buffer_free(obr->xob, 0);
709 if (obr->mxob) evas_software_xlib_x_output_buffer_free(obr->mxob, 0);
713 buf->priv.prev_pending_writes = buf->priv.pending_writes;
714 #ifdef EVAS_FRAME_QUEUING
717 buf->priv.pending_writes = NULL;
718 XFlush(buf->priv.x11.xlib.disp);
720 /* XX async push - disable */
722 EINA_LIST_FOREACH(buf->priv.pending_writes, l, im)
724 obr = im->extended_info;
726 evas_software_xlib_outbuf_debug_show(buf, buf->priv.x11.xlib.win,
727 obr->x, obr->y, obr->w, obr->h);
728 evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
729 buf->priv.x11.xlib.gc,
732 evas_software_xlib_x_output_buffer_paste(obr->mxob,
733 buf->priv.x11.xlib.mask,
734 buf->priv.x11.xlib.gcm,
738 XSync(buf->priv.x11.xlib.disp, False);
740 while (buf->priv.pending_writes)
745 im = eina_list_data_get(buf->priv.pending_writes);
746 buf->priv.pending_writes = eina_list_remove_list(buf->priv.pending_writes, buf->priv.pending_writes);
747 obr = im->extended_info;
748 evas_cache_image_drop(&im->cache_entry);
749 if (obr->xob) _unfind_xob(obr->xob, 0);
750 if (obr->mxob) _unfind_xob(obr->mxob, 0);
752 if (obr->xob) evas_software_xlib_x_output_buffer_free(obr->xob, 0);
753 if (obr->mxob) evas_software_xlib_x_output_buffer_free(obr->mxob, 0);
756 evas_cache_image_drop(&im->cache_entry);
760 evas_common_cpu_end_opt();
764 evas_software_xlib_outbuf_idle_flush(Outbuf *buf)
766 if (buf->priv.onebuf)
771 im = buf->priv.onebuf;
772 buf->priv.onebuf = NULL;
773 obr = im->extended_info;
774 if (obr->xob) evas_software_xlib_x_output_buffer_free(obr->xob, 0);
775 if (obr->mxob) evas_software_xlib_x_output_buffer_free(obr->mxob, 0);
777 evas_cache_image_drop(&im->cache_entry);
781 #ifdef EVAS_FRAME_QUEUING
784 if (buf->priv.prev_pending_writes) XSync(buf->priv.x11.xlib.disp, False);
785 while (buf->priv.prev_pending_writes)
790 im = buf->priv.prev_pending_writes->data;
791 buf->priv.prev_pending_writes =
792 eina_list_remove_list(buf->priv.prev_pending_writes,
793 buf->priv.prev_pending_writes);
794 obr = im->extended_info;
795 evas_cache_image_drop(&im->cache_entry);
796 if (obr->xob) _unfind_xob(obr->xob, 0);
797 if (obr->mxob) _unfind_xob(obr->mxob, 0);
800 #ifdef EVAS_FRAME_QUEUING
808 evas_software_xlib_outbuf_push_updated_region(Outbuf *buf, RGBA_Image *update, int x, int y, int w, int h)
810 Gfx_Func_Convert conv_func = NULL;
816 obr = update->extended_info;
819 if ((buf->rot == 0) || (buf->rot == 180))
820 conv_func = evas_common_convert_func_get(0, w, h,
821 evas_software_xlib_x_output_buffer_depth
822 (obr->xob), buf->priv.mask.r,
823 buf->priv.mask.g, buf->priv.mask.b,
824 buf->priv.pal->colors, buf->rot);
825 else if ((buf->rot == 90) || (buf->rot == 270))
826 conv_func = evas_common_convert_func_get(0, h, w,
827 evas_software_xlib_x_output_buffer_depth
828 (obr->xob), buf->priv.mask.r,
829 buf->priv.mask.g, buf->priv.mask.b,
830 buf->priv.pal->colors, buf->rot);
834 if ((buf->rot == 0) || (buf->rot == 180))
835 conv_func = evas_common_convert_func_get(0, w, h,
836 evas_software_xlib_x_output_buffer_depth
837 (obr->xob), buf->priv.mask.r,
838 buf->priv.mask.g, buf->priv.mask.b,
839 PAL_MODE_NONE, buf->rot);
840 else if ((buf->rot == 90) || (buf->rot == 270))
841 conv_func = evas_common_convert_func_get(0, h, w,
842 evas_software_xlib_x_output_buffer_depth
843 (obr->xob), buf->priv.mask.r,
844 buf->priv.mask.g, buf->priv.mask.b,
845 PAL_MODE_NONE, buf->rot);
847 if (!conv_func) return;
849 data = evas_software_xlib_x_output_buffer_data(obr->xob, &bpl);
850 src_data = update->image.data;
856 else if (buf->rot == 90)
859 obr->y = buf->w - x - w;
861 else if (buf->rot == 180)
863 obr->x = buf->w - x - w;
864 obr->y = buf->h - y - h;
866 else if (buf->rot == 270)
868 obr->x = buf->h - y - h;
871 if ((buf->rot == 0) || (buf->rot == 180))
876 else if ((buf->rot == 90) || (buf->rot == 270))
883 if (data != src_data)
884 conv_func(src_data, data,
887 ((evas_software_xlib_x_output_buffer_depth(obr->xob) /
888 8)) - obr->w, obr->w, obr->h, x, y,
889 buf->priv.pal->lookup);
893 if (data != src_data)
894 conv_func(src_data, data,
897 ((evas_software_xlib_x_output_buffer_depth(obr->xob) /
898 8)) - obr->w, obr->w, obr->h, x, y, NULL);
903 if (!((buf->priv.onebuf) && (buf->priv.onebuf_regions)))
906 evas_software_xlib_outbuf_debug_show(buf, buf->priv.x11.xlib.win,
907 obr->x, obr->y, obr->w, obr->h);
908 evas_software_xlib_x_output_buffer_paste(obr->xob, buf->priv.x11.xlib.win,
909 buf->priv.x11.xlib.gc,
917 for (yy = 0; yy < obr->h; yy++)
918 evas_software_xlib_x_write_mask_line(buf, obr->mxob,
920 (yy * obr->w), obr->w, yy);
922 else if (buf->rot == 90)
924 for (yy = 0; yy < obr->h; yy++)
925 evas_software_xlib_x_write_mask_line_vert(buf, obr->mxob,
928 obr->h - yy - 1, // ym
931 else if (buf->rot == 180)
933 for (yy = 0; yy < obr->h; yy++)
935 evas_software_xlib_x_write_mask_line_rev(buf, obr->mxob,
938 obr->w, obr->h - yy - 1);
941 else if (buf->rot == 270)
943 for (yy = 0; yy < obr->h; yy++)
944 evas_software_xlib_x_write_mask_line_vert_rev(buf, obr->mxob,
953 if (!((buf->priv.onebuf) && (buf->priv.onebuf_regions)))
954 evas_software_xlib_x_output_buffer_paste(obr->mxob,
955 buf->priv.x11.xlib.mask,
956 buf->priv.x11.xlib.gcm,
962 XFlush(buf->priv.x11.xlib.disp);
967 evas_software_xlib_outbuf_reconfigure(Outbuf * buf, int w, int h, int rot,
973 (depth == buf->depth)) return;
977 evas_software_xlib_outbuf_idle_flush(buf);
981 evas_software_xlib_outbuf_get_width(Outbuf * buf)
987 evas_software_xlib_outbuf_get_height(Outbuf * buf)
993 evas_software_xlib_outbuf_get_depth(Outbuf * buf)
999 evas_software_xlib_outbuf_get_rot(Outbuf * buf)
1005 evas_software_xlib_outbuf_drawable_set(Outbuf * buf, Drawable draw)
1009 if (buf->priv.x11.xlib.win == draw) return;
1010 if (buf->priv.x11.xlib.gc)
1012 XFreeGC(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gc);
1013 buf->priv.x11.xlib.gc = NULL;
1015 buf->priv.x11.xlib.win = draw;
1016 buf->priv.x11.xlib.gc = XCreateGC(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.win, 0, &gcv);
1020 evas_software_xlib_outbuf_mask_set(Outbuf * buf, Pixmap mask)
1024 if (buf->priv.x11.xlib.mask == mask) return;
1025 if (buf->priv.x11.xlib.gcm)
1027 XFreeGC(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gcm);
1028 buf->priv.x11.xlib.gcm = NULL;
1030 buf->priv.x11.xlib.mask = mask;
1031 if (buf->priv.x11.xlib.mask)
1032 buf->priv.x11.xlib.gcm = XCreateGC(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.mask, 0, &gcv);
1036 evas_software_xlib_outbuf_debug_set(Outbuf * buf, int debug)
1038 buf->priv.debug = debug;
1042 evas_software_xlib_outbuf_debug_show(Outbuf * buf, Drawable draw, int x, int y, int w,
1050 unsigned int ww, wh, bd, dp;
1052 XWindowAttributes wattr;
1054 XGetGeometry(buf->priv.x11.xlib.disp, draw, &root, &wx, &wy, &ww, &wh, &bd, &dp);
1055 XGetGeometry(buf->priv.x11.xlib.disp, root, &wdum, &wx, &wy, &ww, &wh, &bd, &dp);
1056 XGetWindowAttributes(buf->priv.x11.xlib.disp, root, &wattr);
1057 screen_num = XScreenNumberOfScreen(wattr.screen);
1059 for (i = 0; i < 20; i++)
1063 XSetForeground(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gc,
1064 BlackPixel(buf->priv.x11.xlib.disp, screen_num));
1065 XFillRectangle(buf->priv.x11.xlib.disp, draw, buf->priv.x11.xlib.gc, x, y, w, h);
1066 XSync(buf->priv.x11.xlib.disp, False);
1068 // XGetImage(buf->priv.x11.xlib.disp, draw, x, y, w, h, 0xffffffff, ZPixmap);
1070 // XDestroyImage(xim);
1071 XSync(buf->priv.x11.xlib.disp, False);
1072 XSetForeground(buf->priv.x11.xlib.disp, buf->priv.x11.xlib.gc,
1073 WhitePixel(buf->priv.x11.xlib.disp, screen_num));
1074 XFillRectangle(buf->priv.x11.xlib.disp, draw, buf->priv.x11.xlib.gc, x, y, w, h);
1075 XSync(buf->priv.x11.xlib.disp, False);
1077 // XGetImage(buf->priv.x11.xlib.disp, draw, x, y, w, h, 0xffffffff, ZPixmap);
1079 // XDestroyImage(xim);
1080 XSync(buf->priv.x11.xlib.disp, False);
1085 evas_software_xlib_outbuf_alpha_get(Outbuf *buf)
1087 return buf->priv.x11.xlib.mask;
1090 #ifdef EVAS_FRAME_QUEUING
1092 evas_software_xlib_outbuf_set_priv(Outbuf *buf, void *cur, void *prev)
1094 buf->priv.pending_writes = (Eina_List *)cur;