summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorDongyeon Kim <dy5.kim@samsung.com>2015-01-19 12:28:32 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-02-10 14:48:22 +0900
commit72f3e684d90e115aacaa62f49c66821c4e90782f (patch)
treefa16ee2b81b9cf6eb28dab97a77a3727a317bc3a /src/modules
parent5df768a43aee6a53d1bd44155bdd08f59908aabf (diff)
evas/gl_x11: introduce tbm native surface type
Summary: This native surface type is based on the tbm surface used for the tizen platform. EGL_TIZEN_image_native_surface EGL extension is used to map tbm surface to an egl image @feature Reviewers: raster, cedric, jpeg Subscribers: cedric, wonsik Signed-off-by: Jean-Philippe Andre <jp.andre@samsung.com>
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h8
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c15
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_enum.x4
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x190
-rw-r--r--src/modules/evas/engines/gl_common/shader/tex_external_afill_frag.shd18
-rw-r--r--src/modules/evas/engines/gl_common/shader/tex_external_afill_vert.shd15
-rw-r--r--src/modules/evas/engines/gl_common/shader/tex_external_frag.shd17
-rw-r--r--src/modules/evas/engines/gl_common/shader/tex_external_nomul_afill_frag.shd17
-rw-r--r--src/modules/evas/engines/gl_common/shader/tex_external_nomul_afill_vert.shd12
-rw-r--r--src/modules/evas/engines/gl_common/shader/tex_external_nomul_frag.shd16
-rw-r--r--src/modules/evas/engines/gl_common/shader/tex_external_nomul_vert.shd12
-rw-r--r--src/modules/evas/engines/gl_common/shader/tex_external_vert.shd15
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c105
13 files changed, 444 insertions, 0 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 4f2a552458..481a55713c 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -132,6 +132,10 @@
132#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 132#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
133# define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 133# define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
134#endif 134#endif
135#ifndef GL_TEXTURE_EXTERNAL_OES
136# define GL_TEXTURE_EXTERNAL_OES 0x8D65
137#endif
138
135 139
136#ifndef GL_UNPACK_ROW_LENGTH 140#ifndef GL_UNPACK_ROW_LENGTH
137# define GL_UNPACK_ROW_LENGTH 0x0cf2 141# define GL_UNPACK_ROW_LENGTH 0x0cf2
@@ -186,6 +190,9 @@
186#ifndef EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC 190#ifndef EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC
187# define EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC 0x320c 191# define EGL_MAP_GL_TEXTURE_STRIDE_IN_BYTES_SEC 0x320c
188#endif 192#endif
193#ifndef EGL_NATIVE_SURFACE_TIZEN
194#define EGL_NATIVE_SURFACE_TIZEN 0x32A1
195#endif
189#ifndef GL_PROGRAM_BINARY_LENGTH 196#ifndef GL_PROGRAM_BINARY_LENGTH
190# define GL_PROGRAM_BINARY_LENGTH 0x8741 197# define GL_PROGRAM_BINARY_LENGTH 0x8741
191#endif 198#endif
@@ -378,6 +385,7 @@ struct _Evas_GL_Shared
378 Eina_Hash *native_pm_hash; 385 Eina_Hash *native_pm_hash;
379 Eina_Hash *native_tex_hash; 386 Eina_Hash *native_tex_hash;
380 Eina_Hash *native_wl_hash; 387 Eina_Hash *native_wl_hash;
388 Eina_Hash *native_tbm_hash;
381 389
382#ifdef GL_GLES 390#ifdef GL_GLES
383 // FIXME: hack. 391 // FIXME: hack.
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 bd683bdf6b..bed567cda9 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -907,6 +907,7 @@ evas_gl_common_context_new(void)
907 shared->native_pm_hash = eina_hash_int32_new(NULL); 907 shared->native_pm_hash = eina_hash_int32_new(NULL);
908 shared->native_tex_hash = eina_hash_int32_new(NULL); 908 shared->native_tex_hash = eina_hash_int32_new(NULL);
909 shared->native_wl_hash = eina_hash_pointer_new(NULL); 909 shared->native_wl_hash = eina_hash_pointer_new(NULL);
910 shared->native_tbm_hash = eina_hash_pointer_new(NULL);
910 } 911 }
911 gc->shared = shared; 912 gc->shared = shared;
912 gc->shared->references++; 913 gc->shared->references++;
@@ -981,6 +982,7 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc)
981 eina_hash_free(gc->shared->native_pm_hash); 982 eina_hash_free(gc->shared->native_pm_hash);
982 eina_hash_free(gc->shared->native_tex_hash); 983 eina_hash_free(gc->shared->native_tex_hash);
983 eina_hash_free(gc->shared->native_wl_hash); 984 eina_hash_free(gc->shared->native_wl_hash);
985 eina_hash_free(gc->shared->native_tbm_hash);
984 free(gc->shared); 986 free(gc->shared);
985 shared = NULL; 987 shared = NULL;
986 } 988 }
@@ -1885,6 +1887,19 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
1885 SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA); 1887 SHADER_IMG_MASK_BGRA_NOMUL, SHADER_IMG_MASK_BGRA);
1886 } 1888 }
1887 } 1889 }
1890#ifdef GL_GLES
1891 else if (tex->im && tex->im->native.target == GL_TEXTURE_EXTERNAL_OES)
1892 {
1893 if ((!tex->alpha) && (tex->pt->native))
1894 shader = evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex,
1895 SHADER_TEX_EXTERNAL_NOMUL_AFILL, SHADER_TEX_EXTERNAL_AFILL,
1896 SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK);
1897 else
1898 shader = evas_gl_common_shader_choice(0, NULL, r, g, b, a, !!mtex,
1899 SHADER_TEX_EXTERNAL_NOMUL, SHADER_TEX_EXTERNAL,
1900 SHADER_IMG_MASK_NOMUL, SHADER_IMG_MASK);
1901 }
1902#endif
1888 else 1903 else
1889 { 1904 {
1890 if ((smooth) && ((sw >= (w * 2)) && (sh >= (h * 2)))) 1905 if ((smooth) && ((sw >= (w * 2)) && (sh >= (h * 2))))
diff --git a/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x b/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
index 6a543bb1c0..3da8ac2b09 100644
--- a/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
+++ b/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
@@ -58,5 +58,9 @@ typedef enum {
58 SHADER_MAP_MASK_NOMUL, 58 SHADER_MAP_MASK_NOMUL,
59 SHADER_MAP_MASK_BGRA, 59 SHADER_MAP_MASK_BGRA,
60 SHADER_MAP_MASK_BGRA_NOMUL, 60 SHADER_MAP_MASK_BGRA_NOMUL,
61 SHADER_TEX_EXTERNAL,
62 SHADER_TEX_EXTERNAL_NOMUL,
63 SHADER_TEX_EXTERNAL_AFILL,
64 SHADER_TEX_EXTERNAL_NOMUL_AFILL,
61 SHADER_LAST 65 SHADER_LAST
62} Evas_GL_Shader; 66} Evas_GL_Shader;
diff --git a/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x b/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
index 1aa4b27be1..712a84924e 100644
--- a/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
+++ b/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
@@ -2899,6 +2899,192 @@ Evas_GL_Program_Source shader_map_mask_bgra_nomul_vert_src =
2899 NULL, 0 2899 NULL, 0
2900}; 2900};
2901 2901
2902/* Source: modules/evas/engines/gl_common/shader/tex_external_frag.shd */
2903static const char const tex_external_frag_glsl[] =
2904 "#ifdef GL_ES\n"
2905 "#extension GL_OES_EGL_image_external : require\n"
2906 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
2907 "precision highp float;\n"
2908 "#else\n"
2909 "precision mediump float;\n"
2910 "#endif\n"
2911 "uniform samplerExternalOES tex;\n"
2912 "#else\n"
2913 "uniform sampler2D tex;\n"
2914 "#endif\n"
2915 "varying vec4 col;\n"
2916 "varying vec2 tex_c;\n"
2917 "void main()\n"
2918 "{\n"
2919 " gl_FragColor = texture2D(tex, tex_c.xy) * col;\n"
2920 "}\n";
2921Evas_GL_Program_Source shader_tex_external_frag_src =
2922{
2923 tex_external_frag_glsl,
2924 NULL, 0
2925};
2926
2927/* Source: modules/evas/engines/gl_common/shader/tex_external_vert.shd */
2928static const char const tex_external_vert_glsl[] =
2929 "#ifdef GL_ES\n"
2930 "precision highp float;\n"
2931 "#endif\n"
2932 "attribute vec4 vertex;\n"
2933 "attribute vec4 color;\n"
2934 "attribute vec2 tex_coord;\n"
2935 "uniform mat4 mvp;\n"
2936 "varying vec4 col;\n"
2937 "varying vec2 tex_c;\n"
2938 "void main()\n"
2939 "{\n"
2940 " gl_Position = mvp * vertex;\n"
2941 " col = color;\n"
2942 " tex_c = tex_coord;\n"
2943 "}\n";
2944Evas_GL_Program_Source shader_tex_external_vert_src =
2945{
2946 tex_external_vert_glsl,
2947 NULL, 0
2948};
2949
2950/* Source: modules/evas/engines/gl_common/shader/tex_external_nomul_frag.shd */
2951static const char const tex_external_nomul_frag_glsl[] =
2952 "#ifdef GL_ES\n"
2953 "#extension GL_OES_EGL_image_external : require\n"
2954 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
2955 "precision highp float;\n"
2956 "#else\n"
2957 "precision mediump float;\n"
2958 "#endif\n"
2959 "uniform samplerExternalOES tex;\n"
2960 "#else\n"
2961 "uniform sampler2D tex;\n"
2962 "#endif\n"
2963 "varying vec2 tex_c;\n"
2964 "void main()\n"
2965 "{\n"
2966 " gl_FragColor = texture2D(tex, tex_c.xy);\n"
2967 "}\n";
2968Evas_GL_Program_Source shader_tex_external_nomul_frag_src =
2969{
2970 tex_external_nomul_frag_glsl,
2971 NULL, 0
2972};
2973
2974/* Source: modules/evas/engines/gl_common/shader/tex_external_nomul_vert.shd */
2975static const char const tex_external_nomul_vert_glsl[] =
2976 "#ifdef GL_ES\n"
2977 "precision highp float;\n"
2978 "#endif\n"
2979 "attribute vec4 vertex;\n"
2980 "attribute vec2 tex_coord;\n"
2981 "uniform mat4 mvp;\n"
2982 "varying vec2 tex_c;\n"
2983 "void main()\n"
2984 "{\n"
2985 " gl_Position = mvp * vertex;\n"
2986 " tex_c = tex_coord;\n"
2987 "}\n";
2988Evas_GL_Program_Source shader_tex_external_nomul_vert_src =
2989{
2990 tex_external_nomul_vert_glsl,
2991 NULL, 0
2992};
2993
2994/* Source: modules/evas/engines/gl_common/shader/tex_external_afill_frag.shd */
2995static const char const tex_external_afill_frag_glsl[] =
2996 "#ifdef GL_ES\n"
2997 "#extension GL_OES_EGL_image_external : require\n"
2998 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
2999 "precision highp float;\n"
3000 "#else\n"
3001 "precision mediump float;\n"
3002 "#endif\n"
3003 "uniform samplerExternalOES tex;\n"
3004 "#else\n"
3005 "uniform sampler2D tex;\n"
3006 "#endif\n"
3007 "varying vec4 col;\n"
3008 "varying vec2 tex_c;\n"
3009 "void main()\n"
3010 "{\n"
3011 " vec4 c = texture2D(tex, tex_c.xy);\n"
3012 " gl_FragColor = vec4(c.r, c.g, c.b, 1) * col;\n"
3013 "}\n";
3014Evas_GL_Program_Source shader_tex_external_afill_frag_src =
3015{
3016 tex_external_afill_frag_glsl,
3017 NULL, 0
3018};
3019
3020/* Source: modules/evas/engines/gl_common/shader/tex_external_afill_vert.shd */
3021static const char const tex_external_afill_vert_glsl[] =
3022 "#ifdef GL_ES\n"
3023 "precision highp float;\n"
3024 "#endif\n"
3025 "attribute vec4 vertex;\n"
3026 "attribute vec4 color;\n"
3027 "attribute vec2 tex_coord;\n"
3028 "uniform mat4 mvp;\n"
3029 "varying vec4 col;\n"
3030 "varying vec2 tex_c;\n"
3031 "void main()\n"
3032 "{\n"
3033 " gl_Position = mvp * vertex;\n"
3034 " col = color;\n"
3035 " tex_c = tex_coord;\n"
3036 "}\n";
3037Evas_GL_Program_Source shader_tex_external_afill_vert_src =
3038{
3039 tex_external_afill_vert_glsl,
3040 NULL, 0
3041};
3042
3043/* Source: modules/evas/engines/gl_common/shader/tex_external_nomul_afill_frag.shd */
3044static const char const tex_external_nomul_afill_frag_glsl[] =
3045 "#ifdef GL_ES\n"
3046 "#extension GL_OES_EGL_image_external : require\n"
3047 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
3048 "precision highp float;\n"
3049 "#else\n"
3050 "precision mediump float;\n"
3051 "#endif\n"
3052 "uniform samplerExternalOES tex;\n"
3053 "#else\n"
3054 "uniform sampler2D tex;\n"
3055 "#endif\n"
3056 "varying vec2 tex_c;\n"
3057 "void main()\n"
3058 "{\n"
3059 " vec4 c = texture2D(tex, tex_c.xy);\n"
3060 " gl_FragColor = vec4(c.r, c.g, c.b, 1);\n"
3061 "}\n";
3062Evas_GL_Program_Source shader_tex_external_nomul_afill_frag_src =
3063{
3064 tex_external_nomul_afill_frag_glsl,
3065 NULL, 0
3066};
3067
3068/* Source: modules/evas/engines/gl_common/shader/tex_external_nomul_afill_vert.shd */
3069static const char const tex_external_nomul_afill_vert_glsl[] =
3070 "#ifdef GL_ES\n"
3071 "precision highp float;\n"
3072 "#endif\n"
3073 "attribute vec4 vertex;\n"
3074 "attribute vec2 tex_coord;\n"
3075 "uniform mat4 mvp;\n"
3076 "varying vec2 tex_c;\n"
3077 "void main()\n"
3078 "{\n"
3079 " gl_Position = mvp * vertex;\n"
3080 " tex_c = tex_coord;\n"
3081 "}\n";
3082Evas_GL_Program_Source shader_tex_external_nomul_afill_vert_src =
3083{
3084 tex_external_nomul_afill_vert_glsl,
3085 NULL, 0
3086};
3087
2902static const struct { 3088static const struct {
2903 Evas_GL_Shader id; 3089 Evas_GL_Shader id;
2904 Evas_GL_Program_Source *vert; 3090 Evas_GL_Program_Source *vert;
@@ -2961,5 +3147,9 @@ static const struct {
2961 { SHADER_MAP_MASK_NOMUL, &(shader_map_mask_nomul_vert_src), &(shader_map_mask_nomul_frag_src), "map_mask_nomul" }, 3147 { SHADER_MAP_MASK_NOMUL, &(shader_map_mask_nomul_vert_src), &(shader_map_mask_nomul_frag_src), "map_mask_nomul" },
2962 { SHADER_MAP_MASK_BGRA, &(shader_map_mask_bgra_vert_src), &(shader_map_mask_bgra_frag_src), "map_mask_bgra" }, 3148 { SHADER_MAP_MASK_BGRA, &(shader_map_mask_bgra_vert_src), &(shader_map_mask_bgra_frag_src), "map_mask_bgra" },
2963 { SHADER_MAP_MASK_BGRA_NOMUL, &(shader_map_mask_bgra_nomul_vert_src), &(shader_map_mask_bgra_nomul_frag_src), "map_mask_bgra_nomul" }, 3149 { SHADER_MAP_MASK_BGRA_NOMUL, &(shader_map_mask_bgra_nomul_vert_src), &(shader_map_mask_bgra_nomul_frag_src), "map_mask_bgra_nomul" },
3150 { SHADER_TEX_EXTERNAL, &(shader_tex_external_vert_src), &(shader_tex_external_frag_src), "tex_external" },
3151 { SHADER_TEX_EXTERNAL_NOMUL, &(shader_tex_external_nomul_vert_src), &(shader_tex_external_nomul_frag_src), "tex_external_nomul" },
3152 { SHADER_TEX_EXTERNAL_AFILL, &(shader_tex_external_afill_vert_src), &(shader_tex_external_afill_frag_src), "tex_external_afill" },
3153 { SHADER_TEX_EXTERNAL_NOMUL_AFILL, &(shader_tex_external_nomul_afill_vert_src), &(shader_tex_external_nomul_afill_frag_src), "tex_external_nomul_afill" },
2964}; 3154};
2965 3155
diff --git a/src/modules/evas/engines/gl_common/shader/tex_external_afill_frag.shd b/src/modules/evas/engines/gl_common/shader/tex_external_afill_frag.shd
new file mode 100644
index 0000000000..790911e318
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/tex_external_afill_frag.shd
@@ -0,0 +1,18 @@
1#ifdef GL_ES
2#extension GL_OES_EGL_image_external : require
3#ifdef GL_FRAGMENT_PRECISION_HIGH
4precision highp float;
5#else
6precision mediump float;
7#endif
8uniform samplerExternalOES tex;
9#else
10uniform sampler2D tex;
11#endif
12varying vec4 col;
13varying vec2 tex_c;
14void main()
15{
16 vec4 c = texture2D(tex, tex_c.xy);
17 gl_FragColor = vec4(c.r, c.g, c.b, 1) * col;
18}
diff --git a/src/modules/evas/engines/gl_common/shader/tex_external_afill_vert.shd b/src/modules/evas/engines/gl_common/shader/tex_external_afill_vert.shd
new file mode 100644
index 0000000000..606c297e6d
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/tex_external_afill_vert.shd
@@ -0,0 +1,15 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4attribute vec4 vertex;
5attribute vec4 color;
6attribute vec2 tex_coord;
7uniform mat4 mvp;
8varying vec4 col;
9varying vec2 tex_c;
10void main()
11{
12 gl_Position = mvp * vertex;
13 col = color;
14 tex_c = tex_coord;
15}
diff --git a/src/modules/evas/engines/gl_common/shader/tex_external_frag.shd b/src/modules/evas/engines/gl_common/shader/tex_external_frag.shd
new file mode 100644
index 0000000000..48a6626c74
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/tex_external_frag.shd
@@ -0,0 +1,17 @@
1#ifdef GL_ES
2#extension GL_OES_EGL_image_external : require
3#ifdef GL_FRAGMENT_PRECISION_HIGH
4precision highp float;
5#else
6precision mediump float;
7#endif
8uniform samplerExternalOES tex;
9#else
10uniform sampler2D tex;
11#endif
12varying vec4 col;
13varying vec2 tex_c;
14void main()
15{
16 gl_FragColor = texture2D(tex, tex_c.xy) * col;
17}
diff --git a/src/modules/evas/engines/gl_common/shader/tex_external_nomul_afill_frag.shd b/src/modules/evas/engines/gl_common/shader/tex_external_nomul_afill_frag.shd
new file mode 100644
index 0000000000..93e8aa0c93
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/tex_external_nomul_afill_frag.shd
@@ -0,0 +1,17 @@
1#ifdef GL_ES
2#extension GL_OES_EGL_image_external : require
3#ifdef GL_FRAGMENT_PRECISION_HIGH
4precision highp float;
5#else
6precision mediump float;
7#endif
8uniform samplerExternalOES tex;
9#else
10uniform sampler2D tex;
11#endif
12varying vec2 tex_c;
13void main()
14{
15 vec4 c = texture2D(tex, tex_c.xy);
16 gl_FragColor = vec4(c.r, c.g, c.b, 1);
17}
diff --git a/src/modules/evas/engines/gl_common/shader/tex_external_nomul_afill_vert.shd b/src/modules/evas/engines/gl_common/shader/tex_external_nomul_afill_vert.shd
new file mode 100644
index 0000000000..74f3207177
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/tex_external_nomul_afill_vert.shd
@@ -0,0 +1,12 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4attribute vec4 vertex;
5attribute vec2 tex_coord;
6uniform mat4 mvp;
7varying vec2 tex_c;
8void main()
9{
10 gl_Position = mvp * vertex;
11 tex_c = tex_coord;
12}
diff --git a/src/modules/evas/engines/gl_common/shader/tex_external_nomul_frag.shd b/src/modules/evas/engines/gl_common/shader/tex_external_nomul_frag.shd
new file mode 100644
index 0000000000..f852d1759f
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/tex_external_nomul_frag.shd
@@ -0,0 +1,16 @@
1#ifdef GL_ES
2#extension GL_OES_EGL_image_external : require
3#ifdef GL_FRAGMENT_PRECISION_HIGH
4precision highp float;
5#else
6precision mediump float;
7#endif
8uniform samplerExternalOES tex;
9#else
10uniform sampler2D tex;
11#endif
12varying vec2 tex_c;
13void main()
14{
15 gl_FragColor = texture2D(tex, tex_c.xy);
16}
diff --git a/src/modules/evas/engines/gl_common/shader/tex_external_nomul_vert.shd b/src/modules/evas/engines/gl_common/shader/tex_external_nomul_vert.shd
new file mode 100644
index 0000000000..74f3207177
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/tex_external_nomul_vert.shd
@@ -0,0 +1,12 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4attribute vec4 vertex;
5attribute vec2 tex_coord;
6uniform mat4 mvp;
7varying vec2 tex_c;
8void main()
9{
10 gl_Position = mvp * vertex;
11 tex_c = tex_coord;
12}
diff --git a/src/modules/evas/engines/gl_common/shader/tex_external_vert.shd b/src/modules/evas/engines/gl_common/shader/tex_external_vert.shd
new file mode 100644
index 0000000000..606c297e6d
--- /dev/null
+++ b/src/modules/evas/engines/gl_common/shader/tex_external_vert.shd
@@ -0,0 +1,15 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4attribute vec4 vertex;
5attribute vec4 color;
6attribute vec2 tex_coord;
7uniform mat4 mvp;
8varying vec4 col;
9varying vec2 tex_c;
10void main()
11{
12 gl_Position = mvp * vertex;
13 col = color;
14 tex_c = tex_coord;
15}
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index 3721d31f00..cdbe5d297d 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -1841,6 +1841,7 @@ struct _Native
1841 Evas_Native_Surface ns; 1841 Evas_Native_Surface ns;
1842 Pixmap pixmap; 1842 Pixmap pixmap;
1843 Visual *visual; 1843 Visual *visual;
1844 void *buffer;
1844 1845
1845#ifdef GL_GLES 1846#ifdef GL_GLES
1846 void *egl_surface; 1847 void *egl_surface;
@@ -1899,6 +1900,22 @@ _native_bind_cb(void *data EINA_UNUSED, void *image)
1899 glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id); 1900 glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
1900 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 1901 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1901 } 1902 }
1903 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
1904 {
1905#ifdef GL_GLES
1906 if (n->egl_surface)
1907 {
1908 if (glsym_glEGLImageTargetTexture2DOES)
1909 {
1910 glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, n->egl_surface);
1911 if (eglGetError() != EGL_SUCCESS)
1912 ERR("glEGLImageTargetTexture2DOES() failed.");
1913 }
1914 else
1915 ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
1916 }
1917#endif
1918 }
1902} 1919}
1903 1920
1904static void 1921static void
@@ -1931,6 +1948,10 @@ _native_unbind_cb(void *data EINA_UNUSED, void *image)
1931 glBindTexture(GL_TEXTURE_2D, 0); 1948 glBindTexture(GL_TEXTURE_2D, 0);
1932 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 1949 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1933 } 1950 }
1951 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
1952 {
1953 // nothing
1954 }
1934} 1955}
1935 1956
1936static void 1957static void
@@ -1994,6 +2015,28 @@ _native_free_cb(void *data, void *image)
1994 texid = n->ns.data.opengl.texture_id; 2015 texid = n->ns.data.opengl.texture_id;
1995 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tex_hash, &texid, im); 2016 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tex_hash, &texid, im);
1996 } 2017 }
2018 else if (n->ns.type == EVAS_NATIVE_SURFACE_TBM)
2019 {
2020 eina_hash_del(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &n->buffer, im);
2021#ifdef GL_GLES
2022 if (n->egl_surface)
2023 {
2024 int err;
2025 if (glsym_eglDestroyImage)
2026 {
2027 glsym_eglDestroyImage(eng_get_ob(re)->egl_disp,
2028 n->egl_surface);
2029 if ((err = eglGetError()) != EGL_SUCCESS)
2030 {
2031 ERR("eglDestroyImage() failed.");
2032 glsym_evas_gl_common_error_set(err - EGL_SUCCESS);
2033 }
2034 }
2035 else
2036 ERR("Try eglDestroyImage on EGL with no support");
2037 }
2038#endif
2039 }
1997 im->native.data = NULL; 2040 im->native.data = NULL;
1998 im->native.func.data = NULL; 2041 im->native.func.data = NULL;
1999 im->native.func.bind = NULL; 2042 im->native.func.bind = NULL;
@@ -2014,6 +2057,7 @@ eng_image_native_set(void *data, void *image, void *native)
2014 uint32_t pmid, texid; 2057 uint32_t pmid, texid;
2015 unsigned int tex = 0; 2058 unsigned int tex = 0;
2016 unsigned int fbo = 0; 2059 unsigned int fbo = 0;
2060 void *buffer = NULL;
2017 2061
2018 if (!im) 2062 if (!im)
2019 { 2063 {
@@ -2055,6 +2099,16 @@ eng_image_native_set(void *data, void *image, void *native)
2055 return im; 2099 return im;
2056 } 2100 }
2057 } 2101 }
2102 else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
2103 {
2104 buffer = ns->data.tbm.buffer;
2105 if (im->native.data)
2106 {
2107 Evas_Native_Surface *ens = im->native.data;
2108 if (ens->data.tbm.buffer == buffer)
2109 return im;
2110 }
2111 }
2058 } 2112 }
2059 if ((!ns) && (!im->native.data)) return im; 2113 if ((!ns) && (!im->native.data)) return im;
2060 2114
@@ -2102,6 +2156,21 @@ eng_image_native_set(void *data, void *image, void *native)
2102 } 2156 }
2103 2157
2104 } 2158 }
2159 else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
2160 {
2161 im2 = eina_hash_find(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &buffer);
2162 if (im2 == im) return im;
2163 if (im2)
2164 {
2165 n = im2->native.data;
2166 if (n)
2167 {
2168 glsym_evas_gl_common_image_ref(im2);
2169 glsym_evas_gl_common_image_free(im);
2170 return im2;
2171 }
2172 }
2173 }
2105 im2 = glsym_evas_gl_common_image_new_from_data(eng_get_ob(re)->gl_context, 2174 im2 = glsym_evas_gl_common_image_new_from_data(eng_get_ob(re)->gl_context,
2106 im->w, im->h, NULL, im->alpha, 2175 im->w, im->h, NULL, im->alpha,
2107 EVAS_COLORSPACE_ARGB8888); 2176 EVAS_COLORSPACE_ARGB8888);
@@ -2432,6 +2501,42 @@ eng_image_native_set(void *data, void *image, void *native)
2432 } 2501 }
2433 2502
2434 } 2503 }
2504 else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
2505 {
2506#ifdef GL_GLES
2507 if (native)
2508 {
2509 n = calloc(1, sizeof(Native));
2510 if (n)
2511 {
2512 eina_hash_add(eng_get_ob(re)->gl_context->shared->native_tbm_hash, &buffer, im);
2513
2514 memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
2515 n->buffer = buffer;
2516 if (glsym_eglCreateImage)
2517 n->egl_surface = glsym_eglCreateImage(eng_get_ob(re)->egl_disp,
2518 EGL_NO_CONTEXT,
2519 EGL_NATIVE_SURFACE_TIZEN,
2520 (void *)buffer,
2521 NULL);
2522 else
2523 ERR("Try eglCreateImage on EGL with no support");
2524 if (!n->egl_surface)
2525 ERR("eglCreateImage() for %p failed", buffer);
2526 im->native.yinvert = 1;
2527 im->native.loose = 0;
2528 im->native.data = n;
2529 im->native.func.data = re;
2530 im->native.func.bind = _native_bind_cb;
2531 im->native.func.unbind = _native_unbind_cb;
2532 im->native.func.free = _native_free_cb;
2533 im->native.target = GL_TEXTURE_EXTERNAL_OES;
2534 im->native.mipmap = 0;
2535 glsym_evas_gl_common_image_native_enable(im);
2536 }
2537 }
2538#endif
2539 }
2435 return im; 2540 return im;
2436} 2541}
2437 2542