summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2015-11-02 16:08:27 -0500
committerChris Michael <cp.michael@samsung.com>2015-11-02 16:08:27 -0500
commit1dbecbb6764bdd6f477b5cc6624e791a52cfe1d5 (patch)
tree6882b027282f3d1373602cbe3529479ca898719b
parentc3f40bd0f99637b611fceaca01aa76e73174d1dc (diff)
evas-wayland-egl: Fix missing support for EVAS_NATIVE_SURFACE_WL
Summary: Support for using EVAS_NATIVE_SURFACE_WL was missing/incomplete in the wayland_egl engine. This commit addresses that issue so that now the wayland_egl engine can support both EVAS_NATIVE_SURFACE_OPENGL and EVAS_NATIVE_SURFACE_WL. @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_engine.c174
1 files changed, 160 insertions, 14 deletions
diff --git a/src/modules/evas/engines/wayland_egl/evas_engine.c b/src/modules/evas/engines/wayland_egl/evas_engine.c
index 70ed760eff..c4d2db23a1 100644
--- a/src/modules/evas/engines/wayland_egl/evas_engine.c
+++ b/src/modules/evas/engines/wayland_egl/evas_engine.c
@@ -33,6 +33,7 @@ typedef struct _Native Native;
33struct _Native 33struct _Native
34{ 34{
35 Evas_Native_Surface ns; 35 Evas_Native_Surface ns;
36 struct wl_buffer *wl_buf;
36 void *egl_surface; 37 void *egl_surface;
37}; 38};
38 39
@@ -75,6 +76,7 @@ void (*glsym_eglDestroyImage) (EGLDisplay a, void *b) = NULL;
75void (*glsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL; 76void (*glsym_glEGLImageTargetTexture2DOES) (int a, void *b) = NULL;
76unsigned int (*glsym_eglSwapBuffersWithDamage) (EGLDisplay a, void *b, const EGLint *d, EGLint c) = NULL; 77unsigned int (*glsym_eglSwapBuffersWithDamage) (EGLDisplay a, void *b, const EGLint *d, EGLint c) = NULL;
77unsigned int (*glsym_eglSetDamageRegionKHR) (EGLDisplay a, EGLSurface b, EGLint *c, EGLint d) = NULL; 78unsigned int (*glsym_eglSetDamageRegionKHR) (EGLDisplay a, EGLSurface b, EGLint *c, EGLint d) = NULL;
79unsigned int (*glsym_eglQueryWaylandBufferWL)(EGLDisplay a, struct wl_resource *b, EGLint c, EGLint *d) = NULL;
78 80
79/* local variables */ 81/* local variables */
80static Eina_Bool initted = EINA_FALSE; 82static Eina_Bool initted = EINA_FALSE;
@@ -171,6 +173,9 @@ gl_symbols(void)
171 FINDSYM(glsym_eglSetDamageRegionKHR, "eglSetDamageRegionKHR", 173 FINDSYM(glsym_eglSetDamageRegionKHR, "eglSetDamageRegionKHR",
172 glsym_func_uint); 174 glsym_func_uint);
173 175
176 FINDSYM(glsym_eglQueryWaylandBufferWL, "eglQueryWaylandBufferWL",
177 glsym_func_uint);
178
174 done = EINA_TRUE; 179 done = EINA_TRUE;
175} 180}
176 181
@@ -797,7 +802,21 @@ _native_cb_bind(void *data EINA_UNUSED, void *image)
797 if (!(img = image)) return; 802 if (!(img = image)) return;
798 if (!(n = img->native.data)) return; 803 if (!(n = img->native.data)) return;
799 804
800 if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) 805 if (n->ns.type == EVAS_NATIVE_SURFACE_WL)
806 {
807 if (n->egl_surface)
808 {
809 if (glsym_glEGLImageTargetTexture2DOES)
810 {
811 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface);
812 if (eglGetError() != EGL_SUCCESS)
813 ERR("glEGLImageTargetTexture2DOES() failed.");
814 }
815 else
816 ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
817 }
818 }
819 else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
801 { 820 {
802 glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id); 821 glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
803 } 822 }
@@ -812,7 +831,11 @@ _native_cb_unbind(void *data EINA_UNUSED, void *image)
812 if (!(img = image)) return; 831 if (!(img = image)) return;
813 if (!(n = img->native.data)) return; 832 if (!(n = img->native.data)) return;
814 833
815 if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) 834 if (n->ns.type == EVAS_NATIVE_SURFACE_WL)
835 {
836 //glBindTexture(GL_TEXTURE_2D, 0); //really need?
837 }
838 else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
816 { 839 {
817 glBindTexture(GL_TEXTURE_2D, 0); 840 glBindTexture(GL_TEXTURE_2D, 0);
818 } 841 }
@@ -826,13 +849,30 @@ _native_cb_free(void *data, void *image)
826 Evas_GL_Image *img; 849 Evas_GL_Image *img;
827 Native *n; 850 Native *n;
828 uint32_t texid; 851 uint32_t texid;
852 void *wlid;
829 853
830 if (!(re = (Render_Engine *)data)) return; 854 if (!(re = (Render_Engine *)data)) return;
831 if (!(img = image)) return; 855 if (!(img = image)) return;
832 if (!(n = img->native.data)) return; 856 if (!(n = img->native.data)) return;
833 if (!(ob = eng_get_ob(re))) return; 857 if (!(ob = eng_get_ob(re))) return;
834 858
835 if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) 859 if (n->ns.type == EVAS_NATIVE_SURFACE_WL)
860 {
861 wlid = (void*)n->wl_buf;
862 eina_hash_del(ob->gl_context->shared->native_wl_hash, &wlid, img);
863 if (n->egl_surface)
864 {
865 if (glsym_eglDestroyImage)
866 {
867 glsym_eglDestroyImage(ob->egl_disp, n->egl_surface);
868 if (eglGetError() != EGL_SUCCESS)
869 ERR("eglDestroyImage() failed.");
870 }
871 else
872 ERR("Try eglDestroyImage on EGL with no support");
873 }
874 }
875 else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
836 { 876 {
837 texid = n->ns.data.opengl.texture_id; 877 texid = n->ns.data.opengl.texture_id;
838 eina_hash_del(ob->gl_context->shared->native_tex_hash, &texid, img); 878 eina_hash_del(ob->gl_context->shared->native_tex_hash, &texid, img);
@@ -857,6 +897,7 @@ eng_image_native_set(void *data, void *image, void *native)
857 Evas_GL_Image *img, *img2; 897 Evas_GL_Image *img, *img2;
858 unsigned int tex = 0, fbo = 0; 898 unsigned int tex = 0, fbo = 0;
859 uint32_t texid; 899 uint32_t texid;
900 void *wlid, *wl_buf = NULL;
860 901
861 if (!(re = (Render_Engine *)data)) return NULL; 902 if (!(re = (Render_Engine *)data)) return NULL;
862 if (!(ob = eng_get_ob(re))) return NULL; 903 if (!(ob = eng_get_ob(re))) return NULL;
@@ -878,18 +919,33 @@ eng_image_native_set(void *data, void *image, void *native)
878 return NULL; 919 return NULL;
879 } 920 }
880 921
881 if ((ns) && (ns->type == EVAS_NATIVE_SURFACE_OPENGL)) 922 if (ns)
882 { 923 {
883 tex = ns->data.opengl.texture_id; 924 if (ns->type == EVAS_NATIVE_SURFACE_WL)
884 fbo = ns->data.opengl.framebuffer_id;
885 if (img->native.data)
886 { 925 {
887 Evas_Native_Surface *ens; 926 wl_buf = ns->data.wl.legacy_buffer;
927 if (img->native.data)
928 {
929 Evas_Native_Surface *ens;
888 930
889 ens = img->native.data; 931 ens = img->native.data;
890 if ((ens->data.opengl.texture_id == tex) && 932 if (ens->data.wl.legacy_buffer == wl_buf)
891 (ens->data.opengl.framebuffer_id == fbo)) 933 return img;
892 return img; 934 }
935 }
936 else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
937 {
938 tex = ns->data.opengl.texture_id;
939 fbo = ns->data.opengl.framebuffer_id;
940 if (img->native.data)
941 {
942 Evas_Native_Surface *ens;
943
944 ens = img->native.data;
945 if ((ens->data.opengl.texture_id == tex) &&
946 (ens->data.opengl.framebuffer_id == fbo))
947 return img;
948 }
893 } 949 }
894 } 950 }
895 951
@@ -906,7 +962,22 @@ eng_image_native_set(void *data, void *image, void *native)
906 962
907 if (!ns) return img; 963 if (!ns) return img;
908 964
909 if (ns->type == EVAS_NATIVE_SURFACE_OPENGL) 965 if (ns->type == EVAS_NATIVE_SURFACE_WL)
966 {
967 wlid = wl_buf;
968 img2 = eina_hash_find(ob->gl_context->shared->native_wl_hash, &wlid);
969 if (img2 == img) return img;
970 if (img2)
971 {
972 if((n = img2->native.data))
973 {
974 glsym_evas_gl_common_image_ref(img2);
975 glsym_evas_gl_common_image_free(img);
976 return img2;
977 }
978 }
979 }
980 else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
910 { 981 {
911 texid = tex; 982 texid = tex;
912 img2 = eina_hash_find(ob->gl_context->shared->native_tex_hash, &texid); 983 img2 = eina_hash_find(ob->gl_context->shared->native_tex_hash, &texid);
@@ -929,7 +1000,82 @@ eng_image_native_set(void *data, void *image, void *native)
929 1000
930 if (!(img = img2)) return NULL; 1001 if (!(img = img2)) return NULL;
931 1002
932 if (ns->type == EVAS_NATIVE_SURFACE_OPENGL) 1003 if (ns->type == EVAS_NATIVE_SURFACE_WL)
1004 {
1005 if (native)
1006 {
1007 if ((n = calloc(1, sizeof(Native))))
1008 {
1009 EGLint attribs[3];
1010 int format, yinvert = 1;
1011
1012 glsym_eglQueryWaylandBufferWL(ob->egl_disp, wl_buf,
1013 EGL_TEXTURE_FORMAT, &format);
1014 if ((format != EGL_TEXTURE_RGB) &&
1015 (format != EGL_TEXTURE_RGBA))
1016 {
1017 ERR("eglQueryWaylandBufferWL() %d format is not supported ", format);
1018 glsym_evas_gl_common_image_free(img);
1019 free(n);
1020 return NULL;
1021 }
1022
1023 attribs[0] = EGL_WAYLAND_PLANE_WL;
1024 attribs[1] = 0; //if plane is 1 then 0, if plane is 2 then 1
1025 attribs[2] = EGL_NONE;
1026
1027 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
1028 if (glsym_eglQueryWaylandBufferWL(ob->egl_disp, wl_buf,
1029 EGL_WAYLAND_Y_INVERTED_WL,
1030 &yinvert) == EGL_FALSE)
1031 yinvert = 1;
1032 eina_hash_add(ob->gl_context->shared->native_wl_hash,
1033 &wlid, img);
1034
1035 n->wl_buf = wl_buf;
1036 if (glsym_eglCreateImage)
1037 n->egl_surface = glsym_eglCreateImage(ob->egl_disp,
1038 NULL,
1039 EGL_WAYLAND_BUFFER_WL,
1040 wl_buf, attribs);
1041 else
1042 {
1043 ERR("Try eglCreateImage on EGL with no support");
1044 eina_hash_del(ob->gl_context->shared->native_wl_hash,
1045 &wlid, img);
1046 glsym_evas_gl_common_image_free(img);
1047 free(n);
1048 return NULL;
1049 }
1050
1051 if (!n->egl_surface)
1052 {
1053 ERR("eglCreatePixmapSurface() for %p failed", wl_buf);
1054 eina_hash_del(ob->gl_context->shared->native_wl_hash,
1055 &wlid, img);
1056 glsym_evas_gl_common_image_free(img);
1057 free(n);
1058 return NULL;
1059 }
1060
1061 //XXX: workaround for mesa-10.2.8
1062 // mesa's eglQueryWaylandBufferWL() with EGL_WAYLAND_Y_INVERTED_WL works incorrect.
1063 //img->native.yinvert = yinvert;
1064 img->native.yinvert = 1;
1065 img->native.loose = 0;
1066 img->native.data = n;
1067 img->native.func.data = re;
1068 img->native.func.bind = _native_cb_bind;
1069 img->native.func.unbind = _native_cb_unbind;
1070 img->native.func.free = _native_cb_free;
1071 img->native.target = GL_TEXTURE_2D;
1072 img->native.mipmap = 0;
1073
1074 glsym_evas_gl_common_image_native_enable(img);
1075 }
1076 }
1077 }
1078 else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
933 { 1079 {
934 if (native) 1080 if (native)
935 { 1081 {