summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongyeon Kim <dy5.kim@samsung.com>2015-04-21 10:54:02 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-03 11:30:22 +0900
commitb0d2643f933bca2d959b873701c85c6f237328e9 (patch)
tree717d4b0d1daf101aa98ad74a95eb4cb8033dff77
parent63e057bff9f8a4acdc374e8a8fe697d5d1e758d6 (diff)
Evas GL: Add indirect surface fallback and yinvert callback
Summary: When either FBO or EGL image from texture extension is not supported, we can use pixmap surface as indirect surface fallback. Since native pixmaps have (0,0) in the upper left while FBOs have (0,0) in the lower left, we should invert the y coordinates when native pixmaps are used as the render target. To accomodate run-time y-invert check we add a new callback for EVAS_NATIVE_SURFACE_EVASGL type. Reviewers: cedric, jpeg Subscribers: wonsik, mer.kim, cedric
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h7
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c23
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.c82
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.h7
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core_private.h3
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c151
6 files changed, 191 insertions, 82 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 d2cc58a025..877842a3f7 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -657,9 +657,10 @@ struct _Evas_GL_Image
657 struct { 657 struct {
658 void *data; 658 void *data;
659 struct { 659 struct {
660 void (*bind) (void *data, void *image); 660 void (*bind) (void *data, void *image);
661 void (*unbind) (void *data, void *image); 661 void (*unbind) (void *data, void *image);
662 void (*free) (void *data, void *image); 662 void (*free) (void *data, void *image);
663 int (*yinvert) (void *data, void *image);
663 void *data; 664 void *data;
664 } func; 665 } func;
665 int yinvert; 666 int yinvert;
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 c89c41bed3..eed625bd0e 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -2029,6 +2029,7 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
2029 Evas_GL_Shader shader = SHADER_IMG; 2029 Evas_GL_Shader shader = SHADER_IMG;
2030 GLuint prog = gc->shared->shader[shader].prog; 2030 GLuint prog = gc->shared->shader[shader].prog;
2031 int pn = 0, sam = 0, render_op = gc->dc->render_op, nomul = 0; 2031 int pn = 0, sam = 0, render_op = gc->dc->render_op, nomul = 0;
2032 int yinvert = 0;
2032 2033
2033 if (!!mtex) 2034 if (!!mtex)
2034 { 2035 {
@@ -2121,7 +2122,15 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
2121 ox4 = sx; 2122 ox4 = sx;
2122 oy4 = sy + sh; 2123 oy4 = sy + sh;
2123 2124
2124 if (tex->im) 2125 if ((tex->im) && (tex->im->native.data))
2126 {
2127 if (tex->im->native.func.yinvert)
2128 yinvert = tex->im->native.func.yinvert(tex->im->native.func.data, tex->im);
2129 else
2130 yinvert = tex->im->native.yinvert;
2131 }
2132
2133 if ((tex->im) && (tex->im->native.data) && (!yinvert))
2125 { 2134 {
2126 switch (tex->im->orient) 2135 switch (tex->im->orient)
2127 { 2136 {
@@ -2707,7 +2716,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2707 Eina_Bool use_texa = EINA_FALSE; 2716 Eina_Bool use_texa = EINA_FALSE;
2708 Shader_Type type; 2717 Shader_Type type;
2709 int pn = 0, i; 2718 int pn = 0, i;
2710 int flat = 0, nomul = 0; 2719 int flat = 0, nomul = 0, yinvert = 0;
2711 GLuint prog; 2720 GLuint prog;
2712 2721
2713 if (!(gc->dc->render_op == EVAS_RENDER_COPY) && 2722 if (!(gc->dc->render_op == EVAS_RENDER_COPY) &&
@@ -2868,7 +2877,15 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2868 pipe_region_expand(gc, pn, x, y, w, h); 2877 pipe_region_expand(gc, pn, x, y, w, h);
2869 PIPE_GROW(gc, pn, 6); 2878 PIPE_GROW(gc, pn, 6);
2870 2879
2871 if ((tex->im) && (tex->im->native.data) && (!tex->im->native.yinvert)) 2880 if ((tex->im) && (tex->im->native.data))
2881 {
2882 if (tex->im->native.func.yinvert)
2883 yinvert = tex->im->native.func.yinvert(tex->im->native.func.data, tex->im);
2884 else
2885 yinvert = tex->im->native.yinvert;
2886 }
2887
2888 if ((tex->im) && (tex->im->native.data) && (!yinvert))
2872 { 2889 {
2873 for (i = 0; i < 4; i++) 2890 for (i = 0; i < 4; i++)
2874 { 2891 {
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c
index f53ee1a6d6..ec32d98334 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -239,32 +239,36 @@ _texture_attach_2d(GLuint tex, GLenum attach, GLenum attach2, int samples, Eina_
239} 239}
240 240
241static void * 241static void *
242_egl_image_create(EVGL_Context *context, GLuint tex) 242_egl_image_create(EVGL_Context *context, int target, void *buffer)
243{ 243{
244#ifdef GL_GLES 244#ifdef GL_GLES
245 EGLDisplay dpy = EGL_NO_DISPLAY; 245 EGLDisplay dpy = EGL_NO_DISPLAY;
246 EGLContext ctx = EGL_NO_CONTEXT; 246 EGLContext ctx = EGL_NO_CONTEXT;
247 EVGL_Resource *rsc = NULL; 247 EVGL_Resource *rsc = NULL;
248 int attribs[10];
249 int n = 0;
248 250
249 int attribs[] = {
250 EGL_GL_TEXTURE_LEVEL_KHR, 0,
251 EGL_IMAGE_PRESERVED_KHR, 0,
252 EGL_NONE
253 };
254
255 // Retrieve the resource object 251 // Retrieve the resource object
256 if (!(rsc = _evgl_tls_resource_get())) 252 if (!(rsc = _evgl_tls_resource_get()))
257 { 253 {
258 ERR("Error creating resources in tls."); 254 ERR("Error creating resources in tls.");
259 return NULL; 255 return NULL;
260 } 256 }
261 257
262 dpy = (EGLDisplay)rsc->display; 258 dpy = (EGLDisplay)rsc->display;
263 ctx = (EGLContext)context->context; 259 if (target == EGL_GL_TEXTURE_2D_KHR)
260 {
261 ctx = (EGLContext)context->context;
262 attribs[n++] = EGL_GL_TEXTURE_LEVEL_KHR;
263 attribs[n++] = 0;
264 }
265 attribs[n++] = EGL_IMAGE_PRESERVED_KHR;
266 attribs[n++] = 0;
267 attribs[n++] = EGL_NONE;
264 268
265 return EXT_FUNC(eglCreateImage)(dpy, ctx, EGL_GL_TEXTURE_2D_KHR, (EGLClientBuffer)(uintptr_t)tex, attribs); 269 return EXT_FUNC(eglCreateImage)(dpy, ctx, target, (EGLClientBuffer)(uintptr_t)buffer, attribs);
266#else 270#else
267 (void) context; (void) tex; 271 (void) context; (void) target; (void) buffer;
268 return NULL; 272 return NULL;
269#endif 273#endif
270} 274}
@@ -856,6 +860,10 @@ _surface_cap_init(void *eng_data)
856static int 860static int
857_context_ext_check(EVGL_Context *ctx) 861_context_ext_check(EVGL_Context *ctx)
858{ 862{
863 int fbo_supported = 0;
864 int egl_image_supported = 0;
865 int texture_image_supported = 0;
866
859 if (!ctx) 867 if (!ctx)
860 return 0; 868 return 0;
861 869
@@ -863,9 +871,6 @@ _context_ext_check(EVGL_Context *ctx)
863 return 1; 871 return 1;
864 872
865#ifdef GL_GLES 873#ifdef GL_GLES
866 int fbo_supported = 0;
867 int egl_image_supported = 0;
868
869 switch (ctx->version) 874 switch (ctx->version)
870 { 875 {
871 case EVAS_GL_GLES_1_X: 876 case EVAS_GL_GLES_1_X:
@@ -878,21 +883,31 @@ _context_ext_check(EVGL_Context *ctx)
878 fbo_supported = 1; 883 fbo_supported = 1;
879 } 884 }
880 885
881 if (EXTENSION_SUPPORT(EGL_KHR_image_base) 886 if (EXTENSION_SUPPORT(EGL_KHR_image_base))
882 && EXTENSION_SUPPORT(EGL_KHR_gl_texture_2D_image))
883 egl_image_supported = 1; 887 egl_image_supported = 1;
884 888
885 if (fbo_supported && egl_image_supported) 889 if (EXTENSION_SUPPORT(EGL_KHR_gl_texture_2D_image))
886 ctx->fbo_image_supported = 1; 890 texture_image_supported = 1;
887#else 891#else
888 ctx->fbo_image_supported = 1; 892 fbo_supported = 1;
893 egl_image_supported = 0;
894 texture_image_supported = 0;
889#endif 895#endif
890 896
897 if (egl_image_supported)
898 {
899 if (fbo_supported && texture_image_supported)
900 ctx->fbo_image_supported = 1;
901 else
902 ctx->pixmap_image_supported = 1;
903 }
904
891 ctx->extension_checked = 1; 905 ctx->extension_checked = 1;
892 906
893 return 1; 907 return 1;
894} 908}
895 909
910
896static const char * 911static const char *
897_glenum_string_get(GLenum e) 912_glenum_string_get(GLenum e)
898{ 913{
@@ -1179,7 +1194,7 @@ _surface_buffers_allocate(void *eng_data, EVGL_Surface *sfc, int w, int h, int m
1179 sfc->egl_image = NULL; 1194 sfc->egl_image = NULL;
1180 } 1195 }
1181 if ((sfc->current_ctx) && (sfc->current_ctx->fbo_image_supported) && (w) && (h)) 1196 if ((sfc->current_ctx) && (sfc->current_ctx->fbo_image_supported) && (w) && (h))
1182 sfc->egl_image = _egl_image_create(sfc->current_ctx, sfc->color_buf); 1197 sfc->egl_image = _egl_image_create(sfc->current_ctx, EGL_GL_TEXTURE_2D_KHR, (void *)(uintptr_t)sfc->color_buf);
1183 1198
1184 sfc->buffer_mem[0] = w * h * 4; 1199 sfc->buffer_mem[0] = w * h * 4;
1185 } 1200 }
@@ -1792,6 +1807,7 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h)
1792 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONFIG); 1807 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONFIG);
1793 goto error; 1808 goto error;
1794 } 1809 }
1810 sfc->cfg = cfg;
1795 1811
1796 // Keep track of all the created surfaces 1812 // Keep track of all the created surfaces
1797 LKL(evgl_engine->resource_lock); 1813 LKL(evgl_engine->resource_lock);
@@ -1865,6 +1881,7 @@ evgl_pbuffer_surface_create(void *eng_data, Evas_GL_Config *cfg,
1865 goto error; 1881 goto error;
1866 } 1882 }
1867 } 1883 }
1884 sfc->cfg = cfg;
1868 1885
1869 pbuffer = evgl_engine->funcs->pbuffer_surface_create 1886 pbuffer = evgl_engine->funcs->pbuffer_surface_create
1870 (eng_data, sfc, attrib_list); 1887 (eng_data, sfc, attrib_list);
@@ -2320,7 +2337,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2320 } 2337 }
2321 } 2338 }
2322 2339
2323 if (!ctx->fbo_image_supported) 2340 if (ctx->pixmap_image_supported)
2324 { 2341 {
2325 if (dbg) DBG("ctx %p is GLES %d", ctx, ctx->version); 2342 if (dbg) DBG("ctx %p is GLES %d", ctx, ctx->version);
2326 if (_evgl_direct_renderable(rsc, sfc)) 2343 if (_evgl_direct_renderable(rsc, sfc))
@@ -2338,12 +2355,17 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2338 } 2355 }
2339 else 2356 else
2340 { 2357 {
2358 if (!sfc->indirect_sfc)
2359 {
2360 evgl_engine->funcs->indirect_surface_create(evgl_engine, eng_data, sfc, sfc->cfg, sfc->w, sfc->h);
2361 sfc->egl_image = _egl_image_create(NULL, EVAS_GL_NATIVE_PIXMAP, sfc->indirect_sfc_native);
2362 }
2341 if (!ctx->indirect_context) 2363 if (!ctx->indirect_context)
2342 { 2364 {
2343 ctx->indirect_context = 2365 ctx->indirect_context =
2344 evgl_engine->funcs->gles_context_create(eng_data, ctx, sfc); 2366 evgl_engine->funcs->gles_context_create(eng_data, ctx, sfc);
2345 } 2367 }
2346 if (dbg) DBG("Calling make_current(%p, %p)", sfc->indirect_sfc, ctx->context); 2368 if (dbg) DBG("Calling make_current(%p, %p)", sfc->indirect_sfc, ctx->indirect_context);
2347 if (!evgl_engine->funcs->make_current(eng_data, sfc->indirect_sfc, 2369 if (!evgl_engine->funcs->make_current(eng_data, sfc->indirect_sfc,
2348 ctx->indirect_context, EINA_TRUE)) 2370 ctx->indirect_context, EINA_TRUE))
2349 { 2371 {
@@ -2560,6 +2582,22 @@ evgl_native_surface_buffer_get(EVGL_Surface *sfc)
2560} 2582}
2561 2583
2562int 2584int
2585evgl_native_surface_yinvert_get(EVGL_Surface *sfc)
2586{
2587 int ret = 0;
2588 if (!evgl_engine)
2589 {
2590 ERR("Invalid input data. Engine: %p", evgl_engine);
2591 return 0;
2592 }
2593
2594 if (sfc->indirect)
2595 ret = sfc->yinvert;
2596
2597 return ret;
2598}
2599
2600int
2563evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns) 2601evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns)
2564{ 2602{
2565 // Check the input 2603 // Check the input
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.h b/src/modules/evas/engines/gl_common/evas_gl_core.h
index 3e4fda8549..5a0811a020 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.h
@@ -44,13 +44,12 @@ typedef struct _EVGL_Surface_Cap EVGL_Surface_Cap;
44typedef struct _EVGL_Surface_Format EVGL_Surface_Format; 44typedef struct _EVGL_Surface_Format EVGL_Surface_Format;
45 45
46EAPI void evgl_engine_shutdown(void *eng_data); 46EAPI void evgl_engine_shutdown(void *eng_data);
47
48typedef void (*EVGL_Engine_Call)(void *eng_data);
49
50EAPI void *evgl_native_surface_buffer_get(EVGL_Surface *sfc); 47EAPI void *evgl_native_surface_buffer_get(EVGL_Surface *sfc);
48EAPI int evgl_native_surface_yinvert_get(EVGL_Surface *sfc);
51 49
50typedef void (*EVGL_Engine_Call)(void *eng_data);
52typedef void *(*EVGL_Native_Surface_Call)(void *sfc); 51typedef void *(*EVGL_Native_Surface_Call)(void *sfc);
53 52typedef int (*EVGL_Native_Surface_Yinvert_Call)(void *sfc);
54 53
55EVGL_Engine *evgl_engine_init(void *eng_data, const EVGL_Interface *efunc); 54EVGL_Engine *evgl_engine_init(void *eng_data, const EVGL_Interface *efunc);
56 55
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core_private.h b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
index e87c477243..4ad6426622 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
@@ -116,6 +116,7 @@ struct _EVGL_Surface
116 116
117 // Flag indicating this surface is used for indirect rendering 117 // Flag indicating this surface is used for indirect rendering
118 unsigned indirect : 1; 118 unsigned indirect : 1;
119 unsigned yinvert : 1;
119 120
120 // Moved from evgl_engine 121 // Moved from evgl_engine
121 unsigned direct_override : 1; 122 unsigned direct_override : 1;
@@ -124,6 +125,7 @@ struct _EVGL_Surface
124 // Init Flag 125 // Init Flag
125 unsigned buffers_allocated : 1; 126 unsigned buffers_allocated : 1;
126 127
128 void *cfg;
127 int cfg_index; 129 int cfg_index;
128 130
129 131
@@ -174,6 +176,7 @@ struct _EVGL_Context
174 unsigned viewport_updated : 1; 176 unsigned viewport_updated : 1;
175 unsigned extension_checked : 1; 177 unsigned extension_checked : 1;
176 unsigned fbo_image_supported : 1; 178 unsigned fbo_image_supported : 1;
179 unsigned pixmap_image_supported : 1;
177 180
178 int scissor_coord[4]; 181 int scissor_coord[4];
179 int viewport_coord[4]; 182 int viewport_coord[4];
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index 63f2eebf95..b850e686cc 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -60,6 +60,7 @@ Evas_GL_Preload glsym_evas_gl_preload_init = NULL;
60Evas_GL_Preload glsym_evas_gl_preload_shutdown = NULL; 60Evas_GL_Preload glsym_evas_gl_preload_shutdown = NULL;
61EVGL_Engine_Call glsym_evgl_engine_shutdown = NULL; 61EVGL_Engine_Call glsym_evgl_engine_shutdown = NULL;
62EVGL_Native_Surface_Call glsym_evgl_native_surface_buffer_get = NULL; 62EVGL_Native_Surface_Call glsym_evgl_native_surface_buffer_get = NULL;
63EVGL_Native_Surface_Yinvert_Call glsym_evgl_native_surface_yinvert_get = NULL;
63Evas_Gl_Symbols glsym_evas_gl_symbols = NULL; 64Evas_Gl_Symbols glsym_evas_gl_symbols = NULL;
64 65
65Evas_GL_Common_Context_New glsym_evas_gl_common_context_new = NULL; 66Evas_GL_Common_Context_New glsym_evas_gl_common_context_new = NULL;
@@ -893,8 +894,7 @@ evgl_eng_indirect_surface_create(EVGL_Engine *evgl EINA_UNUSED, void *data,
893 return NULL; 894 return NULL;
894 } 895 }
895 896
896 if (((cfg->gles_version != EVAS_GL_GLES_3_X) && (cfg->gles_version != EVAS_GL_GLES_1_X)) 897 if ((w < 1) || (h < 1))
897 || (w < 1) || (h < 1))
898 { 898 {
899 ERR("Inconsistent parameters, not creating any surface!"); 899 ERR("Inconsistent parameters, not creating any surface!");
900 glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_PARAMETER); 900 glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_PARAMETER);
@@ -932,6 +932,7 @@ evgl_eng_indirect_surface_create(EVGL_Engine *evgl EINA_UNUSED, void *data,
932 int msaa = 0, depth = 0, stencil = 0; 932 int msaa = 0, depth = 0, stencil = 0;
933 Visual *visual = NULL; 933 Visual *visual = NULL;
934 Eina_Bool retried = EINA_FALSE; 934 Eina_Bool retried = EINA_FALSE;
935 int val;
935 936
936 /* Now we need to iterate over all EGL configurations to check the compatible 937 /* Now we need to iterate over all EGL configurations to check the compatible
937 * ones and finally check their visual ID. */ 938 * ones and finally check their visual ID. */
@@ -955,6 +956,8 @@ try_again:
955 config_attrs[i++] = EGL_RENDERABLE_TYPE; 956 config_attrs[i++] = EGL_RENDERABLE_TYPE;
956 if (cfg->gles_version == EVAS_GL_GLES_3_X) 957 if (cfg->gles_version == EVAS_GL_GLES_3_X)
957 config_attrs[i++] = EGL_OPENGL_ES3_BIT; 958 config_attrs[i++] = EGL_OPENGL_ES3_BIT;
959 else if (cfg->gles_version == EVAS_GL_GLES_2_X)
960 config_attrs[i++] = EGL_OPENGL_ES2_BIT;
958 else 961 else
959 config_attrs[i++] = EGL_OPENGL_ES_BIT; 962 config_attrs[i++] = EGL_OPENGL_ES_BIT;
960 if (alpha) 963 if (alpha)
@@ -1084,6 +1087,13 @@ try_again:
1084 return NULL; 1087 return NULL;
1085 } 1088 }
1086 1089
1090 if (extn_have_y_inverted &&
1091 eglGetConfigAttrib(eng_get_ob(re)->egl_disp, egl_cfg,
1092 EGL_Y_INVERTED_NOK, &val))
1093 evgl_sfc->yinvert = val;
1094 else
1095 evgl_sfc->yinvert = 1;
1096
1087 evgl_sfc->indirect = EINA_TRUE; 1097 evgl_sfc->indirect = EINA_TRUE;
1088 evgl_sfc->indirect_sfc = egl_sfc; 1098 evgl_sfc->indirect_sfc = egl_sfc;
1089 evgl_sfc->indirect_sfc_native = (void *)(intptr_t) px; 1099 evgl_sfc->indirect_sfc_native = (void *)(intptr_t) px;
@@ -1171,7 +1181,7 @@ evgl_eng_gles_context_create(void *data,
1171 else config = sfc->indirect_sfc_config; 1181 else config = sfc->indirect_sfc_config;
1172 1182
1173 context = eglCreateContext(eng_get_ob(re)->egl_disp, config, 1183 context = eglCreateContext(eng_get_ob(re)->egl_disp, config,
1174 share_ctx ? share_ctx->context : NULL, 1184 share_ctx->context,
1175 context_attrs); 1185 context_attrs);
1176 if (!context) 1186 if (!context)
1177 { 1187 {
@@ -1269,6 +1279,7 @@ gl_symbols(void)
1269 LINK2GENERIC(evas_gl_preload_shutdown); 1279 LINK2GENERIC(evas_gl_preload_shutdown);
1270 LINK2GENERIC(evgl_engine_shutdown); 1280 LINK2GENERIC(evgl_engine_shutdown);
1271 LINK2GENERIC(evgl_native_surface_buffer_get); 1281 LINK2GENERIC(evgl_native_surface_buffer_get);
1282 LINK2GENERIC(evgl_native_surface_yinvert_get);
1272 LINK2GENERIC(evas_gl_symbols); 1283 LINK2GENERIC(evas_gl_symbols);
1273 LINK2GENERIC(evas_gl_common_error_get); 1284 LINK2GENERIC(evas_gl_common_error_get);
1274 LINK2GENERIC(evas_gl_common_error_set); 1285 LINK2GENERIC(evas_gl_common_error_set);
@@ -1961,12 +1972,14 @@ struct _Native
1961 Visual *visual; 1972 Visual *visual;
1962 void *buffer; 1973 void *buffer;
1963 1974
1964 void *egl_surface; 1975 void *config;
1965 1976 void *surface;
1977/*
1966#ifndef GL_GLES 1978#ifndef GL_GLES
1967 void *fbc; 1979 void *fbc;
1968 XID glx_pixmap; 1980 XID glx_pixmap;
1969#endif 1981#endif
1982*/
1970}; 1983};
1971 1984
1972// FIXME: this is enabled so updates happen - but its SLOOOOOOOOOOOOOOOW 1985// FIXME: this is enabled so updates happen - but its SLOOOOOOOOOOOOOOOW
@@ -1987,11 +2000,11 @@ _native_bind_cb(void *data EINA_UNUSED, void *image)
1987 if (n->ns.type == EVAS_NATIVE_SURFACE_X11) 2000 if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
1988 { 2001 {
1989#ifdef GL_GLES 2002#ifdef GL_GLES
1990 if (n->egl_surface) 2003 if (n->surface)
1991 { 2004 {
1992 if (glsym_glEGLImageTargetTexture2DOES) 2005 if (glsym_glEGLImageTargetTexture2DOES)
1993 { 2006 {
1994 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface); 2007 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->surface);
1995 if (eglGetError() != EGL_SUCCESS) 2008 if (eglGetError() != EGL_SUCCESS)
1996 ERR("glEGLImageTargetTexture2DOES() failed."); 2009 ERR("glEGLImageTargetTexture2DOES() failed.");
1997 } 2010 }
@@ -2004,7 +2017,7 @@ _native_bind_cb(void *data EINA_UNUSED, void *image)
2004 2017
2005 if (glsym_glXBindTexImage) 2018 if (glsym_glXBindTexImage)
2006 { 2019 {
2007 glsym_glXBindTexImage(eng_get_ob(re)->disp, n->glx_pixmap, 2020 glsym_glXBindTexImage(eng_get_ob(re)->disp, (XID)n->surface,
2008 GLX_FRONT_LEFT_EXT, NULL); 2021 GLX_FRONT_LEFT_EXT, NULL);
2009 GLERRV("glsym_glXBindTexImage"); 2022 GLERRV("glsym_glXBindTexImage");
2010 } 2023 }
@@ -2020,11 +2033,11 @@ _native_bind_cb(void *data EINA_UNUSED, void *image)
2020 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM) 2033 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
2021 { 2034 {
2022#ifdef GL_GLES 2035#ifdef GL_GLES
2023 if (n->egl_surface) 2036 if (n->surface)
2024 { 2037 {
2025 if (glsym_glEGLImageTargetTexture2DOES) 2038 if (glsym_glEGLImageTargetTexture2DOES)
2026 { 2039 {
2027 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, n->egl_surface); 2040 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, n->surface);
2028 if (eglGetError() != EGL_SUCCESS) 2041 if (eglGetError() != EGL_SUCCESS)
2029 ERR("glEGLImageTargetTexture2DOES() failed."); 2042 ERR("glEGLImageTargetTexture2DOES() failed.");
2030 } 2043 }
@@ -2035,10 +2048,10 @@ _native_bind_cb(void *data EINA_UNUSED, void *image)
2035 } 2048 }
2036 else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL) 2049 else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL)
2037 { 2050 {
2038 if (n->egl_surface) 2051 if (n->surface)
2039 { 2052 {
2040#ifdef GL_GLES 2053#ifdef GL_GLES
2041 void *surface = glsym_evgl_native_surface_buffer_get(n->egl_surface); 2054 void *surface = glsym_evgl_native_surface_buffer_get(n->surface);
2042 if (glsym_glEGLImageTargetTexture2DOES) 2055 if (glsym_glEGLImageTargetTexture2DOES)
2043 { 2056 {
2044 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, surface); 2057 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, surface);
@@ -2048,7 +2061,7 @@ _native_bind_cb(void *data EINA_UNUSED, void *image)
2048 else 2061 else
2049 ERR("Try glEGLImageTargetTexture2DOES on EGL with no support"); 2062 ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
2050#else 2063#else
2051 GLuint tex = (GLuint)(uintptr_t)glsym_evgl_native_surface_buffer_get(n->egl_surface); 2064 GLuint tex = (GLuint)(uintptr_t)glsym_evgl_native_surface_buffer_get(n->surface);
2052 glBindTexture(GL_TEXTURE_2D, tex); 2065 glBindTexture(GL_TEXTURE_2D, tex);
2053#endif 2066#endif
2054 } 2067 }
@@ -2071,7 +2084,7 @@ _native_unbind_cb(void *data EINA_UNUSED, void *image)
2071 2084
2072 if (glsym_glXReleaseTexImage) 2085 if (glsym_glXReleaseTexImage)
2073 { 2086 {
2074 glsym_glXReleaseTexImage(eng_get_ob(re)->disp, n->glx_pixmap, 2087 glsym_glXReleaseTexImage(eng_get_ob(re)->disp, (XID)n->surface,
2075 GLX_FRONT_LEFT_EXT); 2088 GLX_FRONT_LEFT_EXT);
2076 } 2089 }
2077 else 2090 else
@@ -2110,13 +2123,13 @@ _native_free_cb(void *data, void *image)
2110 pmid = n->pixmap; 2123 pmid = n->pixmap;
2111 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_pm_hash, &pmid, im); 2124 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_pm_hash, &pmid, im);
2112#ifdef GL_GLES 2125#ifdef GL_GLES
2113 if (n->egl_surface) 2126 if (n->surface)
2114 { 2127 {
2115 int err; 2128 int err;
2116 if (glsym_eglDestroyImage) 2129 if (glsym_eglDestroyImage)
2117 { 2130 {
2118 glsym_eglDestroyImage(eng_get_ob(re)->egl_disp, 2131 glsym_eglDestroyImage(eng_get_ob(re)->egl_disp,
2119 n->egl_surface); 2132 n->surface);
2120 if ((err = eglGetError()) != EGL_SUCCESS) 2133 if ((err = eglGetError()) != EGL_SUCCESS)
2121 { 2134 {
2122 ERR("eglDestroyImage() failed."); 2135 ERR("eglDestroyImage() failed.");
@@ -2128,13 +2141,13 @@ _native_free_cb(void *data, void *image)
2128 } 2141 }
2129#else 2142#else
2130# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT 2143# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
2131 if (n->glx_pixmap) 2144 if (n->surface)
2132 { 2145 {
2133 if (im->native.loose) 2146 if (im->native.loose)
2134 { 2147 {
2135 if (glsym_glXReleaseTexImage) 2148 if (glsym_glXReleaseTexImage)
2136 { 2149 {
2137 glsym_glXReleaseTexImage(eng_get_ob(re)->disp, n->glx_pixmap, 2150 glsym_glXReleaseTexImage(eng_get_ob(re)->disp, (XID)n->surface,
2138 GLX_FRONT_LEFT_EXT); 2151 GLX_FRONT_LEFT_EXT);
2139 } 2152 }
2140 else 2153 else
@@ -2142,12 +2155,12 @@ _native_free_cb(void *data, void *image)
2142 } 2155 }
2143 if (glsym_glXDestroyPixmap) 2156 if (glsym_glXDestroyPixmap)
2144 { 2157 {
2145 glsym_glXDestroyPixmap(eng_get_ob(re)->disp, n->glx_pixmap); 2158 glsym_glXDestroyPixmap(eng_get_ob(re)->disp, (XID)n->surface);
2146 GLERRV("glsym_glXDestroyPixmap"); 2159 GLERRV("glsym_glXDestroyPixmap");
2147 } 2160 }
2148 else 2161 else
2149 ERR("Try glXDestroyPixmap on GLX with no support"); 2162 ERR("Try glXDestroyPixmap on GLX with no support");
2150 n->glx_pixmap = 0; 2163 n->surface = 0;
2151 } 2164 }
2152# endif 2165# endif
2153#endif 2166#endif
@@ -2161,13 +2174,13 @@ _native_free_cb(void *data, void *image)
2161 { 2174 {
2162 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &n->buffer, im); 2175 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &n->buffer, im);
2163#ifdef GL_GLES 2176#ifdef GL_GLES
2164 if (n->egl_surface) 2177 if (n->surface)
2165 { 2178 {
2166 int err; 2179 int err;
2167 if (glsym_eglDestroyImage) 2180 if (glsym_eglDestroyImage)
2168 { 2181 {
2169 glsym_eglDestroyImage(eng_get_ob(re)->egl_disp, 2182 glsym_eglDestroyImage(eng_get_ob(re)->egl_disp,
2170 n->egl_surface); 2183 n->surface);
2171 if ((err = eglGetError()) != EGL_SUCCESS) 2184 if ((err = eglGetError()) != EGL_SUCCESS)
2172 { 2185 {
2173 ERR("eglDestroyImage() failed."); 2186 ERR("eglDestroyImage() failed.");
@@ -2191,6 +2204,45 @@ _native_free_cb(void *data, void *image)
2191 free(n); 2204 free(n);
2192} 2205}
2193 2206
2207static int
2208_native_yinvert_cb(void *data, void *image)
2209{
2210 Render_Engine *re = data;
2211 Evas_GL_Image *im = image;
2212 Native *n = im->native.data;
2213 int yinvert = 0, val;
2214
2215 // Yinvert callback should only be used for EVAS_NATIVE_SURFACE_EVASGL type now,
2216 // as yinvert value is not changed for other types.
2217 if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
2218 {
2219#if GL_GLES
2220 if (extn_have_y_inverted &&
2221 eglGetConfigAttrib(eng_get_ob(re)->egl_disp, n->config,
2222 EGL_Y_INVERTED_NOK, &val))
2223 yinvert = val;
2224#else
2225 glXGetFBConfigAttrib(eng_get_ob(re)->disp, n->config,
2226 GLX_Y_INVERTED_EXT, &val);
2227 yinvert = val;
2228#endif
2229 }
2230 else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
2231 {
2232 yinvert = 0;
2233 }
2234 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
2235 {
2236 yinvert = 1;
2237 }
2238 else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL)
2239 {
2240 yinvert = glsym_evgl_native_surface_yinvert_get(n->surface);
2241 }
2242
2243 return yinvert;
2244}
2245
2194static void * 2246static void *
2195eng_image_native_set(void *data, void *image, void *native) 2247eng_image_native_set(void *data, void *image, void *native)
2196{ 2248{
@@ -2406,15 +2458,17 @@ eng_image_native_set(void *data, void *image, void *native)
2406 n->pixmap = pm; 2458 n->pixmap = pm;
2407 n->visual = vis; 2459 n->visual = vis;
2408 if (glsym_eglCreateImage) 2460 if (glsym_eglCreateImage)
2409 n->egl_surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, 2461 n->surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp,
2410 EGL_NO_CONTEXT, 2462 EGL_NO_CONTEXT,
2411 EGL_NATIVE_PIXMAP_KHR, 2463 EGL_NATIVE_PIXMAP_KHR,
2412 (void *)pm, 2464 (void *)pm,
2413 NULL); 2465 NULL);
2414 else 2466 else
2415 ERR("Try eglCreateImage on EGL with no support"); 2467 ERR("Try eglCreateImage on EGL with no support");
2416 if (!n->egl_surface) 2468 if (!n->surface)
2417 ERR("eglCreatePixmapSurface() for 0x%x failed", (unsigned int)pm); 2469 ERR("eglCreatePixmapSurface() for 0x%x failed", (unsigned int)pm);
2470 n->config = (void *)egl_config;
2471
2418 im->native.yinvert = yinvert; 2472 im->native.yinvert = yinvert;
2419 im->native.loose = 0; 2473 im->native.loose = 0;
2420 im->native.data = n; 2474 im->native.data = n;
@@ -2537,7 +2591,7 @@ eng_image_native_set(void *data, void *image, void *native)
2537 glXGetFBConfigAttrib(eng_get_ob(re)->disp, configs[j], 2591 glXGetFBConfigAttrib(eng_get_ob(re)->disp, configs[j],
2538 GLX_BIND_TO_MIPMAP_TEXTURE_EXT, &val); 2592 GLX_BIND_TO_MIPMAP_TEXTURE_EXT, &val);
2539 mipmap = val; 2593 mipmap = val;
2540 n->fbc = configs[j]; 2594 n->config = configs[j];
2541 found = 1; 2595 found = 1;
2542 break; 2596 break;
2543 } 2597 }
@@ -2582,16 +2636,16 @@ eng_image_native_set(void *data, void *image, void *native)
2582 n->pixmap = pm; 2636 n->pixmap = pm;
2583 n->visual = vis; 2637 n->visual = vis;
2584 if (glsym_glXCreatePixmap) 2638 if (glsym_glXCreatePixmap)
2585 n->glx_pixmap = glsym_glXCreatePixmap(eng_get_ob(re)->disp, 2639 n->surface = (void *)glsym_glXCreatePixmap(eng_get_ob(re)->disp,
2586 n->fbc, 2640 n->config,
2587 n->pixmap, 2641 n->pixmap,
2588 pixmap_att); 2642 pixmap_att);
2589 else 2643 else
2590 ERR("Try glXCreatePixmap on GLX with no support"); 2644 ERR("Try glXCreatePixmap on GLX with no support");
2591 if (n->glx_pixmap) 2645 if (n->surface)
2592 { 2646 {
2593// printf("%p: new native texture for %x | %4i x %4i @ %2i = %p\n", 2647// printf("%p: new native texture for %x | %4i x %4i @ %2i = %p\n",
2594// n, pm, w, h, depth, n->glx_pixmap); 2648// n, pm, w, h, depth, n->surface);
2595 if (!target) 2649 if (!target)
2596 { 2650 {
2597 ERR("no target :("); 2651 ERR("no target :(");
@@ -2650,12 +2704,8 @@ eng_image_native_set(void *data, void *image, void *native)
2650 2704
2651 n->pixmap = 0; 2705 n->pixmap = 0;
2652 n->visual = 0; 2706 n->visual = 0;
2653#ifdef GL_GLES 2707 n->config = 0;
2654 n->egl_surface = 0; 2708 n->surface = 0;
2655#else
2656 n->fbc = 0;
2657 n->glx_pixmap = 0;
2658#endif
2659 2709
2660 im->native.yinvert = 0; 2710 im->native.yinvert = 0;
2661 im->native.loose = 0; 2711 im->native.loose = 0;
@@ -2688,14 +2738,14 @@ eng_image_native_set(void *data, void *image, void *native)
2688 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); 2738 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
2689 n->buffer = buffer; 2739 n->buffer = buffer;
2690 if (glsym_eglCreateImage) 2740 if (glsym_eglCreateImage)
2691 n->egl_surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp, 2741 n->surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp,
2692 EGL_NO_CONTEXT, 2742 EGL_NO_CONTEXT,
2693 EGL_NATIVE_SURFACE_TIZEN, 2743 EGL_NATIVE_SURFACE_TIZEN,
2694 (void *)buffer, 2744 (void *)buffer,
2695 NULL); 2745 NULL);
2696 else 2746 else
2697 ERR("Try eglCreateImage on EGL with no support"); 2747 ERR("Try eglCreateImage on EGL with no support");
2698 if (!n->egl_surface) 2748 if (!n->surface)
2699 ERR("eglCreateImage() for %p failed", buffer); 2749 ERR("eglCreateImage() for %p failed", buffer);
2700 im->native.yinvert = 1; 2750 im->native.yinvert = 1;
2701 im->native.loose = 0; 2751 im->native.loose = 0;
@@ -2725,17 +2775,18 @@ eng_image_native_set(void *data, void *image, void *native)
2725 n->pixmap = 0; 2775 n->pixmap = 0;
2726 n->visual = 0; 2776 n->visual = 0;
2727 2777
2728 n->egl_surface = ns->data.evasgl.surface; 2778 n->surface = ns->data.evasgl.surface;
2729 2779
2730 im->native.yinvert = 0; 2780 im->native.yinvert = 0;
2731 im->native.loose = 0; 2781 im->native.loose = 0;
2732 im->native.data = n; 2782 im->native.data = n;
2733 im->native.func.data = re; 2783 im->native.func.data = re;
2734 im->native.func.bind = _native_bind_cb; 2784 im->native.func.bind = _native_bind_cb;
2735 im->native.func.unbind = _native_unbind_cb; 2785 im->native.func.unbind = _native_unbind_cb;
2736 im->native.func.free = _native_free_cb; 2786 im->native.func.free = _native_free_cb;
2737 im->native.target = GL_TEXTURE_2D; 2787 im->native.func.yinvert = _native_yinvert_cb;
2738 im->native.mipmap = 0; 2788 im->native.target = GL_TEXTURE_2D;
2789 im->native.mipmap = 0;
2739 2790
2740 // FIXME: need to implement mapping sub texture regions 2791 // FIXME: need to implement mapping sub texture regions
2741 // x, y, w, h for possible texture atlasing 2792 // x, y, w, h for possible texture atlasing