1 #include "evas_common.h"
2 #include "evas_private.h"
4 #include "Evas_Engine_Software_X11.h"
5 #include "evas_engine.h"
7 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
8 # include "evas_xlib_outbuf.h"
9 # include "evas_xlib_swapbuf.h"
10 # include "evas_xlib_color.h"
11 # include "evas_xlib_image.h"
14 #ifdef BUILD_ENGINE_SOFTWARE_XCB
15 # include "evas_xcb_outbuf.h"
16 # include "evas_xcb_color.h"
17 # include "evas_xcb_xdefaults.h"
20 #include "evas_x_egl.h"
22 int _evas_engine_soft_x11_log_dom = -1;
24 /* function tables - filled in later (func and parent func) */
25 static Evas_Func func, pfunc;
27 /* engine struct data */
28 typedef struct _Render_Engine Render_Engine;
35 Tilebuf_Rect *rects_prev[3];
36 Eina_Inlist *cur_rect;
38 unsigned char end : 1;
39 unsigned char lost_back : 1;
40 void (*outbuf_free)(Outbuf *ob);
41 void (*outbuf_reconfigure)(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth);
42 int (*outbuf_get_rot)(Outbuf *ob);
43 RGBA_Image *(*outbuf_new_region_for_update)(Outbuf *ob, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch);
44 void (*outbuf_push_updated_region)(Outbuf *ob, RGBA_Image *update, int x, int y, int w, int h);
45 void (*outbuf_free_region_for_update)(Outbuf *ob, RGBA_Image *update);
46 void (*outbuf_flush)(Outbuf *ob);
47 void (*outbuf_idle_flush)(Outbuf *ob);
48 int (*outbuf_swap_mode_get)(Outbuf *ob);
49 Eina_Bool (*outbuf_alpha_get)(Outbuf *ob);
58 /* prototypes we will use here */
59 static void *_best_visual_get(int backend, void *connection, int screen);
60 static unsigned int _best_colormap_get(int backend, void *connection, int screen);
61 static int _best_depth_get(int backend, void *connection, int screen);
63 static void *eng_info(Evas *e);
64 static void eng_info_free(Evas *e, void *info);
65 static int eng_setup(Evas *e, void *info);
66 static void eng_output_free(void *data);
67 static void eng_output_resize(void *data, int w, int h);
68 static void eng_output_tile_size_set(void *data, int w, int h);
69 static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
70 static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
71 static void eng_output_redraws_clear(void *data);
72 static void *eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch);
73 static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
74 static void eng_output_flush(void *data);
75 static void eng_output_idle_flush(void *data);
76 static void *eng_image_native_set(void *data, void *image, void *native);
77 static void *eng_image_native_get(void *data __UNUSED__, void *image);
78 static Eina_Bool eng_image_draw(void *data __UNUSED__, void *context, void *surface, void *image,
79 int src_x, int src_y, int src_w, int src_h,
80 int dst_x, int dst_y, int dst_w, int dst_h,
83 /* internal engine routines */
85 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
89 _output_egl_setup(int w, int h, int rot, Display *disp, Drawable draw,
90 Visual *vis, Colormap cmap, int depth, int debug,
91 int grayscale, int max_colors, Pixmap mask,
92 int shape_dither, int destination_alpha)
98 if (depth != 32) return NULL;
99 if (mask) return NULL;
100 if (!(re = calloc(1, sizeof(Render_Engine)))) return NULL;
101 re->egl.disp = _egl_x_disp_get(disp);
107 re->egl.config = _egl_x_disp_choose_config(re->egl.disp);
110 _egl_x_disp_terminate(re->egl.disp);
114 re->egl.surface = _egl_x_win_surf_new(re->egl.disp, draw, re->egl.config);
115 if (!re->egl.surface)
117 _egl_x_disp_terminate(re->egl.disp);
121 ptr = _egl_x_surf_map(re->egl.disp, re->egl.surface, &stride);
124 _egl_x_win_surf_free(re->egl.disp, re->egl.surface);
125 _egl_x_disp_terminate(re->egl.disp);
129 _egl_x_surf_unmap(re->egl.disp, re->egl.surface);
132 evas_software_egl_outbuf_setup_x(w, h, rot, OUTBUF_DEPTH_INHERIT, disp,
133 draw, vis, cmap, depth, grayscale,
134 max_colors, mask, shape_dither,
137 re->tb = evas_common_tilebuf_new(w, h);
140 evas_software_xlib_outbuf_free(re->ob);
144 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
151 _output_egl_shutdown(Render_Engine *re)
153 if (!re->egl.disp) return;
154 _egl_x_win_surf_free(re->egl.disp, re->egl.surface);
155 _egl_x_disp_terminate(re->egl.disp);
159 _output_xlib_setup(int w, int h, int rot, Display *disp, Drawable draw,
160 Visual *vis, Colormap cmap, int depth, int debug,
161 int grayscale, int max_colors, Pixmap mask,
162 int shape_dither, int destination_alpha)
166 if (!(re = calloc(1, sizeof(Render_Engine)))) return NULL;
168 evas_software_xlib_x_init();
169 evas_software_xlib_x_color_init();
170 evas_software_xlib_outbuf_init();
173 evas_software_xlib_outbuf_setup_x(w, h, rot, OUTBUF_DEPTH_INHERIT, disp,
174 draw, vis, cmap, depth, grayscale,
175 max_colors, mask, shape_dither,
183 /* for updates return 1 big buffer, but only use portions of it, also cache
184 * it and keepit around until an idle_flush */
186 /* disable for now - i am hunting down why some expedite tests are slower,
187 * as well as shaped stuff is broken and probable non-32bpp is broken as
188 * convert funcs dont do the right thing
191 // re->ob->onebuf = 1;
193 evas_software_xlib_outbuf_debug_set(re->ob, debug);
194 re->tb = evas_common_tilebuf_new(w, h);
197 evas_software_xlib_outbuf_free(re->ob);
202 /* in preliminary tests 16x16 gave highest framerates */
203 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
208 _output_swapbuf_setup(int w, int h, int rot, Display *disp, Drawable draw,
209 Visual *vis, Colormap cmap, int depth,
210 int debug EINA_UNUSED,
211 int grayscale, int max_colors, Pixmap mask,
212 int shape_dither, int destination_alpha)
216 if (!(re = calloc(1, sizeof(Render_Engine)))) return NULL;
218 evas_software_xlib_x_init();
219 evas_software_xlib_x_color_init();
220 evas_software_xlib_swapbuf_init();
223 evas_software_xlib_swapbuf_setup_x(w, h, rot, OUTBUF_DEPTH_INHERIT, disp,
224 draw, vis, cmap, depth, grayscale,
225 max_colors, mask, shape_dither,
233 re->tb = evas_common_tilebuf_new(w, h);
236 evas_software_xlib_swapbuf_free(re->ob);
241 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
246 #ifdef BUILD_ENGINE_SOFTWARE_XCB
248 _output_xcb_setup(int w, int h, int rot, xcb_connection_t *conn,
249 xcb_screen_t *screen, xcb_drawable_t draw,
250 xcb_visualtype_t *vis, xcb_colormap_t cmap, int depth,
251 int debug, int grayscale, int max_colors, xcb_drawable_t mask,
252 int shape_dither, int destination_alpha)
256 if (!(re = calloc(1, sizeof(Render_Engine)))) return NULL;
258 evas_software_xcb_init();
259 evas_software_xcb_color_init();
260 evas_software_xcb_outbuf_init();
262 evas_software_xcb_outbuf_setup(w, h, rot, OUTBUF_DEPTH_INHERIT, conn,
263 screen, draw, vis, cmap, depth,
264 grayscale, max_colors, mask,
265 shape_dither, destination_alpha);
272 /* for updates return 1 big buffer, but only use portions of it, also cache
273 * it and keepit around until an idle_flush */
275 /* disable for now - i am hunting down why some expedite tests are slower,
276 * as well as shaped stuff is broken and probable non-32bpp is broken as
277 * convert funcs dont do the right thing
280 // re->ob->onebuf = 1;
282 evas_software_xcb_outbuf_debug_set(re->ob, debug);
284 re->tb = evas_common_tilebuf_new(w, h);
287 evas_software_xcb_outbuf_free(re->ob);
292 /* in preliminary tests 16x16 gave highest framerates */
293 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
299 _best_visual_get(int backend, void *connection, int screen)
301 if (!connection) return NULL;
303 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
304 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
305 return DefaultVisual((Display *)connection, screen);
308 #ifdef BUILD_ENGINE_SOFTWARE_XCB
309 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
311 xcb_screen_iterator_t iter_screen;
312 xcb_depth_iterator_t iter_depth;
313 xcb_screen_t *s = NULL;
316 xcb_setup_roots_iterator(xcb_get_setup((xcb_connection_t *)connection));
317 for (; iter_screen.rem; --screen, xcb_screen_next(&iter_screen))
320 s = iter_screen.data;
324 iter_depth = xcb_screen_allowed_depths_iterator(s);
325 for (; iter_depth.rem; xcb_depth_next(&iter_depth))
327 xcb_visualtype_iterator_t iter_vis;
329 iter_vis = xcb_depth_visuals_iterator(iter_depth.data);
330 for (; iter_vis.rem; xcb_visualtype_next(&iter_vis))
332 if (s->root_visual == iter_vis.data->visual_id)
333 return iter_vis.data;
343 _best_colormap_get(int backend, void *connection, int screen)
345 if (!connection) return 0;
347 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
348 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
349 return DefaultColormap((Display *)connection, screen);
352 #ifdef BUILD_ENGINE_SOFTWARE_XCB
353 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
355 xcb_screen_iterator_t iter_screen;
356 xcb_screen_t *s = NULL;
359 xcb_setup_roots_iterator(xcb_get_setup((xcb_connection_t *)connection));
360 for (; iter_screen.rem; --screen, xcb_screen_next(&iter_screen))
363 s = iter_screen.data;
367 return s->default_colormap;
375 _best_depth_get(int backend, void *connection, int screen)
377 if (!connection) return 0;
379 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
380 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
381 return DefaultDepth((Display *)connection, screen);
384 #ifdef BUILD_ENGINE_SOFTWARE_XCB
385 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
387 xcb_screen_iterator_t iter_screen;
388 xcb_screen_t *s = NULL;
391 xcb_setup_roots_iterator(xcb_get_setup((xcb_connection_t *)connection));
392 for (; iter_screen.rem; --screen, xcb_screen_next(&iter_screen))
395 s = iter_screen.data;
399 return s->root_depth;
406 /* engine api this module provides */
408 eng_info(Evas *e __UNUSED__)
410 Evas_Engine_Info_Software_X11 *info;
412 if (!(info = calloc(1, sizeof(Evas_Engine_Info_Software_X11))))
415 info->magic.magic = rand();
416 info->info.debug = 0;
417 info->info.alloc_grayscale = 0;
418 info->info.alloc_colors_max = 216;
419 info->func.best_visual_get = _best_visual_get;
420 info->func.best_colormap_get = _best_colormap_get;
421 info->func.best_depth_get = _best_depth_get;
422 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
427 eng_info_free(Evas *e __UNUSED__, void *info)
429 Evas_Engine_Info_Software_X11 *in;
431 in = (Evas_Engine_Info_Software_X11 *)info;
436 eng_setup(Evas *e, void *in)
438 Evas_Engine_Info_Software_X11 *info;
439 Render_Engine *re = NULL;
441 info = (Evas_Engine_Info_Software_X11 *)in;
442 if (!e->engine.data.output)
444 /* if we haven't initialized - init (automatic abort if already done) */
445 evas_common_cpu_init();
446 evas_common_blend_init();
447 evas_common_image_init();
448 evas_common_convert_init();
449 evas_common_scale_init();
450 evas_common_rectangle_init();
451 evas_common_polygon_init();
452 evas_common_line_init();
453 evas_common_font_init();
454 evas_common_draw_init();
455 evas_common_tilebuf_init();
457 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
458 if (info->info.backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
460 static int try_swapbuf = -1;
462 if (try_swapbuf == -1)
464 if (getenv("EVAS_NO_DRI_SWAPBUF")) try_swapbuf = 0;
465 else try_swapbuf = 1;
468 re = _output_swapbuf_setup(e->output.w, e->output.h,
469 info->info.rotation, info->info.connection,
470 info->info.drawable, info->info.visual,
472 info->info.depth, info->info.debug,
473 info->info.alloc_grayscale,
474 info->info.alloc_colors_max,
475 info->info.mask, info->info.shape_dither,
476 info->info.destination_alpha);
479 re->outbuf_free = evas_software_xlib_swapbuf_free;
480 re->outbuf_reconfigure = evas_software_xlib_swapbuf_reconfigure;
481 re->outbuf_get_rot = evas_software_xlib_swapbuf_get_rot;
482 re->outbuf_new_region_for_update = evas_software_xlib_swapbuf_new_region_for_update;
483 re->outbuf_push_updated_region = evas_software_xlib_swapbuf_push_updated_region;
484 re->outbuf_free_region_for_update = evas_software_xlib_swapbuf_free_region_for_update;
485 re->outbuf_flush = evas_software_xlib_swapbuf_flush;
486 re->outbuf_idle_flush = evas_software_xlib_swapbuf_idle_flush;
487 re->outbuf_alpha_get = evas_software_xlib_swapbuf_alpha_get;
488 re->outbuf_swap_mode_get = evas_software_xlib_swapbuf_buffer_state_get;
493 re = _output_xlib_setup(e->output.w, e->output.h,
494 info->info.rotation, info->info.connection,
495 info->info.drawable, info->info.visual,
497 info->info.depth, info->info.debug,
498 info->info.alloc_grayscale,
499 info->info.alloc_colors_max,
500 info->info.mask, info->info.shape_dither,
501 info->info.destination_alpha);
503 re->outbuf_free = evas_software_xlib_outbuf_free;
504 re->outbuf_reconfigure = evas_software_xlib_outbuf_reconfigure;
505 re->outbuf_get_rot = evas_software_xlib_outbuf_get_rot;
506 re->outbuf_new_region_for_update = evas_software_xlib_outbuf_new_region_for_update;
507 re->outbuf_push_updated_region = evas_software_xlib_outbuf_push_updated_region;
508 re->outbuf_free_region_for_update = evas_software_xlib_outbuf_free_region_for_update;
509 re->outbuf_flush = evas_software_xlib_outbuf_flush;
510 re->outbuf_idle_flush = evas_software_xlib_outbuf_idle_flush;
511 re->outbuf_alpha_get = evas_software_xlib_outbuf_alpha_get;
512 re->outbuf_swap_mode_get = NULL;
517 #ifdef BUILD_ENGINE_SOFTWARE_XCB
518 if (info->info.backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
520 re = _output_xcb_setup(e->output.w, e->output.h,
521 info->info.rotation, info->info.connection,
522 info->info.screen, info->info.drawable,
523 info->info.visual, info->info.colormap,
524 info->info.depth, info->info.debug,
525 info->info.alloc_grayscale,
526 info->info.alloc_colors_max,
527 info->info.mask, info->info.shape_dither,
528 info->info.destination_alpha);
530 re->outbuf_free = evas_software_xcb_outbuf_free;
531 re->outbuf_reconfigure = evas_software_xcb_outbuf_reconfigure;
532 re->outbuf_get_rot = evas_software_xcb_outbuf_rotation_get;
533 re->outbuf_new_region_for_update = evas_software_xcb_outbuf_new_region_for_update;
534 re->outbuf_push_updated_region = evas_software_xcb_outbuf_push_updated_region;
535 re->outbuf_free_region_for_update = evas_software_xcb_outbuf_free_region_for_update;
536 re->outbuf_flush = evas_software_xcb_outbuf_flush;
537 re->outbuf_idle_flush = evas_software_xcb_outbuf_idle_flush;
538 re->outbuf_alpha_get = evas_software_xcb_outbuf_alpha_get;
539 re->outbuf_swap_mode_get = NULL;
543 e->engine.data.output = re;
549 re = e->engine.data.output;
550 if ((re) && (re->ob)) ponebuf = re->ob->onebuf;
552 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
553 if (info->info.backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
556 re->outbuf_free(re->ob);
558 if (re->outbuf_free == evas_software_xlib_swapbuf_free)
561 evas_software_xlib_swapbuf_setup_x(e->output.w, e->output.h,
563 OUTBUF_DEPTH_INHERIT,
564 info->info.connection,
569 info->info.alloc_grayscale,
570 info->info.alloc_colors_max,
572 info->info.shape_dither,
573 info->info.destination_alpha);
578 evas_software_xlib_outbuf_setup_x(e->output.w, e->output.h,
580 OUTBUF_DEPTH_INHERIT,
581 info->info.connection,
586 info->info.alloc_grayscale,
587 info->info.alloc_colors_max,
589 info->info.shape_dither,
590 info->info.destination_alpha);
591 evas_software_xlib_outbuf_debug_set(re->ob, info->info.debug);
596 #ifdef BUILD_ENGINE_SOFTWARE_XCB
597 if (info->info.backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
599 evas_software_xcb_outbuf_free(re->ob);
601 evas_software_xcb_outbuf_setup(e->output.w, e->output.h,
603 OUTBUF_DEPTH_INHERIT,
604 info->info.connection,
610 info->info.alloc_grayscale,
611 info->info.alloc_colors_max,
613 info->info.shape_dither,
614 info->info.destination_alpha);
615 evas_software_xcb_outbuf_debug_set(re->ob, info->info.debug);
618 if ((re) && (re->ob)) re->ob->onebuf = ponebuf;
620 if (!e->engine.data.output) return 0;
621 if (!e->engine.data.context)
623 e->engine.data.context =
624 e->engine.func->context_new(e->engine.data.output);
627 re = e->engine.data.output;
633 eng_output_free(void *data)
637 if ((re = (Render_Engine *)data))
639 re->outbuf_free(re->ob);
640 evas_common_tilebuf_free(re->tb);
641 if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
642 if (re->rects_prev[0]) evas_common_tilebuf_free_render_rects(re->rects_prev[0]);
643 if (re->rects_prev[1]) evas_common_tilebuf_free_render_rects(re->rects_prev[1]);
644 if (re->rects_prev[2]) evas_common_tilebuf_free_render_rects(re->rects_prev[2]);
645 _output_egl_shutdown(re);
649 evas_common_font_shutdown();
650 evas_common_image_shutdown();
654 eng_output_resize(void *data, int w, int h)
658 re = (Render_Engine *)data;
659 re->outbuf_reconfigure(re->ob, w, h, re->outbuf_get_rot(re->ob),
660 OUTBUF_DEPTH_INHERIT);
661 evas_common_tilebuf_free(re->tb);
662 re->tb = evas_common_tilebuf_new(w, h);
664 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
668 eng_output_tile_size_set(void *data, int w, int h)
672 re = (Render_Engine *)data;
673 evas_common_tilebuf_set_tile_size(re->tb, w, h);
677 eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
681 re = (Render_Engine *)data;
682 evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
686 eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
690 re = (Render_Engine *)data;
691 evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
695 eng_output_redraws_clear(void *data)
699 re = (Render_Engine *)data;
700 evas_common_tilebuf_clear(re->tb);
703 static Tilebuf_Rect *
704 _merge_rects(Tilebuf *tb, Tilebuf_Rect *r1, Tilebuf_Rect *r2, Tilebuf_Rect *r3)
706 Tilebuf_Rect *r, *rects;
707 // int px1, py1, px2, py2;
711 EINA_INLIST_FOREACH(EINA_INLIST_GET(r1), r)
713 evas_common_tilebuf_add_redraw(tb, r->x, r->y, r->w, r->h);
718 EINA_INLIST_FOREACH(EINA_INLIST_GET(r2), r)
720 evas_common_tilebuf_add_redraw(tb, r->x, r->y, r->w, r->h);
725 EINA_INLIST_FOREACH(EINA_INLIST_GET(r3), r)
727 evas_common_tilebuf_add_redraw(tb, r->x, r->y, r->w, r->h);
730 rects = evas_common_tilebuf_get_render_rects(tb);
733 // bounding box -> make a bounding box single region update of all regions.
734 // yes we could try and be smart and figure out size of regions, how far
735 // apart etc. etc. to try and figure out an optimal "set". this is a tradeoff
736 // between multiple update regions to render and total pixels to render.
739 px1 = rects->x; py1 = rects->y;
740 px2 = rects->x + rects->w; py2 = rects->y + rects->h;
741 EINA_INLIST_FOREACH(EINA_INLIST_GET(rects), r)
743 if (r->x < x1) px1 = r->x;
744 if (r->y < y1) py1 = r->y;
745 if ((r->x + r->w) > x2) px2 = r->x + r->w;
746 if ((r->y + r->h) > y2) py2 = r->y + r->h;
748 evas_common_tilebuf_free_render_rects(rects);
749 rects = calloc(1, sizeof(Tilebuf_Rect));
754 rects->w = px2 - px1;
755 rects->h = py2 - py1;
759 evas_common_tilebuf_clear(tb);
765 eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
770 Eina_Bool first_rect = EINA_FALSE;
772 #define CLEAR_PREV_RECTS(x) \
774 if (re->rects_prev[x]) \
775 evas_common_tilebuf_free_render_rects(re->rects_prev[x]); \
776 re->rects_prev[x] = NULL; \
779 re = (Render_Engine *)data;
788 int mode = MODE_COPY;
790 if (re->outbuf_swap_mode_get) mode = re->outbuf_swap_mode_get(re->ob);
792 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
797 /* if we lost our backbuffer since the last frame redraw all */
799 evas_common_tilebuf_add_redraw(re->tb, 0, 0, re->ob->w, re->ob->h);
800 evas_common_tilebuf_free_render_rects(re->rects);
801 re->rects = evas_common_tilebuf_get_render_rects(re->tb);
803 /* ensure we get rid of previous rect lists we dont need if mode
804 * changed/is appropriate */
805 evas_common_tilebuf_clear(re->tb);
807 re->rects_prev[2] = re->rects_prev[1];
808 re->rects_prev[1] = re->rects_prev[0];
809 re->rects_prev[0] = re->rects;
814 case MODE_COPY: // no prev rects needed
815 re->rects = _merge_rects(re->tb, re->rects_prev[0], NULL, NULL);
817 case MODE_DOUBLE: // double mode - only 1 level of prev rect
818 re->rects = _merge_rects(re->tb, re->rects_prev[0], re->rects_prev[1], NULL);
820 case MODE_TRIPLE: // keep all
821 re->rects = _merge_rects(re->tb, re->rects_prev[0], re->rects_prev[1], re->rects_prev[2]);
826 first_rect = EINA_TRUE;
828 evas_common_tilebuf_clear(re->tb);
829 re->cur_rect = EINA_INLIST_GET(re->rects);
831 if (!re->cur_rect) return NULL;
832 rect = (Tilebuf_Rect *)re->cur_rect;
840 rect = (Tilebuf_Rect *)re->cur_rect;
849 re->cur_rect = re->cur_rect->next;
855 if (w) *w = re->ob->w;
856 if (h) *h = re->ob->h;
859 if (cw) *cw = re->ob->w;
860 if (ch) *ch = re->ob->h;
867 // do anything needed fir the first frame
870 re->outbuf_new_region_for_update(re->ob,
883 eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
887 re = (Render_Engine *)data;
888 #if defined(BUILD_PIPE_RENDER)
889 evas_common_pipe_map_begin(surface);
890 #endif /* BUILD_PIPE_RENDER */
891 re->outbuf_push_updated_region(re->ob, surface, x, y, w, h);
892 re->outbuf_free_region_for_update(re->ob, surface);
893 evas_common_cpu_end_opt();
897 eng_output_flush(void *data)
901 re = (Render_Engine *)data;
902 re->outbuf_flush(re->ob);
905 evas_common_tilebuf_free_render_rects(re->rects);
911 eng_output_idle_flush(void *data)
915 re = (Render_Engine *)data;
916 re->outbuf_idle_flush(re->ob);
920 eng_canvas_alpha_get(void *data, void *context __UNUSED__)
924 re = (Render_Engine *)data;
925 return (re->ob->priv.destination_alpha) || (re->outbuf_alpha_get(re->ob));
929 evas_software_image_map_draw(void *data, void *context, RGBA_Image *surface, RGBA_Image *im, RGBA_Map *m, int smooth, int level, int offset)
931 if (m->count - offset < 3) return;
933 if ((m->pts[0 + offset].x == m->pts[3 + offset].x) &&
934 (m->pts[1 + offset].x == m->pts[2 + offset].x) &&
935 (m->pts[0 + offset].y == m->pts[1 + offset].y) &&
936 (m->pts[3 + offset].y == m->pts[2 + offset].y) &&
937 (m->pts[0 + offset].x <= m->pts[1 + offset].x) &&
938 (m->pts[0 + offset].y <= m->pts[2 + offset].y) &&
939 (m->pts[0 + offset].u == 0) &&
940 (m->pts[0 + offset].v == 0) &&
941 (m->pts[1 + offset].u == (int)(im->cache_entry.w << FP)) &&
942 (m->pts[1 + offset].v == 0) &&
943 (m->pts[2 + offset].u == (int)(im->cache_entry.w << FP)) &&
944 (m->pts[2 + offset].v == (int)(im->cache_entry.h << FP)) &&
945 (m->pts[3 + offset].u == 0) &&
946 (m->pts[3 + offset].v == (int)(im->cache_entry.h << FP)) &&
947 (m->pts[0 + offset].col == 0xffffffff) &&
948 (m->pts[1 + offset].col == 0xffffffff) &&
949 (m->pts[2 + offset].col == 0xffffffff) &&
950 (m->pts[3 + offset].col == 0xffffffff))
954 dx = m->pts[0 + offset].x >> FP;
955 dy = m->pts[0 + offset].y >> FP;
956 dw = (m->pts[2 + offset].x >> FP) - dx;
957 dh = (m->pts[2 + offset].y >> FP) - dy;
959 (data, context, surface, im,
960 0, 0, im->cache_entry.w, im->cache_entry.h,
961 dx, dy, dw, dh, smooth);
965 #ifdef BUILD_PIPE_RENDER
968 evas_common_pipe_map_draw(im, surface, context, m, smooth, level);
974 evas_common_map_rgba(im, surface, context, m->count - offset, &m->pts[offset], smooth, level);
977 evas_common_cpu_end_opt();
981 evas_software_image_map_draw(data, context, surface, im, m, smooth, level, offset + 2);
986 eng_image_map_draw(void *data, void *context, void *surface, void *image, RGBA_Map *m, int smooth, int level)
989 if (m->count < 3) return;
991 evas_software_image_map_draw(data, context, surface, image, m, smooth, level, 0);
995 eng_image_native_set(void *data, void *image, void *native)
998 Render_Engine *re = (Render_Engine *)data;
999 Evas_Native_Surface *ns = native;
1000 RGBA_Image *im = image, *im2;
1001 Image_Entry *ie = image;
1007 if (ns->type != EVAS_NATIVE_SURFACE_X11) return im;
1008 if (im->native.data)
1010 //image have native surface already
1011 Evas_Native_Surface *ens = im->native.data;
1012 if ((ens->data.x11.visual == ns->data.x11.visual) &&
1013 (ens->data.x11.pixmap == ns->data.x11.pixmap))
1017 if ((!ns) && (!im->native.data)) return im;
1019 //create new im and clean already existed im even though ns = NULL
1020 im2 = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
1021 ie->w, ie->h, NULL, ie->flags.alpha,
1022 EVAS_COLORSPACE_ARGB8888);
1023 if (im->native.data)
1025 if (im->native.func.free)
1026 im->native.func.free(im->native.func.data, im);
1029 evas_cache_image_drop(&im->cache_entry);
1033 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
1034 return evas_xlib_image_native_set(re->ob, im, ns);
1040 eng_image_native_get(void *data __UNUSED__, void *image)
1042 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
1043 RGBA_Image *im = image;
1045 if (!im) return NULL;
1046 n = im->native.data;
1047 if (!n) return NULL;
1054 eng_image_draw(void *data __UNUSED__, void *context, void *surface, void *image,
1055 int src_x, int src_y, int src_w, int src_h,
1056 int dst_x, int dst_y, int dst_w, int dst_h,
1062 if (!image) return EINA_FALSE;
1064 if (im->native.data)
1065 n = im->native.data;
1066 if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_X11))
1068 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
1069 if(evas_xlib_image_shm_copy(im))
1071 evas_common_image_colorspace_dirty(im);
1075 evas_common_rgba_image_scalecache_prepare(&im->cache_entry, surface, context, smooth,
1076 src_x, src_y, src_w, src_h,
1077 dst_x, dst_y, dst_w, dst_h);
1078 evas_common_rgba_image_scalecache_do(&im->cache_entry, surface, context, smooth,
1079 src_x, src_y, src_w, src_h,
1080 dst_x, dst_y, dst_w, dst_h);
1081 evas_common_cpu_end_opt();
1085 /* module advertising code */
1087 module_open(Evas_Module *em)
1091 /* get whatever engine module we inherit from */
1092 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
1094 _evas_engine_soft_x11_log_dom =
1095 eina_log_domain_register("evas-software_x11", EVAS_DEFAULT_LOG_COLOR);
1097 if (_evas_engine_soft_x11_log_dom < 0)
1099 EINA_LOG_ERR("Can not create a module log domain.");
1103 /* store it for later use */
1106 /* now to override methods */
1107 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
1111 ORD(canvas_alpha_get);
1114 ORD(output_tile_size_set);
1115 ORD(output_redraws_rect_add);
1116 ORD(output_redraws_rect_del);
1117 ORD(output_redraws_clear);
1118 ORD(output_redraws_next_update_get);
1119 ORD(output_redraws_next_update_push);
1121 ORD(output_idle_flush);
1123 ORD(image_map_draw);
1125 ORD(image_native_set);
1126 ORD(image_native_get);
1127 /* now advertise out own api */
1128 em->functions = (void *)(&func);
1133 module_close(Evas_Module *em __UNUSED__)
1135 eina_log_domain_unregister(_evas_engine_soft_x11_log_dom);
1138 static Evas_Module_Api evas_modapi =
1140 EVAS_MODULE_API_VERSION, "software_x11", "none",
1147 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_x11);
1149 #ifndef EVAS_STATIC_BUILD_SOFTWARE_X11
1150 EVAS_EINA_MODULE_DEFINE(engine, software_x11);