diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2016-03-09 16:18:34 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2016-03-15 11:11:59 +0900 |
commit | 20b4d9dd6adb88f9dd0cd51fa849f0c360432279 (patch) | |
tree | a98d6dc1d361e843cb74fd363ecbc52b73975b05 | |
parent | a58a3532e3e8e890b8cde0ef6d2610466beebd25 (diff) | |
download | efl-20b4d9dd6adb88f9dd0cd51fa849f0c360432279.tar.gz |
Evas engines: Add internal functions for native images
- image_native_init
- image_native_shutdown
init() will be used to test whether the engine supports a
certain type of native image.
Note: Native image support is very much dependent on the engine,
and some stuff like opengl should work everywhere (even in sw
with osmesa) but that's not the case.
-rw-r--r-- | src/lib/evas/include/evas_private.h | 3 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_drm/evas_engine.c | 30 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_generic/evas_engine.c | 28 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_x11/evas_engine.c | 48 | ||||
-rw-r--r-- | src/modules/evas/engines/software_generic/evas_engine.c | 22 | ||||
-rw-r--r-- | src/modules/evas/engines/software_generic/evas_native_common.h | 4 | ||||
-rw-r--r-- | src/modules/evas/engines/software_generic/evas_native_tbm.c | 20 | ||||
-rw-r--r-- | src/modules/evas/engines/software_x11/evas_engine.c | 39 | ||||
-rw-r--r-- | src/modules/evas/engines/wayland_egl/evas_engine.c | 39 | ||||
-rw-r--r-- | src/modules/evas/engines/wayland_shm/evas_engine.c | 29 |
10 files changed, 251 insertions, 11 deletions
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 759327f5d6..9683e5c576 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1348,6 +1348,9 @@ struct _Evas_Func Evas_Colorspace (*image_colorspace_get) (void *data, void *image); Evas_Colorspace (*image_file_colorspace_get)(void *data, void *image); Eina_Bool (*image_can_region_get) (void *data, void *image); + + int (*image_native_init) (void *data, Evas_Native_Surface_Type type); + void (*image_native_shutdown) (void *data, Evas_Native_Surface_Type type); void *(*image_native_set) (void *data, void *image, void *native); void *(*image_native_get) (void *data, void *image); diff --git a/src/modules/evas/engines/gl_drm/evas_engine.c b/src/modules/evas/engines/gl_drm/evas_engine.c index a8261448fc..3973a5f326 100644 --- a/src/modules/evas/engines/gl_drm/evas_engine.c +++ b/src/modules/evas/engines/gl_drm/evas_engine.c @@ -1012,6 +1012,34 @@ eng_output_dump(void *data) _re_winfree(re); } +static int +eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { + case EVAS_NATIVE_SURFACE_OPENGL: + case EVAS_NATIVE_SURFACE_WL: + return 1; + default: + ERR("Native surface type %d not supported!", type); + return 0; + } +} + +static void +eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { + case EVAS_NATIVE_SURFACE_OPENGL: + case EVAS_NATIVE_SURFACE_WL: + return; + default: + ERR("Native surface type %d not supported!", type); + return; + } +} + static void * eng_image_native_set(void *data, void *image, void *native) { @@ -1270,6 +1298,8 @@ module_open(Evas_Module *em) EVAS_API_OVERRIDE(output_free, &func, eng_); EVAS_API_OVERRIDE(output_dump, &func, eng_); EVAS_API_OVERRIDE(image_native_set, &func, eng_); + EVAS_API_OVERRIDE(image_native_init, &func, eng_); + EVAS_API_OVERRIDE(image_native_shutdown, &func, eng_); /* Mesa's EGL driver loads wayland egl by default. (called by eglGetProcaddr() ) * implicit env set (EGL_PLATFORM=drm) prevent that. */ diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index d296cf660e..11f9581ac7 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -373,6 +373,32 @@ _native_free_cb(void *data, void *image) free(n); } +static int +eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { + case EVAS_NATIVE_SURFACE_OPENGL: + return 1; + default: + ERR("Native surface type %d not supported!", type); + return 0; + } +} + +static void +eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { + case EVAS_NATIVE_SURFACE_OPENGL: + return; + default: + ERR("Native surface type %d not supported!", type); + return; + } +} + static void * eng_image_native_set(void *data, void *image, void *native) { @@ -2816,6 +2842,8 @@ module_open(Evas_Module *em) ORD(image_colorspace_get); ORD(image_file_colorspace_get); ORD(image_can_region_get); + ORD(image_native_init); + ORD(image_native_shutdown); ORD(image_native_set); ORD(image_native_get); diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c index 8524d495fe..e48dea03a0 100644 --- a/src/modules/evas/engines/gl_x11/evas_engine.c +++ b/src/modules/evas/engines/gl_x11/evas_engine.c @@ -2309,6 +2309,52 @@ _native_yinvert_cb(void *data, void *image) return yinvert; } +static int +eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { +#ifdef GL_GLES + case EVAS_NATIVE_SURFACE_TBM: + return _evas_native_tbm_init(); +#endif + case EVAS_NATIVE_SURFACE_X11: + case EVAS_NATIVE_SURFACE_OPENGL: + case EVAS_NATIVE_SURFACE_EVASGL: + return 1; +#if defined(GL_GLES) && defined(HAVE_WAYLAND) + case EVAS_NATIVE_SURFACE_WL: + return (glsym_eglQueryWaylandBufferWL != NULL) ? 1 : 0; +#endif + default: + ERR("Native surface type %d not supported!", type); + return 0; + } +} + +static void +eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { +#ifdef GL_GLES + case EVAS_NATIVE_SURFACE_TBM: + _evas_native_tbm_shutdown(); + return; +#endif + case EVAS_NATIVE_SURFACE_X11: + case EVAS_NATIVE_SURFACE_OPENGL: + case EVAS_NATIVE_SURFACE_EVASGL: +#if defined(GL_GLES) && defined(HAVE_WAYLAND) + case EVAS_NATIVE_SURFACE_WL: +#endif + return; + default: + ERR("Native surface type %d not supported!", type); + return; + } +} + static void * eng_image_native_set(void *data, void *image, void *native) { @@ -3015,6 +3061,8 @@ module_open(Evas_Module *em) ORD(output_free); ORD(output_dump); + ORD(image_native_init); + ORD(image_native_shutdown); ORD(image_native_set); ORD(gl_error_get); diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index f2018a626b..c28872cf0b 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -26,6 +26,7 @@ #endif #include "Evas_Engine_Software_Generic.h" +#include "evas_native_common.h" #ifdef EVAS_GL //----------------------------------// @@ -1113,6 +1114,25 @@ eng_image_colorspace_set(void *data EINA_UNUSED, void *image, Evas_Colorspace cs evas_cache_image_colorspace(im, cspace); } +static int +eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + if (type == EVAS_NATIVE_SURFACE_TBM) + return _evas_native_tbm_init(); + + ERR("Native surface type %d not supported!", type); + return 0; +} + +static void +eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + if (type == EVAS_NATIVE_SURFACE_TBM) + _evas_native_tbm_shutdown(); + else + ERR("Native surface type %d not supported!", type); +} + static void * eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) { @@ -4124,6 +4144,8 @@ static Evas_Func func = eng_image_colorspace_get, eng_image_file_colorspace_get, eng_image_can_region_get, + eng_image_native_init, + eng_image_native_shutdown, eng_image_native_set, eng_image_native_get, /* image cache funcs */ diff --git a/src/modules/evas/engines/software_generic/evas_native_common.h b/src/modules/evas/engines/software_generic/evas_native_common.h index 0ff0b7437d..0ea2b66862 100644 --- a/src/modules/evas/engines/software_generic/evas_native_common.h +++ b/src/modules/evas/engines/software_generic/evas_native_common.h @@ -75,7 +75,9 @@ struct _Native } ns_data; /**< Choose one union data according to your surface in Evas Engine. */ }; -EAPI void * evas_native_tbm_surface_image_set(void *data, void *image, void *native); +EAPI void *_evas_native_tbm_surface_image_set(void *data, void *image, void *native); +EAPI int _evas_native_tbm_init(void); +EAPI void _evas_native_tbm_shutdown(void); typedef void *(*Evas_Native_Tbm_Surface_Image_Set_Call)(void *data, void *image, void *native); diff --git a/src/modules/evas/engines/software_generic/evas_native_tbm.c b/src/modules/evas/engines/software_generic/evas_native_tbm.c index b6931a99f3..c046422a7d 100644 --- a/src/modules/evas/engines/software_generic/evas_native_tbm.c +++ b/src/modules/evas/engines/software_generic/evas_native_tbm.c @@ -67,13 +67,13 @@ typedef struct _tbm_surface_info static int (*sym_tbm_surface_map) (tbm_surface_h surface, int opt, tbm_surface_info_s *info) = NULL; static int (*sym_tbm_surface_unmap) (tbm_surface_h surface) = NULL; -static Eina_Bool -tbm_init(void) +EAPI int +_evas_native_tbm_init(void) { if (tbm_lib) { tbm_ref++; - return EINA_TRUE; + return tbm_ref; } const char *tbm_libs[] = @@ -108,14 +108,14 @@ tbm_init(void) else break; } } - if (!tbm_lib) return EINA_FALSE; + if (!tbm_lib) return 0; tbm_ref++; - return EINA_TRUE; + return tbm_ref; } -static void -tbm_shutdown(void) +EAPI void +_evas_native_tbm_shutdown(void) { if (tbm_ref > 0) { @@ -254,11 +254,11 @@ _native_free_cb(void *data EINA_UNUSED, void *image) free(n); - tbm_shutdown(); + _evas_native_tbm_shutdown(); } EAPI void * -evas_native_tbm_surface_image_set(void *data EINA_UNUSED, void *image, void *native) +_evas_native_tbm_surface_image_set(void *data EINA_UNUSED, void *image, void *native) { Evas_Native_Surface *ns = native; RGBA_Image *im = image; @@ -279,7 +279,7 @@ evas_native_tbm_surface_image_set(void *data EINA_UNUSED, void *image, void *nat tbm_surf = ns->data.tbm.buffer; - if (!tbm_init()) + if (!_evas_native_tbm_init()) { ERR("Could not initialize TBM!"); return NULL; diff --git a/src/modules/evas/engines/software_x11/evas_engine.c b/src/modules/evas/engines/software_x11/evas_engine.c index b6dc615f48..8f68d43f6e 100644 --- a/src/modules/evas/engines/software_x11/evas_engine.c +++ b/src/modules/evas/engines/software_x11/evas_engine.c @@ -671,6 +671,43 @@ _native_evasgl_free(void *data EINA_UNUSED, void *image) free(n); } +static int +eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { +#ifdef GL_GLES + case EVAS_NATIVE_SURFACE_TBM: + return _evas_native_tbm_init(); +#endif + case EVAS_NATIVE_SURFACE_X11: + case EVAS_NATIVE_SURFACE_EVASGL: + return 1; + default: + ERR("Native surface type %d not supported!", type); + return 0; + } +} + +static void +eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { +#ifdef GL_GLES + case EVAS_NATIVE_SURFACE_TBM: + _evas_native_tbm_shutdown(); + return; +#endif + case EVAS_NATIVE_SURFACE_X11: + case EVAS_NATIVE_SURFACE_OPENGL: + return; + default: + ERR("Native surface type %d not supported!", type); + return; + } +} + static void * eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) { @@ -817,6 +854,8 @@ module_open(Evas_Module *em) ORD(setup); ORD(canvas_alpha_get); ORD(output_free); + ORD(image_native_init); + ORD(image_native_shutdown); ORD(image_native_set); ORD(image_native_get); diff --git a/src/modules/evas/engines/wayland_egl/evas_engine.c b/src/modules/evas/engines/wayland_egl/evas_engine.c index 4e7674d2ee..a33c904095 100644 --- a/src/modules/evas/engines/wayland_egl/evas_engine.c +++ b/src/modules/evas/engines/wayland_egl/evas_engine.c @@ -992,6 +992,45 @@ _native_cb_yinvert(void *data EINA_UNUSED, void *image) return yinvert; } +static int +eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { +#ifdef GL_GLES + case EVAS_NATIVE_SURFACE_TBM: + return _evas_native_tbm_init(); +#endif + case EVAS_NATIVE_SURFACE_EVASGL: + case EVAS_NATIVE_SURFACE_OPENGL: + case EVAS_NATIVE_SURFACE_WL: + return 1; + default: + ERR("Native surface type %d not supported!", type); + return 0; + } +} + +static void +eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { +#ifdef GL_GLES + case EVAS_NATIVE_SURFACE_TBM: + _evas_native_tbm_shutdown(); + return; +#endif + case EVAS_NATIVE_SURFACE_EVASGL: + case EVAS_NATIVE_SURFACE_OPENGL: + case EVAS_NATIVE_SURFACE_WL: + return; + default: + ERR("Native surface type %d not supported!", type); + return; + } +} + static void * eng_image_native_set(void *data, void *image, void *native) { diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.c b/src/modules/evas/engines/wayland_shm/evas_engine.c index 5f1f78aab9..adf33f68b0 100644 --- a/src/modules/evas/engines/wayland_shm/evas_engine.c +++ b/src/modules/evas/engines/wayland_shm/evas_engine.c @@ -265,6 +265,33 @@ eng_output_resize(void *data, int w, int h) re->generic.h = h; } +static int +eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { + case EVAS_NATIVE_SURFACE_TBM: + return _evas_native_tbm_init(); + default: + ERR("Native surface type %d not supported!", type); + return 0; + } +} + +static void +eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type) +{ + switch (type) + { + case EVAS_NATIVE_SURFACE_TBM: + _evas_native_tbm_shutdown(); + return; + default: + ERR("Native surface type %d not supported!", type); + return; + } +} + static void * eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) { @@ -287,6 +314,8 @@ eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) } } + /* FIXME: WTF is this? OPENGL supported here? uh? and x11.visual used??? + * It looks like this code needs to fail and return NULL. */ if ((ns->type == EVAS_NATIVE_SURFACE_OPENGL) && (ns->version == EVAS_NATIVE_SURFACE_VERSION)) im2 = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(), |