1 #include "evas_common_private.h"
2 #include "evas_private.h"
4 #include "evas_cs2_private.h"
7 #include "Evas_Engine_Software_X11.h"
8 #include "evas_engine.h"
10 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
11 # include "evas_xlib_outbuf.h"
12 # include "evas_xlib_buffer.h"
13 # include "evas_xlib_swapbuf.h"
14 # include "evas_xlib_color.h"
15 # include "evas_xlib_image.h"
16 # include "evas_xlib_dri_image.h"
19 #ifdef BUILD_ENGINE_SOFTWARE_XCB
20 # include "evas_xcb_outbuf.h"
21 # include "evas_xcb_color.h"
22 # include "evas_xcb_xdefaults.h"
23 # include "evas_xcb_image.h"
24 # include "evas_xcb_buffer.h"
27 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
28 #include "evas_x_egl.h"
31 #include "../software_generic/evas_native_common.h"
40 Evas_Native_Tbm_Surface_Image_Set_Call glsym__evas_native_tbm_surface_image_set = NULL;
41 Evas_Native_Tbm_Surface_Stride_Get_Call glsym__evas_native_tbm_surface_stride_get = NULL;
42 int _evas_engine_soft_x11_log_dom = -1;
44 /* function tables - filled in later (func and parent func) */
45 static Evas_Func func, pfunc;
47 /* engine struct data */
48 typedef struct _Render_Engine Render_Engine;
52 Render_Engine_Software_Generic generic;
53 Eina_Bool (*outbuf_alpha_get)(Outbuf *ob);
62 typedef struct _Region_Push_Hook_Ctx {
63 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
64 X_Output_Buffer *changed_pixels;
66 Xcb_Output_Buffer *changed_pixels;
71 void (*cb)(Evas *evas, int x, int y, int w, int h, const void *pixels);
76 } Region_Push_Hook_Ctx;
78 /* prototypes we will use here */
79 static void *_best_visual_get(int backend, void *connection, int screen);
80 static unsigned int _best_colormap_get(int backend, void *connection, int screen);
81 static int _best_depth_get(int backend, void *connection, int screen);
83 static void *eng_info(Evas *eo_e);
84 static void eng_info_free(Evas *eo_e, void *info);
85 static int eng_setup(Evas *eo_e, void *info);
86 static void eng_output_free(void *data);
88 static Eina_List *_outbufs = NULL;
90 /* internal engine routines */
94 _evas_software_x11_region_push_hook_call(void *data)
96 Region_Push_Hook_Ctx *ctx = data;
98 if (eina_list_data_find(_outbufs, ctx->buf))
100 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
101 ctx->region_push_hook.cb(ctx->region_push_hook.evas, ctx->x, ctx->y,
102 ctx->changed_pixels->xim->width,
103 ctx->changed_pixels->xim->height,
104 evas_software_xlib_x_output_buffer_data(ctx->changed_pixels, NULL));
105 eina_spinlock_take(ctx->lock);
106 evas_software_xlib_x_output_buffer_unref(ctx->changed_pixels, 0);
107 eina_spinlock_release(ctx->lock);
109 ctx->region_push_hook.cb(ctx->region_push_hook.evas, ctx->x, ctx->y,
110 ctx->changed_pixels->xim->width,
111 ctx->changed_pixels->xim->height,
112 evas_software_xcb_output_buffer_data(ctx->changed_pixels, NULL));
113 eina_spinlock_take(ctx->lock);
114 evas_software_xcb_output_buffer_unref(ctx->changed_pixels, EINA_FALSE);
115 eina_spinlock_release(ctx->lock);
122 evas_software_x11_region_push_hook_call(Outbuf *buf, int x, int y, void *out_buf,
125 Region_Push_Hook_Ctx *ctx;
127 if (!buf->region_push_hook.cb)
130 ctx = malloc(sizeof(Region_Push_Hook_Ctx));
131 EINA_SAFETY_ON_NULL_RETURN(ctx);
134 ctx->region_push_hook.cb = buf->region_push_hook.cb;
135 ctx->region_push_hook.evas = buf->region_push_hook.evas;
136 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
137 ctx->changed_pixels = evas_software_xlib_x_output_buffer_ref(out_buf);
139 ctx->changed_pixels = evas_software_xcb_output_buffer_ref(out_buf);
143 ecore_main_loop_thread_safe_call_async(_evas_software_x11_region_push_hook_call,
147 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
151 _output_egl_setup(int w, int h, int rot, Display *disp, Drawable draw,
152 Visual *vis, Colormap cmap, int depth, int debug,
153 int grayscale, int max_colors, Pixmap mask,
154 int shape_dither, int destination_alpha)
160 if (depth != 32) return NULL;
161 if (mask) return NULL;
162 if (!(re = calloc(1, sizeof(Render_Engine)))) return NULL;
163 re->egl.disp = _egl_x_disp_get(disp);
169 re->egl.config = _egl_x_disp_choose_config(re->egl.disp);
172 _egl_x_disp_terminate(re->egl.disp);
176 re->egl.surface = _egl_x_win_surf_new(re->egl.disp, draw, re->egl.config);
177 if (!re->egl.surface)
179 _egl_x_disp_terminate(re->egl.disp);
183 ptr = _egl_x_surf_map(re->egl.disp, re->egl.surface, &stride);
186 _egl_x_win_surf_free(re->egl.disp, re->egl.surface);
187 _egl_x_disp_terminate(re->egl.disp);
191 _egl_x_surf_unmap(re->egl.disp, re->egl.surface);
194 evas_software_egl_outbuf_setup_x(w, h, rot, OUTBUF_DEPTH_INHERIT, disp,
195 draw, vis, cmap, depth, grayscale,
196 max_colors, mask, shape_dither,
199 re->tb = evas_common_tilebuf_new(w, h);
202 evas_software_xlib_outbuf_free(re->ob);
207 evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
215 _output_egl_shutdown(Render_Engine *re)
217 if (!re->egl.disp) return;
218 _egl_x_win_surf_free(re->egl.disp, re->egl.surface);
219 _egl_x_disp_terminate(re->egl.disp);
223 _output_xlib_setup(int w, int h, int rot, Display *disp, Drawable draw,
224 Visual *vis, Colormap cmap, int depth, int debug,
225 int grayscale, int max_colors, Pixmap mask,
226 int shape_dither, int destination_alpha)
230 Render_Engine_Merge_Mode merge_mode = MERGE_SMART;
233 if (!(re = calloc(1, sizeof(Render_Engine)))) return NULL;
235 evas_software_xlib_x_init();
236 evas_software_xlib_x_color_init();
237 evas_software_xlib_outbuf_init();
240 evas_software_xlib_outbuf_setup_x(w, h, rot, OUTBUF_DEPTH_INHERIT, disp,
241 draw, vis, cmap, depth, grayscale,
242 max_colors, mask, shape_dither,
244 if (!ob) goto on_error;
246 /* for updates return 1 big buffer, but only use portions of it, also cache
247 * it and keepit around until an idle_flush */
249 /* disable for now - i am hunting down why some expedite tests are slower,
250 * as well as shaped stuff is broken and probable non-32bpp is broken as
251 * convert funcs dont do the right thing
254 // re->ob->onebuf = 1;
256 evas_software_xlib_outbuf_debug_set(ob, debug);
257 if (!evas_render_engine_software_generic_init(&re->generic, ob, NULL,
258 evas_software_xlib_outbuf_get_rot,
259 evas_software_xlib_outbuf_reconfigure,
262 evas_software_xlib_outbuf_new_region_for_update,
263 evas_software_xlib_outbuf_push_updated_region,
264 evas_software_xlib_outbuf_free_region_for_update,
265 evas_software_xlib_outbuf_idle_flush,
266 evas_software_xlib_outbuf_flush,
268 evas_software_xlib_outbuf_free,
272 if ((s = getenv("EVAS_SOFTWARE_PARTIAL_MERGE")))
274 if ((!strcmp(s, "bounding")) ||
276 merge_mode = MERGE_BOUNDING;
277 else if ((!strcmp(s, "full")) ||
279 merge_mode = MERGE_FULL;
280 else if ((!strcmp(s, "smart")) ||
282 merge_mode = MERGE_SMART;
285 evas_render_engine_software_generic_merge_mode_set(&re->generic, merge_mode);
290 if (ob) evas_software_xlib_outbuf_free(ob);
296 _output_swapbuf_setup(int w, int h, int rot, Display *disp, Drawable draw,
297 Visual *vis, Colormap cmap, int depth,
298 int debug EINA_UNUSED,
299 int grayscale, int max_colors, Pixmap mask,
300 int shape_dither, int destination_alpha)
305 if (!(re = calloc(1, sizeof(Render_Engine)))) return NULL;
307 evas_software_xlib_x_init();
308 evas_software_xlib_x_color_init();
309 evas_software_xlib_swapbuf_init();
312 evas_software_xlib_swapbuf_setup_x(w, h, rot, OUTBUF_DEPTH_INHERIT, disp,
313 draw, vis, cmap, depth, grayscale,
314 max_colors, mask, shape_dither,
316 if (!ob) goto on_error;
318 if (!evas_render_engine_software_generic_init(&re->generic, ob,
319 evas_software_xlib_swapbuf_buffer_state_get,
320 evas_software_xlib_swapbuf_get_rot,
321 evas_software_xlib_swapbuf_reconfigure,
324 evas_software_xlib_swapbuf_new_region_for_update,
325 evas_software_xlib_swapbuf_push_updated_region,
326 evas_software_xlib_swapbuf_free_region_for_update,
327 evas_software_xlib_swapbuf_idle_flush,
328 evas_software_xlib_swapbuf_flush,
330 evas_software_xlib_swapbuf_free,
336 if (ob) evas_software_xlib_swapbuf_free(ob);
342 #ifdef BUILD_ENGINE_SOFTWARE_XCB
344 _output_xcb_setup(int w, int h, int rot, xcb_connection_t *conn,
345 xcb_screen_t *screen, xcb_drawable_t draw,
346 xcb_visualtype_t *vis, xcb_colormap_t cmap, int depth,
347 int debug, int grayscale, int max_colors, xcb_drawable_t mask,
348 int shape_dither, int destination_alpha)
353 if (!(re = calloc(1, sizeof(Render_Engine)))) return NULL;
355 evas_software_xcb_init();
356 evas_software_xcb_color_init();
357 evas_software_xcb_outbuf_init();
360 evas_software_xcb_outbuf_setup(w, h, rot, OUTBUF_DEPTH_INHERIT, conn,
361 screen, draw, vis, cmap, depth,
362 grayscale, max_colors, mask,
363 shape_dither, destination_alpha);
364 if (!ob) goto on_error;
366 /* for updates return 1 big buffer, but only use portions of it, also cache
367 * it and keepit around until an idle_flush */
369 /* disable for now - i am hunting down why some expedite tests are slower,
370 * as well as shaped stuff is broken and probable non-32bpp is broken as
371 * convert funcs dont do the right thing
374 // re->ob->onebuf = 1;
376 evas_software_xcb_outbuf_debug_set(ob, debug);
378 if (!evas_render_engine_software_generic_init(&re->generic, ob, NULL,
379 evas_software_xcb_outbuf_rotation_get,
380 evas_software_xcb_outbuf_reconfigure,
383 evas_software_xcb_outbuf_new_region_for_update,
384 evas_software_xcb_outbuf_push_updated_region,
385 evas_software_xcb_outbuf_free_region_for_update,
386 evas_software_xcb_outbuf_idle_flush,
387 evas_software_xcb_outbuf_flush,
389 evas_software_xcb_outbuf_free,
395 if (ob) evas_software_xcb_outbuf_free(ob);
402 _best_visual_get(int backend, void *connection, int screen)
404 if (!connection) return NULL;
406 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
407 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
408 return DefaultVisual((Display *)connection, screen);
411 #ifdef BUILD_ENGINE_SOFTWARE_XCB
412 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
414 xcb_screen_iterator_t iter_screen;
415 xcb_depth_iterator_t iter_depth;
416 xcb_screen_t *s = NULL;
419 xcb_setup_roots_iterator(xcb_get_setup((xcb_connection_t *)connection));
420 for (; iter_screen.rem; --screen, xcb_screen_next(&iter_screen))
423 s = iter_screen.data;
427 iter_depth = xcb_screen_allowed_depths_iterator(s);
428 for (; iter_depth.rem; xcb_depth_next(&iter_depth))
430 xcb_visualtype_iterator_t iter_vis;
432 iter_vis = xcb_depth_visuals_iterator(iter_depth.data);
433 for (; iter_vis.rem; xcb_visualtype_next(&iter_vis))
435 if (s->root_visual == iter_vis.data->visual_id)
436 return iter_vis.data;
446 _best_colormap_get(int backend, void *connection, int screen)
448 if (!connection) return 0;
450 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
451 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
452 return DefaultColormap((Display *)connection, screen);
455 #ifdef BUILD_ENGINE_SOFTWARE_XCB
456 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
458 xcb_screen_iterator_t iter_screen;
459 xcb_screen_t *s = NULL;
462 xcb_setup_roots_iterator(xcb_get_setup((xcb_connection_t *)connection));
463 for (; iter_screen.rem; --screen, xcb_screen_next(&iter_screen))
466 s = iter_screen.data;
470 if (s) return s->default_colormap;
478 _best_depth_get(int backend, void *connection, int screen)
480 if (!connection) return 0;
482 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
483 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
484 return DefaultDepth((Display *)connection, screen);
487 #ifdef BUILD_ENGINE_SOFTWARE_XCB
488 if (backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
490 xcb_screen_iterator_t iter_screen;
491 xcb_screen_t *s = NULL;
494 xcb_setup_roots_iterator(xcb_get_setup((xcb_connection_t *)connection));
495 for (; iter_screen.rem; --screen, xcb_screen_next(&iter_screen))
498 s = iter_screen.data;
502 return s->root_depth;
516 #define LINK2GENERIC(sym) \
517 glsym_##sym = dlsym(RTLD_DEFAULT, #sym);
519 // Get function pointer to native_common that is now provided through the link of SW_Generic.
520 LINK2GENERIC(_evas_native_tbm_surface_image_set);
521 LINK2GENERIC(_evas_native_tbm_surface_stride_get);
526 /* engine api this module provides */
528 eng_info(Evas *eo_e EINA_UNUSED)
530 Evas_Engine_Info_Software_X11 *info;
532 if (!(info = calloc(1, sizeof(Evas_Engine_Info_Software_X11))))
535 info->magic.magic = rand();
536 info->info.debug = 0;
537 info->info.alloc_grayscale = 0;
538 info->info.alloc_colors_max = 216;
539 info->func.best_visual_get = _best_visual_get;
540 info->func.best_colormap_get = _best_colormap_get;
541 info->func.best_depth_get = _best_depth_get;
542 info->render_mode = EVAS_RENDER_MODE_BLOCKING;
547 eng_info_free(Evas *eo_e EINA_UNUSED, void *info)
549 Evas_Engine_Info_Software_X11 *in;
551 in = (Evas_Engine_Info_Software_X11 *)info;
556 eng_setup(Evas *eo_e, void *in)
558 Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
559 Evas_Engine_Info_Software_X11 *info;
560 Render_Engine *re = NULL;
562 info = (Evas_Engine_Info_Software_X11 *)in;
563 if (!e->engine.data.output)
565 /* if we haven't initialized - init (automatic abort if already done) */
568 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
569 if (info->info.backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
571 static int try_swapbuf = -1;
574 if (try_swapbuf == -1)
576 if ((s = getenv("EVAS_NO_DRI_SWAPBUF")) != NULL)
578 if (atoi(s) == 1) try_swapbuf = 0;
579 else try_swapbuf = 1;
581 else try_swapbuf = 1;
584 re = _output_swapbuf_setup(e->output.w, e->output.h,
585 info->info.rotation, info->info.connection,
586 info->info.drawable, info->info.visual,
588 info->info.depth, info->info.debug,
589 info->info.alloc_grayscale,
590 info->info.alloc_colors_max,
591 info->info.mask, info->info.shape_dither,
592 info->info.destination_alpha);
593 if (re) re->outbuf_alpha_get = evas_software_xlib_swapbuf_alpha_get;
596 re = _output_xlib_setup(e->output.w, e->output.h,
597 info->info.rotation, info->info.connection,
598 info->info.drawable, info->info.visual,
600 info->info.depth, info->info.debug,
601 info->info.alloc_grayscale,
602 info->info.alloc_colors_max,
603 info->info.mask, info->info.shape_dither,
604 info->info.destination_alpha);
605 re->outbuf_alpha_get = evas_software_xlib_outbuf_alpha_get;
607 re->generic.ob->region_push_hook.cb = info->func.region_push_hook;
608 re->generic.ob->region_push_hook.evas = eo_e;
612 #ifdef BUILD_ENGINE_SOFTWARE_XCB
613 if (info->info.backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
615 re = _output_xcb_setup(e->output.w, e->output.h,
616 info->info.rotation, info->info.connection,
617 info->info.screen, info->info.drawable,
618 info->info.visual, info->info.colormap,
619 info->info.depth, info->info.debug,
620 info->info.alloc_grayscale,
621 info->info.alloc_colors_max,
622 info->info.mask, info->info.shape_dither,
623 info->info.destination_alpha);
624 re->outbuf_alpha_get = evas_software_xcb_outbuf_alpha_get;
625 re->generic.ob->region_push_hook.cb = info->func.region_push_hook;
626 re->generic.ob->region_push_hook.evas = eo_e;
630 e->engine.data.output = re;
635 /* int ponebuf = 0; */
637 re = e->engine.data.output;
638 /* if ((re) && (re->ob)) ponebuf = re->ob->onebuf; */
640 _outbufs = eina_list_remove(_outbufs, re->generic.ob);
642 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
643 if (info->info.backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB)
645 if (re->generic.outbuf_free == evas_software_xlib_swapbuf_free)
648 evas_software_xlib_swapbuf_setup_x(e->output.w, e->output.h,
650 OUTBUF_DEPTH_INHERIT,
651 info->info.connection,
656 info->info.alloc_grayscale,
657 info->info.alloc_colors_max,
659 info->info.shape_dither,
660 info->info.destination_alpha);
665 evas_software_xlib_outbuf_setup_x(e->output.w, e->output.h,
667 OUTBUF_DEPTH_INHERIT,
668 info->info.connection,
673 info->info.alloc_grayscale,
674 info->info.alloc_colors_max,
676 info->info.shape_dither,
677 info->info.destination_alpha);
678 evas_software_xlib_outbuf_debug_set(ob, info->info.debug);
683 #ifdef BUILD_ENGINE_SOFTWARE_XCB
684 if (info->info.backend == EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB)
687 evas_software_xcb_outbuf_setup(e->output.w, e->output.h,
689 OUTBUF_DEPTH_INHERIT,
690 info->info.connection,
696 info->info.alloc_grayscale,
697 info->info.alloc_colors_max,
699 info->info.shape_dither,
700 info->info.destination_alpha);
701 evas_software_xcb_outbuf_debug_set(ob, info->info.debug);
707 evas_render_engine_software_generic_update(&re->generic, ob, e->output.w, e->output.h);
708 ob->region_push_hook.cb = info->func.region_push_hook;
709 ob->region_push_hook.evas = eo_e;
712 /* if ((re) && (re->ob)) re->ob->onebuf = ponebuf; */
714 if (!e->engine.data.output) return 0;
715 if (!e->engine.data.context)
717 e->engine.data.context =
718 e->engine.func->context_new(e->engine.data.output);
721 re = e->engine.data.output;
722 _outbufs = eina_list_append(_outbufs, re->generic.ob);
728 eng_output_free(void *data)
732 if ((re = (Render_Engine *)data))
734 _outbufs = eina_list_remove(_outbufs, re->generic.ob);
735 evas_render_engine_software_generic_clean(&re->generic);
736 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
737 _output_egl_shutdown(re);
742 evas_common_shutdown();
746 eng_canvas_alpha_get(void *data, void *context EINA_UNUSED)
750 re = (Render_Engine *)data;
751 return (re->generic.ob->priv.destination_alpha) ||
752 (re->outbuf_alpha_get(re->generic.ob));
756 _native_evasgl_free(void *image)
758 RGBA_Image *im = image;
759 Native *n = im->native.data;
761 im->native.data = NULL;
762 im->native.func.bind = NULL;
763 im->native.func.unbind = NULL;
764 im->native.func.free = NULL;
765 //im->image.data = NULL;
770 eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
775 case EVAS_NATIVE_SURFACE_TBM:
776 return _evas_native_tbm_init();
778 case EVAS_NATIVE_SURFACE_X11:
779 case EVAS_NATIVE_SURFACE_EVASGL:
782 ERR("Native surface type %d not supported!", type);
788 eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
793 case EVAS_NATIVE_SURFACE_TBM:
794 _evas_native_tbm_shutdown();
797 case EVAS_NATIVE_SURFACE_X11:
798 case EVAS_NATIVE_SURFACE_OPENGL:
801 ERR("Native surface type %d not supported!", type);
807 eng_image_native_set(void *data EINA_UNUSED, void *image, void *native)
809 Render_Engine *re = (Render_Engine *)data;
810 Evas_Native_Surface *ns = native;
811 Image_Entry *ie = image, *ie2 = NULL;
812 RGBA_Image *im = image;
815 if (!im) return NULL;
818 if (im->native.data && im->native.func.free)
819 im->native.func.free(im);
823 if (ns->type == EVAS_NATIVE_SURFACE_X11)
827 //image have native surface already
828 Evas_Native_Surface *ens = im->native.data;
830 if ((ens->type == ns->type) &&
831 (ens->data.x11.visual == ns->data.x11.visual) &&
832 (ens->data.x11.pixmap == ns->data.x11.pixmap))
836 else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
840 //image have native surface already
841 Evas_Native_Surface *ens = im->native.data;
843 if ((ens->type == ns->type) &&
844 (ens->data.tbm.buffer == ns->data.tbm.buffer))
849 // Code from software_generic
850 if ((ns->type == EVAS_NATIVE_SURFACE_EVASGL) &&
851 (ns->version == EVAS_NATIVE_SURFACE_VERSION))
852 ie2 = evas_cache_image_data(evas_common_image_cache_get(),
853 ie->w, ie->h, ns->data.evasgl.surface, 1,
854 EVAS_COLORSPACE_ARGB8888);
855 else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
857 stride = glsym__evas_native_tbm_surface_stride_get(re->generic.ob, ns);
858 ie2 = evas_cache_image_copied_data(evas_common_image_cache_get(),
859 stride, ie->h, NULL, ie->flags.alpha,
860 EVAS_COLORSPACE_ARGB8888);
863 ie2 = evas_cache_image_data(evas_common_image_cache_get(),
864 ie->w, ie->h, NULL, ie->flags.alpha,
865 EVAS_COLORSPACE_ARGB8888);
869 if (im->native.func.free)
870 im->native.func.free(im);
874 if (evas_cserve2_use_get() && evas_cache2_image_cached(ie))
875 evas_cache2_image_close(ie);
878 evas_cache_image_drop(ie);
881 if (ns->type == EVAS_NATIVE_SURFACE_X11)
883 #ifdef BUILD_ENGINE_SOFTWARE_XLIB
884 RGBA_Image *ret_im = NULL;
885 ret_im = evas_xlib_image_dri_native_set(re->generic.ob, ie, ns);
887 ret_im = evas_xlib_image_native_set(re->generic.ob, ie, ns);
890 #ifdef BUILD_ENGINE_SOFTWARE_XCB
891 return evas_xcb_image_native_set(re->generic.ob, ie, ns);
894 else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
896 return glsym__evas_native_tbm_surface_image_set(re->generic.ob, ie, ns);
898 else if (ns->type == EVAS_NATIVE_SURFACE_EVASGL)
900 /* Native contains Evas_Native_Surface. What a mess. */
901 Native *n = calloc(1, sizeof(Native));
904 n->ns_data.evasgl.surface = ns->data.evasgl.surface;
905 im = (RGBA_Image *) ie;
906 n->ns.type = EVAS_NATIVE_SURFACE_EVASGL;
907 n->ns.version = EVAS_NATIVE_SURFACE_VERSION;
908 n->ns.data.evasgl.surface = ns->data.evasgl.surface;
910 im->native.func.free = _native_evasgl_free;
911 im->native.func.bind = NULL;
912 im->native.func.unbind = NULL;
920 eng_image_native_get(void *data EINA_UNUSED, void *image)
922 RGBA_Image *im = image;
924 if (!im) return NULL;
931 /* module advertising code */
933 module_open(Evas_Module *em)
937 /* get whatever engine module we inherit from */
938 if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
940 _evas_engine_soft_x11_log_dom =
941 eina_log_domain_register("evas-software_x11", EVAS_DEFAULT_LOG_COLOR);
943 if (_evas_engine_soft_x11_log_dom < 0)
945 EINA_LOG_ERR("Can not create a module log domain.");
949 /* store it for later use */
952 /* now to override methods */
953 #define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
957 ORD(canvas_alpha_get);
959 ORD(image_native_init);
960 ORD(image_native_shutdown);
961 ORD(image_native_set);
962 ORD(image_native_get);
965 /* now advertise out own api */
966 em->functions = (void *)(&func);
971 module_close(Evas_Module *em EINA_UNUSED)
973 eina_log_domain_unregister(_evas_engine_soft_x11_log_dom);
976 static Evas_Module_Api evas_modapi =
978 EVAS_MODULE_API_VERSION, "software_x11", "none",
985 EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_x11);
987 #ifndef EVAS_STATIC_BUILD_SOFTWARE_X11
988 EVAS_EINA_MODULE_DEFINE(engine, software_x11);