summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-11-10 13:42:11 +0900
committersubhransu mohanty <sub.mohanty@samsung.com>2017-11-10 14:14:40 +0900
commitf7347a4b9ba310230b67f4c3f7228e76cbd3a804 (patch)
tree1df3e058042a2aff2e7ff31ece8f077832d58779
parentba4545eb8463c9babfc88e9727b5d0bb21748104 (diff)
ector/gl: cleanup the ector gl backenddevs/subhransu/glvg
-rw-r--r--src/Makefile_Ector.am15
-rw-r--r--src/lib/ector/CMakeLists.txt18
-rw-r--r--src/lib/ector/gl/ector_gl_shader.c166
-rw-r--r--src/lib/ector/gl/shader/.gitignore1
-rw-r--r--src/lib/ector/gl/shader/ector_gl_shaders.x285
-rw-r--r--src/lib/ector/gl/shader/fragment.glsl168
-rwxr-xr-xsrc/lib/ector/gl/shader/gen_shaders.sh52
-rw-r--r--src/lib/ector/gl/shader/include.glsl22
-rw-r--r--src/lib/ector/gl/shader/vertex.glsl137
9 files changed, 3 insertions, 861 deletions
diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am
index 8aac906732..40e9a134db 100644
--- a/src/Makefile_Ector.am
+++ b/src/Makefile_Ector.am
@@ -138,17 +138,6 @@ lib/ector/gl/ector_gl_engine.c \
138lib/ector/gl/ector_gl_private.h \ 138lib/ector/gl/ector_gl_private.h \
139lib/ector/gl/ector_gl_shaders.x 139lib/ector/gl/ector_gl_shaders.x
140 140
141
142ECTOR_GL_SHADERS_GEN = \
143lib/ector/gl/shader/gen_shaders.sh \
144lib/ector/gl/shader/fragment.glsl \
145lib/ector/gl/shader/vertex.glsl \
146lib/ector/gl/shader/include.glsl
147
148lib/ector/gl/shader/ector_gl_shaders.x: $(ECTOR_GL_SHADERS_GEN)
149 @echo " SHADERS $@"
150 @sh $(srcdir)/lib/ector/gl/shader/gen_shaders.sh
151
152lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ 141lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
153-I$(top_builddir)/src/lib \ 142-I$(top_builddir)/src/lib \
154-I$(top_builddir)/src/lib/ector \ 143-I$(top_builddir)/src/lib/ector \
@@ -209,6 +198,4 @@ static_libs/freetype/sw_ft_raster.h \
209static_libs/freetype/sw_ft_stroker.h \ 198static_libs/freetype/sw_ft_stroker.h \
210static_libs/freetype/sw_ft_types.h \ 199static_libs/freetype/sw_ft_types.h \
211static_libs/draw/draw.h \ 200static_libs/draw/draw.h \
212static_libs/draw/draw_private.h \ 201static_libs/draw/draw_private.h
213$(ECTOR_GL_SHADERS_GEN)
214
diff --git a/src/lib/ector/CMakeLists.txt b/src/lib/ector/CMakeLists.txt
index fa6263408d..7593a5499e 100644
--- a/src/lib/ector/CMakeLists.txt
+++ b/src/lib/ector/CMakeLists.txt
@@ -61,7 +61,7 @@ set(PUBLIC_HEADERS
61 61
62 cairo/Ector_Cairo.h 62 cairo/Ector_Cairo.h
63 63
64 gl/Ector_GL.h 64 gl/Ector_Gl.h
65 65
66 software/Ector_Software.h 66 software/Ector_Software.h
67) 67)
@@ -87,13 +87,12 @@ set(SOURCES
87 gl/ector_gl_buffer.c 87 gl/ector_gl_buffer.c
88 gl/ector_gl_buffer_base.c 88 gl/ector_gl_buffer_base.c
89 gl/ector_gl_private.h 89 gl/ector_gl_private.h
90 gl/ector_gl_shader.c
91 gl/ector_gl_surface.c 90 gl/ector_gl_surface.c
92 gl/ector_renderer_gl.c 91 gl/ector_renderer_gl.c
93 gl/ector_renderer_gl_gradient_linear.c 92 gl/ector_renderer_gl_gradient_linear.c
94 gl/ector_renderer_gl_gradient_radial.c 93 gl/ector_renderer_gl_gradient_radial.c
95 gl/ector_renderer_gl_shape.c 94 gl/ector_renderer_gl_shape.c
96 gl/shader/ector_gl_shaders.x 95 gl/ector_gl_shaders.x
97 96
98 software/ector_renderer_software_buffer.c 97 software/ector_renderer_software_buffer.c
99 software/ector_renderer_software_gradient_linear.c 98 software/ector_renderer_software_gradient_linear.c
@@ -104,16 +103,3 @@ set(SOURCES
104 software/ector_software_rasterizer.c 103 software/ector_software_rasterizer.c
105 software/ector_software_surface.c 104 software/ector_software_surface.c
106) 105)
107
108add_custom_target(ector-update-shaders
109 COMMAND /bin/sh ${EFL_LIB_SOURCE_DIR}/gl/shader/gen_shaders.sh
110 DEPENDS
111 ${EFL_LIB_SOURCE_DIR}/gl/shader/gen_shaders.sh
112 ${EFL_LIB_SOURCE_DIR}/gl/shader/fragment.glsl
113 ${EFL_LIB_SOURCE_DIR}/gl/shader/vertex.glsl
114 ${EFL_LIB_SOURCE_DIR}/gl/shader/include.glsl
115 WORKING_DIRECTORY "${EFL_LIB_SOURCE_DIR}"
116 COMMENT "SHADERS src/lib/ector/gl/shader/ector_gl_shaders.x (if needed)"
117)
118
119set(DEPENDENCIES ector-update-shaders)
diff --git a/src/lib/ector/gl/ector_gl_shader.c b/src/lib/ector/gl/ector_gl_shader.c
deleted file mode 100644
index 159d8eb34b..0000000000
--- a/src/lib/ector/gl/ector_gl_shader.c
+++ /dev/null
@@ -1,166 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <Eina.h>
6#include <Ector.h>
7
8#include "gl/Ector_GL.h"
9#include "ector_private.h"
10#include "ector_gl_private.h"
11
12#include "shader/ector_gl_shaders.x"
13
14static const char *_shader_flags[SHADER_FLAG_COUNT] = {
15 "TEX",
16 "BGRA",
17 "MASK",
18 "SAM12",
19 "SAM21",
20 "SAM22",
21 "MASKSAM12",
22 "MASKSAM21",
23 "MASKSAM22",
24 "IMG",
25 "BIGENDIAN",
26 "YUV",
27 "YUY2",
28 "NV12",
29 "YUV_709",
30 "EXTERNAL",
31 "AFILL",
32 "NOMUL",
33 "ALPHA",
34 "RGB_A_PAIR"
35};
36
37static Eina_Strbuf *
38_ector_gl_shader_glsl_get(uint64_t flags, const char *base)
39{
40 Eina_Strbuf *r;
41 unsigned int k;
42
43 r = eina_strbuf_new();
44 for (k =0; k < SHADER_FLAG_COUNT; k++)
45 {
46 if (flags & (1 << k))
47 eina_strbuf_append_printf(r, "#define SHD_%s\n", _shader_flags[k]);
48 }
49
50 eina_strbuf_append(r, base);
51
52 return r;
53}
54
55static GLint
56_ector_gl_shader_glsl_compile(GLuint s, const Eina_Strbuf *shader, const char *type)
57{
58 const char *str;
59 GLint ok = 0;
60
61 str = eina_strbuf_string_get(shader);
62
63 GL.glShaderSource(s, 1, &str, NULL);
64 GL.glCompileShader(s);
65 GL.glGetShaderiv(s, GL_COMPILE_STATUS, &ok);
66 if (!ok)
67 {
68 Eina_Strbuf *err;
69
70 err = eina_strbuf_new();
71 if (!err) goto on_error;
72 eina_strbuf_append_printf(err, "compile of %s shader", type);
73
74 gl_compile_link_error(s, eina_strbuf_string_get(err), EINA_TRUE);
75 ERR("Abort %s:\n%s", eina_strbuf_string_get(err), str);
76
77 eina_strbuf_free(err);
78 }
79
80 on_error:
81 return ok;
82}
83
84static GLint
85_ector_gl_shader_glsl_link(uint64_t flags,
86 const Eina_Strbuf *vertex,
87 const Eina_Strbuf *fragment)
88{
89 GLuint vtx = 0, frg = 0, prg = 0;
90 GLint ok = 0;
91
92 vtx = GL.glCreateShader(GL_VERTEX_SHADER);
93 frg = GL.glCreateShader(GL_FRAGMENT_SHADER);
94
95 // Compiling vertex shader
96 ok = _ector_gl_shader_glsl_compile(vtx, vertex, "vertex");
97 if (!ok) goto on_error;
98
99 // Compile fragment shader
100 ok = _ector_gl_shader_glsl_compile(frg, fragment, "fragment");
101 if (!ok) goto on_error;
102
103 // Link both shader together
104 ok = 0;
105
106 prg = GL.glCreateProgram();
107#ifndef GL_GLES
108 if ((GL.glGetProgramBinary) && (GL.glProgramParameteri))
109 GL.glProgramParameteri(prg, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
110#endif
111 GL.glAttachShader(prg, vtx);
112 GL.glAttachShader(prg, frg);
113
114 GL.glBindAttribLocation(prg, SHAD_VERTEX, "vertex");
115 GL.glBindAttribLocation(prg, SHAD_COLOR, "color");
116 GL.glBindAttribLocation(prg, SHAD_TEXUV, "tex_coord");
117 GL.glBindAttribLocation(prg, SHAD_TEXUV2, "tex_coord2");
118 GL.glBindAttribLocation(prg, SHAD_TEXUV3, "tex_coord3");
119 GL.glBindAttribLocation(prg, SHAD_TEXA, "tex_coorda");
120 GL.glBindAttribLocation(prg, SHAD_TEXSAM, "tex_sample");
121 GL.glBindAttribLocation(prg, SHAD_MASK, "mask_coord");
122 GL.glBindAttribLocation(prg, SHAD_MASKSAM, "tex_masksample");
123
124 GL.glLinkProgram(prg);
125 GL.glGetProgramiv(prg, GL_LINK_STATUS, &ok);
126 if (!ok)
127 {
128 gl_compile_link_error(prg, "link fragment and vertex shaders", EINA_FALSE);
129 ERR("Abort compile of shader (flags: %16" PRIx64 ")", flags);
130 GL.glDeleteProgram(prg);
131 prg = 0;
132 goto on_error;
133 }
134
135 on_error:
136 if (vtx) GL.glDeleteShader(vtx);
137 if (frg) GL.glDeleteShader(frg);
138
139 return prg;
140}
141
142GLuint
143ector_gl_shader_compile(uint64_t flags)
144{
145 Eina_Strbuf *vertex, *fragment;
146 GLuint shd = 0;
147
148 vertex = _ector_gl_shader_glsl_get(flags, vertex_glsl);
149 fragment = _ector_gl_shader_glsl_get(flags, fragment_glsl);
150 if (!vertex || !fragment) goto on_error;
151
152 shd = _ector_gl_shader_glsl_link(flags, vertex, fragment);
153
154 on_error:
155 eina_strbuf_free(vertex);
156 eina_strbuf_free(fragment);
157
158#ifdef GL_GLES
159 GL.glReleaseShaderCompiler();
160#else
161 if (GL.glReleaseShaderCompiler)
162 GL.glReleaseShaderCompiler();
163#endif
164
165 return shd;
166}
diff --git a/src/lib/ector/gl/shader/.gitignore b/src/lib/ector/gl/shader/.gitignore
deleted file mode 100644
index 0074827b13..0000000000
--- a/src/lib/ector/gl/shader/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
1*.shd
diff --git a/src/lib/ector/gl/shader/ector_gl_shaders.x b/src/lib/ector/gl/shader/ector_gl_shaders.x
deleted file mode 100644
index 19120e26c3..0000000000
--- a/src/lib/ector/gl/shader/ector_gl_shaders.x
+++ /dev/null
@@ -1,285 +0,0 @@
1/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */
2/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */
3
4static const char fragment_glsl[] =
5 "/* General-purpose fragment shader for all operations in Evas.\n"
6 " * This file can either be used directly by evas at runtime to\n"
7 " * generate its shaders with the appropriate #defines, or passed\n"
8 " * through cpp first (in which case the precision must be manually added).\n"
9 " */\n"
10 "#ifdef GL_ES\n"
11 "# ifdef GL_FRAGMENT_PRECISION_HIGH\n"
12 "precision highp float;\n"
13 "# else\n"
14 "precision mediump float;\n"
15 "# endif\n"
16 "# ifdef SHD_EXTERNAL\n"
17 "extension GL_OES_EGL_image_external : require\n"
18 "# define SAMPLER_EXTERNAL_OES samplerExternalOES\n"
19 "# endif\n"
20 "#else\n"
21 "# define SAMPLER_EXTERNAL_OES sampler2D\n"
22 "#endif\n"
23 "#ifndef SHD_NOMUL\n"
24 "varying vec4 col;\n"
25 "#endif\n"
26 "#ifdef SHD_EXTERNAL\n"
27 "uniform SAMPLER_EXTERNAL_OES tex;\n"
28 "varying vec2 tex_c;\n"
29 "#elif defined(SHD_TEX)\n"
30 "uniform sampler2D tex;\n"
31 "varying vec2 tex_c;\n"
32 "#endif\n"
33 "#if defined(SHD_NV12) || defined(SHD_YUY2)\n"
34 "uniform sampler2D texuv;\n"
35 "varying vec2 tex_c2;\n"
36 "#endif\n"
37 "#if defined(SHD_YUV)\n"
38 "uniform sampler2D texu;\n"
39 "uniform sampler2D texv;\n"
40 "varying vec2 tex_c2;\n"
41 "varying vec2 tex_c3;\n"
42 "#endif\n"
43 "#ifdef SHD_TEXA\n"
44 "uniform sampler2D texa;\n"
45 "varying vec2 tex_a;\n"
46 "#endif\n"
47 "#if defined(SHD_SAM12) || defined(SHD_SAM21) || defined(SHD_SAM22)\n"
48 "varying vec4 div_s;\n"
49 "# if defined(SHD_SAM12) || defined(SHD_SAM21)\n"
50 "varying vec2 tex_s[2];\n"
51 "# else\n"
52 "varying vec2 tex_s[4];\n"
53 "# endif\n"
54 "#endif\n"
55 "#ifdef SHD_MASK\n"
56 "uniform sampler2D texm;\n"
57 "varying vec2 tex_m;\n"
58 "# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n"
59 "varying float maskdiv_s;\n"
60 "varying vec2 masktex_s[2];\n"
61 "# elif defined(SHD_MASKSAM22)\n"
62 "varying float maskdiv_s;\n"
63 "varying vec2 masktex_s[4];\n"
64 "# endif\n"
65 "#endif\n"
66 "#ifdef SHD_ALPHA\n"
67 "# define SWZ aaaa\n"
68 "#else\n"
69 "# ifndef SHD_BGRA\n"
70 "# if defined(SHD_IMG) && defined(BIGENDIAN)\n"
71 "# define SWZ gbar\n"
72 "# else\n"
73 "# define SWZ bgra\n"
74 "#endif\n"
75 "# else\n"
76 "# if defined(SHD_IMG) && defined(BIGENDIAN)\n"
77 "# define SWZ grab\n"
78 "# else\n"
79 "# define SWZ rgba\n"
80 "# endif\n"
81 "# endif\n"
82 "#endif\n"
83 "void main()\n"
84 "{\n"
85 " vec4 c;\n"
86 "#if defined(SHD_YUV) || defined(SHD_NV12) || defined(SHD_YUY2)\n"
87 " float r, g, b, y, u, v, vmu;\n"
88 "# if defined(SHD_YUV)\n"
89 " y = texture2D(tex, tex_c).r;\n"
90 " u = texture2D(texu, tex_c2).r;\n"
91 " v = texture2D(texv, tex_c3).r;\n"
92 "# elif defined(SHD_NV12) || defined(SHD_YUY2)\n"
93 " y = texture2D(tex, tex_c).g;\n"
94 " u = texture2D(texuv, tex_c2).g;\n"
95 " v = texture2D(texuv, tex_c2).a;\n"
96 "# endif\n"
97 "// center u and v around 0 for uv and y (with 128/255 for u + v, 16/255 for y)\n"
98 " u = u - 0.5;\n"
99 " v = v - 0.5;\n"
100 "# if defined (SHD_YUV_709)\n"
101 "// 709 yuv colorspace for hd content\n"
102 " y = (y - 0.062) * 1.164;\n"
103 " vmu = (v * 0.534) + (u * 0.213);\n"
104 " v = v * 1.793;\n"
105 " u = u * 2.115;\n"
106 "# else\n"
107 "// 601 colorspace constants (older yuv content)\n"
108 " y = (y - 0.062) * 1.164;\n"
109 " vmu = (v * 0.813) + (u * 0.391);\n"
110 " v = v * 1.596;\n"
111 " u = u * 2.018;\n"
112 "# endif\n"
113 "// common yuv\n"
114 " r = y + v;\n"
115 " g = y - vmu;\n"
116 " b = y + u;\n"
117 " c = vec4(r, g, b, 1.0);\n"
118 "#elif defined(SHD_SAM12) || defined(SHD_SAM21)\n"
119 " vec4 col00 = texture2D(tex, tex_c + tex_s[0]).SWZ;\n"
120 " vec4 col01 = texture2D(tex, tex_c + tex_s[1]).SWZ;\n"
121 " c = (col00 + col01) / div_s;\n"
122 "#elif defined(SHD_SAM22)\n"
123 " vec4 col00 = texture2D(tex, tex_c + tex_s[0]).SWZ;\n"
124 " vec4 col01 = texture2D(tex, tex_c + tex_s[1]).SWZ;\n"
125 " vec4 col10 = texture2D(tex, tex_c + tex_s[2]).SWZ;\n"
126 " vec4 col11 = texture2D(tex, tex_c + tex_s[3]).SWZ;\n"
127 " c = (col00 + col01 + col10 + col11) / div_s;\n"
128 "#elif defined(SHD_TEX) || defined(SHD_EXTERNAL)\n"
129 " c = texture2D(tex, tex_c).SWZ;\n"
130 "#else\n"
131 " c = vec4(1, 1, 1, 1);\n"
132 "#endif\n"
133 "#ifdef SHD_MASK\n"
134 " float ma;\n"
135 "# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n"
136 " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
137 " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
138 " ma = (ma00 + ma01) / maskdiv_s;\n"
139 "# elif defined(SHD_MASKSAM22)\n"
140 " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
141 " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
142 " float ma10 = texture2D(texm, tex_m + masktex_s[2]).a;\n"
143 " float ma11 = texture2D(texm, tex_m + masktex_s[3]).a;\n"
144 " ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s;\n"
145 "# else\n"
146 " ma = texture2D(texm, tex_m).a;\n"
147 "# endif\n"
148 "#endif\n"
149 " gl_FragColor =\n"
150 " c\n"
151 "#ifndef SHD_NOMUL\n"
152 " * col\n"
153 "#endif\n"
154 "#ifdef SHD_MASK\n"
155 " * ma\n"
156 "#endif\n"
157 "#ifdef SHD_TEXA\n"
158 " * texture2D(texa, tex_a).r\n"
159 "#endif\n"
160 " ;\n"
161 "#ifdef SHD_AFILL\n"
162 " gl_FragColor.a = 1.0;\n"
163 "#endif\n"
164 "}\n";
165
166static const char vertex_glsl[] =
167 "/* General-purpose vertex shader for all operations in Evas.\n"
168 " * This file can either be used directly by evas at runtime to\n"
169 " * generate its shaders with the appropriate #defines, or passed\n"
170 " * through cpp first (in which case the precision must be manually added).\n"
171 " */\n"
172 "#ifdef GL_ES\n"
173 "precision highp float;\n"
174 "#endif\n"
175 "attribute vec4 vertex;\n"
176 "uniform mat4 mvp;\n"
177 "/* All except nomul */\n"
178 "#ifndef SHD_NOMUL\n"
179 "attribute vec4 color;\n"
180 "varying vec4 col;\n"
181 "#endif\n"
182 "/* All images & fonts */\n"
183 "#if defined(SHD_TEX) || defined(SHD_EXTERNAL)\n"
184 "attribute vec2 tex_coord;\n"
185 "varying vec2 tex_c;\n"
186 "#endif\n"
187 "/* NV12, YUY2 */\n"
188 "#if defined(SHD_NV12) || defined(SHD_YUY2) || defined(SHD_YUV)\n"
189 "attribute vec2 tex_coord2;\n"
190 "varying vec2 tex_c2;\n"
191 "#endif\n"
192 "/* YUV */\n"
193 "#ifdef SHD_YUV\n"
194 "attribute vec2 tex_coord3;\n"
195 "varying vec2 tex_c3;\n"
196 "#endif\n"
197 "/* RGB+A */\n"
198 "#ifdef SHD_TEXA\n"
199 "attribute vec2 tex_coorda;\n"
200 "varying vec2 tex_a;\n"
201 "#endif\n"
202 "/* Sampling */\n"
203 "#if defined(SHD_SAM12) || defined(SHD_SAM21) || defined(SHD_SAM22)\n"
204 "attribute vec2 tex_sample;\n"
205 "varying vec4 div_s;\n"
206 "# if defined(SHD_SAM12) || defined(SHD_SAM21)\n"
207 "varying vec2 tex_s[2];\n"
208 "# else\n"
209 "varying vec2 tex_s[4];\n"
210 "# endif\n"
211 "#endif\n"
212 "/* Masking */\n"
213 "#ifdef SHD_MASK\n"
214 "attribute vec4 mask_coord;\n"
215 "varying vec2 tex_m;\n"
216 "# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n"
217 "attribute vec2 tex_masksample;\n"
218 "varying float maskdiv_s;\n"
219 "varying vec2 masktex_s[2];\n"
220 "# elif defined(SHD_MASKSAM22)\n"
221 "attribute vec2 tex_masksample;\n"
222 "varying float maskdiv_s;\n"
223 "varying vec2 masktex_s[4];\n"
224 "# endif\n"
225 "#endif\n"
226 "void main()\n"
227 "{\n"
228 " gl_Position = mvp * vertex;\n"
229 "#ifndef SHD_NOMUL\n"
230 " col = color;\n"
231 "#endif\n"
232 "#if defined(SHD_TEX) || defined(SHD_EXTERNAL)\n"
233 " tex_c = tex_coord;\n"
234 "#endif\n"
235 "#ifdef SHD_NV12\n"
236 " tex_c2 = tex_coord2 * 0.5;\n"
237 "#endif\n"
238 "#ifdef SHD_YUY2\n"
239 " tex_c2 = vec2(tex_coord2.x * 0.5, tex_coord2.y);\n"
240 "#endif\n"
241 "#ifdef SHD_YUV\n"
242 " tex_c2 = tex_coord2;\n"
243 " tex_c3 = tex_coord3;\n"
244 "#endif\n"
245 "#ifdef SHD_TEXA\n"
246 " tex_a = tex_coorda;\n"
247 "#endif\n"
248 "#if defined(SHD_SAM12)\n"
249 " tex_s[0] = vec2(0, -tex_sample.y);\n"
250 " tex_s[1] = vec2(0, tex_sample.y);\n"
251 " div_s = vec4(2, 2, 2, 2);\n"
252 "#elif defined(SHD_SAM21)\n"
253 " tex_s[0] = vec2(-tex_sample.x, 0);\n"
254 " tex_s[1] = vec2( tex_sample.x, 0);\n"
255 " div_s = vec4(2, 2, 2, 2);\n"
256 "#elif defined(SHD_SAM22)\n"
257 " tex_s[0] = vec2(-tex_sample.x, -tex_sample.y);\n"
258 " tex_s[1] = vec2( tex_sample.x, -tex_sample.y);\n"
259 " tex_s[2] = vec2( tex_sample.x, tex_sample.y);\n"
260 " tex_s[3] = vec2(-tex_sample.x, tex_sample.y);\n"
261 " div_s = vec4(4, 4, 4, 4);\n"
262 "#endif\n"
263 "#if defined(SHD_MASKSAM12)\n"
264 " masktex_s[0] = vec2(0, -tex_masksample.y);\n"
265 " masktex_s[1] = vec2(0, tex_masksample.y);\n"
266 " maskdiv_s = 2.0;\n"
267 "#elif defined(SHD_MASKSAM21)\n"
268 " masktex_s[0] = vec2(-tex_masksample.x, 0);\n"
269 " masktex_s[1] = vec2( tex_masksample.x, 0);\n"
270 " maskdiv_s = 2.0;\n"
271 "#elif defined(SHD_MASKSAM22)\n"
272 " masktex_s[0] = vec2(-tex_masksample.x, -tex_masksample.y);\n"
273 " masktex_s[1] = vec2( tex_masksample.x, -tex_masksample.y);\n"
274 " masktex_s[2] = vec2( tex_masksample.x, tex_masksample.y);\n"
275 " masktex_s[3] = vec2(-tex_masksample.x, tex_masksample.y);\n"
276 " maskdiv_s = 4.0;\n"
277 "#endif\n"
278 "#ifdef SHD_MASK\n"
279 " // mask_coord.w contains the Y-invert flag\n"
280 " // position on screen in [0..1] range of current pixel\n"
281 " vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n"
282 " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
283 "#endif\n"
284 "}\n";
285
diff --git a/src/lib/ector/gl/shader/fragment.glsl b/src/lib/ector/gl/shader/fragment.glsl
deleted file mode 100644
index 3dce873f40..0000000000
--- a/src/lib/ector/gl/shader/fragment.glsl
+++ /dev/null
@@ -1,168 +0,0 @@
1/* General-purpose fragment shader for all operations in Evas.
2 * This file can either be used directly by evas at runtime to
3 * generate its shaders with the appropriate #defines, or passed
4 * through cpp first (in which case the precision must be manually added).
5 */
6
7FRAGMENT_SHADER
8
9#ifndef SHD_NOMUL
10varying vec4 col;
11#endif
12
13#ifdef SHD_EXTERNAL
14uniform SAMPLER_EXTERNAL_OES tex;
15varying vec2 tex_c;
16#elif defined(SHD_TEX)
17uniform sampler2D tex;
18varying vec2 tex_c;
19#endif
20
21#if defined(SHD_NV12) || defined(SHD_YUY2)
22uniform sampler2D texuv;
23varying vec2 tex_c2;
24#endif
25
26#if defined(SHD_YUV)
27uniform sampler2D texu;
28uniform sampler2D texv;
29varying vec2 tex_c2;
30varying vec2 tex_c3;
31#endif
32
33#ifdef SHD_TEXA
34uniform sampler2D texa;
35varying vec2 tex_a;
36#endif
37
38#if defined(SHD_SAM12) || defined(SHD_SAM21) || defined(SHD_SAM22)
39varying vec4 div_s;
40# if defined(SHD_SAM12) || defined(SHD_SAM21)
41varying vec2 tex_s[2];
42# else
43varying vec2 tex_s[4];
44# endif
45#endif
46
47#ifdef SHD_MASK
48uniform sampler2D texm;
49varying vec2 tex_m;
50# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)
51varying float maskdiv_s;
52varying vec2 masktex_s[2];
53# elif defined(SHD_MASKSAM22)
54varying float maskdiv_s;
55varying vec2 masktex_s[4];
56# endif
57#endif
58
59#ifdef SHD_ALPHA
60# define SWZ aaaa
61#else
62# ifndef SHD_BGRA
63# if defined(SHD_IMG) && defined(BIGENDIAN)
64# define SWZ gbar
65# else
66# define SWZ bgra
67#endif
68# else
69# if defined(SHD_IMG) && defined(BIGENDIAN)
70# define SWZ grab
71# else
72# define SWZ rgba
73# endif
74# endif
75#endif
76
77void main()
78{
79 vec4 c;
80
81#if defined(SHD_YUV) || defined(SHD_NV12) || defined(SHD_YUY2)
82 float r, g, b, y, u, v, vmu;
83# if defined(SHD_YUV)
84 y = texture2D(tex, tex_c).r;
85 u = texture2D(texu, tex_c2).r;
86 v = texture2D(texv, tex_c3).r;
87# elif defined(SHD_NV12) || defined(SHD_YUY2)
88 y = texture2D(tex, tex_c).g;
89 u = texture2D(texuv, tex_c2).g;
90 v = texture2D(texuv, tex_c2).a;
91# endif
92// center u and v around 0 for uv and y (with 128/255 for u + v, 16/255 for y)
93 u = u - 0.5;
94 v = v - 0.5;
95
96# if defined (SHD_YUV_709)
97// 709 yuv colorspace for hd content
98 y = (y - 0.062) * 1.164;
99 vmu = (v * 0.534) + (u * 0.213);
100 v = v * 1.793;
101 u = u * 2.115;
102# else
103// 601 colorspace constants (older yuv content)
104 y = (y - 0.062) * 1.164;
105 vmu = (v * 0.813) + (u * 0.391);
106 v = v * 1.596;
107 u = u * 2.018;
108# endif
109// common yuv
110 r = y + v;
111 g = y - vmu;
112 b = y + u;
113 c = vec4(r, g, b, 1.0);
114
115#elif defined(SHD_SAM12) || defined(SHD_SAM21)
116 vec4 col00 = texture2D(tex, tex_c + tex_s[0]).SWZ;
117 vec4 col01 = texture2D(tex, tex_c + tex_s[1]).SWZ;
118 c = (col00 + col01) / div_s;
119
120#elif defined(SHD_SAM22)
121 vec4 col00 = texture2D(tex, tex_c + tex_s[0]).SWZ;
122 vec4 col01 = texture2D(tex, tex_c + tex_s[1]).SWZ;
123 vec4 col10 = texture2D(tex, tex_c + tex_s[2]).SWZ;
124 vec4 col11 = texture2D(tex, tex_c + tex_s[3]).SWZ;
125 c = (col00 + col01 + col10 + col11) / div_s;
126
127#elif defined(SHD_TEX) || defined(SHD_EXTERNAL)
128 c = texture2D(tex, tex_c).SWZ;
129
130#else
131 c = vec4(1, 1, 1, 1);
132#endif
133
134#ifdef SHD_MASK
135 float ma;
136# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)
137 float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;
138 float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;
139 ma = (ma00 + ma01) / maskdiv_s;
140# elif defined(SHD_MASKSAM22)
141 float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;
142 float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;
143 float ma10 = texture2D(texm, tex_m + masktex_s[2]).a;
144 float ma11 = texture2D(texm, tex_m + masktex_s[3]).a;
145 ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s;
146# else
147 ma = texture2D(texm, tex_m).a;
148# endif
149#endif
150
151 gl_FragColor =
152 c
153#ifndef SHD_NOMUL
154 * col
155#endif
156#ifdef SHD_MASK
157 * ma
158#endif
159#ifdef SHD_TEXA
160 * texture2D(texa, tex_a).r
161#endif
162 ;
163
164#ifdef SHD_AFILL
165 gl_FragColor.a = 1.0;
166#endif
167}
168
diff --git a/src/lib/ector/gl/shader/gen_shaders.sh b/src/lib/ector/gl/shader/gen_shaders.sh
deleted file mode 100755
index 9656e67ad9..0000000000
--- a/src/lib/ector/gl/shader/gen_shaders.sh
+++ /dev/null
@@ -1,52 +0,0 @@
1#!/bin/sh
2
3# This script will generate a C file containing all the shaders used by Evas
4
5DIR=`dirname $0`
6
7OUTPUT="$DIR/ector_gl_shaders.x"
8
9# Skip generation if there is no diff (or no git)
10if ! git rev-parse 2>> /dev/null >> /dev/null ; then exit 0 ; fi
11if git diff --quiet --exit-code -- "$DIR"
12then
13 for f in gen_shaders.sh fragment.glsl vertex.glsl include.glsl; do
14 if [ "$DIR/$f" -nt "$OUTPUT" ]; then
15 touch "$OUTPUT"
16 break
17 fi
18 done
19 exit 0
20fi
21
22# Write header
23rm -f "$OUTPUT.tmp"
24cat <<EOF >> $OUTPUT.tmp
25/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */
26/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */
27
28EOF
29
30for SHD in fragment vertex ; do
31 m4 "$DIR/include.glsl" "$DIR/$SHD.glsl" > "$SHD.tmp"
32
33 OIFS="$IFS"
34 IFS=$'\n'
35 echo -n "static const char ${SHD}_glsl[] =" >> "$OUTPUT.tmp"
36 for LINE in `cat "$SHD.tmp"` ; do
37 printf "\n \"$LINE\\\n\"" >> "$OUTPUT.tmp"
38 done
39 printf ";\n\n" >> "$OUTPUT.tmp"
40 IFS="$OIFS"
41
42 rm "$SHD.tmp"
43done
44
45if ! cmp "$OUTPUT" "$OUTPUT.tmp" >/dev/null 2>/dev/null; then
46 echo "$OUTPUT updated, please 'git commit' it."
47 rm -f "$OUTPUT"
48 mv "$OUTPUT.tmp" "$OUTPUT"
49else
50 rm -f "$OUTPUT.tmp"
51fi
52
diff --git a/src/lib/ector/gl/shader/include.glsl b/src/lib/ector/gl/shader/include.glsl
deleted file mode 100644
index b8f8ac115e..0000000000
--- a/src/lib/ector/gl/shader/include.glsl
+++ /dev/null
@@ -1,22 +0,0 @@
1define(`FRAGMENT_SHADER',`
2#ifdef GL_ES
3# ifdef GL_FRAGMENT_PRECISION_HIGH
4precision highp float;
5# else
6precision mediump float;
7# endif
8# ifdef SHD_EXTERNAL
9extension GL_OES_EGL_image_external : require
10# define SAMPLER_EXTERNAL_OES samplerExternalOES
11# endif
12#else
13# define SAMPLER_EXTERNAL_OES sampler2D
14#endif
15')
16
17define(`VERTEX_SHADER',`
18#ifdef GL_ES
19precision highp float;
20#endif
21')
22
diff --git a/src/lib/ector/gl/shader/vertex.glsl b/src/lib/ector/gl/shader/vertex.glsl
deleted file mode 100644
index d67eb0684e..0000000000
--- a/src/lib/ector/gl/shader/vertex.glsl
+++ /dev/null
@@ -1,137 +0,0 @@
1/* General-purpose vertex shader for all operations in Evas.
2 * This file can either be used directly by evas at runtime to
3 * generate its shaders with the appropriate #defines, or passed
4 * through cpp first (in which case the precision must be manually added).
5 */
6
7VERTEX_SHADER
8
9attribute vec4 vertex;
10uniform mat4 mvp;
11
12/* All except nomul */
13#ifndef SHD_NOMUL
14attribute vec4 color;
15varying vec4 col;
16#endif
17
18/* All images & fonts */
19#if defined(SHD_TEX) || defined(SHD_EXTERNAL)
20attribute vec2 tex_coord;
21varying vec2 tex_c;
22#endif
23
24/* NV12, YUY2 */
25#if defined(SHD_NV12) || defined(SHD_YUY2) || defined(SHD_YUV)
26attribute vec2 tex_coord2;
27varying vec2 tex_c2;
28#endif
29
30/* YUV */
31#ifdef SHD_YUV
32attribute vec2 tex_coord3;
33varying vec2 tex_c3;
34#endif
35
36/* RGB+A */
37#ifdef SHD_TEXA
38attribute vec2 tex_coorda;
39varying vec2 tex_a;
40#endif
41
42/* Sampling */
43#if defined(SHD_SAM12) || defined(SHD_SAM21) || defined(SHD_SAM22)
44attribute vec2 tex_sample;
45varying vec4 div_s;
46# if defined(SHD_SAM12) || defined(SHD_SAM21)
47varying vec2 tex_s[2];
48# else
49varying vec2 tex_s[4];
50# endif
51#endif
52
53/* Masking */
54#ifdef SHD_MASK
55attribute vec4 mask_coord;
56varying vec2 tex_m;
57# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)
58attribute vec2 tex_masksample;
59varying float maskdiv_s;
60varying vec2 masktex_s[2];
61# elif defined(SHD_MASKSAM22)
62attribute vec2 tex_masksample;
63varying float maskdiv_s;
64varying vec2 masktex_s[4];
65# endif
66#endif
67
68
69void main()
70{
71 gl_Position = mvp * vertex;
72
73#ifndef SHD_NOMUL
74 col = color;
75#endif
76
77#if defined(SHD_TEX) || defined(SHD_EXTERNAL)
78 tex_c = tex_coord;
79#endif
80
81#ifdef SHD_NV12
82 tex_c2 = tex_coord2 * 0.5;
83#endif
84
85#ifdef SHD_YUY2
86 tex_c2 = vec2(tex_coord2.x * 0.5, tex_coord2.y);
87#endif
88
89#ifdef SHD_YUV
90 tex_c2 = tex_coord2;
91 tex_c3 = tex_coord3;
92#endif
93
94#ifdef SHD_TEXA
95 tex_a = tex_coorda;
96#endif
97
98#if defined(SHD_SAM12)
99 tex_s[0] = vec2(0, -tex_sample.y);
100 tex_s[1] = vec2(0, tex_sample.y);
101 div_s = vec4(2, 2, 2, 2);
102#elif defined(SHD_SAM21)
103 tex_s[0] = vec2(-tex_sample.x, 0);
104 tex_s[1] = vec2( tex_sample.x, 0);
105 div_s = vec4(2, 2, 2, 2);
106#elif defined(SHD_SAM22)
107 tex_s[0] = vec2(-tex_sample.x, -tex_sample.y);
108 tex_s[1] = vec2( tex_sample.x, -tex_sample.y);
109 tex_s[2] = vec2( tex_sample.x, tex_sample.y);
110 tex_s[3] = vec2(-tex_sample.x, tex_sample.y);
111 div_s = vec4(4, 4, 4, 4);
112#endif
113
114#if defined(SHD_MASKSAM12)
115 masktex_s[0] = vec2(0, -tex_masksample.y);
116 masktex_s[1] = vec2(0, tex_masksample.y);
117 maskdiv_s = 2.0;
118#elif defined(SHD_MASKSAM21)
119 masktex_s[0] = vec2(-tex_masksample.x, 0);
120 masktex_s[1] = vec2( tex_masksample.x, 0);
121 maskdiv_s = 2.0;
122#elif defined(SHD_MASKSAM22)
123 masktex_s[0] = vec2(-tex_masksample.x, -tex_masksample.y);
124 masktex_s[1] = vec2( tex_masksample.x, -tex_masksample.y);
125 masktex_s[2] = vec2( tex_masksample.x, tex_masksample.y);
126 masktex_s[3] = vec2(-tex_masksample.x, tex_masksample.y);
127 maskdiv_s = 4.0;
128#endif
129
130#ifdef SHD_MASK
131 // mask_coord.w contains the Y-invert flag
132 // position on screen in [0..1] range of current pixel
133 vec4 mask_Position = mvp * vertex * vec4(0.5, sign(mask_coord.w) * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);
134 tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;
135#endif
136}
137