diff options
author | subhransu mohanty <sub.mohanty@samsung.com> | 2017-11-10 13:42:11 +0900 |
---|---|---|
committer | subhransu mohanty <sub.mohanty@samsung.com> | 2017-11-10 14:14:40 +0900 |
commit | f7347a4b9ba310230b67f4c3f7228e76cbd3a804 (patch) | |
tree | 1df3e058042a2aff2e7ff31ece8f077832d58779 | |
parent | ba4545eb8463c9babfc88e9727b5d0bb21748104 (diff) | |
download | efl-devs/subhransu/glvg.tar.gz |
ector/gl: cleanup the ector gl backenddevs/subhransu/glvg
-rw-r--r-- | src/Makefile_Ector.am | 15 | ||||
-rw-r--r-- | src/lib/ector/CMakeLists.txt | 18 | ||||
-rw-r--r-- | src/lib/ector/gl/ector_gl_shader.c | 166 | ||||
-rw-r--r-- | src/lib/ector/gl/shader/.gitignore | 1 | ||||
-rw-r--r-- | src/lib/ector/gl/shader/ector_gl_shaders.x | 285 | ||||
-rw-r--r-- | src/lib/ector/gl/shader/fragment.glsl | 168 | ||||
-rwxr-xr-x | src/lib/ector/gl/shader/gen_shaders.sh | 52 | ||||
-rw-r--r-- | src/lib/ector/gl/shader/include.glsl | 22 | ||||
-rw-r--r-- | src/lib/ector/gl/shader/vertex.glsl | 137 |
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 \ lib/ector/gl/ector_gl_private.h \ lib/ector/gl/ector_gl_shaders.x - -ECTOR_GL_SHADERS_GEN = \ -lib/ector/gl/shader/gen_shaders.sh \ -lib/ector/gl/shader/fragment.glsl \ -lib/ector/gl/shader/vertex.glsl \ -lib/ector/gl/shader/include.glsl - -lib/ector/gl/shader/ector_gl_shaders.x: $(ECTOR_GL_SHADERS_GEN) - @echo " SHADERS $@" - @sh $(srcdir)/lib/ector/gl/shader/gen_shaders.sh - lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ -I$(top_builddir)/src/lib \ -I$(top_builddir)/src/lib/ector \ @@ -209,6 +198,4 @@ static_libs/freetype/sw_ft_raster.h \ static_libs/freetype/sw_ft_stroker.h \ static_libs/freetype/sw_ft_types.h \ static_libs/draw/draw.h \ -static_libs/draw/draw_private.h \ -$(ECTOR_GL_SHADERS_GEN) - +static_libs/draw/draw_private.h 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 cairo/Ector_Cairo.h - gl/Ector_GL.h + gl/Ector_Gl.h software/Ector_Software.h ) @@ -87,13 +87,12 @@ set(SOURCES gl/ector_gl_buffer.c gl/ector_gl_buffer_base.c gl/ector_gl_private.h - gl/ector_gl_shader.c gl/ector_gl_surface.c gl/ector_renderer_gl.c gl/ector_renderer_gl_gradient_linear.c gl/ector_renderer_gl_gradient_radial.c gl/ector_renderer_gl_shape.c - gl/shader/ector_gl_shaders.x + gl/ector_gl_shaders.x software/ector_renderer_software_buffer.c software/ector_renderer_software_gradient_linear.c @@ -104,16 +103,3 @@ set(SOURCES software/ector_software_rasterizer.c software/ector_software_surface.c ) - -add_custom_target(ector-update-shaders - COMMAND /bin/sh ${EFL_LIB_SOURCE_DIR}/gl/shader/gen_shaders.sh - DEPENDS - ${EFL_LIB_SOURCE_DIR}/gl/shader/gen_shaders.sh - ${EFL_LIB_SOURCE_DIR}/gl/shader/fragment.glsl - ${EFL_LIB_SOURCE_DIR}/gl/shader/vertex.glsl - ${EFL_LIB_SOURCE_DIR}/gl/shader/include.glsl - WORKING_DIRECTORY "${EFL_LIB_SOURCE_DIR}" - COMMENT "SHADERS src/lib/ector/gl/shader/ector_gl_shaders.x (if needed)" -) - -set(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 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <Eina.h> -#include <Ector.h> - -#include "gl/Ector_GL.h" -#include "ector_private.h" -#include "ector_gl_private.h" - -#include "shader/ector_gl_shaders.x" - -static const char *_shader_flags[SHADER_FLAG_COUNT] = { - "TEX", - "BGRA", - "MASK", - "SAM12", - "SAM21", - "SAM22", - "MASKSAM12", - "MASKSAM21", - "MASKSAM22", - "IMG", - "BIGENDIAN", - "YUV", - "YUY2", - "NV12", - "YUV_709", - "EXTERNAL", - "AFILL", - "NOMUL", - "ALPHA", - "RGB_A_PAIR" -}; - -static Eina_Strbuf * -_ector_gl_shader_glsl_get(uint64_t flags, const char *base) -{ - Eina_Strbuf *r; - unsigned int k; - - r = eina_strbuf_new(); - for (k =0; k < SHADER_FLAG_COUNT; k++) - { - if (flags & (1 << k)) - eina_strbuf_append_printf(r, "#define SHD_%s\n", _shader_flags[k]); - } - - eina_strbuf_append(r, base); - - return r; -} - -static GLint -_ector_gl_shader_glsl_compile(GLuint s, const Eina_Strbuf *shader, const char *type) -{ - const char *str; - GLint ok = 0; - - str = eina_strbuf_string_get(shader); - - GL.glShaderSource(s, 1, &str, NULL); - GL.glCompileShader(s); - GL.glGetShaderiv(s, GL_COMPILE_STATUS, &ok); - if (!ok) - { - Eina_Strbuf *err; - - err = eina_strbuf_new(); - if (!err) goto on_error; - eina_strbuf_append_printf(err, "compile of %s shader", type); - - gl_compile_link_error(s, eina_strbuf_string_get(err), EINA_TRUE); - ERR("Abort %s:\n%s", eina_strbuf_string_get(err), str); - - eina_strbuf_free(err); - } - - on_error: - return ok; -} - -static GLint -_ector_gl_shader_glsl_link(uint64_t flags, - const Eina_Strbuf *vertex, - const Eina_Strbuf *fragment) -{ - GLuint vtx = 0, frg = 0, prg = 0; - GLint ok = 0; - - vtx = GL.glCreateShader(GL_VERTEX_SHADER); - frg = GL.glCreateShader(GL_FRAGMENT_SHADER); - - // Compiling vertex shader - ok = _ector_gl_shader_glsl_compile(vtx, vertex, "vertex"); - if (!ok) goto on_error; - - // Compile fragment shader - ok = _ector_gl_shader_glsl_compile(frg, fragment, "fragment"); - if (!ok) goto on_error; - - // Link both shader together - ok = 0; - - prg = GL.glCreateProgram(); -#ifndef GL_GLES - if ((GL.glGetProgramBinary) && (GL.glProgramParameteri)) - GL.glProgramParameteri(prg, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE); -#endif - GL.glAttachShader(prg, vtx); - GL.glAttachShader(prg, frg); - - GL.glBindAttribLocation(prg, SHAD_VERTEX, "vertex"); - GL.glBindAttribLocation(prg, SHAD_COLOR, "color"); - GL.glBindAttribLocation(prg, SHAD_TEXUV, "tex_coord"); - GL.glBindAttribLocation(prg, SHAD_TEXUV2, "tex_coord2"); - GL.glBindAttribLocation(prg, SHAD_TEXUV3, "tex_coord3"); - GL.glBindAttribLocation(prg, SHAD_TEXA, "tex_coorda"); - GL.glBindAttribLocation(prg, SHAD_TEXSAM, "tex_sample"); - GL.glBindAttribLocation(prg, SHAD_MASK, "mask_coord"); - GL.glBindAttribLocation(prg, SHAD_MASKSAM, "tex_masksample"); - - GL.glLinkProgram(prg); - GL.glGetProgramiv(prg, GL_LINK_STATUS, &ok); - if (!ok) - { - gl_compile_link_error(prg, "link fragment and vertex shaders", EINA_FALSE); - ERR("Abort compile of shader (flags: %16" PRIx64 ")", flags); - GL.glDeleteProgram(prg); - prg = 0; - goto on_error; - } - - on_error: - if (vtx) GL.glDeleteShader(vtx); - if (frg) GL.glDeleteShader(frg); - - return prg; -} - -GLuint -ector_gl_shader_compile(uint64_t flags) -{ - Eina_Strbuf *vertex, *fragment; - GLuint shd = 0; - - vertex = _ector_gl_shader_glsl_get(flags, vertex_glsl); - fragment = _ector_gl_shader_glsl_get(flags, fragment_glsl); - if (!vertex || !fragment) goto on_error; - - shd = _ector_gl_shader_glsl_link(flags, vertex, fragment); - - on_error: - eina_strbuf_free(vertex); - eina_strbuf_free(fragment); - -#ifdef GL_GLES - GL.glReleaseShaderCompiler(); -#else - if (GL.glReleaseShaderCompiler) - GL.glReleaseShaderCompiler(); -#endif - - return shd; -} 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 @@ -*.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 @@ -/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */ -/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */ - -static const char fragment_glsl[] = - "/* General-purpose fragment shader for all operations in Evas.\n" - " * This file can either be used directly by evas at runtime to\n" - " * generate its shaders with the appropriate #defines, or passed\n" - " * through cpp first (in which case the precision must be manually added).\n" - " */\n" - "#ifdef GL_ES\n" - "# ifdef GL_FRAGMENT_PRECISION_HIGH\n" - "precision highp float;\n" - "# else\n" - "precision mediump float;\n" - "# endif\n" - "# ifdef SHD_EXTERNAL\n" - "extension GL_OES_EGL_image_external : require\n" - "# define SAMPLER_EXTERNAL_OES samplerExternalOES\n" - "# endif\n" - "#else\n" - "# define SAMPLER_EXTERNAL_OES sampler2D\n" - "#endif\n" - "#ifndef SHD_NOMUL\n" - "varying vec4 col;\n" - "#endif\n" - "#ifdef SHD_EXTERNAL\n" - "uniform SAMPLER_EXTERNAL_OES tex;\n" - "varying vec2 tex_c;\n" - "#elif defined(SHD_TEX)\n" - "uniform sampler2D tex;\n" - "varying vec2 tex_c;\n" - "#endif\n" - "#if defined(SHD_NV12) || defined(SHD_YUY2)\n" - "uniform sampler2D texuv;\n" - "varying vec2 tex_c2;\n" - "#endif\n" - "#if defined(SHD_YUV)\n" - "uniform sampler2D texu;\n" - "uniform sampler2D texv;\n" - "varying vec2 tex_c2;\n" - "varying vec2 tex_c3;\n" - "#endif\n" - "#ifdef SHD_TEXA\n" - "uniform sampler2D texa;\n" - "varying vec2 tex_a;\n" - "#endif\n" - "#if defined(SHD_SAM12) || defined(SHD_SAM21) || defined(SHD_SAM22)\n" - "varying vec4 div_s;\n" - "# if defined(SHD_SAM12) || defined(SHD_SAM21)\n" - "varying vec2 tex_s[2];\n" - "# else\n" - "varying vec2 tex_s[4];\n" - "# endif\n" - "#endif\n" - "#ifdef SHD_MASK\n" - "uniform sampler2D texm;\n" - "varying vec2 tex_m;\n" - "# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n" - "varying float maskdiv_s;\n" - "varying vec2 masktex_s[2];\n" - "# elif defined(SHD_MASKSAM22)\n" - "varying float maskdiv_s;\n" - "varying vec2 masktex_s[4];\n" - "# endif\n" - "#endif\n" - "#ifdef SHD_ALPHA\n" - "# define SWZ aaaa\n" - "#else\n" - "# ifndef SHD_BGRA\n" - "# if defined(SHD_IMG) && defined(BIGENDIAN)\n" - "# define SWZ gbar\n" - "# else\n" - "# define SWZ bgra\n" - "#endif\n" - "# else\n" - "# if defined(SHD_IMG) && defined(BIGENDIAN)\n" - "# define SWZ grab\n" - "# else\n" - "# define SWZ rgba\n" - "# endif\n" - "# endif\n" - "#endif\n" - "void main()\n" - "{\n" - " vec4 c;\n" - "#if defined(SHD_YUV) || defined(SHD_NV12) || defined(SHD_YUY2)\n" - " float r, g, b, y, u, v, vmu;\n" - "# if defined(SHD_YUV)\n" - " y = texture2D(tex, tex_c).r;\n" - " u = texture2D(texu, tex_c2).r;\n" - " v = texture2D(texv, tex_c3).r;\n" - "# elif defined(SHD_NV12) || defined(SHD_YUY2)\n" - " y = texture2D(tex, tex_c).g;\n" - " u = texture2D(texuv, tex_c2).g;\n" - " v = texture2D(texuv, tex_c2).a;\n" - "# endif\n" - "// center u and v around 0 for uv and y (with 128/255 for u + v, 16/255 for y)\n" - " u = u - 0.5;\n" - " v = v - 0.5;\n" - "# if defined (SHD_YUV_709)\n" - "// 709 yuv colorspace for hd content\n" - " y = (y - 0.062) * 1.164;\n" - " vmu = (v * 0.534) + (u * 0.213);\n" - " v = v * 1.793;\n" - " u = u * 2.115;\n" - "# else\n" - "// 601 colorspace constants (older yuv content)\n" - " y = (y - 0.062) * 1.164;\n" - " vmu = (v * 0.813) + (u * 0.391);\n" - " v = v * 1.596;\n" - " u = u * 2.018;\n" - "# endif\n" - "// common yuv\n" - " r = y + v;\n" - " g = y - vmu;\n" - " b = y + u;\n" - " c = vec4(r, g, b, 1.0);\n" - "#elif defined(SHD_SAM12) || defined(SHD_SAM21)\n" - " vec4 col00 = texture2D(tex, tex_c + tex_s[0]).SWZ;\n" - " vec4 col01 = texture2D(tex, tex_c + tex_s[1]).SWZ;\n" - " c = (col00 + col01) / div_s;\n" - "#elif defined(SHD_SAM22)\n" - " vec4 col00 = texture2D(tex, tex_c + tex_s[0]).SWZ;\n" - " vec4 col01 = texture2D(tex, tex_c + tex_s[1]).SWZ;\n" - " vec4 col10 = texture2D(tex, tex_c + tex_s[2]).SWZ;\n" - " vec4 col11 = texture2D(tex, tex_c + tex_s[3]).SWZ;\n" - " c = (col00 + col01 + col10 + col11) / div_s;\n" - "#elif defined(SHD_TEX) || defined(SHD_EXTERNAL)\n" - " c = texture2D(tex, tex_c).SWZ;\n" - "#else\n" - " c = vec4(1, 1, 1, 1);\n" - "#endif\n" - "#ifdef SHD_MASK\n" - " float ma;\n" - "# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n" - " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n" - " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n" - " ma = (ma00 + ma01) / maskdiv_s;\n" - "# elif defined(SHD_MASKSAM22)\n" - " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n" - " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n" - " float ma10 = texture2D(texm, tex_m + masktex_s[2]).a;\n" - " float ma11 = texture2D(texm, tex_m + masktex_s[3]).a;\n" - " ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s;\n" - "# else\n" - " ma = texture2D(texm, tex_m).a;\n" - "# endif\n" - "#endif\n" - " gl_FragColor =\n" - " c\n" - "#ifndef SHD_NOMUL\n" - " * col\n" - "#endif\n" - "#ifdef SHD_MASK\n" - " * ma\n" - "#endif\n" - "#ifdef SHD_TEXA\n" - " * texture2D(texa, tex_a).r\n" - "#endif\n" - " ;\n" - "#ifdef SHD_AFILL\n" - " gl_FragColor.a = 1.0;\n" - "#endif\n" - "}\n"; - -static const char vertex_glsl[] = - "/* General-purpose vertex shader for all operations in Evas.\n" - " * This file can either be used directly by evas at runtime to\n" - " * generate its shaders with the appropriate #defines, or passed\n" - " * through cpp first (in which case the precision must be manually added).\n" - " */\n" - "#ifdef GL_ES\n" - "precision highp float;\n" - "#endif\n" - "attribute vec4 vertex;\n" - "uniform mat4 mvp;\n" - "/* All except nomul */\n" - "#ifndef SHD_NOMUL\n" - "attribute vec4 color;\n" - "varying vec4 col;\n" - "#endif\n" - "/* All images & fonts */\n" - "#if defined(SHD_TEX) || defined(SHD_EXTERNAL)\n" - "attribute vec2 tex_coord;\n" - "varying vec2 tex_c;\n" - "#endif\n" - "/* NV12, YUY2 */\n" - "#if defined(SHD_NV12) || defined(SHD_YUY2) || defined(SHD_YUV)\n" - "attribute vec2 tex_coord2;\n" - "varying vec2 tex_c2;\n" - "#endif\n" - "/* YUV */\n" - "#ifdef SHD_YUV\n" - "attribute vec2 tex_coord3;\n" - "varying vec2 tex_c3;\n" - "#endif\n" - "/* RGB+A */\n" - "#ifdef SHD_TEXA\n" - "attribute vec2 tex_coorda;\n" - "varying vec2 tex_a;\n" - "#endif\n" - "/* Sampling */\n" - "#if defined(SHD_SAM12) || defined(SHD_SAM21) || defined(SHD_SAM22)\n" - "attribute vec2 tex_sample;\n" - "varying vec4 div_s;\n" - "# if defined(SHD_SAM12) || defined(SHD_SAM21)\n" - "varying vec2 tex_s[2];\n" - "# else\n" - "varying vec2 tex_s[4];\n" - "# endif\n" - "#endif\n" - "/* Masking */\n" - "#ifdef SHD_MASK\n" - "attribute vec4 mask_coord;\n" - "varying vec2 tex_m;\n" - "# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n" - "attribute vec2 tex_masksample;\n" - "varying float maskdiv_s;\n" - "varying vec2 masktex_s[2];\n" - "# elif defined(SHD_MASKSAM22)\n" - "attribute vec2 tex_masksample;\n" - "varying float maskdiv_s;\n" - "varying vec2 masktex_s[4];\n" - "# endif\n" - "#endif\n" - "void main()\n" - "{\n" - " gl_Position = mvp * vertex;\n" - "#ifndef SHD_NOMUL\n" - " col = color;\n" - "#endif\n" - "#if defined(SHD_TEX) || defined(SHD_EXTERNAL)\n" - " tex_c = tex_coord;\n" - "#endif\n" - "#ifdef SHD_NV12\n" - " tex_c2 = tex_coord2 * 0.5;\n" - "#endif\n" - "#ifdef SHD_YUY2\n" - " tex_c2 = vec2(tex_coord2.x * 0.5, tex_coord2.y);\n" - "#endif\n" - "#ifdef SHD_YUV\n" - " tex_c2 = tex_coord2;\n" - " tex_c3 = tex_coord3;\n" - "#endif\n" - "#ifdef SHD_TEXA\n" - " tex_a = tex_coorda;\n" - "#endif\n" - "#if defined(SHD_SAM12)\n" - " tex_s[0] = vec2(0, -tex_sample.y);\n" - " tex_s[1] = vec2(0, tex_sample.y);\n" - " div_s = vec4(2, 2, 2, 2);\n" - "#elif defined(SHD_SAM21)\n" - " tex_s[0] = vec2(-tex_sample.x, 0);\n" - " tex_s[1] = vec2( tex_sample.x, 0);\n" - " div_s = vec4(2, 2, 2, 2);\n" - "#elif defined(SHD_SAM22)\n" - " tex_s[0] = vec2(-tex_sample.x, -tex_sample.y);\n" - " tex_s[1] = vec2( tex_sample.x, -tex_sample.y);\n" - " tex_s[2] = vec2( tex_sample.x, tex_sample.y);\n" - " tex_s[3] = vec2(-tex_sample.x, tex_sample.y);\n" - " div_s = vec4(4, 4, 4, 4);\n" - "#endif\n" - "#if defined(SHD_MASKSAM12)\n" - " masktex_s[0] = vec2(0, -tex_masksample.y);\n" - " masktex_s[1] = vec2(0, tex_masksample.y);\n" - " maskdiv_s = 2.0;\n" - "#elif defined(SHD_MASKSAM21)\n" - " masktex_s[0] = vec2(-tex_masksample.x, 0);\n" - " masktex_s[1] = vec2( tex_masksample.x, 0);\n" - " maskdiv_s = 2.0;\n" - "#elif defined(SHD_MASKSAM22)\n" - " masktex_s[0] = vec2(-tex_masksample.x, -tex_masksample.y);\n" - " masktex_s[1] = vec2( tex_masksample.x, -tex_masksample.y);\n" - " masktex_s[2] = vec2( tex_masksample.x, tex_masksample.y);\n" - " masktex_s[3] = vec2(-tex_masksample.x, tex_masksample.y);\n" - " maskdiv_s = 4.0;\n" - "#endif\n" - "#ifdef SHD_MASK\n" - " // mask_coord.w contains the Y-invert flag\n" - " // position on screen in [0..1] range of current pixel\n" - " 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" - " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n" - "#endif\n" - "}\n"; - 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 @@ -/* General-purpose fragment shader for all operations in Evas. - * This file can either be used directly by evas at runtime to - * generate its shaders with the appropriate #defines, or passed - * through cpp first (in which case the precision must be manually added). - */ - -FRAGMENT_SHADER - -#ifndef SHD_NOMUL -varying vec4 col; -#endif - -#ifdef SHD_EXTERNAL -uniform SAMPLER_EXTERNAL_OES tex; -varying vec2 tex_c; -#elif defined(SHD_TEX) -uniform sampler2D tex; -varying vec2 tex_c; -#endif - -#if defined(SHD_NV12) || defined(SHD_YUY2) -uniform sampler2D texuv; -varying vec2 tex_c2; -#endif - -#if defined(SHD_YUV) -uniform sampler2D texu; -uniform sampler2D texv; -varying vec2 tex_c2; -varying vec2 tex_c3; -#endif - -#ifdef SHD_TEXA -uniform sampler2D texa; -varying vec2 tex_a; -#endif - -#if defined(SHD_SAM12) || defined(SHD_SAM21) || defined(SHD_SAM22) -varying vec4 div_s; -# if defined(SHD_SAM12) || defined(SHD_SAM21) -varying vec2 tex_s[2]; -# else -varying vec2 tex_s[4]; -# endif -#endif - -#ifdef SHD_MASK -uniform sampler2D texm; -varying vec2 tex_m; -# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21) -varying float maskdiv_s; -varying vec2 masktex_s[2]; -# elif defined(SHD_MASKSAM22) -varying float maskdiv_s; -varying vec2 masktex_s[4]; -# endif -#endif - -#ifdef SHD_ALPHA -# define SWZ aaaa -#else -# ifndef SHD_BGRA -# if defined(SHD_IMG) && defined(BIGENDIAN) -# define SWZ gbar -# else -# define SWZ bgra -#endif -# else -# if defined(SHD_IMG) && defined(BIGENDIAN) -# define SWZ grab -# else -# define SWZ rgba -# endif -# endif -#endif - -void main() -{ - vec4 c; - -#if defined(SHD_YUV) || defined(SHD_NV12) || defined(SHD_YUY2) - float r, g, b, y, u, v, vmu; -# if defined(SHD_YUV) - y = texture2D(tex, tex_c).r; - u = texture2D(texu, tex_c2).r; - v = texture2D(texv, tex_c3).r; -# elif defined(SHD_NV12) || defined(SHD_YUY2) - y = texture2D(tex, tex_c).g; - u = texture2D(texuv, tex_c2).g; - v = texture2D(texuv, tex_c2).a; -# endif -// center u and v around 0 for uv and y (with 128/255 for u + v, 16/255 for y) - u = u - 0.5; - v = v - 0.5; - -# if defined (SHD_YUV_709) -// 709 yuv colorspace for hd content - y = (y - 0.062) * 1.164; - vmu = (v * 0.534) + (u * 0.213); - v = v * 1.793; - u = u * 2.115; -# else -// 601 colorspace constants (older yuv content) - y = (y - 0.062) * 1.164; - vmu = (v * 0.813) + (u * 0.391); - v = v * 1.596; - u = u * 2.018; -# endif -// common yuv - r = y + v; - g = y - vmu; - b = y + u; - c = vec4(r, g, b, 1.0); - -#elif defined(SHD_SAM12) || defined(SHD_SAM21) - vec4 col00 = texture2D(tex, tex_c + tex_s[0]).SWZ; - vec4 col01 = texture2D(tex, tex_c + tex_s[1]).SWZ; - c = (col00 + col01) / div_s; - -#elif defined(SHD_SAM22) - vec4 col00 = texture2D(tex, tex_c + tex_s[0]).SWZ; - vec4 col01 = texture2D(tex, tex_c + tex_s[1]).SWZ; - vec4 col10 = texture2D(tex, tex_c + tex_s[2]).SWZ; - vec4 col11 = texture2D(tex, tex_c + tex_s[3]).SWZ; - c = (col00 + col01 + col10 + col11) / div_s; - -#elif defined(SHD_TEX) || defined(SHD_EXTERNAL) - c = texture2D(tex, tex_c).SWZ; - -#else - c = vec4(1, 1, 1, 1); -#endif - -#ifdef SHD_MASK - float ma; -# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21) - float ma00 = texture2D(texm, tex_m + masktex_s[0]).a; - float ma01 = texture2D(texm, tex_m + masktex_s[1]).a; - ma = (ma00 + ma01) / maskdiv_s; -# elif defined(SHD_MASKSAM22) - float ma00 = texture2D(texm, tex_m + masktex_s[0]).a; - float ma01 = texture2D(texm, tex_m + masktex_s[1]).a; - float ma10 = texture2D(texm, tex_m + masktex_s[2]).a; - float ma11 = texture2D(texm, tex_m + masktex_s[3]).a; - ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s; -# else - ma = texture2D(texm, tex_m).a; -# endif -#endif - - gl_FragColor = - c -#ifndef SHD_NOMUL - * col -#endif -#ifdef SHD_MASK - * ma -#endif -#ifdef SHD_TEXA - * texture2D(texa, tex_a).r -#endif - ; - -#ifdef SHD_AFILL - gl_FragColor.a = 1.0; -#endif -} - 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 @@ -#!/bin/sh - -# This script will generate a C file containing all the shaders used by Evas - -DIR=`dirname $0` - -OUTPUT="$DIR/ector_gl_shaders.x" - -# Skip generation if there is no diff (or no git) -if ! git rev-parse 2>> /dev/null >> /dev/null ; then exit 0 ; fi -if git diff --quiet --exit-code -- "$DIR" -then - for f in gen_shaders.sh fragment.glsl vertex.glsl include.glsl; do - if [ "$DIR/$f" -nt "$OUTPUT" ]; then - touch "$OUTPUT" - break - fi - done - exit 0 -fi - -# Write header -rm -f "$OUTPUT.tmp" -cat <<EOF >> $OUTPUT.tmp -/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */ -/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */ - -EOF - -for SHD in fragment vertex ; do - m4 "$DIR/include.glsl" "$DIR/$SHD.glsl" > "$SHD.tmp" - - OIFS="$IFS" - IFS=$'\n' - echo -n "static const char ${SHD}_glsl[] =" >> "$OUTPUT.tmp" - for LINE in `cat "$SHD.tmp"` ; do - printf "\n \"$LINE\\\n\"" >> "$OUTPUT.tmp" - done - printf ";\n\n" >> "$OUTPUT.tmp" - IFS="$OIFS" - - rm "$SHD.tmp" -done - -if ! cmp "$OUTPUT" "$OUTPUT.tmp" >/dev/null 2>/dev/null; then - echo "$OUTPUT updated, please 'git commit' it." - rm -f "$OUTPUT" - mv "$OUTPUT.tmp" "$OUTPUT" -else - rm -f "$OUTPUT.tmp" -fi - 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 @@ -define(`FRAGMENT_SHADER',` -#ifdef GL_ES -# ifdef GL_FRAGMENT_PRECISION_HIGH -precision highp float; -# else -precision mediump float; -# endif -# ifdef SHD_EXTERNAL -extension GL_OES_EGL_image_external : require -# define SAMPLER_EXTERNAL_OES samplerExternalOES -# endif -#else -# define SAMPLER_EXTERNAL_OES sampler2D -#endif -') - -define(`VERTEX_SHADER',` -#ifdef GL_ES -precision highp float; -#endif -') - 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 @@ -/* General-purpose vertex shader for all operations in Evas. - * This file can either be used directly by evas at runtime to - * generate its shaders with the appropriate #defines, or passed - * through cpp first (in which case the precision must be manually added). - */ - -VERTEX_SHADER - -attribute vec4 vertex; -uniform mat4 mvp; - -/* All except nomul */ -#ifndef SHD_NOMUL -attribute vec4 color; -varying vec4 col; -#endif - -/* All images & fonts */ -#if defined(SHD_TEX) || defined(SHD_EXTERNAL) -attribute vec2 tex_coord; -varying vec2 tex_c; -#endif - -/* NV12, YUY2 */ -#if defined(SHD_NV12) || defined(SHD_YUY2) || defined(SHD_YUV) -attribute vec2 tex_coord2; -varying vec2 tex_c2; -#endif - -/* YUV */ -#ifdef SHD_YUV -attribute vec2 tex_coord3; -varying vec2 tex_c3; -#endif - -/* RGB+A */ -#ifdef SHD_TEXA -attribute vec2 tex_coorda; -varying vec2 tex_a; -#endif - -/* Sampling */ -#if defined(SHD_SAM12) || defined(SHD_SAM21) || defined(SHD_SAM22) -attribute vec2 tex_sample; -varying vec4 div_s; -# if defined(SHD_SAM12) || defined(SHD_SAM21) -varying vec2 tex_s[2]; -# else -varying vec2 tex_s[4]; -# endif -#endif - -/* Masking */ -#ifdef SHD_MASK -attribute vec4 mask_coord; -varying vec2 tex_m; -# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21) -attribute vec2 tex_masksample; -varying float maskdiv_s; -varying vec2 masktex_s[2]; -# elif defined(SHD_MASKSAM22) -attribute vec2 tex_masksample; -varying float maskdiv_s; -varying vec2 masktex_s[4]; -# endif -#endif - - -void main() -{ - gl_Position = mvp * vertex; - -#ifndef SHD_NOMUL - col = color; -#endif - -#if defined(SHD_TEX) || defined(SHD_EXTERNAL) - tex_c = tex_coord; -#endif - -#ifdef SHD_NV12 - tex_c2 = tex_coord2 * 0.5; -#endif - -#ifdef SHD_YUY2 - tex_c2 = vec2(tex_coord2.x * 0.5, tex_coord2.y); -#endif - -#ifdef SHD_YUV - tex_c2 = tex_coord2; - tex_c3 = tex_coord3; -#endif - -#ifdef SHD_TEXA - tex_a = tex_coorda; -#endif - -#if defined(SHD_SAM12) - tex_s[0] = vec2(0, -tex_sample.y); - tex_s[1] = vec2(0, tex_sample.y); - div_s = vec4(2, 2, 2, 2); -#elif defined(SHD_SAM21) - tex_s[0] = vec2(-tex_sample.x, 0); - tex_s[1] = vec2( tex_sample.x, 0); - div_s = vec4(2, 2, 2, 2); -#elif defined(SHD_SAM22) - tex_s[0] = vec2(-tex_sample.x, -tex_sample.y); - tex_s[1] = vec2( tex_sample.x, -tex_sample.y); - tex_s[2] = vec2( tex_sample.x, tex_sample.y); - tex_s[3] = vec2(-tex_sample.x, tex_sample.y); - div_s = vec4(4, 4, 4, 4); -#endif - -#if defined(SHD_MASKSAM12) - masktex_s[0] = vec2(0, -tex_masksample.y); - masktex_s[1] = vec2(0, tex_masksample.y); - maskdiv_s = 2.0; -#elif defined(SHD_MASKSAM21) - masktex_s[0] = vec2(-tex_masksample.x, 0); - masktex_s[1] = vec2( tex_masksample.x, 0); - maskdiv_s = 2.0; -#elif defined(SHD_MASKSAM22) - masktex_s[0] = vec2(-tex_masksample.x, -tex_masksample.y); - masktex_s[1] = vec2( tex_masksample.x, -tex_masksample.y); - masktex_s[2] = vec2( tex_masksample.x, tex_masksample.y); - masktex_s[3] = vec2(-tex_masksample.x, tex_masksample.y); - maskdiv_s = 4.0; -#endif - -#ifdef SHD_MASK - // mask_coord.w contains the Y-invert flag - // position on screen in [0..1] range of current pixel - 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); - tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy; -#endif -} - |