summaryrefslogtreecommitdiff
path: root/src/modules/evas
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 16:55:59 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-05 17:08:22 +0900
commit3593186a60e5530871a252a4bd6b03d881a0ead4 (patch)
tree188e336cdefd0b58262dc74332d0b46f83d88a16 /src/modules/evas
parentd7903e40b326de5323276cdf2869a608cd0c5a33 (diff)
wayland: Add support for TBM buffers
This is a follow up on the previous commits. The original patch on Phab was split in 3 parts (factorization, fix & this one). Adds support to both SHM and EGL. See D3501.
Diffstat (limited to 'src/modules/evas')
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_engine.c277
-rw-r--r--src/modules/evas/engines/wayland_shm/evas_engine.c91
2 files changed, 253 insertions, 115 deletions
diff --git a/src/modules/evas/engines/wayland_egl/evas_engine.c b/src/modules/evas/engines/wayland_egl/evas_engine.c
index 629547e016..e9a35a9bde 100644
--- a/src/modules/evas/engines/wayland_egl/evas_engine.c
+++ b/src/modules/evas/engines/wayland_egl/evas_engine.c
@@ -1,6 +1,7 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2#include "evas_engine.h" 2#include "evas_engine.h"
3#include "../gl_common/evas_gl_define.h" 3#include "../gl_common/evas_gl_define.h"
4#include "../software_generic/evas_native_common.h"
4 5
5#ifdef HAVE_DLSYM 6#ifdef HAVE_DLSYM
6# include <dlfcn.h> 7# include <dlfcn.h>
@@ -30,14 +31,6 @@ struct _Render_Engine
30 Render_Engine_GL_Generic generic; 31 Render_Engine_GL_Generic generic;
31}; 32};
32 33
33typedef struct _Native Native;
34struct _Native
35{
36 Evas_Native_Surface ns;
37 struct wl_buffer *wl_buf;
38 void *egl_surface;
39};
40
41/* local function prototypes */ 34/* local function prototypes */
42typedef void (*_eng_fn) (void); 35typedef void (*_eng_fn) (void);
43typedef _eng_fn (*glsym_func_eng_fn) (); 36typedef _eng_fn (*glsym_func_eng_fn) ();
@@ -57,6 +50,8 @@ Evas_GL_Common_Context_Call glsym_evas_gl_common_image_all_unload = NULL;
57Evas_GL_Preload glsym_evas_gl_preload_init = NULL; 50Evas_GL_Preload glsym_evas_gl_preload_init = NULL;
58Evas_GL_Preload glsym_evas_gl_preload_shutdown = NULL; 51Evas_GL_Preload glsym_evas_gl_preload_shutdown = NULL;
59EVGL_Engine_Call glsym_evgl_engine_shutdown = NULL; 52EVGL_Engine_Call glsym_evgl_engine_shutdown = NULL;
53EVGL_Native_Surface_Call glsym_evgl_native_surface_buffer_get = NULL;
54EVGL_Native_Surface_Yinvert_Call glsym_evgl_native_surface_yinvert_get = NULL;
60Evas_Gl_Symbols glsym_evas_gl_symbols = NULL; 55Evas_Gl_Symbols glsym_evas_gl_symbols = NULL;
61 56
62Evas_GL_Common_Context_New glsym_evas_gl_common_context_new = NULL; 57Evas_GL_Common_Context_New glsym_evas_gl_common_context_new = NULL;
@@ -96,7 +91,7 @@ eng_get_ob(Render_Engine *re)
96 return re->generic.software.ob; 91 return re->generic.software.ob;
97} 92}
98 93
99static void 94static void
100gl_symbols(void) 95gl_symbols(void)
101{ 96{
102 static Eina_Bool done = EINA_FALSE; 97 static Eina_Bool done = EINA_FALSE;
@@ -135,6 +130,8 @@ gl_symbols(void)
135 LINK2GENERIC(evas_gl_preload_render_relax); 130 LINK2GENERIC(evas_gl_preload_render_relax);
136 LINK2GENERIC(evas_gl_preload_init); 131 LINK2GENERIC(evas_gl_preload_init);
137 LINK2GENERIC(evas_gl_preload_shutdown); 132 LINK2GENERIC(evas_gl_preload_shutdown);
133 LINK2GENERIC(evgl_native_surface_buffer_get);
134 LINK2GENERIC(evgl_native_surface_yinvert_get);
138 LINK2GENERIC(evgl_engine_shutdown); 135 LINK2GENERIC(evgl_engine_shutdown);
139 LINK2GENERIC(evas_gl_symbols); 136 LINK2GENERIC(evas_gl_symbols);
140 137
@@ -809,11 +806,11 @@ _native_cb_bind(void *data EINA_UNUSED, void *image)
809 806
810 if (n->ns.type == EVAS_NATIVE_SURFACE_WL) 807 if (n->ns.type == EVAS_NATIVE_SURFACE_WL)
811 { 808 {
812 if (n->egl_surface) 809 if (n->ns_data.wl_surface.surface)
813 { 810 {
814 if (glsym_glEGLImageTargetTexture2DOES) 811 if (glsym_glEGLImageTargetTexture2DOES)
815 { 812 {
816 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface); 813 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->ns_data.wl_surface.surface);
817 GLERRV("glsym_glEGLImageTargetTexture2DOES"); 814 GLERRV("glsym_glEGLImageTargetTexture2DOES");
818 } 815 }
819 else 816 else
@@ -824,6 +821,49 @@ _native_cb_bind(void *data EINA_UNUSED, void *image)
824 { 821 {
825 glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id); 822 glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
826 } 823 }
824 else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL)
825 {
826 if (n->ns_data.evasgl.surface)
827 {
828 Eina_Bool is_egl_image = EINA_FALSE;
829 void *surface;
830
831 if (glsym_evgl_native_surface_buffer_get)
832 surface = glsym_evgl_native_surface_buffer_get(n->ns_data.evasgl.surface, &is_egl_image);
833
834 if (is_egl_image)
835 {
836 if (glsym_glEGLImageTargetTexture2DOES)
837 {
838 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, surface);
839 if (eglGetError() != EGL_SUCCESS)
840 ERR("glEGLImageTargetTexture2DOES() failed.");
841 }
842 else
843 ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
844 }
845 else
846 {
847 glBindTexture(GL_TEXTURE_2D, (GLuint)(uintptr_t)surface);
848 }
849 }
850 }
851 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
852 {
853#ifdef GL_GLES
854 if (n->ns_data.tbm.surface)
855 {
856 if (glsym_glEGLImageTargetTexture2DOES)
857 {
858 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, n->ns_data.tbm.surface);
859 if (eglGetError() != EGL_SUCCESS)
860 ERR("glEGLImageTargetTexture2DOES() failed.");
861 }
862 else
863 ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
864 }
865#endif
866 }
827} 867}
828 868
829static void 869static void
@@ -843,6 +883,14 @@ _native_cb_unbind(void *data EINA_UNUSED, void *image)
843 { 883 {
844 glBindTexture(GL_TEXTURE_2D, 0); 884 glBindTexture(GL_TEXTURE_2D, 0);
845 } 885 }
886 else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL)
887 {
888 // nothing
889 }
890 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
891 {
892 // nothing
893 }
846} 894}
847 895
848static void 896static void
@@ -862,13 +910,13 @@ _native_cb_free(void *data, void *image)
862 910
863 if (n->ns.type == EVAS_NATIVE_SURFACE_WL) 911 if (n->ns.type == EVAS_NATIVE_SURFACE_WL)
864 { 912 {
865 wlid = (void*)n->wl_buf; 913 wlid = (void*)n->ns_data.wl_surface.wl_buf;
866 eina_hash_del(ob->gl_context->shared->native_wl_hash, &wlid, img); 914 eina_hash_del(ob->gl_context->shared->native_wl_hash, &wlid, img);
867 if (n->egl_surface) 915 if (n->ns_data.wl_surface.surface)
868 { 916 {
869 if (glsym_eglDestroyImage) 917 if (glsym_eglDestroyImage)
870 { 918 {
871 glsym_eglDestroyImage(ob->egl_disp, n->egl_surface); 919 glsym_eglDestroyImage(ob->egl_disp, n->ns_data.wl_surface.surface);
872 if (eglGetError() != EGL_SUCCESS) 920 if (eglGetError() != EGL_SUCCESS)
873 ERR("eglDestroyImage() failed."); 921 ERR("eglDestroyImage() failed.");
874 } 922 }
@@ -881,7 +929,31 @@ _native_cb_free(void *data, void *image)
881 texid = n->ns.data.opengl.texture_id; 929 texid = n->ns.data.opengl.texture_id;
882 eina_hash_del(ob->gl_context->shared->native_tex_hash, &texid, img); 930 eina_hash_del(ob->gl_context->shared->native_tex_hash, &texid, img);
883 } 931 }
884 932 else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL)
933 {
934 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_evasgl_hash, &n->ns_data.evasgl.surface, img);
935 }
936 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
937 {
938 eina_hash_del(ob->gl_context->shared->native_tbm_hash, &n->ns_data.tbm.buffer, img);
939#ifdef GL_GLES
940 if (n->ns_data.tbm.surface)
941 {
942 int err;
943 if (glsym_eglDestroyImage)
944 {
945 glsym_eglDestroyImage(ob->egl_disp,
946 n->ns_data.tbm.surface);
947 if ((err = eglGetError()) != EGL_SUCCESS)
948 {
949 ERR("eglDestroyImage() failed.");
950 }
951 }
952 else
953 ERR("Try eglDestroyImage on EGL with no support");
954 }
955#endif
956 }
885 img->native.data = NULL; 957 img->native.data = NULL;
886 img->native.func.data = NULL; 958 img->native.func.data = NULL;
887 img->native.func.bind = NULL; 959 img->native.func.bind = NULL;
@@ -891,6 +963,36 @@ _native_cb_free(void *data, void *image)
891 free(n); 963 free(n);
892} 964}
893 965
966static int
967_native_cb_yinvert(void *data, void *image)
968{
969 Render_Engine *re = data;
970 Evas_GL_Image *im = image;
971 Native *n = im->native.data;
972 int yinvert = 0, val;
973
974 // Yinvert callback should only be used for EVAS_NATIVE_SURFACE_EVASGL type now,
975 // as yinvert value is not changed for other types.
976 if (n->ns.type == EVAS_NATIVE_SURFACE_WL)
977 {
978 }
979 else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
980 {
981 yinvert = 0;
982 }
983 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
984 {
985 yinvert = 1;
986 }
987 else if (n->ns.type == EVAS_NATIVE_SURFACE_EVASGL)
988 {
989 if (glsym_evgl_native_surface_yinvert_get)
990 yinvert = glsym_evgl_native_surface_yinvert_get(n->ns_data.evasgl.surface);
991 }
992
993 return yinvert;
994}
995
894static void * 996static void *
895eng_image_native_set(void *data, void *image, void *native) 997eng_image_native_set(void *data, void *image, void *native)
896{ 998{
@@ -901,6 +1003,7 @@ eng_image_native_set(void *data, void *image, void *native)
901 Evas_GL_Image *img, *img2; 1003 Evas_GL_Image *img, *img2;
902 unsigned int tex = 0, fbo = 0; 1004 unsigned int tex = 0, fbo = 0;
903 uint32_t texid; 1005 uint32_t texid;
1006 void *buffer = NULL;
904 void *wlid, *wl_buf = NULL; 1007 void *wlid, *wl_buf = NULL;
905 1008
906 if (!(re = (Render_Engine *)data)) return NULL; 1009 if (!(re = (Render_Engine *)data)) return NULL;
@@ -951,6 +1054,26 @@ eng_image_native_set(void *data, void *image, void *native)
951 return img; 1054 return img;
952 } 1055 }
953 } 1056 }
1057 else if (ns->type == EVAS_NATIVE_SURFACE_EVASGL)
1058 {
1059 buffer = ns->data.evasgl.surface;
1060 if (img->native.data)
1061 {
1062 Evas_Native_Surface *ens = img->native.data;
1063 if (ens->data.evasgl.surface == buffer)
1064 return img;
1065 }
1066 }
1067 else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
1068 {
1069 buffer = ns->data.tbm.buffer;
1070 if (img->native.data)
1071 {
1072 Evas_Native_Surface *ens = img->native.data;
1073 if (ens->data.tbm.buffer == buffer)
1074 return img;
1075 }
1076 }
954 } 1077 }
955 1078
956 if ((!ns) && (!img->native.data)) return img; 1079 if ((!ns) && (!img->native.data)) return img;
@@ -987,7 +1110,7 @@ eng_image_native_set(void *data, void *image, void *native)
987 img2 = eina_hash_find(ob->gl_context->shared->native_tex_hash, &texid); 1110 img2 = eina_hash_find(ob->gl_context->shared->native_tex_hash, &texid);
988 if (img2 == img) return img; 1111 if (img2 == img) return img;
989 if (img2) 1112 if (img2)
990 { 1113 {
991 if ((n = img2->native.data)) 1114 if ((n = img2->native.data))
992 { 1115 {
993 glsym_evas_gl_common_image_ref(img2); 1116 glsym_evas_gl_common_image_ref(img2);
@@ -996,9 +1119,39 @@ eng_image_native_set(void *data, void *image, void *native)
996 } 1119 }
997 } 1120 }
998 } 1121 }
999 1122 else if (ns->type == EVAS_NATIVE_SURFACE_EVASGL)
1000 img2 = glsym_evas_gl_common_image_new_from_data(ob->gl_context, img->w, 1123 {
1001 img->h, NULL, img->alpha, 1124 img2 = eina_hash_find(eng_get_ob(re)->gl_context->shared->native_evasgl_hash, &buffer);
1125 if (img2 == img) return img;
1126 if (img2)
1127 {
1128 n = img2->native.data;
1129 if (n)
1130 {
1131 glsym_evas_gl_common_image_ref(img2);
1132 glsym_evas_gl_common_image_free(img);
1133 return img2;
1134 }
1135 }
1136 }
1137 else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
1138 {
1139 img2 = eina_hash_find(ob->gl_context->shared->native_tbm_hash, &buffer);
1140 if (img2 == img) return img;
1141 if (img2)
1142 {
1143 n = img2->native.data;
1144 if (n)
1145 {
1146 glsym_evas_gl_common_image_ref(img2);
1147 glsym_evas_gl_common_image_free(img);
1148 return img2;
1149 }
1150 }
1151 }
1152
1153 img2 = glsym_evas_gl_common_image_new_from_data(ob->gl_context, img->w,
1154 img->h, NULL, img->alpha,
1002 EVAS_COLORSPACE_ARGB8888); 1155 EVAS_COLORSPACE_ARGB8888);
1003 glsym_evas_gl_common_image_free(img); 1156 glsym_evas_gl_common_image_free(img);
1004 1157
@@ -1036,9 +1189,9 @@ eng_image_native_set(void *data, void *image, void *native)
1036 eina_hash_add(ob->gl_context->shared->native_wl_hash, 1189 eina_hash_add(ob->gl_context->shared->native_wl_hash,
1037 &wlid, img); 1190 &wlid, img);
1038 1191
1039 n->wl_buf = wl_buf; 1192 n->ns_data.wl_surface.wl_buf = wl_buf;
1040 if (glsym_eglCreateImage) 1193 if (glsym_eglCreateImage)
1041 n->egl_surface = glsym_eglCreateImage(ob->egl_disp, 1194 n->ns_data.wl_surface.surface = glsym_eglCreateImage(ob->egl_disp,
1042 NULL, 1195 NULL,
1043 EGL_WAYLAND_BUFFER_WL, 1196 EGL_WAYLAND_BUFFER_WL,
1044 wl_buf, attribs); 1197 wl_buf, attribs);
@@ -1052,7 +1205,7 @@ eng_image_native_set(void *data, void *image, void *native)
1052 return NULL; 1205 return NULL;
1053 } 1206 }
1054 1207
1055 if (!n->egl_surface) 1208 if (!n->ns_data.wl_surface.surface)
1056 { 1209 {
1057 ERR("eglCreatePixmapSurface() for %p failed", wl_buf); 1210 ERR("eglCreatePixmapSurface() for %p failed", wl_buf);
1058 eina_hash_del(ob->gl_context->shared->native_wl_hash, 1211 eina_hash_del(ob->gl_context->shared->native_wl_hash,
@@ -1088,7 +1241,7 @@ eng_image_native_set(void *data, void *image, void *native)
1088 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); 1241 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
1089 eina_hash_add(ob->gl_context->shared->native_tex_hash, &texid, img); 1242 eina_hash_add(ob->gl_context->shared->native_tex_hash, &texid, img);
1090 1243
1091 n->egl_surface = 0; 1244 n->ns_data.opengl.surface = 0;
1092 1245
1093 img->native.yinvert = 0; 1246 img->native.yinvert = 0;
1094 img->native.loose = 0; 1247 img->native.loose = 0;
@@ -1097,6 +1250,7 @@ eng_image_native_set(void *data, void *image, void *native)
1097 img->native.func.bind = _native_cb_bind; 1250 img->native.func.bind = _native_cb_bind;
1098 img->native.func.unbind = _native_cb_unbind; 1251 img->native.func.unbind = _native_cb_unbind;
1099 img->native.func.free = _native_cb_free; 1252 img->native.func.free = _native_cb_free;
1253 img->native.func.yinvert = _native_cb_yinvert;
1100 img->native.target = GL_TEXTURE_2D; 1254 img->native.target = GL_TEXTURE_2D;
1101 img->native.mipmap = 0; 1255 img->native.mipmap = 0;
1102 1256
@@ -1104,11 +1258,86 @@ eng_image_native_set(void *data, void *image, void *native)
1104 } 1258 }
1105 } 1259 }
1106 } 1260 }
1261 else if (ns->type == EVAS_NATIVE_SURFACE_EVASGL)
1262 {
1263 if (native)
1264 {
1265 n = calloc(1, sizeof(Native));
1266 if (n)
1267 {
1268 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
1269
1270 eina_hash_add(eng_get_ob(re)->gl_context->shared->native_evasgl_hash, &buffer, img);
1271
1272 n->ns_data.evasgl.surface = ns->data.evasgl.surface;
1273 img->native.yinvert = 0;
1274 img->native.loose = 0;
1275 img->native.data = n;
1276 img->native.func.data = re;
1277 img->native.func.bind = _native_cb_bind;
1278 img->native.func.unbind = _native_cb_unbind;
1279 img->native.func.free = _native_cb_free;
1280 img->native.target = GL_TEXTURE_2D;
1281 img->native.mipmap = 0;
1282
1283 glsym_evas_gl_common_image_native_enable(img);
1284 }
1285 }
1286 }
1287 else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
1288 {
1289#ifdef GL_GLES
1290 if (native)
1291 {
1292 n = calloc(1, sizeof(Native));
1293 if (n)
1294 {
1295 eina_hash_add(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &buffer, img);
1296
1297 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
1298 n->ns_data.tbm.buffer = buffer;
1299
1300 if (glsym_eglCreateImage)
1301 n->ns_data.tbm.surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp,
1302 EGL_NO_CONTEXT,
1303 EGL_NATIVE_SURFACE_TIZEN,
1304 (void *)buffer,
1305 NULL);
1306 else
1307 ERR("Try eglCreateImage on EGL with no support");
1308 if (!n->ns_data.tbm.surface)
1309 ERR("eglCreateImage() for %p failed", buffer);
1310 img->native.yinvert = 1;
1311 img->native.loose = 0;
1312 img->native.data = n;
1313 img->native.func.data = re;
1314 img->native.func.bind = _native_cb_bind;
1315 img->native.func.unbind = _native_cb_unbind;
1316 img->native.func.free = _native_cb_free;
1317 img->native.target = GL_TEXTURE_EXTERNAL_OES;
1318 img->native.mipmap = 0;
1319 glsym_evas_gl_common_image_native_enable(img);
1320 }
1321 }
1322#endif
1323 }
1107 1324
1108 return img; 1325 return img;
1109} 1326}
1110 1327
1111Eina_Bool 1328static void *
1329eng_image_native_get(void *data EINA_UNUSED, void *image)
1330{
1331 Evas_GL_Image *im = image;
1332 Evas_Native_Surface *n;
1333
1334 if (!im) return NULL;
1335 n = im->native.data;
1336 if (!n) return NULL;
1337 return n;
1338}
1339
1340Eina_Bool
1112eng_preload_make_current(void *data, void *doit) 1341eng_preload_make_current(void *data, void *doit)
1113{ 1342{
1114 Outbuf *ob; 1343 Outbuf *ob;
diff --git a/src/modules/evas/engines/wayland_shm/evas_engine.c b/src/modules/evas/engines/wayland_shm/evas_engine.c
index e6a810c130..82500908b3 100644
--- a/src/modules/evas/engines/wayland_shm/evas_engine.c
+++ b/src/modules/evas/engines/wayland_shm/evas_engine.c
@@ -5,11 +5,6 @@
5#endif 5#endif
6 6
7#include "evas_engine.h" 7#include "evas_engine.h"
8#include "../software_generic/evas_native_common.h"
9
10#ifdef HAVE_DLSYM
11# include <dlfcn.h>
12#endif
13 8
14/* logging domain variable */ 9/* logging domain variable */
15int _evas_engine_way_shm_log_dom = -1; 10int _evas_engine_way_shm_log_dom = -1;
@@ -17,8 +12,6 @@ int _evas_engine_way_shm_log_dom = -1;
17/* evas function tables - filled in later (func and parent func) */ 12/* evas function tables - filled in later (func and parent func) */
18static Evas_Func func, pfunc; 13static Evas_Func func, pfunc;
19 14
20Evas_Native_Tbm_Surface_Image_Set_Call glsym_evas_native_tbm_surface_image_set = NULL;
21
22/* engine structure data */ 15/* engine structure data */
23typedef struct _Render_Engine Render_Engine; 16typedef struct _Render_Engine Render_Engine;
24struct _Render_Engine 17struct _Render_Engine
@@ -84,22 +77,6 @@ err:
84 return NULL; 77 return NULL;
85} 78}
86 79
87static void
88_symbols(void)
89{
90 static int done = 0;
91
92 if (done) return;
93
94#define LINK2GENERIC(sym) \
95 glsym_##sym = dlsym(RTLD_DEFAULT, #sym);
96
97 // Get function pointer to native_common that is now provided through the link of SW_Generic.
98 LINK2GENERIC(evas_native_tbm_surface_image_set);
99
100 done = 1;
101}
102
103/* ENGINE API FUNCTIONS WE PROVIDE */ 80/* ENGINE API FUNCTIONS WE PROVIDE */
104static void * 81static void *
105eng_info(Evas *eo_evas EINA_UNUSED) 82eng_info(Evas *eo_evas EINA_UNUSED)
@@ -265,71 +242,6 @@ eng_output_resize(void *data, int w, int h)
265 re->generic.h = h; 242 re->generic.h = h;
266} 243}
267 244
268static void *
269eng_image_native_set(void *data EINA_UNUSED, void *image, void *native)
270{
271 Evas_Native_Surface *ns = native;
272 Image_Entry *ie = image;
273 RGBA_Image *im = image, *im2;
274
275 if (!im || !ns) return im;
276
277 if (ns->type == EVAS_NATIVE_SURFACE_TBM)
278 {
279 if (im->native.data)
280 {
281 //image have native surface already
282 Evas_Native_Surface *ens = im->native.data;
283
284 if ((ens->type == ns->type) &&
285 (ens->data.tbm.buffer == ns->data.tbm.buffer))
286 return im;
287 }
288 }
289
290 if ((ns->type == EVAS_NATIVE_SURFACE_OPENGL) &&
291 (ns->version == EVAS_NATIVE_SURFACE_VERSION))
292 im2 = evas_cache_image_data(evas_common_image_cache_get(),
293 ie->w, ie->h,
294 ns->data.x11.visual, 1,
295 EVAS_COLORSPACE_ARGB8888);
296 else
297 im2 = evas_cache_image_data(evas_common_image_cache_get(),
298 ie->w, ie->h,
299 NULL, 1,
300 EVAS_COLORSPACE_ARGB8888);
301
302 if (im->native.data)
303 {
304 if (im->native.func.free)
305 im->native.func.free(im->native.func.data, im);
306 }
307
308#ifdef EVAS_CSERVE2
309 if (evas_cserve2_use_get() && evas_cache2_image_cached(ie))
310 evas_cache2_image_close(ie);
311 else
312#endif
313 evas_cache_image_drop(ie);
314 im = im2;
315
316 if (ns->type == EVAS_NATIVE_SURFACE_TBM)
317 return glsym_evas_native_tbm_surface_image_set(NULL, im, ns);
318
319 return im;
320}
321
322static void *
323eng_image_native_get(void *data EINA_UNUSED, void *image)
324{
325 RGBA_Image *im = image;
326 Native *n;
327 if (!im) return NULL;
328 n = im->native.data;
329 if (!n) return NULL;
330 return &(n->ns);
331}
332
333/* EVAS MODULE FUNCTIONS */ 245/* EVAS MODULE FUNCTIONS */
334static int 246static int
335module_open(Evas_Module *em) 247module_open(Evas_Module *em)
@@ -361,10 +273,7 @@ module_open(Evas_Module *em)
361 ORD(setup); 273 ORD(setup);
362 ORD(output_free); 274 ORD(output_free);
363 ORD(output_resize); 275 ORD(output_resize);
364 ORD(image_native_set);
365 ORD(image_native_get);
366 276
367 _symbols();
368 /* advertise our own engine functions */ 277 /* advertise our own engine functions */
369 em->functions = (void *)(&func); 278 em->functions = (void *)(&func);
370 279