summaryrefslogtreecommitdiff
path: root/src/modules/evas
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-03-09 16:18:34 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-03-15 11:11:59 +0900
commit20b4d9dd6adb88f9dd0cd51fa849f0c360432279 (patch)
treea98d6dc1d361e843cb74fd363ecbc52b73975b05 /src/modules/evas
parenta58a3532e3e8e890b8cde0ef6d2610466beebd25 (diff)
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.
Diffstat (limited to 'src/modules/evas')
-rw-r--r--src/modules/evas/engines/gl_drm/evas_engine.c30
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c28
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c48
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c22
-rw-r--r--src/modules/evas/engines/software_generic/evas_native_common.h4
-rw-r--r--src/modules/evas/engines/software_generic/evas_native_tbm.c20
-rw-r--r--src/modules/evas/engines/software_x11/evas_engine.c39
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_engine.c39
-rw-r--r--src/modules/evas/engines/wayland_shm/evas_engine.c29
9 files changed, 248 insertions, 11 deletions
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)
1012 _re_winfree(re); 1012 _re_winfree(re);
1013} 1013}
1014 1014
1015static int
1016eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
1017{
1018 switch (type)
1019 {
1020 case EVAS_NATIVE_SURFACE_OPENGL:
1021 case EVAS_NATIVE_SURFACE_WL:
1022 return 1;
1023 default:
1024 ERR("Native surface type %d not supported!", type);
1025 return 0;
1026 }
1027}
1028
1029static void
1030eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
1031{
1032 switch (type)
1033 {
1034 case EVAS_NATIVE_SURFACE_OPENGL:
1035 case EVAS_NATIVE_SURFACE_WL:
1036 return;
1037 default:
1038 ERR("Native surface type %d not supported!", type);
1039 return;
1040 }
1041}
1042
1015static void * 1043static void *
1016eng_image_native_set(void *data, void *image, void *native) 1044eng_image_native_set(void *data, void *image, void *native)
1017{ 1045{
@@ -1270,6 +1298,8 @@ module_open(Evas_Module *em)
1270 EVAS_API_OVERRIDE(output_free, &func, eng_); 1298 EVAS_API_OVERRIDE(output_free, &func, eng_);
1271 EVAS_API_OVERRIDE(output_dump, &func, eng_); 1299 EVAS_API_OVERRIDE(output_dump, &func, eng_);
1272 EVAS_API_OVERRIDE(image_native_set, &func, eng_); 1300 EVAS_API_OVERRIDE(image_native_set, &func, eng_);
1301 EVAS_API_OVERRIDE(image_native_init, &func, eng_);
1302 EVAS_API_OVERRIDE(image_native_shutdown, &func, eng_);
1273 1303
1274 /* Mesa's EGL driver loads wayland egl by default. (called by eglGetProcaddr() ) 1304 /* Mesa's EGL driver loads wayland egl by default. (called by eglGetProcaddr() )
1275 * implicit env set (EGL_PLATFORM=drm) prevent that. */ 1305 * 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)
373 free(n); 373 free(n);
374} 374}
375 375
376static int
377eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
378{
379 switch (type)
380 {
381 case EVAS_NATIVE_SURFACE_OPENGL:
382 return 1;
383 default:
384 ERR("Native surface type %d not supported!", type);
385 return 0;
386 }
387}
388
389static void
390eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
391{
392 switch (type)
393 {
394 case EVAS_NATIVE_SURFACE_OPENGL:
395 return;
396 default:
397 ERR("Native surface type %d not supported!", type);
398 return;
399 }
400}
401
376static void * 402static void *
377eng_image_native_set(void *data, void *image, void *native) 403eng_image_native_set(void *data, void *image, void *native)
378{ 404{
@@ -2816,6 +2842,8 @@ module_open(Evas_Module *em)
2816 ORD(image_colorspace_get); 2842 ORD(image_colorspace_get);
2817 ORD(image_file_colorspace_get); 2843 ORD(image_file_colorspace_get);
2818 ORD(image_can_region_get); 2844 ORD(image_can_region_get);
2845 ORD(image_native_init);
2846 ORD(image_native_shutdown);
2819 ORD(image_native_set); 2847 ORD(image_native_set);
2820 ORD(image_native_get); 2848 ORD(image_native_get);
2821 2849
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)
2309 return yinvert; 2309 return yinvert;
2310} 2310}
2311 2311
2312static int
2313eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
2314{
2315 switch (type)
2316 {
2317#ifdef GL_GLES
2318 case EVAS_NATIVE_SURFACE_TBM:
2319 return _evas_native_tbm_init();
2320#endif
2321 case EVAS_NATIVE_SURFACE_X11:
2322 case EVAS_NATIVE_SURFACE_OPENGL:
2323 case EVAS_NATIVE_SURFACE_EVASGL:
2324 return 1;
2325#if defined(GL_GLES) && defined(HAVE_WAYLAND)
2326 case EVAS_NATIVE_SURFACE_WL:
2327 return (glsym_eglQueryWaylandBufferWL != NULL) ? 1 : 0;
2328#endif
2329 default:
2330 ERR("Native surface type %d not supported!", type);
2331 return 0;
2332 }
2333}
2334
2335static void
2336eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
2337{
2338 switch (type)
2339 {
2340#ifdef GL_GLES
2341 case EVAS_NATIVE_SURFACE_TBM:
2342 _evas_native_tbm_shutdown();
2343 return;
2344#endif
2345 case EVAS_NATIVE_SURFACE_X11:
2346 case EVAS_NATIVE_SURFACE_OPENGL:
2347 case EVAS_NATIVE_SURFACE_EVASGL:
2348#if defined(GL_GLES) && defined(HAVE_WAYLAND)
2349 case EVAS_NATIVE_SURFACE_WL:
2350#endif
2351 return;
2352 default:
2353 ERR("Native surface type %d not supported!", type);
2354 return;
2355 }
2356}
2357
2312static void * 2358static void *
2313eng_image_native_set(void *data, void *image, void *native) 2359eng_image_native_set(void *data, void *image, void *native)
2314{ 2360{
@@ -3015,6 +3061,8 @@ module_open(Evas_Module *em)
3015 ORD(output_free); 3061 ORD(output_free);
3016 ORD(output_dump); 3062 ORD(output_dump);
3017 3063
3064 ORD(image_native_init);
3065 ORD(image_native_shutdown);
3018 ORD(image_native_set); 3066 ORD(image_native_set);
3019 3067
3020 ORD(gl_error_get); 3068 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 @@
26#endif 26#endif
27 27
28#include "Evas_Engine_Software_Generic.h" 28#include "Evas_Engine_Software_Generic.h"
29#include "evas_native_common.h"
29 30
30#ifdef EVAS_GL 31#ifdef EVAS_GL
31//----------------------------------// 32//----------------------------------//
@@ -1113,6 +1114,25 @@ eng_image_colorspace_set(void *data EINA_UNUSED, void *image, Evas_Colorspace cs
1113 evas_cache_image_colorspace(im, cspace); 1114 evas_cache_image_colorspace(im, cspace);
1114} 1115}
1115 1116
1117static int
1118eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
1119{
1120 if (type == EVAS_NATIVE_SURFACE_TBM)
1121 return _evas_native_tbm_init();
1122
1123 ERR("Native surface type %d not supported!", type);
1124 return 0;
1125}
1126
1127static void
1128eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
1129{
1130 if (type == EVAS_NATIVE_SURFACE_TBM)
1131 _evas_native_tbm_shutdown();
1132 else
1133 ERR("Native surface type %d not supported!", type);
1134}
1135
1116static void * 1136static void *
1117eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) 1137eng_image_native_set(void *data EINA_UNUSED, void *image, void *native)
1118{ 1138{
@@ -4124,6 +4144,8 @@ static Evas_Func func =
4124 eng_image_colorspace_get, 4144 eng_image_colorspace_get,
4125 eng_image_file_colorspace_get, 4145 eng_image_file_colorspace_get,
4126 eng_image_can_region_get, 4146 eng_image_can_region_get,
4147 eng_image_native_init,
4148 eng_image_native_shutdown,
4127 eng_image_native_set, 4149 eng_image_native_set,
4128 eng_image_native_get, 4150 eng_image_native_get,
4129 /* image cache funcs */ 4151 /* 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
75 } ns_data; /**< Choose one union data according to your surface in Evas Engine. */ 75 } ns_data; /**< Choose one union data according to your surface in Evas Engine. */
76}; 76};
77 77
78EAPI void * evas_native_tbm_surface_image_set(void *data, void *image, void *native); 78EAPI void *_evas_native_tbm_surface_image_set(void *data, void *image, void *native);
79EAPI int _evas_native_tbm_init(void);
80EAPI void _evas_native_tbm_shutdown(void);
79 81
80typedef void *(*Evas_Native_Tbm_Surface_Image_Set_Call)(void *data, void *image, void *native); 82typedef void *(*Evas_Native_Tbm_Surface_Image_Set_Call)(void *data, void *image, void *native);
81 83
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
67static int (*sym_tbm_surface_map) (tbm_surface_h surface, int opt, tbm_surface_info_s *info) = NULL; 67static int (*sym_tbm_surface_map) (tbm_surface_h surface, int opt, tbm_surface_info_s *info) = NULL;
68static int (*sym_tbm_surface_unmap) (tbm_surface_h surface) = NULL; 68static int (*sym_tbm_surface_unmap) (tbm_surface_h surface) = NULL;
69 69
70static Eina_Bool 70EAPI int
71tbm_init(void) 71_evas_native_tbm_init(void)
72{ 72{
73 if (tbm_lib) 73 if (tbm_lib)
74 { 74 {
75 tbm_ref++; 75 tbm_ref++;
76 return EINA_TRUE; 76 return tbm_ref;
77 } 77 }
78 78
79 const char *tbm_libs[] = 79 const char *tbm_libs[] =
@@ -108,14 +108,14 @@ tbm_init(void)
108 else break; 108 else break;
109 } 109 }
110 } 110 }
111 if (!tbm_lib) return EINA_FALSE; 111 if (!tbm_lib) return 0;
112 112
113 tbm_ref++; 113 tbm_ref++;
114 return EINA_TRUE; 114 return tbm_ref;
115} 115}
116 116
117static void 117EAPI void
118tbm_shutdown(void) 118_evas_native_tbm_shutdown(void)
119{ 119{
120 if (tbm_ref > 0) 120 if (tbm_ref > 0)
121 { 121 {
@@ -254,11 +254,11 @@ _native_free_cb(void *data EINA_UNUSED, void *image)
254 254
255 free(n); 255 free(n);
256 256
257 tbm_shutdown(); 257 _evas_native_tbm_shutdown();
258} 258}
259 259
260EAPI void * 260EAPI void *
261evas_native_tbm_surface_image_set(void *data EINA_UNUSED, void *image, void *native) 261_evas_native_tbm_surface_image_set(void *data EINA_UNUSED, void *image, void *native)
262{ 262{
263 Evas_Native_Surface *ns = native; 263 Evas_Native_Surface *ns = native;
264 RGBA_Image *im = image; 264 RGBA_Image *im = image;
@@ -279,7 +279,7 @@ evas_native_tbm_surface_image_set(void *data EINA_UNUSED, void *image, void *nat
279 279
280 tbm_surf = ns->data.tbm.buffer; 280 tbm_surf = ns->data.tbm.buffer;
281 281
282 if (!tbm_init()) 282 if (!_evas_native_tbm_init())
283 { 283 {
284 ERR("Could not initialize TBM!"); 284 ERR("Could not initialize TBM!");
285 return NULL; 285 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)
671 free(n); 671 free(n);
672} 672}
673 673
674static int
675eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
676{
677 switch (type)
678 {
679#ifdef GL_GLES
680 case EVAS_NATIVE_SURFACE_TBM:
681 return _evas_native_tbm_init();
682#endif
683 case EVAS_NATIVE_SURFACE_X11:
684 case EVAS_NATIVE_SURFACE_EVASGL:
685 return 1;
686 default:
687 ERR("Native surface type %d not supported!", type);
688 return 0;
689 }
690}
691
692static void
693eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
694{
695 switch (type)
696 {
697#ifdef GL_GLES
698 case EVAS_NATIVE_SURFACE_TBM:
699 _evas_native_tbm_shutdown();
700 return;
701#endif
702 case EVAS_NATIVE_SURFACE_X11:
703 case EVAS_NATIVE_SURFACE_OPENGL:
704 return;
705 default:
706 ERR("Native surface type %d not supported!", type);
707 return;
708 }
709}
710
674static void * 711static void *
675eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) 712eng_image_native_set(void *data EINA_UNUSED, void *image, void *native)
676{ 713{
@@ -817,6 +854,8 @@ module_open(Evas_Module *em)
817 ORD(setup); 854 ORD(setup);
818 ORD(canvas_alpha_get); 855 ORD(canvas_alpha_get);
819 ORD(output_free); 856 ORD(output_free);
857 ORD(image_native_init);
858 ORD(image_native_shutdown);
820 ORD(image_native_set); 859 ORD(image_native_set);
821 ORD(image_native_get); 860 ORD(image_native_get);
822 861
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)
992 return yinvert; 992 return yinvert;
993} 993}
994 994
995static int
996eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
997{
998 switch (type)
999 {
1000#ifdef GL_GLES
1001 case EVAS_NATIVE_SURFACE_TBM:
1002 return _evas_native_tbm_init();
1003#endif
1004 case EVAS_NATIVE_SURFACE_EVASGL:
1005 case EVAS_NATIVE_SURFACE_OPENGL:
1006 case EVAS_NATIVE_SURFACE_WL:
1007 return 1;
1008 default:
1009 ERR("Native surface type %d not supported!", type);
1010 return 0;
1011 }
1012}
1013
1014static void
1015eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
1016{
1017 switch (type)
1018 {
1019#ifdef GL_GLES
1020 case EVAS_NATIVE_SURFACE_TBM:
1021 _evas_native_tbm_shutdown();
1022 return;
1023#endif
1024 case EVAS_NATIVE_SURFACE_EVASGL:
1025 case EVAS_NATIVE_SURFACE_OPENGL:
1026 case EVAS_NATIVE_SURFACE_WL:
1027 return;
1028 default:
1029 ERR("Native surface type %d not supported!", type);
1030 return;
1031 }
1032}
1033
995static void * 1034static void *
996eng_image_native_set(void *data, void *image, void *native) 1035eng_image_native_set(void *data, void *image, void *native)
997{ 1036{
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)
265 re->generic.h = h; 265 re->generic.h = h;
266} 266}
267 267
268static int
269eng_image_native_init(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
270{
271 switch (type)
272 {
273 case EVAS_NATIVE_SURFACE_TBM:
274 return _evas_native_tbm_init();
275 default:
276 ERR("Native surface type %d not supported!", type);
277 return 0;
278 }
279}
280
281static void
282eng_image_native_shutdown(void *data EINA_UNUSED, Evas_Native_Surface_Type type)
283{
284 switch (type)
285 {
286 case EVAS_NATIVE_SURFACE_TBM:
287 _evas_native_tbm_shutdown();
288 return;
289 default:
290 ERR("Native surface type %d not supported!", type);
291 return;
292 }
293}
294
268static void * 295static void *
269eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) 296eng_image_native_set(void *data EINA_UNUSED, void *image, void *native)
270{ 297{
@@ -287,6 +314,8 @@ eng_image_native_set(void *data EINA_UNUSED, void *image, void *native)
287 } 314 }
288 } 315 }
289 316
317 /* FIXME: WTF is this? OPENGL supported here? uh? and x11.visual used???
318 * It looks like this code needs to fail and return NULL. */
290 if ((ns->type == EVAS_NATIVE_SURFACE_OPENGL) && 319 if ((ns->type == EVAS_NATIVE_SURFACE_OPENGL) &&
291 (ns->version == EVAS_NATIVE_SURFACE_VERSION)) 320 (ns->version == EVAS_NATIVE_SURFACE_VERSION))
292 im2 = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(), 321 im2 = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),