summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2015-11-04 14:10:06 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2015-11-04 14:14:16 -0500
commit6b1af3c55abefd5cb1e1a0218900e763dcbad31b (patch)
treeeb7bfdd57e011674940f3ad342b3b372c7b529a1
parentf77ba645d58d8a544c0723b3ebc8f8668d7cdd59 (diff)
evas gl-x11: add missing EVAS_NATIVE_SURFACE_WL support
copy/pasted from other engines, only functional with gles+wayland, A Thoroughly Tested Calculated Riskā„¢ ref 1dbecbb6764bdd6f477b5cc6624e791a52cfe1d5
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c171
1 files changed, 171 insertions, 0 deletions
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index 80fcc53ec4..7713c210ab 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -84,6 +84,7 @@ void (*glsym_eglDestroyImage) (EGLDisplay a, void *b) = NULL;
84void (*glsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL; 84void (*glsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
85unsigned int (*glsym_eglSwapBuffersWithDamage) (EGLDisplay a, void *b, const EGLint *d, EGLint c) = NULL; 85unsigned int (*glsym_eglSwapBuffersWithDamage) (EGLDisplay a, void *b, const EGLint *d, EGLint c) = NULL;
86unsigned int (*glsym_eglSetDamageRegionKHR) (EGLDisplay a, EGLSurface b, EGLint *c, EGLint d) = NULL; 86unsigned int (*glsym_eglSetDamageRegionKHR) (EGLDisplay a, EGLSurface b, EGLint *c, EGLint d) = NULL;
87unsigned int (*glsym_eglQueryWaylandBufferWL)(EGLDisplay a, /*struct wl_resource */void *b, EGLint c, EGLint *d) = NULL;
87 88
88#else 89#else
89 90
@@ -1245,6 +1246,8 @@ gl_symbols(void)
1245 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressEXT", glsym_func_eng_fn); 1246 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressEXT", glsym_func_eng_fn);
1246 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressARB", glsym_func_eng_fn); 1247 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressARB", glsym_func_eng_fn);
1247 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddress", glsym_func_eng_fn); 1248 FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddress", glsym_func_eng_fn);
1249 FINDSYM(glsym_eglQueryWaylandBufferWL, "eglQueryWaylandBufferWL",
1250 glsym_func_uint)
1248#else 1251#else
1249#define FINDSYM(dst, sym, typ) \ 1252#define FINDSYM(dst, sym, typ) \
1250 if (glsym_glXGetProcAddress) { \ 1253 if (glsym_glXGetProcAddress) { \
@@ -1933,6 +1936,12 @@ struct _Native
1933 1936
1934 void *config; 1937 void *config;
1935 void *surface; 1938 void *surface;
1939#ifdef GL_GLES
1940# ifdef HAVE_WAYLAND
1941 void *wl_buf;
1942 void *egl_surface;
1943# endif
1944#endif
1936/* 1945/*
1937#ifndef GL_GLES 1946#ifndef GL_GLES
1938 void *fbc; 1947 void *fbc;
@@ -2027,6 +2036,24 @@ _native_bind_cb(void *data EINA_UNUSED, void *image)
2027 } 2036 }
2028 } 2037 }
2029 } 2038 }
2039 else if (n->ns.type == EVAS_NATIVE_SURFACE_WL)
2040 {
2041#ifdef GL_GLES
2042# ifdef HAVE_WAYLAND
2043 if (n->egl_surface)
2044 {
2045 if (glsym_glEGLImageTargetTexture2DOES)
2046 {
2047 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface);
2048 if (eglGetError() != EGL_SUCCESS)
2049 ERR("glEGLImageTargetTexture2DOES() failed.");
2050 }
2051 else
2052 ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
2053 }
2054# endif
2055#endif
2056 }
2030} 2057}
2031 2058
2032static void 2059static void
@@ -2078,6 +2105,11 @@ _native_free_cb(void *data, void *image)
2078 Evas_GL_Image *im = image; 2105 Evas_GL_Image *im = image;
2079 Native *n = im->native.data; 2106 Native *n = im->native.data;
2080 uint32_t pmid, texid; 2107 uint32_t pmid, texid;
2108#ifdef GL_GLES
2109# ifdef HAVE_WAYLAND
2110 void *wlid;
2111# endif
2112#endif
2081 2113
2082 if (n->ns.type == EVAS_NATIVE_SURFACE_X11) 2114 if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
2083 { 2115 {
@@ -2157,6 +2189,26 @@ _native_free_cb(void *data, void *image)
2157 { 2189 {
2158 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_evasgl_hash, &n->ns.data.evasgl.surface, im); 2190 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_evasgl_hash, &n->ns.data.evasgl.surface, im);
2159 } 2191 }
2192 else if (n->ns.type == EVAS_NATIVE_SURFACE_WL)
2193 {
2194#ifdef GL_GLES
2195# ifdef HAVE_WAYLAND
2196 wlid = (void*)n->wl_buf;
2197 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_wl_hash, &wlid, image);
2198 if (n->egl_surface)
2199 {
2200 if (glsym_eglDestroyImage)
2201 {
2202 glsym_eglDestroyImage(eng_get_ob(re)->egl_disp, n->egl_surface);
2203 if (eglGetError() != EGL_SUCCESS)
2204 ERR("eglDestroyImage() failed.");
2205 }
2206 else
2207 ERR("Try eglDestroyImage on EGL with no support");
2208 }
2209# endif
2210#endif
2211 }
2160 im->native.data = NULL; 2212 im->native.data = NULL;
2161 im->native.func.data = NULL; 2213 im->native.func.data = NULL;
2162 im->native.func.bind = NULL; 2214 im->native.func.bind = NULL;
@@ -2217,6 +2269,11 @@ eng_image_native_set(void *data, void *image, void *native)
2217 unsigned int tex = 0; 2269 unsigned int tex = 0;
2218 unsigned int fbo = 0; 2270 unsigned int fbo = 0;
2219 void *buffer = NULL; 2271 void *buffer = NULL;
2272#ifdef GL_GLES
2273# ifdef HAVE_WAYLAND
2274 void *wlid, *wl_buf = NULL;
2275# endif
2276#endif
2220 2277
2221 if (!im) 2278 if (!im)
2222 { 2279 {
@@ -2278,6 +2335,22 @@ eng_image_native_set(void *data, void *image, void *native)
2278 return im; 2335 return im;
2279 } 2336 }
2280 } 2337 }
2338 else if (ns->type == EVAS_NATIVE_SURFACE_WL)
2339 {
2340#ifdef GL_GLES
2341# ifdef HAVE_WAYLAND
2342 wl_buf = ns->data.wl.legacy_buffer;
2343 if (im->native.data)
2344 {
2345 Evas_Native_Surface *ens;
2346
2347 ens = im->native.data;
2348 if (ens->data.wl.legacy_buffer == wl_buf)
2349 return im;
2350 }
2351# endif
2352#endif
2353 }
2281 } 2354 }
2282 if ((!ns) && (!im->native.data)) return im; 2355 if ((!ns) && (!im->native.data)) return im;
2283 2356
@@ -2354,6 +2427,25 @@ eng_image_native_set(void *data, void *image, void *native)
2354 } 2427 }
2355 } 2428 }
2356 } 2429 }
2430 else if (ns->type == EVAS_NATIVE_SURFACE_WL)
2431 {
2432#ifdef GL_GLES
2433# ifdef HAVE_WAYLAND
2434 wlid = wl_buf;
2435 im2 = eina_hash_find(eng_get_ob(re)->gl_context->shared->native_wl_hash, &wlid);
2436 if (im2 == im) return im;
2437 if (im2)
2438 {
2439 if((n = im2->native.data))
2440 {
2441 glsym_evas_gl_common_image_ref(im2);
2442 glsym_evas_gl_common_image_free(im);
2443 return im2;
2444 }
2445 }
2446# endif
2447#endif
2448 }
2357 im2 = glsym_evas_gl_common_image_new_from_data(eng_get_ob(re)->gl_context, 2449 im2 = glsym_evas_gl_common_image_new_from_data(eng_get_ob(re)->gl_context,
2358 im->w, im->h, NULL, im->alpha, 2450 im->w, im->h, NULL, im->alpha,
2359 EVAS_COLORSPACE_ARGB8888); 2451 EVAS_COLORSPACE_ARGB8888);
@@ -2754,6 +2846,85 @@ eng_image_native_set(void *data, void *image, void *native)
2754 } 2846 }
2755 } 2847 }
2756 } 2848 }
2849 else if (ns->type == EVAS_NATIVE_SURFACE_WL)
2850 {
2851#ifdef GL_GLES
2852# ifdef HAVE_WAYLAND
2853 if (native)
2854 {
2855 if ((n = calloc(1, sizeof(Native))))
2856 {
2857 EGLint attribs[3];
2858 int format, yinvert = 1;
2859
2860 glsym_eglQueryWaylandBufferWL(eng_get_ob(re)->egl_disp, wl_buf,
2861 EGL_TEXTURE_FORMAT, &format);
2862 if ((format != EGL_TEXTURE_RGB) &&
2863 (format != EGL_TEXTURE_RGBA))
2864 {
2865 ERR("eglQueryWaylandBufferWL() %d format is not supported ", format);
2866 glsym_evas_gl_common_image_free(im);
2867 free(n);
2868 return NULL;
2869 }
2870
2871 attribs[0] = EGL_WAYLAND_PLANE_WL;
2872 attribs[1] = 0; //if plane is 1 then 0, if plane is 2 then 1
2873 attribs[2] = EGL_NONE;
2874
2875 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
2876 if (glsym_eglQueryWaylandBufferWL(eng_get_ob(re)->egl_disp, wl_buf,
2877 EGL_WAYLAND_Y_INVERTED_WL,
2878 &yinvert) == EGL_FALSE)
2879 yinvert = 1;
2880 eina_hash_add(eng_get_ob(re)->gl_context->shared->native_wl_hash,
2881 &wlid, im);
2882
2883 n->wl_buf = wl_buf;
2884 if (glsym_eglCreateImage)
2885 n->egl_surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp,
2886 NULL,
2887 EGL_WAYLAND_BUFFER_WL,
2888 wl_buf, attribs);
2889 else
2890 {
2891 ERR("Try eglCreateImage on EGL with no support");
2892 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_wl_hash,
2893 &wlid, im);
2894 glsym_evas_gl_common_image_free(im);
2895 free(n);
2896 return NULL;
2897 }
2898
2899 if (!n->egl_surface)
2900 {
2901 ERR("eglCreatePixmapSurface() for %p failed", wl_buf);
2902 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_wl_hash,
2903 &wlid, im);
2904 glsym_evas_gl_common_image_free(im);
2905 free(n);
2906 return NULL;
2907 }
2908
2909 //XXX: workaround for mesa-10.2.8
2910 // mesa's eglQueryWaylandBufferWL() with EGL_WAYLAND_Y_INVERTED_WL works incorrect.
2911 //im->native.yinvert = yinvert;
2912 im->native.yinvert = 1;
2913 im->native.loose = 0;
2914 im->native.data = n;
2915 im->native.func.data = re;
2916 im->native.func.bind = _native_bind_cb;
2917 im->native.func.unbind = _native_unbind_cb;
2918 im->native.func.free = _native_free_cb;
2919 im->native.target = GL_TEXTURE_2D;
2920 im->native.mipmap = 0;
2921
2922 glsym_evas_gl_common_image_native_enable(im);
2923 }
2924 }
2925# endif
2926#endif
2927 }
2757 return im; 2928 return im;
2758} 2929}
2759 2930