summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-12-19 14:33:09 -0600
committerDerek Foreman <derekf@osg.samsung.com>2016-12-19 15:52:58 -0600
commit74a456253a2365911222b602cd4b77da33f9c6d5 (patch)
tree23ff8678b48fda2d2c05918b66526390a5a2419d /src
parent98ef74eeba5dbc8ff62dccca9a317ef7dd64e2bf (diff)
gl_common: Make secsym_eglCreateImage a wrapper
eglCreateImage and eglCreateImageKHR are subtly different. Now we try to handle them both properly by exposing an abstraction.
Diffstat (limited to 'src')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h6
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c46
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_texture.c18
3 files changed, 51 insertions, 19 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h
index c83a828114..eaff9276de 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -32,6 +32,7 @@
32# endif 32# endif
33# else 33# else
34# ifdef GL_GLES 34# ifdef GL_GLES
35# include <EGL/egl.h>
35# include <GLES2/gl2.h> 36# include <GLES2/gl2.h>
36# include <GLES2/gl2ext.h> 37# include <GLES2/gl2ext.h>
37# else 38# else
@@ -713,7 +714,7 @@ extern void *(*glsym_glMapBuffer) (GLenum a, GLenum b);
713extern GLboolean (*glsym_glUnmapBuffer) (GLenum a); 714extern GLboolean (*glsym_glUnmapBuffer) (GLenum a);
714 715
715#ifdef GL_GLES 716#ifdef GL_GLES
716extern void *(*secsym_eglCreateImage) (void *a, void *b, GLenum c, void *d, const int *e); 717EAPI void * evas_gl_common_eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
717extern unsigned int (*secsym_eglDestroyImage) (void *a, void *b); 718extern unsigned int (*secsym_eglDestroyImage) (void *a, void *b);
718extern void (*secsym_glEGLImageTargetTexture2DOES) (int a, void *b); 719extern void (*secsym_glEGLImageTargetTexture2DOES) (int a, void *b);
719extern void *(*secsym_eglMapImageSEC) (void *a, void *b, int c, int d); 720extern void *(*secsym_eglMapImageSEC) (void *a, void *b, int c, int d);
@@ -873,7 +874,8 @@ __evas_gl_errdyn(int err, const char *file, const char *func, int line, const ch
873# define glsym_glReleaseShaderCompiler(...) GL_ERROR_TRACE(glsym_glReleaseShaderCompiler, #__VA_ARGS__, __VA_ARGS__) 874# define glsym_glReleaseShaderCompiler(...) GL_ERROR_TRACE(glsym_glReleaseShaderCompiler, #__VA_ARGS__, __VA_ARGS__)
874# define glsym_glMapBuffer(...) GL_ERROR_TRACE_RET(void *, glsym_glMapBuffer, #__VA_ARGS__, __VA_ARGS__) 875# define glsym_glMapBuffer(...) GL_ERROR_TRACE_RET(void *, glsym_glMapBuffer, #__VA_ARGS__, __VA_ARGS__)
875# define glsym_glUnmapBuffer(...) GL_ERROR_TRACE_RET(unsigned int, glsym_glUnmapBuffer, #__VA_ARGS__, __VA_ARGS__) 876# define glsym_glUnmapBuffer(...) GL_ERROR_TRACE_RET(unsigned int, glsym_glUnmapBuffer, #__VA_ARGS__, __VA_ARGS__)
876# define secsym_eglCreateImage(...) GL_ERROR_TRACE_RET(void *, secsym_eglCreateImage, #__VA_ARGS__, __VA_ARGS__) 877# define eglsym_eglCreateImage(...) GL_ERROR_TRACE_RET(void *, eglsym_eglCreateImage, #__VA_ARGS__, __VA_ARGS__)
878# define eglsym_eglCreateImageKHR(...) GL_ERROR_TRACE_RET(void *, eglsym_eglCreateImageKHR, #__VA_ARGS__, __VA_ARGS__)
877# define secsym_eglDestroyImage(...) GL_ERROR_TRACE_RET(unsigned int, secsym_eglDestroyImage, #__VA_ARGS__, __VA_ARGS__) 879# define secsym_eglDestroyImage(...) GL_ERROR_TRACE_RET(unsigned int, secsym_eglDestroyImage, #__VA_ARGS__, __VA_ARGS__)
878# define secsym_glEGLImageTargetTexture2DOES(...) GL_ERROR_TRACE(secsym_glEGLImageTargetTexture2DOES, #__VA_ARGS__, __VA_ARGS__) 880# define secsym_glEGLImageTargetTexture2DOES(...) GL_ERROR_TRACE(secsym_glEGLImageTargetTexture2DOES, #__VA_ARGS__, __VA_ARGS__)
879# define secsym_eglMapImageSEC(...) GL_ERROR_TRACE_RET(void *, secsym_eglMapImageSEC, #__VA_ARGS__, __VA_ARGS__) 881# define secsym_eglMapImageSEC(...) GL_ERROR_TRACE_RET(void *, secsym_eglMapImageSEC, #__VA_ARGS__, __VA_ARGS__)
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c
index e0cd1f776e..8cca90a3d9 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -49,13 +49,18 @@ typedef int (*secsym_func_int) ();
49typedef unsigned int (*secsym_func_uint) (); 49typedef unsigned int (*secsym_func_uint) ();
50typedef void *(*secsym_func_void_ptr) (); 50typedef void *(*secsym_func_void_ptr) ();
51 51
52void *(*secsym_eglCreateImage) (void *a, void *b, GLenum c, void *d, const int *e) = NULL;
53unsigned int (*secsym_eglDestroyImage) (void *a, void *b) = NULL; 52unsigned int (*secsym_eglDestroyImage) (void *a, void *b) = NULL;
54void (*secsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL; 53void (*secsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
55void *(*secsym_eglMapImageSEC) (void *a, void *b, int c, int d) = NULL; 54void *(*secsym_eglMapImageSEC) (void *a, void *b, int c, int d) = NULL;
56unsigned int (*secsym_eglUnmapImageSEC) (void *a, void *b, int c) = NULL; 55unsigned int (*secsym_eglUnmapImageSEC) (void *a, void *b, int c) = NULL;
57unsigned int (*secsym_eglGetImageAttribSEC) (void *a, void *b, int c, int *d) = NULL; 56unsigned int (*secsym_eglGetImageAttribSEC) (void *a, void *b, int c, int *d) = NULL;
58 57
58
59/* This one is now a local wrapper to avoid type mixups */
60void * evas_gl_common_eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list);
61static void * (*eglsym_eglCreateImage) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list) = NULL;
62static void * (*eglsym_eglCreateImageKHR) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *e) = NULL;
63
59//////////////////////////////////// 64////////////////////////////////////
60//libtbm.so.1 65//libtbm.so.1
61static void *tbm_lib_handle; 66static void *tbm_lib_handle;
@@ -114,6 +119,32 @@ _has_ext(const char *ext, const char **pexts, int *pnum)
114 } 119 }
115} 120}
116 121
122#ifdef GL_GLES
123void *
124evas_gl_common_eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list)
125{
126 if (eglsym_eglCreateImage)
127 return eglsym_eglCreateImage(dpy, ctx, target, buffer, attrib_list);
128 if (eglsym_eglCreateImageKHR)
129 {
130 int count, i;
131 EGLint *ints = NULL;
132
133 if (attrib_list)
134 {
135 for (count = 0; attrib_list[count] != EGL_NONE; count += 2);
136 count++;
137 ints = alloca(count * sizeof(EGLint));
138 for (i = 0; i < count; i++)
139 ints[i] = attrib_list[i];
140 }
141 return eglsym_eglCreateImageKHR(dpy, ctx, target, buffer, ints);
142 }
143 return NULL;
144}
145
146#endif
147
117/* FIXME: return error if a required symbol was not found */ 148/* FIXME: return error if a required symbol was not found */
118EAPI void 149EAPI void
119evas_gl_symbols(void *(*GetProcAddress)(const char *name)) 150evas_gl_symbols(void *(*GetProcAddress)(const char *name))
@@ -267,11 +298,11 @@ evas_gl_symbols(void *(*GetProcAddress)(const char *name))
267// wrong as this is not x11 (output) layer specific like the native surface 298// wrong as this is not x11 (output) layer specific like the native surface
268// stuff. this is generic zero-copy textures for gl 299// stuff. this is generic zero-copy textures for gl
269 300
270 FINDSYM(secsym_eglCreateImage, "eglCreateImage", NULL, secsym_func_void_ptr); 301 FINDSYM(eglsym_eglCreateImage, "eglCreateImage", NULL, secsym_func_void_ptr);
271 FINDSYM(secsym_eglCreateImage, "eglCreateImageKHR", "EGL_KHR_image_base", secsym_func_void_ptr); 302 FINDSYM(eglsym_eglCreateImageKHR, "eglCreateImageKHR", "EGL_KHR_image_base", secsym_func_void_ptr);
272 FINDSYM(secsym_eglCreateImage, "eglCreateImageKHR", "EGL_KHR_image", secsym_func_void_ptr); 303 FINDSYM(eglsym_eglCreateImageKHR, "eglCreateImageKHR", "EGL_KHR_image", secsym_func_void_ptr);
273 FINDSYM(secsym_eglCreateImage, "eglCreateImageOES", "GL_OES_EGL_image_base", secsym_func_void_ptr); 304 FINDSYM(eglsym_eglCreateImageKHR, "eglCreateImageOES", "GL_OES_EGL_image_base", secsym_func_void_ptr);
274 FINDSYM(secsym_eglCreateImage, "eglCreateImageOES", "GL_OES_EGL_image", secsym_func_void_ptr); 305 FINDSYM(eglsym_eglCreateImageKHR, "eglCreateImageOES", "GL_OES_EGL_image", secsym_func_void_ptr);
275 306
276 FINDSYM(secsym_eglDestroyImage, "eglDestroyImage", NULL, secsym_func_uint); 307 FINDSYM(secsym_eglDestroyImage, "eglDestroyImage", NULL, secsym_func_uint);
277 FINDSYM(secsym_eglDestroyImage, "eglDestroyImageKHR", "EGL_KHR_image_base", secsym_func_uint); 308 FINDSYM(secsym_eglDestroyImage, "eglDestroyImageKHR", "EGL_KHR_image_base", secsym_func_uint);
@@ -842,8 +873,7 @@ evas_gl_common_context_new(void)
842 { 873 {
843 // test for all needed symbols - be "conservative" and 874 // test for all needed symbols - be "conservative" and
844 // need all of it 875 // need all of it
845 if ((secsym_eglCreateImage) && 876 if ((secsym_eglDestroyImage) &&
846 (secsym_eglDestroyImage) &&
847 (secsym_glEGLImageTargetTexture2DOES) && 877 (secsym_glEGLImageTargetTexture2DOES) &&
848 (secsym_eglMapImageSEC) && 878 (secsym_eglMapImageSEC) &&
849 (secsym_eglUnmapImageSEC) && 879 (secsym_eglUnmapImageSEC) &&
diff --git a/src/modules/evas/engines/gl_common/evas_gl_texture.c b/src/modules/evas/engines/gl_common/evas_gl_texture.c
index 7158e30263..903a60b214 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_texture.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_texture.c
@@ -849,10 +849,10 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
849 buffer_format); 849 buffer_format);
850 if (!pt->dyn.buffer) goto error; 850 if (!pt->dyn.buffer) goto error;
851 851
852 pt->dyn.img = secsym_eglCreateImage(egldisplay, 852 pt->dyn.img = evas_gl_common_eglCreateImage(egldisplay,
853 EGL_NO_CONTEXT, 853 EGL_NO_CONTEXT,
854 EGL_NATIVE_SURFACE_TIZEN, 854 EGL_NATIVE_SURFACE_TIZEN,
855 pt->dyn.buffer, NULL); 855 pt->dyn.buffer, NULL);
856 if (!pt->dyn.img) 856 if (!pt->dyn.img)
857 { 857 {
858 secsym_tbm_surface_destroy(pt->dyn.buffer); 858 secsym_tbm_surface_destroy(pt->dyn.buffer);
@@ -867,7 +867,7 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
867 { 867 {
868 int fmt; // EGL_MAP_GL_TEXTURE_RGBA_SEC or EGL_MAP_GL_TEXTURE_RGB_SEC or bust 868 int fmt; // EGL_MAP_GL_TEXTURE_RGBA_SEC or EGL_MAP_GL_TEXTURE_RGB_SEC or bust
869 int pixtype; // EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC or bust 869 int pixtype; // EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC or bust
870 int attr[] = 870 EGLAttrib attr[] =
871 { 871 {
872 EGL_MAP_GL_TEXTURE_WIDTH_SEC, 32, 872 EGL_MAP_GL_TEXTURE_WIDTH_SEC, 32,
873 EGL_MAP_GL_TEXTURE_HEIGHT_SEC, 32, 873 EGL_MAP_GL_TEXTURE_HEIGHT_SEC, 32,
@@ -894,10 +894,10 @@ _pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, i
894 894
895 // FIXME: seems a bit slower than i'd like - maybe too many flushes? 895 // FIXME: seems a bit slower than i'd like - maybe too many flushes?
896 // FIXME: YCbCr no support as yet 896 // FIXME: YCbCr no support as yet
897 pt->dyn.img = secsym_eglCreateImage(egldisplay, 897 pt->dyn.img = evas_gl_common_eglCreateImage(egldisplay,
898 EGL_NO_CONTEXT, 898 EGL_NO_CONTEXT,
899 EGL_MAP_GL_TEXTURE_2D_SEC, 899 EGL_MAP_GL_TEXTURE_2D_SEC,
900 0, attr); 900 0, attr);
901 if (!pt->dyn.img) goto error; 901 if (!pt->dyn.img) goto error;
902 902
903 if (secsym_eglGetImageAttribSEC(egldisplay, 903 if (secsym_eglGetImageAttribSEC(egldisplay,