summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-11-05 15:39:32 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-11-10 16:12:20 +0900
commit38ad8fda8ddb681707b42a17a23eba29b3bbd86e (patch)
treedcf22fb1ed0be42ae79acb4c75d08130a4171051 /src
parent43ef6152eda0ac0e4ef3aee55b25264f12e4e64b (diff)
Evas GL: Implement runtime generation and load of shaders
Instead of generating the shaders at compile-time, do this at runtime. Also load only the required shaders in memory. This saves 25000 LOC, lots of strings inside the .so files and save a non negligible amount of memory since those shader binaries can weigh a few megabytes in total. The current shader selection mechanism is a bit complex and uses eina_hash_int32 but this can be optimized later if it's deemed too slow.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Evas.am12
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h40
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c393
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_shader.c764
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_enum.x595
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x13392
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders_bigendian.x13345
-rw-r--r--src/modules/evas/engines/gl_common/shader/fragment.glsl8
-rwxr-xr-xsrc/modules/evas/engines/gl_common/shader/gen_shaders.sh199
-rw-r--r--src/modules/evas/engines/gl_common/shader/include.glsl22
-rw-r--r--src/modules/evas/engines/gl_common/shader/shaders.txt302
-rw-r--r--src/modules/evas/engines/gl_common/shader/vertex.glsl5
12 files changed, 876 insertions, 28201 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index b94ac1fa20..aaf4ea22f2 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -682,9 +682,8 @@ modules/evas/engines/gl_common/evas_gl_api_gles1.c \
682modules/evas/engines/gl_common/evas_gl_api_gles3_def.h \ 682modules/evas/engines/gl_common/evas_gl_api_gles3_def.h \
683modules/evas/engines/gl_common/evas_gl_api_ext.c \ 683modules/evas/engines/gl_common/evas_gl_api_ext.c \
684modules/evas/engines/gl_common/shader/evas_gl_shaders.x \ 684modules/evas/engines/gl_common/shader/evas_gl_shaders.x \
685modules/evas/engines/gl_common/shader/evas_gl_shaders_bigendian.x \
686modules/evas/engines/gl_common/shader_3d/evas_gl_3d_shaders.x \ 685modules/evas/engines/gl_common/shader_3d/evas_gl_3d_shaders.x \
687modules/evas/engines/gl_common/shader/evas_gl_enum.x 686$(NULL)
688 687
689# 3D 688# 3D
690GL_COMMON_SOURCES += \ 689GL_COMMON_SOURCES += \
@@ -696,24 +695,17 @@ modules/evas/engines/gl_common/evas_gl_3d_shader.c
696 695
697GL_SHADERS_GEN = \ 696GL_SHADERS_GEN = \
698modules/evas/engines/gl_common/shader/gen_shaders.sh \ 697modules/evas/engines/gl_common/shader/gen_shaders.sh \
699modules/evas/engines/gl_common/shader/shaders.txt \
700modules/evas/engines/gl_common/shader/fragment.glsl \ 698modules/evas/engines/gl_common/shader/fragment.glsl \
701modules/evas/engines/gl_common/shader/vertex.glsl \ 699modules/evas/engines/gl_common/shader/vertex.glsl \
700modules/evas/engines/gl_common/shader/include.glsl \
702$(NULL) 701$(NULL)
703 702
704EXTRA_DIST += $(GL_SHADERS_GEN) 703EXTRA_DIST += $(GL_SHADERS_GEN)
705EXTRA_lib_evas_libevas_la_DEPENDENCIES = modules/evas/engines/gl_common/shader/evas_gl_enum.x
706 704
707modules/evas/engines/gl_common/shader/evas_gl_shaders.x: $(GL_SHADERS_GEN) 705modules/evas/engines/gl_common/shader/evas_gl_shaders.x: $(GL_SHADERS_GEN)
708 @echo " SHADERS $@" 706 @echo " SHADERS $@"
709 @bash $(srcdir)/modules/evas/engines/gl_common/shader/gen_shaders.sh 707 @bash $(srcdir)/modules/evas/engines/gl_common/shader/gen_shaders.sh
710 708
711modules/evas/engines/gl_common/shader/evas_gl_shaders_bigendian.x: $(GL_SHADERS_GEN)
712 @echo " SHADERS $@"
713 @bash $(srcdir)/modules/evas/engines/gl_common/shader/gen_shaders.sh _bigendian
714
715modules/evas/engines/gl_common/shader/evas_gl_enum.x: modules/evas/engines/gl_common/shader/evas_gl_shaders.x modules/evas/engines/gl_common/shader/evas_gl_shaders_bigendian.x
716
717# NOTE: order here should be equal with modes in file Evas_Eo.h 709# NOTE: order here should be equal with modes in file Evas_Eo.h
718GL_SHADERS_3D_GEN = \ 710GL_SHADERS_3D_GEN = \
719modules/evas/engines/gl_common/shader_3d/vertex_color_vert.shd \ 711modules/evas/engines/gl_common/shader_3d/vertex_color_vert.shd \
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 fb7da52099..c1435843c3 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -67,9 +67,6 @@ typedef struct _Evas_GL_Texture_Async_Preload Evas_GL_Texture_Async_Preload;
67 67
68typedef Eina_Bool (*evas_gl_make_current_cb)(void *engine_data, void *doit); 68typedef Eina_Bool (*evas_gl_make_current_cb)(void *engine_data, void *doit);
69 69
70/* enum Evas_GL_Shader is defined below */
71#include "shader/evas_gl_enum.x"
72
73#ifdef EAPI 70#ifdef EAPI
74# undef EAPI 71# undef EAPI
75#endif 72#endif
@@ -96,12 +93,16 @@ typedef Eina_Bool (*evas_gl_make_current_cb)(void *engine_data, void *doit);
96# endif 93# endif
97#endif /* ! _WIN32 */ 94#endif /* ! _WIN32 */
98 95
96#define PROGRAM_HITCOUNT_MAX 0x1000000
97
99struct _Evas_GL_Program 98struct _Evas_GL_Program
100{ 99{
101 GLuint vert, frag, prog; 100 GLuint vert, frag, prog;
101 unsigned int flags, hitcount;
102 102
103 int tex_count; 103 int tex_count;
104 Eina_Bool reset; 104 Eina_Bool reset : 1;
105 Eina_Bool bin_saved : 1;
105}; 106};
106 107
107struct _Evas_GL_Shared 108struct _Evas_GL_Shared
@@ -181,12 +182,13 @@ struct _Evas_GL_Shared
181 Eina_Hash *native_tbm_hash; 182 Eina_Hash *native_tbm_hash;
182 Eina_Hash *native_evasgl_hash; 183 Eina_Hash *native_evasgl_hash;
183 184
185 Eet_File *shaders_cache;
186 Eina_Hash *shaders_hash;
187
184#ifdef GL_GLES 188#ifdef GL_GLES
185 // FIXME: hack. 189 // FIXME: hack.
186 void *eglctxt; 190 void *eglctxt;
187#endif 191#endif
188
189 Evas_GL_Program shader[SHADER_LAST];
190 192
191 int references; 193 int references;
192 int w, h; 194 int w, h;
@@ -212,6 +214,7 @@ enum _Shader_Sampling {
212enum _Shader_Type { 214enum _Shader_Type {
213 SHD_UNKNOWN, 215 SHD_UNKNOWN,
214 SHD_RECT, 216 SHD_RECT,
217 SHD_LINE,
215 SHD_FONT, 218 SHD_FONT,
216 SHD_IMAGE, 219 SHD_IMAGE,
217 SHD_IMAGENATIVE, 220 SHD_IMAGENATIVE,
@@ -221,9 +224,7 @@ enum _Shader_Type {
221 SHD_YUV_709, 224 SHD_YUV_709,
222 SHD_YUY2_709, 225 SHD_YUY2_709,
223 SHD_NV12_709, 226 SHD_NV12_709,
224 SHD_LINE,
225 SHD_RGB_A_PAIR, 227 SHD_RGB_A_PAIR,
226 SHD_TEX_EXTERNAL,
227 SHD_MAP, 228 SHD_MAP,
228 SHD_TYPE_LAST 229 SHD_TYPE_LAST
229}; 230};
@@ -245,8 +246,7 @@ struct _Evas_Engine_GL_Context
245 struct { 246 struct {
246 int top_pipe; 247 int top_pipe;
247 struct { 248 struct {
248 Evas_GL_Shader id; 249 Evas_GL_Program *prog;
249 GLuint cur_prog;
250 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm; 250 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm;
251 int render_op; 251 int render_op;
252 int cx, cy, cw, ch; 252 int cx, cy, cw, ch;
@@ -273,9 +273,8 @@ struct _Evas_Engine_GL_Context
273 Eina_Bool active : 1; 273 Eina_Bool active : 1;
274 } clip; 274 } clip;
275 struct { 275 struct {
276 Evas_GL_Shader id; 276 Evas_GL_Program *prog;
277 Evas_GL_Image *surface; 277 Evas_GL_Image *surface;
278 GLuint cur_prog;
279 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm; 278 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm;
280 void *cur_tex_dyn, *cur_texu_dyn, *cur_texv_dyn; 279 void *cur_tex_dyn, *cur_texu_dyn, *cur_texv_dyn;
281 int render_op; 280 int render_op;
@@ -595,9 +594,19 @@ void evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *g
595 594
596int evas_gl_common_shader_program_init(Evas_GL_Shared *shared); 595int evas_gl_common_shader_program_init(Evas_GL_Shared *shared);
597void evas_gl_common_shader_program_init_done(void); 596void evas_gl_common_shader_program_init_done(void);
598void evas_gl_common_shader_program_shutdown(Evas_GL_Program *p); 597void evas_gl_common_shader_program_shutdown(Evas_GL_Shared *shared);
599Evas_GL_Shader evas_gl_common_img_shader_select(Shader_Type type, Shader_Sampling sam, int nomul, int afill, int bgra, int mask, int masksam); 598
600const char *evas_gl_common_shader_name_get(Evas_GL_Shader shd); 599Evas_GL_Program *evas_gl_common_shader_program_get(Evas_Engine_GL_Context *gc,
600 Shader_Type type,
601 RGBA_Map_Point *p, int npoints,
602 int r, int g, int b, int a,
603 int sw, int sh, int w, int h, Eina_Bool smooth,
604 Evas_GL_Texture *tex, Eina_Bool tex_only,
605 Evas_GL_Texture *mtex, Eina_Bool mask_smooth,
606 int mw, int mh,
607 Shader_Sampling *psam, int *pnomul,
608 Shader_Sampling *pmasksam);
609void evas_gl_common_shader_textures_bind(Evas_GL_Program *p);
601 610
602Eina_Bool evas_gl_common_file_cache_is_dir(const char *file); 611Eina_Bool evas_gl_common_file_cache_is_dir(const char *file);
603Eina_Bool evas_gl_common_file_cache_mkdir(const char *dir); 612Eina_Bool evas_gl_common_file_cache_mkdir(const char *dir);
@@ -606,7 +615,6 @@ Eina_Bool evas_gl_common_file_cache_mkpath_if_not_exists(const char *pat
606Eina_Bool evas_gl_common_file_cache_mkpath(const char *path); 615Eina_Bool evas_gl_common_file_cache_mkpath(const char *path);
607int evas_gl_common_file_cache_dir_check(char *cache_dir, int num); 616int evas_gl_common_file_cache_dir_check(char *cache_dir, int num);
608int evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_name, char *cache_file, int dir_num); 617int evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_name, char *cache_file, int dir_num);
609int evas_gl_common_file_cache_save(Evas_GL_Shared *shared);
610 618
611void evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h); 619void evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h);
612 620
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 5e33fbe6e7..58ec6fe173 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -7,7 +7,7 @@
7# error gl_common should not get compiled if dlsym is not found on the system! 7# error gl_common should not get compiled if dlsym is not found on the system!
8#endif 8#endif
9 9
10#define PRG_INVALID 0xffffffff 10#define PRG_INVALID NULL
11#define GLPIPES 1 11#define GLPIPES 1
12 12
13static int sym_done = 0; 13static int sym_done = 0;
@@ -487,8 +487,9 @@ _evas_gl_common_version_check(int *gles_ver)
487static void 487static void
488_evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc) 488_evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
489{ 489{
490 unsigned int i;
491 int w = 1, h = 1, m = 1, rot = 1, foc = 0; 490 int w = 1, h = 1, m = 1, rot = 1, foc = 0;
491 Evas_GL_Program *prog;
492 Eina_Iterator *it;
492 493
493 EINA_SAFETY_ON_NULL_RETURN(gc); 494 EINA_SAFETY_ON_NULL_RETURN(gc);
494 foc = gc->foc; 495 foc = gc->foc;
@@ -619,21 +620,24 @@ _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
619 gc->shared->ay = ay; 620 gc->shared->ay = ay;
620 } 621 }
621 622
622 for (i = 0; i < SHADER_LAST; ++i) 623 // FIXME: Is this heavy work?
623 { 624 it = eina_hash_iterator_data_new(gc->shared->shaders_hash);
624 gc->shared->shader[i].reset = EINA_TRUE; 625 EINA_ITERATOR_FOREACH(it, prog)
625 } 626 prog->reset = EINA_TRUE;
627 eina_iterator_free(it);
626 628
627 if (gc->state.current.cur_prog == PRG_INVALID) 629 if (gc->state.current.prog != PRG_INVALID)
630 /*
628 { 631 {
629 glUseProgram(gc->shared->shader[0].prog); 632 glUseProgram(gc->shared->shader[0].prog);
630 glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader[0].prog, "mvp"), 1, GL_FALSE, gc->shared->proj); 633 glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader[0].prog, "mvp"), 1, GL_FALSE, gc->shared->proj);
631 gc->shared->shader[0].reset = EINA_FALSE; 634 gc->shared->shader[0].reset = EINA_FALSE;
632 } 635 }
633 else 636 else
637 */
634 { 638 {
635 glUseProgram(gc->state.current.cur_prog); 639 glUseProgram(gc->state.current.prog->prog);
636 glUniformMatrix4fv(glGetUniformLocation(gc->state.current.cur_prog, "mvp"), 1, GL_FALSE, gc->shared->proj); 640 glUniformMatrix4fv(glGetUniformLocation(gc->state.current.prog->prog, "mvp"), 1, GL_FALSE, gc->shared->proj);
637 } 641 }
638} 642}
639 643
@@ -677,7 +681,6 @@ evas_gl_common_context_new(void)
677 if (!shared) 681 if (!shared)
678 { 682 {
679 const char *ext; 683 const char *ext;
680 int shd;
681 684
682 shared = calloc(1, sizeof(Evas_GL_Shared)); 685 shared = calloc(1, sizeof(Evas_GL_Shared));
683 ext = (const char *) glGetString(GL_EXTENSIONS); 686 ext = (const char *) glGetString(GL_EXTENSIONS);
@@ -924,20 +927,11 @@ evas_gl_common_context_new(void)
924 glEnableVertexAttribArray(SHAD_VERTEX); 927 glEnableVertexAttribArray(SHAD_VERTEX);
925 glEnableVertexAttribArray(SHAD_COLOR); 928 glEnableVertexAttribArray(SHAD_COLOR);
926 929
927 if (!evas_gl_common_shader_program_init(shared)) goto error; 930 if (!evas_gl_common_shader_program_init(shared))
931 goto error;
928 932
929 /* Bind textures */ 933 if (gc->state.current.prog)
930 for (shd = 0; _shaders_textures[shd].id != SHADER_LAST; shd++) 934 glUseProgram(gc->state.current.prog->prog);
931 {
932 GLuint loc;
933 glUseProgram(shared->shader[_shaders_textures[shd].id].prog);
934 loc = glGetUniformLocation(shared->shader[_shaders_textures[shd].id].prog, _shaders_textures[shd].tname);
935 glUniform1i(loc, shared->shader[_shaders_textures[shd].id].tex_count++);
936 }
937
938 if (gc->state.current.cur_prog == PRG_INVALID)
939 glUseProgram(shared->shader[0].prog);
940 else glUseProgram(gc->state.current.cur_prog);
941 935
942 evas_gl_common_shader_program_init_done(); 936 evas_gl_common_shader_program_init_done();
943 // in shader: 937 // in shader:
@@ -961,7 +955,8 @@ evas_gl_common_context_new(void)
961 gc->def_surface = evas_gl_common_image_surface_new(gc, 1, 1, 1); 955 gc->def_surface = evas_gl_common_image_surface_new(gc, 1, 1, 1);
962 956
963 return gc; 957 return gc;
964 error: 958
959error:
965 evas_gl_common_context_free(gc); 960 evas_gl_common_context_free(gc);
966 return NULL; 961 return NULL;
967} 962}
@@ -1010,8 +1005,7 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc)
1010 { 1005 {
1011 Evas_GL_Texture_Pool *pt; 1006 Evas_GL_Texture_Pool *pt;
1012 1007
1013 for (i = 0; i < SHADER_LAST; ++i) 1008 evas_gl_common_shader_program_shutdown(gc->shared);
1014 evas_gl_common_shader_program_shutdown(&(gc->shared->shader[i]));
1015 1009
1016 while (gc->shared->images) 1010 while (gc->shared->images)
1017 { 1011 {
@@ -1072,8 +1066,7 @@ evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc)
1072// fprintf(stderr, "------------------------\n"); 1066// fprintf(stderr, "------------------------\n");
1073 1067
1074 gc->flushnum = 0; 1068 gc->flushnum = 0;
1075 gc->state.current.id = SHADER_LAST; 1069 gc->state.current.prog = NULL;
1076 gc->state.current.cur_prog = 0;
1077 gc->state.current.cur_tex = 0; 1070 gc->state.current.cur_tex = 0;
1078 gc->state.current.cur_texu = 0; 1071 gc->state.current.cur_texu = 0;
1079 gc->state.current.cur_texv = 0; 1072 gc->state.current.cur_texv = 0;
@@ -1101,8 +1094,7 @@ evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc)
1101 gc->pipe[i].clip.w = 0; 1094 gc->pipe[i].clip.w = 0;
1102 gc->pipe[i].clip.h = 0; 1095 gc->pipe[i].clip.h = 0;
1103 gc->pipe[i].shader.surface = NULL; 1096 gc->pipe[i].shader.surface = NULL;
1104 gc->pipe[i].shader.id = SHADER_LAST; 1097 gc->pipe[i].shader.prog = NULL;
1105 gc->pipe[i].shader.cur_prog = 0;
1106 gc->pipe[i].shader.cur_tex = 0; 1098 gc->pipe[i].shader.cur_tex = 0;
1107 gc->pipe[i].shader.cur_texu = 0; 1099 gc->pipe[i].shader.cur_texu = 0;
1108 gc->pipe[i].shader.cur_texv = 0; 1100 gc->pipe[i].shader.cur_texv = 0;
@@ -1142,9 +1134,8 @@ evas_gl_common_context_newframe(Evas_Engine_GL_Context *gc)
1142 1134
1143 glEnableVertexAttribArray(SHAD_VERTEX); 1135 glEnableVertexAttribArray(SHAD_VERTEX);
1144 glEnableVertexAttribArray(SHAD_COLOR); 1136 glEnableVertexAttribArray(SHAD_COLOR);
1145 if (gc->state.current.cur_prog == PRG_INVALID) 1137 if (gc->state.current.prog != PRG_INVALID)
1146 glUseProgram(gc->shared->shader[0].prog); 1138 glUseProgram(gc->state.current.prog->prog);
1147 else glUseProgram(gc->state.current.cur_prog);
1148 1139
1149 glActiveTexture(GL_TEXTURE0); 1140 glActiveTexture(GL_TEXTURE0);
1150 glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex); 1141 glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
@@ -1226,8 +1217,7 @@ evas_gl_common_context_target_surface_set(Evas_Engine_GL_Context *gc,
1226 evas_gl_common_context_flush(gc); 1217 evas_gl_common_context_flush(gc);
1227 evas_gl_common_context_done(gc); 1218 evas_gl_common_context_done(gc);
1228 1219
1229 gc->state.current.id = SHADER_LAST; 1220 gc->state.current.prog = NULL;
1230 gc->state.current.cur_prog = PRG_INVALID;
1231 gc->state.current.cur_tex = 0; 1221 gc->state.current.cur_tex = 0;
1232 gc->state.current.cur_texu = 0; 1222 gc->state.current.cur_texu = 0;
1233 gc->state.current.cur_texv = 0; 1223 gc->state.current.cur_texv = 0;
@@ -1516,165 +1506,12 @@ vertex_array_size_check(Evas_Engine_GL_Context *gc EINA_UNUSED, int pn EINA_UNUS
1516 */ 1506 */
1517} 1507}
1518 1508
1519static Evas_GL_Shader
1520evas_gl_common_shader_select(Evas_Engine_GL_Context *gc,
1521 Shader_Type type,
1522 RGBA_Map_Point *p, int npoints,
1523 int r, int g, int b, int a,
1524 int sw, int sh, int w, int h, Eina_Bool smooth,
1525 Evas_GL_Texture *tex, Eina_Bool tex_only,
1526 Evas_GL_Texture *mtex, Eina_Bool mask_smooth,
1527 int mw, int mh,
1528 Shader_Sampling *psam, int *pnomul, Shader_Sampling *pmasksam)
1529{
1530 const Eina_Bool gc_bgra = gc->shared->info.bgra;
1531 int nomul = 1, bgra = 0;
1532 int mask = (mtex != NULL), afill = 0;
1533 Shader_Sampling sam = SHD_SAM11, masksam = SHD_SAM11;
1534 Evas_GL_Shader shader = SHADER_RECT;
1535 int k = 0;
1536
1537 if ((type <= SHD_UNKNOWN) || (type >= SHD_TYPE_LAST))
1538 {
1539 CRI("Unknown shader type requested!");
1540 goto end;
1541 }
1542
1543 // image downscale sampling
1544 if (smooth && ((type == SHD_IMAGE) || (type == SHD_IMAGENATIVE)))
1545 {
1546 if ((sw >= (w * 2)) && (sh >= (h * 2)))
1547 sam = SHD_SAM22;
1548 else if (sw >= (w * 2))
1549 sam = SHD_SAM21;
1550 else if (sh >= (h * 2))
1551 sam = SHD_SAM12;
1552 }
1553
1554 // mask downscale sampling
1555 if (mtex && mask_smooth)
1556 {
1557 if ((mtex->w >= (mw * 2)) && (mtex->h >= (mh * 2)))
1558 masksam = SHD_SAM22;
1559 else if (mtex->w >= (mw * 2))
1560 masksam = SHD_SAM21;
1561 else if (mtex->h >= (mh * 2))
1562 masksam = SHD_SAM12;
1563 }
1564
1565 // rect, line, polygon
1566 if ((type == SHD_RECT) || (type == SHD_LINE))
1567 {
1568 static const Evas_GL_Shader rect_shaders[] = {
1569 SHADER_RECT_MASK, SHADER_RECT_MASK12, SHADER_RECT_MASK21, SHADER_RECT_MASK22
1570 };
1571 if (!mtex) shader = SHADER_RECT;
1572 else shader = rect_shaders[masksam];
1573 goto end;
1574 }
1575
1576 // text
1577 if (type == SHD_FONT)
1578 {
1579 static const Evas_GL_Shader font_shaders[] = {
1580 SHADER_FONT_MASK, SHADER_FONT_MASK12, SHADER_FONT_MASK21, SHADER_FONT_MASK22
1581 };
1582 if (!mtex) shader = SHADER_FONT;
1583 else shader = font_shaders[masksam];
1584 goto end;
1585 }
1586
1587 // color mul
1588 if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
1589 {
1590 if (p)
1591 {
1592 for (k = 0; k < npoints; k++)
1593 if (p[k].col != 0xffffffff)
1594 {
1595 nomul = 0;
1596 break;
1597 }
1598 }
1599 }
1600 else
1601 nomul = 0;
1602
1603 // bgra
1604 if (tex_only)
1605 {
1606 if (tex->pt->dyn.img)
1607 {
1608 afill = !tex->alpha;
1609 bgra = 1;
1610 }
1611 else if (tex->im && tex->im->native.target == GL_TEXTURE_EXTERNAL_OES)
1612 {
1613 type = SHD_TEX_EXTERNAL;
1614 afill = !tex->alpha;
1615 }
1616 else
1617 bgra = 1;
1618 }
1619 else
1620 bgra = gc_bgra;
1621
1622 if ((type == SHD_IMAGE) || (type == SHD_IMAGENATIVE) || (type == SHD_MAP))
1623 shader = evas_gl_common_img_shader_select(type, sam, nomul, afill, bgra, mask, masksam);
1624 else
1625 {
1626#define SHADERS(name, ...) \
1627 SHADER_##name##_NOMUL##__VA_ARGS__, SHADER_##name##__VA_ARGS__, \
1628 SHADER_##name##_MASK_NOMUL, SHADER_##name##_MASK
1629 static const Evas_GL_Shader yuv_shaders[] = {
1630 SHADERS(YUV),
1631 SHADERS(YUY2),
1632 SHADERS(NV12),
1633 SHADERS(YUV_709),
1634 SHADERS(YUY2_709),
1635 SHADERS(NV12_709),
1636 SHADERS(RGB_A_PAIR),
1637 SHADERS(TEX_EXTERNAL),
1638 SHADERS(TEX_EXTERNAL, _AFILL), /* note: afill + mask does not exist */
1639 };
1640#undef SHADERS
1641
1642 switch (type)
1643 {
1644 case SHD_YUV: k = 0; break;
1645 case SHD_YUY2: k = 4; break;
1646 case SHD_NV12: k = 8; break;
1647 case SHD_YUV_709: k = 12; break;
1648 case SHD_YUY2_709: k = 16; break;
1649 case SHD_NV12_709: k = 20; break;
1650 case SHD_RGB_A_PAIR: k = 24; break;
1651 case SHD_TEX_EXTERNAL: k = 28; break;
1652 default:
1653 CRI("Unknown shader type requested!");
1654 goto end;
1655 }
1656
1657 shader = yuv_shaders[k + (afill * 4) + (mask * 2) + (!nomul)];
1658 }
1659
1660 /*
1661 DBG("sam %d, nomul %d, afill %d, bgra %d, mask %d --> [%02d] %s",
1662 (int) sam, nomul, afill, bgra, mask, shader,
1663 evas_gl_common_shader_name_get(shader));
1664 */
1665end:
1666 if (psam) *psam = sam;
1667 if (pnomul) *pnomul = nomul;
1668 if (pmasksam) *pmasksam = masksam;
1669 return shader;
1670}
1671
1672static int 1509static int
1673_evas_gl_common_context_push(Shader_Type rtype, 1510_evas_gl_common_context_push(Shader_Type rtype,
1674 Evas_Engine_GL_Context *gc, 1511 Evas_Engine_GL_Context *gc,
1675 Evas_GL_Texture *tex, 1512 Evas_GL_Texture *tex,
1676 Evas_GL_Texture *texm, 1513 Evas_GL_Texture *texm,
1677 GLuint prog, 1514 Evas_GL_Program *prog,
1678 int x, int y, int w, int h, 1515 int x, int y, int w, int h,
1679 Eina_Bool blend, 1516 Eina_Bool blend,
1680 Eina_Bool smooth, 1517 Eina_Bool smooth,
@@ -1705,7 +1542,7 @@ _evas_gl_common_context_push(Shader_Type rtype,
1705 && (!tex || gc->pipe[i].shader.cur_tex == current_tex) 1542 && (!tex || gc->pipe[i].shader.cur_tex == current_tex)
1706 && (!texm || ((gc->pipe[i].shader.cur_texm == texm->pt->texture) 1543 && (!texm || ((gc->pipe[i].shader.cur_texm == texm->pt->texture)
1707 && (gc->pipe[i].shader.mask_smooth == mask_smooth))) 1544 && (gc->pipe[i].shader.mask_smooth == mask_smooth)))
1708 && (gc->pipe[i].shader.cur_prog == prog) 1545 && (gc->pipe[i].shader.prog == prog)
1709 && (gc->pipe[i].shader.smooth == smooth) 1546 && (gc->pipe[i].shader.smooth == smooth)
1710 && (gc->pipe[i].shader.blend == blend) 1547 && (gc->pipe[i].shader.blend == blend)
1711 && (gc->pipe[i].shader.render_op == gc->dc->render_op) 1548 && (gc->pipe[i].shader.render_op == gc->dc->render_op)
@@ -1748,7 +1585,7 @@ _evas_gl_common_context_push(Shader_Type rtype,
1748 /* && (!texa || gc->pipe[pn].shader.cur_texa == current_texa) */ 1585 /* && (!texa || gc->pipe[pn].shader.cur_texa == current_texa) */
1749 && (!texm || ((gc->pipe[i].shader.cur_texm == texm->pt->texture) 1586 && (!texm || ((gc->pipe[i].shader.cur_texm == texm->pt->texture)
1750 && (gc->pipe[i].shader.mask_smooth == mask_smooth))) 1587 && (gc->pipe[i].shader.mask_smooth == mask_smooth)))
1751 && (gc->pipe[pn].shader.cur_prog == prog) 1588 && (gc->pipe[pn].shader.prog == prog)
1752 && (gc->pipe[pn].shader.smooth == smooth) 1589 && (gc->pipe[pn].shader.smooth == smooth)
1753 && (gc->pipe[pn].shader.blend == blend) 1590 && (gc->pipe[pn].shader.blend == blend)
1754 && (gc->pipe[pn].shader.render_op == gc->dc->render_op) 1591 && (gc->pipe[pn].shader.render_op == gc->dc->render_op)
@@ -1781,28 +1618,26 @@ evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
1781 int r, int g, int b, int a) 1618 int r, int g, int b, int a)
1782{ 1619{
1783 Eina_Bool blend = EINA_FALSE; 1620 Eina_Bool blend = EINA_FALSE;
1784 Evas_GL_Shader shader; 1621 Evas_GL_Program *prog;
1785 int pn = 0, i; 1622 int pn = 0, i;
1786 GLuint prog, mtexid = mtex ? mtex->pt->texture : 0; 1623 GLuint mtexid = mtex ? mtex->pt->texture : 0;
1787 Shader_Sampling masksam = SHD_SAM11; 1624 Shader_Sampling masksam = SHD_SAM11;
1788 1625
1789 if (!(gc->dc->render_op == EVAS_RENDER_COPY) && ((a < 255) || (mtex))) 1626 if (!(gc->dc->render_op == EVAS_RENDER_COPY) && ((a < 255) || (mtex)))
1790 blend = EINA_TRUE; 1627 blend = EINA_TRUE;
1791 1628
1792 shader = evas_gl_common_shader_select(gc, SHD_LINE, NULL, 0, r, g, b, a, 1629 prog = evas_gl_common_shader_program_get(gc, SHD_LINE, NULL, 0, r, g, b, a,
1793 0, 0, 0, 0, EINA_FALSE, NULL, EINA_FALSE, 1630 0, 0, 0, 0, EINA_FALSE, NULL, EINA_FALSE,
1794 mtex, mask_smooth, mw, mh, NULL, NULL, &masksam); 1631 mtex, mask_smooth, mw, mh, NULL, NULL, &masksam);
1795 1632
1796 prog = gc->shared->shader[shader].prog;
1797 shader_array_flush(gc); 1633 shader_array_flush(gc);
1798 vertex_array_size_check(gc, gc->state.top_pipe, 2); 1634 vertex_array_size_check(gc, gc->state.top_pipe, 2);
1799 pn = gc->state.top_pipe; 1635 pn = gc->state.top_pipe;
1800 1636
1801 gc->pipe[pn].region.type = SHD_LINE; 1637 gc->pipe[pn].region.type = SHD_LINE;
1802 gc->pipe[pn].shader.id = shader; 1638 gc->pipe[pn].shader.prog = prog;
1803 gc->pipe[pn].shader.cur_tex = 0; 1639 gc->pipe[pn].shader.cur_tex = 0;
1804 gc->pipe[pn].shader.cur_texm = mtexid; 1640 gc->pipe[pn].shader.cur_texm = mtexid;
1805 gc->pipe[pn].shader.cur_prog = prog;
1806 gc->pipe[pn].shader.blend = blend; 1641 gc->pipe[pn].shader.blend = blend;
1807 gc->pipe[pn].shader.render_op = gc->dc->render_op; 1642 gc->pipe[pn].shader.render_op = gc->dc->render_op;
1808 gc->pipe[pn].shader.clip = clip; 1643 gc->pipe[pn].shader.clip = clip;
@@ -1856,18 +1691,16 @@ evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
1856{ 1691{
1857 Eina_Bool blend = EINA_FALSE; 1692 Eina_Bool blend = EINA_FALSE;
1858 Shader_Sampling masksam = SHD_SAM11; 1693 Shader_Sampling masksam = SHD_SAM11;
1859 Evas_GL_Shader shader; 1694 Evas_GL_Program *prog;
1860 GLuint prog;
1861 GLuint mtexid = mtex ? mtex->pt->texture : 0; 1695 GLuint mtexid = mtex ? mtex->pt->texture : 0;
1862 int pn = 0; 1696 int pn = 0;
1863 1697
1864 if (!(gc->dc->render_op == EVAS_RENDER_COPY) && ((a < 255) || mtex)) 1698 if (!(gc->dc->render_op == EVAS_RENDER_COPY) && ((a < 255) || mtex))
1865 blend = EINA_TRUE; 1699 blend = EINA_TRUE;
1866 1700
1867 shader = evas_gl_common_shader_select(gc, SHD_RECT, NULL, 0, r, g, b, a, 1701 prog = evas_gl_common_shader_program_get(gc, SHD_RECT, NULL, 0, r, g, b, a,
1868 0, 0, 0, 0, EINA_FALSE, NULL, EINA_FALSE, 1702 0, 0, 0, 0, EINA_FALSE, NULL, EINA_FALSE,
1869 mtex, mask_smooth, mw, mh, NULL, NULL, &masksam); 1703 mtex, mask_smooth, mw, mh, NULL, NULL, &masksam);
1870 prog = gc->shared->shader[shader].prog;
1871 1704
1872again: 1705again:
1873 vertex_array_size_check(gc, gc->state.top_pipe, 6); 1706 vertex_array_size_check(gc, gc->state.top_pipe, 6);
@@ -1876,10 +1709,9 @@ again:
1876 if ((pn == 0) && (gc->pipe[pn].array.num == 0)) 1709 if ((pn == 0) && (gc->pipe[pn].array.num == 0))
1877 { 1710 {
1878 gc->pipe[pn].region.type = SHD_RECT; 1711 gc->pipe[pn].region.type = SHD_RECT;
1879 gc->pipe[pn].shader.id = shader; 1712 gc->pipe[pn].shader.prog = prog;
1880 gc->pipe[pn].shader.cur_tex = 0; 1713 gc->pipe[pn].shader.cur_tex = 0;
1881 gc->pipe[pn].shader.cur_texm = mtexid; 1714 gc->pipe[pn].shader.cur_texm = mtexid;
1882 gc->pipe[pn].shader.cur_prog = prog;
1883 gc->pipe[pn].shader.blend = blend; 1715 gc->pipe[pn].shader.blend = blend;
1884 gc->pipe[pn].shader.render_op = gc->dc->render_op; 1716 gc->pipe[pn].shader.render_op = gc->dc->render_op;
1885 gc->pipe[pn].shader.mask_smooth = mask_smooth; 1717 gc->pipe[pn].shader.mask_smooth = mask_smooth;
@@ -1908,7 +1740,7 @@ again:
1908 if ((gc->pipe[i].region.type == SHD_RECT) 1740 if ((gc->pipe[i].region.type == SHD_RECT)
1909 && (gc->pipe[i].shader.cur_tex == 0) 1741 && (gc->pipe[i].shader.cur_tex == 0)
1910 && (gc->pipe[i].shader.cur_texm == mtexid) 1742 && (gc->pipe[i].shader.cur_texm == mtexid)
1911 && (gc->pipe[i].shader.cur_prog == prog) 1743 && (gc->pipe[i].shader.prog == prog)
1912 && (gc->pipe[i].shader.blend == blend) 1744 && (gc->pipe[i].shader.blend == blend)
1913 && (gc->pipe[i].shader.render_op == gc->dc->render_op) 1745 && (gc->pipe[i].shader.render_op == gc->dc->render_op)
1914 && (gc->pipe[i].shader.clip == 0) 1746 && (gc->pipe[i].shader.clip == 0)
@@ -1931,10 +1763,9 @@ again:
1931 } 1763 }
1932 gc->state.top_pipe = pn; 1764 gc->state.top_pipe = pn;
1933 gc->pipe[pn].region.type = SHD_RECT; 1765 gc->pipe[pn].region.type = SHD_RECT;
1934 gc->pipe[pn].shader.id = shader; 1766 gc->pipe[pn].shader.prog = prog;
1935 gc->pipe[pn].shader.cur_tex = 0; 1767 gc->pipe[pn].shader.cur_tex = 0;
1936 gc->pipe[pn].shader.cur_texm = mtexid; 1768 gc->pipe[pn].shader.cur_texm = mtexid;
1937 gc->pipe[pn].shader.cur_prog = prog;
1938 gc->pipe[pn].shader.blend = blend; 1769 gc->pipe[pn].shader.blend = blend;
1939 gc->pipe[pn].shader.render_op = gc->dc->render_op; 1770 gc->pipe[pn].shader.render_op = gc->dc->render_op;
1940 gc->pipe[pn].shader.mask_smooth = mask_smooth; 1771 gc->pipe[pn].shader.mask_smooth = mask_smooth;
@@ -1958,7 +1789,7 @@ again:
1958#else 1789#else
1959 if ((gc->pipe[pn].shader.cur_tex != 0) 1790 if ((gc->pipe[pn].shader.cur_tex != 0)
1960 || (gc->pipe[pn].shader.cur_texm != mtexid) 1791 || (gc->pipe[pn].shader.cur_texm != mtexid)
1961 || (gc->pipe[pn].shader.cur_prog != prog) 1792 || (gc->pipe[pn].shader.prog != prog)
1962 || (gc->pipe[pn].shader.blend != blend) 1793 || (gc->pipe[pn].shader.blend != blend)
1963 || (gc->pipe[pn].shader.render_op != gc->dc->render_op) 1794 || (gc->pipe[pn].shader.render_op != gc->dc->render_op)
1964 || (gc->pipe[pn].shader.clip != 0) 1795 || (gc->pipe[pn].shader.clip != 0)
@@ -1967,10 +1798,9 @@ again:
1967 { 1798 {
1968 shader_array_flush(gc); 1799 shader_array_flush(gc);
1969 pn = gc->state.top_pipe; 1800 pn = gc->state.top_pipe;
1970 gc->pipe[pn].shader.id = shader; 1801 gc->pipe[pn].shader.prog = prog;
1971 gc->pipe[pn].shader.cur_tex = 0; 1802 gc->pipe[pn].shader.cur_tex = 0;
1972 gc->pipe[pn].shader.cur_texm = mtexid; 1803 gc->pipe[pn].shader.cur_texm = mtexid;
1973 gc->pipe[pn].shader.cur_prog = prog;
1974 gc->pipe[pn].shader.blend = blend; 1804 gc->pipe[pn].shader.blend = blend;
1975 gc->pipe[pn].shader.render_op = gc->dc->render_op; 1805 gc->pipe[pn].shader.render_op = gc->dc->render_op;
1976 gc->pipe[pn].shader.mask_smooth = mask_smooth; 1806 gc->pipe[pn].shader.mask_smooth = mask_smooth;
@@ -2083,8 +1913,7 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
2083 GLfloat offsetx, offsety; 1913 GLfloat offsetx, offsety;
2084 double pw, ph; 1914 double pw, ph;
2085 Eina_Bool blend = EINA_FALSE; 1915 Eina_Bool blend = EINA_FALSE;
2086 Evas_GL_Shader shader = SHADER_IMG; 1916 Evas_GL_Program *prog;
2087 GLuint prog = gc->shared->shader[shader].prog;
2088 int pn = 0, render_op = gc->dc->render_op, nomul = 0; 1917 int pn = 0, render_op = gc->dc->render_op, nomul = 0;
2089 Shader_Sampling sam = 0, masksam = 0; 1918 Shader_Sampling sam = 0, masksam = 0;
2090 int yinvert = 0; 1919 int yinvert = 0;
@@ -2102,11 +1931,10 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
2102 else if (!(render_op == EVAS_RENDER_COPY) && ((a < 255) || (tex->alpha))) 1931 else if (!(render_op == EVAS_RENDER_COPY) && ((a < 255) || (tex->alpha)))
2103 blend = EINA_TRUE; 1932 blend = EINA_TRUE;
2104 1933
2105 shader = evas_gl_common_shader_select(gc, shd_in, NULL, 0, r, g, b, a, 1934 prog = evas_gl_common_shader_program_get(gc, shd_in, NULL, 0, r, g, b, a,
2106 sw, sh, w, h, smooth, tex, tex_only, 1935 sw, sh, w, h, smooth, tex, tex_only,
2107 mtex, mask_smooth, mw, mh, 1936 mtex, mask_smooth, mw, mh,
2108 &sam, &nomul, &masksam); 1937 &sam, &nomul, &masksam);
2109 prog = gc->shared->shader[shader].prog;
2110 1938
2111 if (tex->ptt) 1939 if (tex->ptt)
2112 { 1940 {
@@ -2138,10 +1966,9 @@ evas_gl_common_context_image_push(Evas_Engine_GL_Context *gc,
2138 mask_smooth); 1966 mask_smooth);
2139 1967
2140 gc->pipe[pn].region.type = SHD_IMAGE; 1968 gc->pipe[pn].region.type = SHD_IMAGE;
2141 gc->pipe[pn].shader.id = shader; 1969 gc->pipe[pn].shader.prog = prog;
2142 gc->pipe[pn].shader.cur_tex = pt->texture; 1970 gc->pipe[pn].shader.cur_tex = pt->texture;
2143 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0; 1971 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0;
2144 gc->pipe[pn].shader.cur_prog = prog;
2145 gc->pipe[pn].shader.smooth = smooth; 1972 gc->pipe[pn].shader.smooth = smooth;
2146 gc->pipe[pn].shader.mask_smooth = mask_smooth; 1973 gc->pipe[pn].shader.mask_smooth = mask_smooth;
2147 gc->pipe[pn].shader.blend = blend; 1974 gc->pipe[pn].shader.blend = blend;
@@ -2290,15 +2117,13 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
2290{ 2117{
2291 GLfloat tx1, tx2, ty1, ty2; 2118 GLfloat tx1, tx2, ty1, ty2;
2292 Shader_Sampling masksam = SHD_SAM11; 2119 Shader_Sampling masksam = SHD_SAM11;
2293 Evas_GL_Shader shader; 2120 Evas_GL_Program *prog;
2294 GLuint prog;
2295 int pn = 0; 2121 int pn = 0;
2296 2122
2297 shader = evas_gl_common_shader_select(gc, SHD_FONT, NULL, 0, r, g, b, a, 2123 prog = evas_gl_common_shader_program_get(gc, SHD_FONT, NULL, 0, r, g, b, a,
2298 sw, sh, w, h, EINA_FALSE, tex, EINA_FALSE, 2124 sw, sh, w, h, EINA_FALSE, tex, EINA_FALSE,
2299 mtex, mask_smooth, mw, mh, 2125 mtex, mask_smooth, mw, mh,
2300 NULL, NULL, &masksam); 2126 NULL, NULL, &masksam);
2301 prog = gc->shared->shader[shader].prog;
2302 2127
2303 pn = _evas_gl_common_context_push(SHD_FONT, 2128 pn = _evas_gl_common_context_push(SHD_FONT,
2304 gc, tex, mtex, 2129 gc, tex, mtex,
@@ -2310,10 +2135,9 @@ evas_gl_common_context_font_push(Evas_Engine_GL_Context *gc,
2310 mask_smooth); 2135 mask_smooth);
2311 2136
2312 gc->pipe[pn].region.type = SHD_FONT; 2137 gc->pipe[pn].region.type = SHD_FONT;
2313 gc->pipe[pn].shader.id = shader; 2138 gc->pipe[pn].shader.prog = prog;
2314 gc->pipe[pn].shader.cur_tex = tex->pt->texture; 2139 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
2315 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0; 2140 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0;
2316 gc->pipe[pn].shader.cur_prog = prog;
2317 gc->pipe[pn].shader.smooth = 0; 2141 gc->pipe[pn].shader.smooth = 0;
2318 gc->pipe[pn].shader.blend = 1; 2142 gc->pipe[pn].shader.blend = 1;
2319 gc->pipe[pn].shader.render_op = gc->dc->render_op; 2143 gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -2369,18 +2193,16 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
2369 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2; 2193 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
2370 Shader_Sampling masksam = SHD_SAM11; 2194 Shader_Sampling masksam = SHD_SAM11;
2371 Eina_Bool blend = 0; 2195 Eina_Bool blend = 0;
2372 Evas_GL_Shader shader; 2196 Evas_GL_Program *prog;
2373 GLuint prog;
2374 int pn = 0, nomul = 0; 2197 int pn = 0, nomul = 0;
2375 2198
2376 if ((a < 255) || (!!mtex)) 2199 if ((a < 255) || (!!mtex))
2377 blend = 1; 2200 blend = 1;
2378 2201
2379 shader = evas_gl_common_shader_select(gc, SHD_YUV, NULL, 0, r, g, b, a, 2202 prog = evas_gl_common_shader_program_get(gc, SHD_YUV, NULL, 0, r, g, b, a,
2380 w, h, w, h, smooth, tex, 0, 2203 w, h, w, h, smooth, tex, 0,
2381 mtex, mask_smooth, mw, mh, 2204 mtex, mask_smooth, mw, mh,
2382 NULL, &nomul, &masksam); 2205 NULL, &nomul, &masksam);
2383 prog = gc->shared->shader[shader].prog;
2384 2206
2385 pn = _evas_gl_common_context_push(SHD_YUV, 2207 pn = _evas_gl_common_context_push(SHD_YUV,
2386 gc, tex, mtex, 2208 gc, tex, mtex,
@@ -2392,12 +2214,11 @@ evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
2392 mask_smooth); 2214 mask_smooth);
2393 2215
2394 gc->pipe[pn].region.type = SHD_YUV; 2216 gc->pipe[pn].region.type = SHD_YUV;
2395 gc->pipe[pn].shader.id = shader; 2217 gc->pipe[pn].shader.prog = prog;
2396 gc->pipe[pn].shader.cur_tex = tex->pt->texture; 2218 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
2397 gc->pipe[pn].shader.cur_texu = tex->ptu->texture; 2219 gc->pipe[pn].shader.cur_texu = tex->ptu->texture;
2398 gc->pipe[pn].shader.cur_texv = tex->ptv->texture; 2220 gc->pipe[pn].shader.cur_texv = tex->ptv->texture;
2399 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0; 2221 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0;
2400 gc->pipe[pn].shader.cur_prog = prog;
2401 gc->pipe[pn].shader.smooth = smooth; 2222 gc->pipe[pn].shader.smooth = smooth;
2402 gc->pipe[pn].shader.blend = blend; 2223 gc->pipe[pn].shader.blend = blend;
2403 gc->pipe[pn].shader.render_op = gc->dc->render_op; 2224 gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -2451,18 +2272,16 @@ evas_gl_common_context_yuv_709_push(Evas_Engine_GL_Context *gc,
2451 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2; 2272 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
2452 Shader_Sampling masksam = SHD_SAM11; 2273 Shader_Sampling masksam = SHD_SAM11;
2453 Eina_Bool blend = 0; 2274 Eina_Bool blend = 0;
2454 Evas_GL_Shader shader; 2275 Evas_GL_Program *prog;
2455 GLuint prog;
2456 int pn = 0, nomul = 0; 2276 int pn = 0, nomul = 0;
2457 2277
2458 if ((a < 255) || (!!mtex)) 2278 if ((a < 255) || (!!mtex))
2459 blend = 1; 2279 blend = 1;
2460 2280
2461 shader = evas_gl_common_shader_select(gc, SHD_YUV_709, NULL, 0, r, g, b, a, 2281 prog = evas_gl_common_shader_program_get(gc, SHD_YUV_709, NULL, 0, r, g, b, a,
2462 w, h, w, h, smooth, tex, 0, 2282 w, h, w, h, smooth, tex, 0,
2463 mtex, mask_smooth, mw, mh, 2283 mtex, mask_smooth, mw, mh,
2464 NULL, &nomul, &masksam); 2284 NULL, &nomul, &masksam);
2465 prog = gc->shared->shader[shader].prog;
2466 2285
2467 pn = _evas_gl_common_context_push(SHD_YUV_709, 2286 pn = _evas_gl_common_context_push(SHD_YUV_709,
2468 gc, tex, mtex, 2287 gc, tex, mtex,
@@ -2474,12 +2293,11 @@ evas_gl_common_context_yuv_709_push(Evas_Engine_GL_Context *gc,
2474 mask_smooth); 2293 mask_smooth);
2475 2294
2476 gc->pipe[pn].region.type = SHD_YUV_709; 2295 gc->pipe[pn].region.type = SHD_YUV_709;
2477 gc->pipe[pn].shader.id = shader; 2296 gc->pipe[pn].shader.prog = prog;
2478 gc->pipe[pn].shader.cur_tex = tex->pt->texture; 2297 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
2479 gc->pipe[pn].shader.cur_texu = tex->ptu->texture; 2298 gc->pipe[pn].shader.cur_texu = tex->ptu->texture;
2480 gc->pipe[pn].shader.cur_texv = tex->ptv->texture; 2299 gc->pipe[pn].shader.cur_texv = tex->ptv->texture;
2481 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0; 2300 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0;
2482 gc->pipe[pn].shader.cur_prog = prog;
2483 gc->pipe[pn].shader.smooth = smooth; 2301 gc->pipe[pn].shader.smooth = smooth;
2484 gc->pipe[pn].shader.blend = blend; 2302 gc->pipe[pn].shader.blend = blend;
2485 gc->pipe[pn].shader.render_op = gc->dc->render_op; 2303 gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -2533,18 +2351,16 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
2533 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2; 2351 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
2534 Shader_Sampling masksam = SHD_SAM11; 2352 Shader_Sampling masksam = SHD_SAM11;
2535 Eina_Bool blend = 0; 2353 Eina_Bool blend = 0;
2536 Evas_GL_Shader shader; 2354 Evas_GL_Program *prog;
2537 GLuint prog;
2538 int pn = 0, nomul = 0; 2355 int pn = 0, nomul = 0;
2539 2356
2540 if ((a < 255) || (!!mtex)) 2357 if ((a < 255) || (!!mtex))
2541 blend = 1; 2358 blend = 1;
2542 2359
2543 shader = evas_gl_common_shader_select(gc, SHD_YUY2, NULL, 0, r, g, b, a, 2360 prog = evas_gl_common_shader_program_get(gc, SHD_YUY2, NULL, 0, r, g, b, a,
2544 sw, sh, w, h, smooth, tex, 0, 2361 sw, sh, w, h, smooth, tex, 0,
2545 mtex, mask_smooth, mw, mh, 2362 mtex, mask_smooth, mw, mh,
2546 NULL, &nomul, &masksam); 2363 NULL, &nomul, &masksam);
2547 prog = gc->shared->shader[shader].prog;
2548 2364
2549 pn = _evas_gl_common_context_push(SHD_YUY2, 2365 pn = _evas_gl_common_context_push(SHD_YUY2,
2550 gc, tex, mtex, 2366 gc, tex, mtex,
@@ -2556,11 +2372,10 @@ evas_gl_common_context_yuy2_push(Evas_Engine_GL_Context *gc,
2556 mask_smooth); 2372 mask_smooth);
2557 2373
2558 gc->pipe[pn].region.type = SHD_YUY2; 2374 gc->pipe[pn].region.type = SHD_YUY2;
2559 gc->pipe[pn].shader.id = shader; 2375 gc->pipe[pn].shader.prog = prog;
2560 gc->pipe[pn].shader.cur_tex = tex->pt->texture; 2376 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
2561 gc->pipe[pn].shader.cur_texu = tex->ptuv->texture; 2377 gc->pipe[pn].shader.cur_texu = tex->ptuv->texture;
2562 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0; 2378 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0;
2563 gc->pipe[pn].shader.cur_prog = prog;
2564 gc->pipe[pn].shader.smooth = smooth; 2379 gc->pipe[pn].shader.smooth = smooth;
2565 gc->pipe[pn].shader.blend = blend; 2380 gc->pipe[pn].shader.blend = blend;
2566 gc->pipe[pn].shader.render_op = gc->dc->render_op; 2381 gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -2613,19 +2428,16 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
2613 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2; 2428 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
2614 Shader_Sampling masksam = SHD_SAM11; 2429 Shader_Sampling masksam = SHD_SAM11;
2615 Eina_Bool blend = 0; 2430 Eina_Bool blend = 0;
2616 Evas_GL_Shader shader; 2431 Evas_GL_Program *prog;
2617 GLuint prog;
2618 int pn = 0, nomul = 0; 2432 int pn = 0, nomul = 0;
2619 2433
2620 if ((a < 255) || (!!mtex)) 2434 if ((a < 255) || (!!mtex))
2621 blend = 1; 2435 blend = 1;
2622 2436
2623 shader = evas_gl_common_shader_select(gc, SHD_NV12, NULL, 0, r, g, b, a, 2437 prog = evas_gl_common_shader_program_get(gc, SHD_NV12, NULL, 0, r, g, b, a,
2624 sw, sh, w, h, smooth, tex, 0, 2438 sw, sh, w, h, smooth, tex, 0,
2625 mtex, mask_smooth, mw, mh, 2439 mtex, mask_smooth, mw, mh,
2626 NULL, &nomul, &masksam); 2440 NULL, &nomul, &masksam);
2627 prog = gc->shared->shader[shader].prog;
2628 prog = gc->shared->shader[shader].prog;
2629 2441
2630 pn = _evas_gl_common_context_push(SHD_NV12, 2442 pn = _evas_gl_common_context_push(SHD_NV12,
2631 gc, tex, mtex, 2443 gc, tex, mtex,
@@ -2637,13 +2449,12 @@ evas_gl_common_context_nv12_push(Evas_Engine_GL_Context *gc,
2637 mask_smooth); 2449 mask_smooth);
2638 2450
2639 gc->pipe[pn].region.type = SHD_NV12; 2451 gc->pipe[pn].region.type = SHD_NV12;
2640 gc->pipe[pn].shader.id = shader; 2452 gc->pipe[pn].shader.prog = prog;
2641 gc->pipe[pn].shader.cur_tex = tex->pt->texture; 2453 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
2642 gc->pipe[pn].shader.cur_tex_dyn = tex->pt->dyn.img; 2454 gc->pipe[pn].shader.cur_tex_dyn = tex->pt->dyn.img;
2643 gc->pipe[pn].shader.cur_texu = tex->ptuv->texture; 2455 gc->pipe[pn].shader.cur_texu = tex->ptuv->texture;
2644 gc->pipe[pn].shader.cur_texu_dyn = tex->ptuv->dyn.img; 2456 gc->pipe[pn].shader.cur_texu_dyn = tex->ptuv->dyn.img;
2645 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0; 2457 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0;
2646 gc->pipe[pn].shader.cur_prog = prog;
2647 gc->pipe[pn].shader.smooth = smooth; 2458 gc->pipe[pn].shader.smooth = smooth;
2648 gc->pipe[pn].shader.blend = blend; 2459 gc->pipe[pn].shader.blend = blend;
2649 gc->pipe[pn].shader.render_op = gc->dc->render_op; 2460 gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -2704,15 +2515,13 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
2704 2515
2705 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2; 2516 GLfloat tx1, tx2, ty1, ty2, t2x1, t2x2, t2y1, t2y2;
2706 Shader_Sampling masksam = SHD_SAM11; 2517 Shader_Sampling masksam = SHD_SAM11;
2707 Evas_GL_Shader shader; 2518 Evas_GL_Program *prog;
2708 GLuint prog;
2709 int pn, nomul = 0; 2519 int pn, nomul = 0;
2710 2520
2711 shader = evas_gl_common_shader_select(gc, SHD_RGB_A_PAIR, NULL, 0, r, g, b, a, 2521 prog = evas_gl_common_shader_program_get(gc, SHD_RGB_A_PAIR, NULL, 0, r, g, b, a,
2712 sw, sh, w, h, smooth, tex, 0, 2522 sw, sh, w, h, smooth, tex, 0,
2713 mtex, mask_smooth, mw, mh, 2523 mtex, mask_smooth, mw, mh,
2714 NULL, &nomul, &masksam); 2524 NULL, &nomul, &masksam);
2715 prog = gc->shared->shader[shader].prog;
2716 2525
2717 pn = _evas_gl_common_context_push(SHD_RGB_A_PAIR, 2526 pn = _evas_gl_common_context_push(SHD_RGB_A_PAIR,
2718 gc, tex, mtex, 2527 gc, tex, mtex,
@@ -2724,11 +2533,10 @@ evas_gl_common_context_rgb_a_pair_push(Evas_Engine_GL_Context *gc,
2724 mask_smooth); 2533 mask_smooth);
2725 2534
2726 gc->pipe[pn].region.type = SHD_RGB_A_PAIR; 2535 gc->pipe[pn].region.type = SHD_RGB_A_PAIR;
2727 gc->pipe[pn].shader.id = shader; 2536 gc->pipe[pn].shader.prog = prog;
2728 gc->pipe[pn].shader.cur_tex = tex->pt->texture; 2537 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
2729 gc->pipe[pn].shader.cur_texa = tex->pta->texture; 2538 gc->pipe[pn].shader.cur_texa = tex->pta->texture;
2730 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0; 2539 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0;
2731 gc->pipe[pn].shader.cur_prog = prog;
2732 gc->pipe[pn].shader.smooth = smooth; 2540 gc->pipe[pn].shader.smooth = smooth;
2733 gc->pipe[pn].shader.blend = EINA_TRUE; 2541 gc->pipe[pn].shader.blend = EINA_TRUE;
2734 gc->pipe[pn].shader.render_op = gc->dc->render_op; 2542 gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -2788,14 +2596,13 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2788 Eina_Bool blend = EINA_FALSE; 2596 Eina_Bool blend = EINA_FALSE;
2789 DATA32 cmul; 2597 DATA32 cmul;
2790 Shader_Sampling masksam = SHD_SAM11; 2598 Shader_Sampling masksam = SHD_SAM11;
2791 Evas_GL_Shader shader = SHADER_IMG; 2599 Evas_GL_Program *prog;
2792 Eina_Bool utexture = EINA_FALSE; 2600 Eina_Bool utexture = EINA_FALSE;
2793 Eina_Bool uvtexture = EINA_FALSE; 2601 Eina_Bool uvtexture = EINA_FALSE;
2794 Eina_Bool use_texa = EINA_FALSE; 2602 Eina_Bool use_texa = EINA_FALSE;
2795 Shader_Type type; 2603 Shader_Type type;
2796 int pn = 0, i; 2604 int pn = 0, i;
2797 int flat = 0, nomul = 0, yinvert = 0; 2605 int flat = 0, nomul = 0, yinvert = 0;
2798 GLuint prog;
2799 2606
2800 if (!(gc->dc->render_op == EVAS_RENDER_COPY) && 2607 if (!(gc->dc->render_op == EVAS_RENDER_COPY) &&
2801 ((a < 255) || (tex->alpha) || (!!mtex))) blend = EINA_TRUE; 2608 ((a < 255) || (tex->alpha) || (!!mtex))) blend = EINA_TRUE;
@@ -2841,11 +2648,10 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2841 type = SHD_MAP; 2648 type = SHD_MAP;
2842 break; 2649 break;
2843 } 2650 }
2844 shader = evas_gl_common_shader_select(gc, type, p, npoints, r, g, b, a, 2651 prog = evas_gl_common_shader_program_get(gc, type, p, npoints, r, g, b, a,
2845 w, h, w, h, smooth, tex, tex_only, 2652 w, h, w, h, smooth, tex, tex_only,
2846 mtex, mask_smooth, mw, mh, 2653 mtex, mask_smooth, mw, mh,
2847 NULL, &nomul, &masksam); 2654 NULL, &nomul, &masksam);
2848 prog = gc->shared->shader[shader].prog;
2849 2655
2850 x = w = (p[0].x >> FP); 2656 x = w = (p[0].x >> FP);
2851 y = h = (p[0].y >> FP); 2657 y = h = (p[0].y >> FP);
@@ -2918,7 +2724,7 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2918 clip, cx, cy, cw, ch, 2724 clip, cx, cy, cw, ch,
2919 mask_smooth); 2725 mask_smooth);
2920 gc->pipe[pn].region.type = SHD_MAP; 2726 gc->pipe[pn].region.type = SHD_MAP;
2921 gc->pipe[pn].shader.id = shader; 2727 gc->pipe[pn].shader.prog = prog;
2922 gc->pipe[pn].shader.cur_tex = tex->pt->texture; 2728 gc->pipe[pn].shader.cur_tex = tex->pt->texture;
2923 if (utexture) 2729 if (utexture)
2924 { 2730 {
@@ -2933,7 +2739,6 @@ evas_gl_common_context_image_map_push(Evas_Engine_GL_Context *gc,
2933 gc->pipe[pn].shader.cur_texu_dyn = tex->ptuv->dyn.img; 2739 gc->pipe[pn].shader.cur_texu_dyn = tex->ptuv->dyn.img;
2934 } 2740 }
2935 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0; 2741 gc->pipe[pn].shader.cur_texm = mtex ? mtex->pt->texture : 0;
2936 gc->pipe[pn].shader.cur_prog = prog;
2937 gc->pipe[pn].shader.smooth = smooth; 2742 gc->pipe[pn].shader.smooth = smooth;
2938 gc->pipe[pn].shader.blend = blend; 2743 gc->pipe[pn].shader.blend = blend;
2939 gc->pipe[pn].shader.render_op = gc->dc->render_op; 2744 gc->pipe[pn].shader.render_op = gc->dc->render_op;
@@ -3114,20 +2919,23 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
3114 } 2919 }
3115 for (i = 0; i < gc->shared->info.tune.pipes.max; i++) 2920 for (i = 0; i < gc->shared->info.tune.pipes.max; i++)
3116 { 2921 {
2922 Evas_GL_Program *prog;
2923
3117 if (gc->pipe[i].array.num <= 0) break; 2924 if (gc->pipe[i].array.num <= 0) break;
3118 2925
2926 prog = gc->pipe[i].shader.prog;
3119 setclip = EINA_FALSE; 2927 setclip = EINA_FALSE;
3120 pipe_done++; 2928 pipe_done++;
3121 gc->flushnum++; 2929 gc->flushnum++;
3122 2930
3123 GLERRV("<flush err>"); 2931 GLERRV("<flush err>");
3124 if (gc->pipe[i].shader.cur_prog != gc->state.current.cur_prog) 2932 if (prog && (prog != gc->state.current.prog))
3125 { 2933 {
3126 glUseProgram(gc->pipe[i].shader.cur_prog); 2934 glUseProgram(prog->prog);
3127 if (gc->shared->shader[gc->pipe[i].shader.id].reset) 2935 if (prog->reset)
3128 { 2936 {
3129 glUniformMatrix4fv(glGetUniformLocation(gc->pipe[i].shader.cur_prog, "mvp"), 1, GL_FALSE, gc->shared->proj); 2937 glUniformMatrix4fv(glGetUniformLocation(prog->prog, "mvp"), 1, GL_FALSE, gc->shared->proj);
3130 gc->shared->shader[gc->pipe[i].shader.id].reset = EINA_FALSE; 2938 prog->reset = EINA_FALSE;
3131 } 2939 }
3132 } 2940 }
3133 2941
@@ -3711,8 +3519,7 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
3711 gc->pipe[i].array.im = NULL; 3519 gc->pipe[i].array.im = NULL;
3712 } 3520 }
3713 3521
3714 gc->state.current.id = gc->pipe[i].shader.id; 3522 gc->state.current.prog = gc->pipe[i].shader.prog;
3715 gc->state.current.cur_prog = gc->pipe[i].shader.cur_prog;
3716 gc->state.current.cur_tex = gc->pipe[i].shader.cur_tex; 3523 gc->state.current.cur_tex = gc->pipe[i].shader.cur_tex;
3717 gc->state.current.cur_texm = gc->pipe[i].shader.cur_texm; 3524 gc->state.current.cur_texm = gc->pipe[i].shader.cur_texm;
3718 gc->state.current.cur_texa = gc->pipe[i].shader.cur_texa; 3525 gc->state.current.cur_texa = gc->pipe[i].shader.cur_texa;
diff --git a/src/modules/evas/engines/gl_common/evas_gl_shader.c b/src/modules/evas/engines/gl_common/evas_gl_shader.c
index 9f70418e22..715a045c94 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_shader.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_shader.c
@@ -1,10 +1,65 @@
1#include "config.h" 1#include "config.h"
2#include "shader/evas_gl_shaders.x"
3#include "evas_gl_common.h"
4
5#define SHADER_FLAG_SAM_BITSHIFT 3
6#define SHADER_FLAG_MASKSAM_BITSHIFT 6
7#define SHADER_PROG_NAME_FMT "prog_%08x"
8#define SHADER_BINARY_EET_COMPRESS 1
9
2#ifdef WORDS_BIGENDIAN 10#ifdef WORDS_BIGENDIAN
3# include "shader/evas_gl_shaders_bigendian.x" 11# define BASEFLAG SHADER_FLAG_BIGENDIAN;
4#else 12#else
5# include "shader/evas_gl_shaders.x" 13# define BASEFLAG 0
6#endif 14#endif
7 15
16typedef enum {
17 SHADER_FLAG_TEX = (1 << 0),
18 SHADER_FLAG_BGRA = (1 << 1),
19 SHADER_FLAG_MASK = (1 << 2),
20 SHADER_FLAG_SAM12 = (1 << (SHADER_FLAG_SAM_BITSHIFT + 0)),
21 SHADER_FLAG_SAM21 = (1 << (SHADER_FLAG_SAM_BITSHIFT + 1)),
22 SHADER_FLAG_SAM22 = (1 << (SHADER_FLAG_SAM_BITSHIFT + 2)),
23 SHADER_FLAG_MASKSAM12 = (1 << (SHADER_FLAG_MASKSAM_BITSHIFT + 0)),
24 SHADER_FLAG_MASKSAM21 = (1 << (SHADER_FLAG_MASKSAM_BITSHIFT + 1)),
25 SHADER_FLAG_MASKSAM22 = (1 << (SHADER_FLAG_MASKSAM_BITSHIFT + 2)),
26 SHADER_FLAG_IMG = (1 << 9),
27 SHADER_FLAG_BIGENDIAN = (1 << 10),
28 SHADER_FLAG_YUV = (1 << 11),
29 SHADER_FLAG_YUY2 = (1 << 12),
30 SHADER_FLAG_NV12 = (1 << 13),
31 SHADER_FLAG_YUV_709 = (1 << 14),
32 SHADER_FLAG_EXTERNAL = (1 << 15),
33 SHADER_FLAG_AFILL = (1 << 16),
34 SHADER_FLAG_NOMUL = (1 << 17),
35 SHADER_FLAG_ALPHA = (1 << 18),
36 SHADER_FLAG_RGB_A_PAIR = (1 << 19),
37} Shader_Flag;
38#define SHADER_FLAG_COUNT 20
39
40static const char *_shader_flags[SHADER_FLAG_COUNT] = {
41 "TEX",
42 "BGRA",
43 "MASK",
44 "SAM12",
45 "SAM21",
46 "SAM22",
47 "MASKSAM12",
48 "MASKSAM21",
49 "MASKSAM22",
50 "IMG",
51 "BIGENDIAN",
52 "YUV",
53 "YUY2",
54 "NV12",
55 "YUV_709",
56 "EXTERNAL",
57 "AFILL",
58 "NOMUL",
59 "ALPHA",
60 "RGB_A_PAIR"
61};
62
8///////////////////////////////////////////// 63/////////////////////////////////////////////
9static void 64static void
10gl_compile_link_error(GLuint target, const char *action) 65gl_compile_link_error(GLuint target, const char *action)
@@ -39,19 +94,26 @@ gl_compile_link_error(GLuint target, const char *action)
39 } 94 }
40} 95}
41 96
42static int 97static Evas_GL_Program *
43_evas_gl_common_shader_program_binary_init(Evas_GL_Program *p, 98_evas_gl_common_shader_program_binary_load(Eet_File *ef, unsigned int flags)
44 const char *pname,
45 Eet_File *ef)
46{ 99{
47 int res = 0, num = 0, length = 0; 100 int num = 0, length = 0;
48 int *formats = NULL; 101 int *formats = NULL;
49 void *data = NULL; 102 void *data = NULL;
50 GLint ok = 0; 103 char pname[32];
104 GLint ok = 0, prg, vtx = GL_NONE, frg = GL_NONE;
105 Evas_GL_Program *p = NULL;
106 Eina_Bool direct = 1;
51 107
52 if (!ef) return res; 108 if (!ef || !glsym_glProgramBinary) return NULL;
53 109
54 data = eet_read(ef, pname, &length); 110 sprintf(pname, SHADER_PROG_NAME_FMT, flags);
111 data = (void *) eet_read_direct(ef, pname, &length);
112 if (!data)
113 {
114 data = eet_read(ef, pname, &length);
115 direct = 0;
116 }
55 if ((!data) || (length <= 0)) goto finish; 117 if ((!data) || (length <= 0)) goto finish;
56 118
57 glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num); 119 glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num);
@@ -63,58 +125,62 @@ _evas_gl_common_shader_program_binary_init(Evas_GL_Program *p,
63 glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, formats); 125 glGetIntegerv(GL_PROGRAM_BINARY_FORMATS, formats);
64 if (!formats[0]) goto finish; 126 if (!formats[0]) goto finish;
65 127
66 p->prog = glCreateProgram(); 128 prg = glCreateProgram();
67 129
68#if 1 130#if 1
69 // TODO: invalid rendering error occurs when attempting to use a 131 // TODO: invalid rendering error occurs when attempting to use a
70 // glProgramBinary. in order to render correctly we should create a dummy 132 // glProgramBinary. in order to render correctly we should create a dummy
71 // vertex shader. 133 // vertex shader.
72 p->vert = glCreateShader(GL_VERTEX_SHADER); 134 vtx = glCreateShader(GL_VERTEX_SHADER);
73 glAttachShader(p->prog, p->vert); 135 glAttachShader(prg, vtx);
74 p->frag = glCreateShader(GL_FRAGMENT_SHADER); 136 frg = glCreateShader(GL_FRAGMENT_SHADER);
75 glAttachShader(p->prog, p->frag); 137 glAttachShader(prg, frg);
76#endif 138#endif
77 glsym_glProgramBinary(p->prog, formats[0], data, length); 139 glsym_glProgramBinary(prg, formats[0], data, length);
78 140
79 glBindAttribLocation(p->prog, SHAD_VERTEX, "vertex"); 141 glBindAttribLocation(prg, SHAD_VERTEX, "vertex");
80 glBindAttribLocation(p->prog, SHAD_COLOR, "color"); 142 glBindAttribLocation(prg, SHAD_COLOR, "color");
81 glBindAttribLocation(p->prog, SHAD_TEXUV, "tex_coord"); 143 glBindAttribLocation(prg, SHAD_TEXUV, "tex_coord");
82 glBindAttribLocation(p->prog, SHAD_TEXUV2, "tex_coord2"); 144 glBindAttribLocation(prg, SHAD_TEXUV2, "tex_coord2");
83 glBindAttribLocation(p->prog, SHAD_TEXUV3, "tex_coord3"); 145 glBindAttribLocation(prg, SHAD_TEXUV3, "tex_coord3");
84 glBindAttribLocation(p->prog, SHAD_TEXA, "tex_coorda"); 146 glBindAttribLocation(prg, SHAD_TEXA, "tex_coorda");
85 glBindAttribLocation(p->prog, SHAD_TEXSAM, "tex_sample"); 147 glBindAttribLocation(prg, SHAD_TEXSAM, "tex_sample");
86 glBindAttribLocation(p->prog, SHAD_MASK, "mask_coord"); 148 glBindAttribLocation(prg, SHAD_MASK, "mask_coord");
87 glBindAttribLocation(p->prog, SHAD_MASKSAM, "tex_masksample"); 149 glBindAttribLocation(prg, SHAD_MASKSAM, "tex_masksample");
88 150
89 glGetProgramiv(p->prog, GL_LINK_STATUS, &ok); 151 glGetProgramiv(prg, GL_LINK_STATUS, &ok);
90 if (!ok) 152 if (!ok)
91 { 153 {
92 gl_compile_link_error(p->prog, "load a program object"); 154 gl_compile_link_error(prg, "load a program object");
93 ERR("Abort load of program (%s)", pname); 155 ERR("Abort load of program (%s)", pname);
156 glDeleteProgram(prg);
157 glDeleteShader(vtx);
158 glDeleteShader(frg);
94 goto finish; 159 goto finish;
95 } 160 }
96 161
97 res = 1; 162 p = calloc(1, sizeof(*p));
163 p->flags = flags;
164 p->prog = prg;
165 p->vert = vtx;
166 p->frag = frg;
167 p->reset = EINA_TRUE;
168 p->bin_saved = EINA_TRUE;
169 evas_gl_common_shader_textures_bind(p);
98 170
99finish: 171finish:
100 if (formats) free(formats); 172 free(formats);
101 if (data) free(data); 173 if (!direct) free(data);
102 if ((!res) && (p->prog)) 174 return p;
103 {
104 glDeleteProgram(p->prog);
105 p->prog = 0;
106 }
107 return res;
108} 175}
109 176
110static int 177static int
111_evas_gl_common_shader_program_binary_save(Evas_GL_Program *p, 178_evas_gl_common_shader_program_binary_save(Evas_GL_Program *p, Eet_File *ef)
112 const char *pname,
113 Eet_File *ef)
114{ 179{
115 void* data = NULL; 180 void* data = NULL;
116 GLenum format; 181 GLenum format;
117 int length = 0, size = 0; 182 int length = 0, size = 0;
183 char pname[32];
118 184
119 if (!glsym_glGetProgramBinary) return 0; 185 if (!glsym_glGetProgramBinary) return 0;
120 186
@@ -132,133 +198,47 @@ _evas_gl_common_shader_program_binary_save(Evas_GL_Program *p,
132 return 0; 198 return 0;
133 } 199 }
134 200
135 if (eet_write(ef, pname, data, length, 1) < 0) 201 sprintf(pname, SHADER_PROG_NAME_FMT, p->flags);
136 { 202 if (eet_write(ef, pname, data, length, SHADER_BINARY_EET_COMPRESS) < 0)
137 if (data) free(data);
138 return 0;
139 }
140 if (data) free(data);
141 return 1;
142}
143
144static int
145_evas_gl_common_shader_program_source_init(Evas_GL_Program *p,
146 const char *vert,
147 const char *frag,
148 const char *name)
149{
150 GLint ok;
151
152 p->vert = glCreateShader(GL_VERTEX_SHADER);
153 p->frag = glCreateShader(GL_FRAGMENT_SHADER);
154
155 glShaderSource(p->vert, 1, &vert, NULL);
156 glCompileShader(p->vert);
157 ok = 0;
158 glGetShaderiv(p->vert, GL_COMPILE_STATUS, &ok);
159 if (!ok)
160 {
161 gl_compile_link_error(p->vert, "compile vertex shader");
162 ERR("Abort compile of shader vert (%s): %s", name, vert);
163 return 0;
164 }
165 glShaderSource(p->frag, 1, &frag, NULL);
166 glCompileShader(p->frag);
167 ok = 0;
168 glGetShaderiv(p->frag, GL_COMPILE_STATUS, &ok);
169 if (!ok)
170 {
171 gl_compile_link_error(p->frag, "compile fragment shader");
172 ERR("Abort compile of shader frag (%s): %s", name, frag);
173 return 0;
174 }
175
176 p->prog = glCreateProgram();
177#ifdef GL_GLES
178#else
179 if ((glsym_glGetProgramBinary) && (glsym_glProgramParameteri))
180 {
181 glsym_glProgramParameteri(p->prog, GL_PROGRAM_BINARY_RETRIEVABLE_HINT,
182 GL_TRUE);
183 }
184#endif
185 glAttachShader(p->prog, p->vert);
186 glAttachShader(p->prog, p->frag);
187
188 glBindAttribLocation(p->prog, SHAD_VERTEX, "vertex");
189 glBindAttribLocation(p->prog, SHAD_COLOR, "color");
190 glBindAttribLocation(p->prog, SHAD_TEXUV, "tex_coord");
191 glBindAttribLocation(p->prog, SHAD_TEXUV2, "tex_coord2");
192 glBindAttribLocation(p->prog, SHAD_TEXUV3, "tex_coord3");
193 glBindAttribLocation(p->prog, SHAD_TEXA, "tex_coorda");
194 glBindAttribLocation(p->prog, SHAD_TEXSAM, "tex_sample");
195 glBindAttribLocation(p->prog, SHAD_MASK, "mask_coord");
196 glBindAttribLocation(p->prog, SHAD_MASKSAM, "tex_masksample");
197
198 glLinkProgram(p->prog);
199 ok = 0;
200 glGetProgramiv(p->prog, GL_LINK_STATUS, &ok);
201 if (!ok)
202 { 203 {
203 gl_compile_link_error(p->prog, "link fragment and vertex shaders"); 204 free(data);
204 ERR("Abort compile of shader frag (%s): %s", name, frag);
205 ERR("Abort compile of shader vert (%s): %s", name, vert);
206 return 0; 205 return 0;
207 } 206 }
208 207
209 return 1; 208 free(data);
210} 209 p->bin_saved = 1;
211
212static int
213_evas_gl_common_shader_source_init(Evas_GL_Shared *shared)
214{
215 unsigned int i;
216
217 for (i = 0; i < sizeof (_shaders_source) / sizeof (_shaders_source[0]); i++)
218 {
219 if (!_evas_gl_common_shader_program_source_init
220 (&(shared->shader[_shaders_source[i].id]),
221 _shaders_source[i].vert,
222 _shaders_source[i].frag,
223 _shaders_source[i].name))
224 return 0;
225 }
226 return 1; 210 return 1;
227} 211}
228 212
229static int 213static int
230_evas_gl_common_shader_binary_init(Evas_GL_Shared *shared) 214_evas_gl_common_shader_binary_init(Evas_GL_Shared *shared)
231{ 215{
232 /* check eet */ 216 Eet_File *ef = NULL;
233 Eet_File *et = NULL;
234 char bin_dir_path[PATH_MAX]; 217 char bin_dir_path[PATH_MAX];
235 char bin_file_path[PATH_MAX]; 218 char bin_file_path[PATH_MAX];
236 unsigned int i; 219
220 if (!shared || !shared->info.bin_program)
221 return 1;
222
223 if (shared->shaders_cache)
224 return 1;
237 225
238 if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path))) 226 if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path)))
239 return 0; 227 return 0;
240 228
241 if (!evas_gl_common_file_cache_file_check(bin_dir_path, "binary_shader", bin_file_path, 229 if (!evas_gl_common_file_cache_file_check(bin_dir_path, "binary_shader", bin_file_path,
242 sizeof(bin_dir_path))) 230 sizeof(bin_dir_path)))
243 return 0; 231 return 0;
244 232
245 /* use eet */
246 if (!eet_init()) return 0; 233 if (!eet_init()) return 0;
247 et = eet_open(bin_file_path, EET_FILE_MODE_READ); 234 ef = eet_open(bin_file_path, EET_FILE_MODE_READ);
248 if (!et) goto error; 235 if (!ef) goto error;
249
250 for (i = 0; i < sizeof (_shaders_source) / sizeof (_shaders_source[0]); ++i)
251 if (!_evas_gl_common_shader_program_binary_init(&(shared->shader[_shaders_source[i].id]),
252 _shaders_source[i].name,
253 et))
254 goto error;
255 236
256 if (et) eet_close(et); 237 shared->shaders_cache = ef;
257 eet_shutdown();
258 return 1; 238 return 1;
259 239
260error: 240error:
261 if (et) eet_close(et); 241 if (ef) eet_close(ef);
262 eet_shutdown(); 242 eet_shutdown();
263 return 0; 243 return 0;
264} 244}
@@ -266,14 +246,16 @@ error:
266static int 246static int
267_evas_gl_common_shader_binary_save(Evas_GL_Shared *shared) 247_evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
268{ 248{
269 /* check eet */ 249 // FIXME: Save should happen early, before shutdown.
270 Eet_File *et = NULL; //check eet file 250
271 int tmpfd;
272 int res = 0;
273 char bin_dir_path[PATH_MAX]; 251 char bin_dir_path[PATH_MAX];
274 char bin_file_path[PATH_MAX]; 252 char bin_file_path[PATH_MAX];
275 char tmp_file[PATH_MAX]; 253 char tmp_file[PATH_MAX];
276 unsigned int i; 254 int tmpfd, res = 0, copy;
255 Eet_File *ef = NULL;
256 Evas_GL_Program *p;
257 Eina_Iterator *it;
258 char pname[32];
277 259
278 if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path))) 260 if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path)))
279 { 261 {
@@ -281,8 +263,8 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
281 if (!res) return 0; /* we can't make directory */ 263 if (!res) return 0; /* we can't make directory */
282 } 264 }
283 265
284 evas_gl_common_file_cache_file_check(bin_dir_path, "binary_shader", bin_file_path, 266 copy = evas_gl_common_file_cache_file_check(bin_dir_path, "binary_shader", bin_file_path,
285 sizeof(bin_dir_path)); 267 sizeof(bin_dir_path));
286 268
287 /* use mkstemp for writing */ 269 /* use mkstemp for writing */
288 snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", bin_file_path); 270 snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", bin_file_path);
@@ -295,49 +277,97 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
295 umask(old_umask); 277 umask(old_umask);
296#endif 278#endif
297 279
298 if (tmpfd < 0) goto error; 280 if (tmpfd < 0) return 0;
299 close(tmpfd); 281 close(tmpfd);
300 282
301 /* use eet */ 283 /* use eet */
302 if (!eet_init()) goto error; 284 if (!eet_init()) return 0;
285
286 /* copy old file */
287 if (copy)
288 eina_file_copy(bin_file_path, tmp_file, EINA_FILE_COPY_DATA, NULL, NULL);
289
290 ef = eet_open(tmp_file, EET_FILE_MODE_READ_WRITE);
291 if (!ef) goto error;
303 292
304 et = eet_open(tmp_file, EET_FILE_MODE_WRITE); 293 it = eina_hash_iterator_data_new(shared->shaders_hash);
305 if (!et) goto error; 294 EINA_ITERATOR_FOREACH(it, p)
295 {
296 if (!p->bin_saved)
297 {
298 int len = 0;
299 sprintf(pname, SHADER_PROG_NAME_FMT, p->flags);
300 eet_read_direct(ef, pname, &len);
301 if (len > 0)
302 p->bin_saved = 1; // assume bin data is correct
303 else
304 _evas_gl_common_shader_program_binary_save(p, ef);
305 }
306 }
307 eina_iterator_free(it);
306 308
307 for (i = 0; i < sizeof (_shaders_source) / sizeof (_shaders_source[0]); ++i) 309 if (shared->shaders_cache)
308 if (!_evas_gl_common_shader_program_binary_save(&(shared->shader[_shaders_source[i].id]), 310 {
309 _shaders_source[i].name, 311 eet_close(shared->shaders_cache);
310 et)) 312 shared->shaders_cache = NULL;
311 goto error; 313 eet_shutdown();
314 }
312 315
313 if (eet_close(et) != EET_ERROR_NONE) goto error; 316 if (eet_close(ef) != EET_ERROR_NONE) goto error;
314 if (rename(tmp_file,bin_file_path) < 0) goto error; 317 if (rename(tmp_file, bin_file_path) < 0) goto error;
315 eet_shutdown(); 318 eet_shutdown();
316 return 1; 319 return 1;
317 320
318error: 321error:
319 if (et) eet_close(et); 322 if (ef) eet_close(ef);
320 if (evas_gl_common_file_cache_file_exists(tmp_file)) unlink(tmp_file); 323 if (evas_gl_common_file_cache_file_exists(tmp_file)) unlink(tmp_file);
321 eet_shutdown(); 324 eet_shutdown();
322 return 0; 325 return 0;
323} 326}
324 327
328static void
329_shaders_hash_free_cb(void *data)
330{
331 Evas_GL_Program *p = data;
332 if (p->vert) glDeleteShader(p->vert);
333 if (p->frag) glDeleteShader(p->frag);
334 if (p->prog) glDeleteProgram(p->prog);
335 free(p);
336}
337
325int 338int
326evas_gl_common_shader_program_init(Evas_GL_Shared *shared) 339evas_gl_common_shader_program_init(Evas_GL_Shared *shared)
327{ 340{
328 // gl support binary shader and get env of binary shader path 341 /* most popular shaders */
329 if (shared->info.bin_program && 342 const int BGRA = (shared->info.bgra ? SHADER_FLAG_BGRA : 0);
330 _evas_gl_common_shader_binary_init(shared)) return 1; 343 const int autoload[] = {
331 /* compile all shader.*/ 344 /* rect */ BASEFLAG,
332 if (!_evas_gl_common_shader_source_init(shared)) return 0; 345 /* text */ BASEFLAG | SHADER_FLAG_TEX | SHADER_FLAG_ALPHA,
333 /* success compile all shader. if gl support binary shader, we need to save */ 346 /* img1 */ BASEFLAG | SHADER_FLAG_TEX | SHADER_FLAG_IMG | BGRA,
334 if (shared->info.bin_program) _evas_gl_common_shader_binary_save(shared); 347 /* img2 */ BASEFLAG | SHADER_FLAG_TEX | SHADER_FLAG_IMG | SHADER_FLAG_NOMUL | BGRA,
348 };
349 unsigned i;
350
351 shared->shaders_hash = eina_hash_int32_new(_shaders_hash_free_cb);
352 if (_evas_gl_common_shader_binary_init(shared))
353 {
354 for (i = 0; i < (sizeof(autoload) / sizeof(autoload[0])); i++)
355 {
356 Evas_GL_Program *p;
357
358 p = _evas_gl_common_shader_program_binary_load(shared->shaders_cache, autoload[i]);
359 if (p) eina_hash_add(shared->shaders_hash, &autoload[i], p);
360 }
361 }
362
335 return 1; 363 return 1;
336} 364}
337 365
338void 366void
339evas_gl_common_shader_program_init_done(void) 367evas_gl_common_shader_program_init_done(void)
340{ 368{
369#warning FIXME: Disabled compiler unload for now.
370 return;
341#ifdef GL_GLES 371#ifdef GL_GLES
342 glReleaseShaderCompiler(); 372 glReleaseShaderCompiler();
343#else 373#else
@@ -347,69 +377,361 @@ evas_gl_common_shader_program_init_done(void)
347} 377}
348 378
349void 379void
350evas_gl_common_shader_program_shutdown(Evas_GL_Program *p) 380evas_gl_common_shader_program_shutdown(Evas_GL_Shared *shared)
351{ 381{
352 if (p->vert) glDeleteShader(p->vert); 382 if (!shared) return;
353 if (p->frag) glDeleteShader(p->frag); 383
354 if (p->prog) glDeleteProgram(p->prog); 384 if (shared->info.bin_program)
385 _evas_gl_common_shader_binary_save(shared);
386
387 if (shared->shaders_cache)
388 {
389 eet_close(shared->shaders_cache);
390 shared->shaders_cache = NULL;
391 eet_shutdown();
392 }
393
394 eina_hash_free(shared->shaders_hash);
395 shared->shaders_hash = NULL;
355} 396}
356 397
357Evas_GL_Shader 398static inline unsigned int
358evas_gl_common_img_shader_select(Shader_Type type, Shader_Sampling sam, int nomul, int afill, int bgra, int mask, int masksam) 399evas_gl_common_shader_flags_get(Evas_GL_Shared *shared, Shader_Type type,
400 RGBA_Map_Point *map_points, int npoints,
401 int r, int g, int b, int a,
402 int sw, int sh, int w, int h, Eina_Bool smooth,
403 Evas_GL_Texture *tex, Eina_Bool tex_only,
404 Evas_GL_Texture *mtex, Eina_Bool mask_smooth,
405 int mw, int mh,
406 Shader_Sampling *psam, int *pnomul, Shader_Sampling *pmasksam)
359{ 407{
360 // 256 combinaisons including many impossible 408 Shader_Sampling sam = SHD_SAM11, masksam = SHD_SAM11;
361 static Evas_GL_Shader _shaders[4 * 2 * 2 * 2 * 2 * 4 * 2]; 409 int nomul = 1, bgra = 0, afill = 0, k;
362 static Eina_Bool init = EINA_FALSE; 410 unsigned int flags = BASEFLAG;
363 int idx;
364 411
365 if (EINA_UNLIKELY(!init)) 412 // image downscale sampling
413 if (smooth && ((type == SHD_IMAGE) || (type == SHD_IMAGENATIVE)))
366 { 414 {
367 unsigned int k; 415 if ((sw >= (w * 2)) && (sh >= (h * 2)))
416 sam = SHD_SAM22;
417 else if (sw >= (w * 2))
418 sam = SHD_SAM21;
419 else if (sh >= (h * 2))
420 sam = SHD_SAM12;
421 flags |= (1 << (SHADER_FLAG_SAM_BITSHIFT + sam - 1));
422 }
368 423
369 init = EINA_TRUE; 424 // mask downscale sampling
370 for (k = 0; k < (sizeof(_shaders) / sizeof(_shaders[0])); k++) 425 if (mtex && mask_smooth)
371 _shaders[k] = SHADER_IMG; 426 {
427 if ((mtex->w >= (mw * 2)) && (mtex->h >= (mh * 2)))
428 masksam = SHD_SAM22;
429 else if (mtex->w >= (mw * 2))
430 masksam = SHD_SAM21;
431 else if (mtex->h >= (mh * 2))
432 masksam = SHD_SAM12;
433 flags |= (1 << (SHADER_FLAG_MASKSAM_BITSHIFT + masksam - 1));
434 }
435
436 switch (type)
437 {
438 case SHD_RECT:
439 case SHD_LINE:
440 goto end;
441 case SHD_FONT:
442 flags |= (SHADER_FLAG_ALPHA | SHADER_FLAG_TEX);
443 goto end;
444 case SHD_IMAGE:
445 flags |= SHADER_FLAG_IMG;
446 break;
447 case SHD_IMAGENATIVE:
448 break;
449 case SHD_YUV:
450 flags |= SHADER_FLAG_YUV;
451 break;
452 case SHD_YUY2:
453 flags |= SHADER_FLAG_YUY2;
454 break;
455 case SHD_NV12:
456 flags |= SHADER_FLAG_NV12;
457 break;
458 case SHD_YUV_709:
459 flags |= (SHADER_FLAG_YUV_709 | SHADER_FLAG_YUV);
460 break;
461 case SHD_RGB_A_PAIR:
462 case SHD_MAP:
463 break;
464 default:
465 CRI("Impossible shader type.");
466 return 0;
467 }
372 468
373 for (k = 0; k < (sizeof(_shaders_source) / sizeof(_shaders_source[0])); k++) 469 // color mul
470 if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
471 {
472 if (map_points)
374 { 473 {
375 if (_shaders_source[k].type == SHD_IMAGE) 474 for (k = 0; k < npoints; k++)
376 { 475 if (map_points[k].col != 0xffffffff)
377 idx = _shaders_source[k].sam << 6; // 2 bits 476 {
378 idx |= _shaders_source[k].masksam << 4; // 2 bits 477 nomul = 0;
379 idx |= _shaders_source[k].bgra << 3; // bool 478 break;
380 idx |= _shaders_source[k].mask << 2; // bool 479 }
381 idx |= _shaders_source[k].nomul << 1; // bool 480 }
382 idx |= _shaders_source[k].afill; // bool 481 }
383 _shaders[idx] = _shaders_source[k].id; 482 else
384 } 483 nomul = 0;
385 else if (_shaders_source[k].type == SHD_IMAGENATIVE) 484
485 if (nomul)
486 flags |= SHADER_FLAG_NOMUL;
487
488 // bgra
489 if (tex_only)
490 {
491 if (tex->pt->dyn.img)
492 {
493 afill = !tex->alpha;
494 bgra = 1;
495 }
496 else if (tex->im && tex->im->native.target == GL_TEXTURE_EXTERNAL_OES)
497 {
498 flags |= SHADER_FLAG_EXTERNAL;
499 afill = !tex->alpha;
500 }
501 else
502 bgra = 1;
503 }
504 else
505 bgra = shared->info.bgra;
506
507 if (tex)
508 flags |= SHADER_FLAG_TEX;
509
510 if (mtex)
511 flags |= SHADER_FLAG_MASK;
512
513 if (afill)
514 flags |= SHADER_FLAG_AFILL;
515
516 if (bgra)
517 flags |= SHADER_FLAG_BGRA;
518
519end:
520 if (psam) *psam = sam;
521 if (pnomul) *pnomul = nomul;
522 if (pmasksam) *pmasksam = masksam;
523 return flags;
524}
525
526static char *
527evas_gl_common_shader_glsl_get(unsigned int flags, const char *base)
528{
529 Eina_Strbuf *s = eina_strbuf_new();
530 unsigned int k;
531 char *str;
532
533 for (k = 0; k < SHADER_FLAG_COUNT; k++)
534 {
535 if (flags & (1 << k))
536 eina_strbuf_append_printf(s, "#define SHD_%s\n", _shader_flags[k]);
537 }
538
539 eina_strbuf_append(s, base);
540 str = eina_strbuf_string_steal(s);
541 eina_strbuf_free(s);
542 return str;
543}
544
545static Evas_GL_Program *
546evas_gl_common_shader_compile(unsigned int flags, const char *vertex,
547 const char *fragment)
548{
549 Evas_GL_Program *p;
550 GLuint vtx, frg, prg;
551 GLint ok = 0;
552
553 vtx = glCreateShader(GL_VERTEX_SHADER);
554 frg = glCreateShader(GL_FRAGMENT_SHADER);
555
556 glShaderSource(vtx, 1, &vertex, NULL);
557 glCompileShader(vtx);
558 glGetShaderiv(vtx, GL_COMPILE_STATUS, &ok);
559 if (!ok)
560 {
561 gl_compile_link_error(vtx, "compile vertex shader");
562 ERR("Abort compile of vertex shader:\n%s", vertex);
563 glDeleteShader(vtx);
564 return NULL;
565 }
566 ok = 0;
567
568 glShaderSource(frg, 1, &fragment, NULL);
569 glCompileShader(frg);
570 glGetShaderiv(frg, GL_COMPILE_STATUS, &ok);
571 if (!ok)
572 {
573 gl_compile_link_error(frg, "compile fragment shader");
574 ERR("Abort compile of fragment shader:\n%s", fragment);
575 glDeleteShader(vtx);
576 glDeleteShader(frg);
577 return NULL;
578 }
579 ok = 0;
580
581 prg = glCreateProgram();
582#ifndef GL_GLES
583 if ((glsym_glGetProgramBinary) && (glsym_glProgramParameteri))
584 glsym_glProgramParameteri(prg, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
585#endif
586 glAttachShader(prg, vtx);
587 glAttachShader(prg, frg);
588
589 glBindAttribLocation(prg, SHAD_VERTEX, "vertex");
590 glBindAttribLocation(prg, SHAD_COLOR, "color");
591 glBindAttribLocation(prg, SHAD_TEXUV, "tex_coord");
592 glBindAttribLocation(prg, SHAD_TEXUV2, "tex_coord2");
593 glBindAttribLocation(prg, SHAD_TEXUV3, "tex_coord3");
594 glBindAttribLocation(prg, SHAD_TEXA, "tex_coorda");
595 glBindAttribLocation(prg, SHAD_TEXSAM, "tex_sample");
596 glBindAttribLocation(prg, SHAD_MASK, "mask_coord");
597 glBindAttribLocation(prg, SHAD_MASKSAM, "tex_masksample");
598
599 glLinkProgram(prg);
600 glGetProgramiv(prg, GL_LINK_STATUS, &ok);
601 if (!ok)
602 {
603 gl_compile_link_error(prg, "link fragment and vertex shaders");
604 ERR("Abort compile of shader (flags: %#x)", flags);
605 glDeleteShader(vtx);
606 glDeleteShader(frg);
607 glDeleteProgram(prg);
608 return 0;
609 }
610
611 p = calloc(1, sizeof(*p));
612 p->flags = flags;
613 p->prog = prg;
614 p->vert = vtx;
615 p->frag = frg;
616 p->reset = EINA_TRUE;
617
618 return p;
619}
620
621void
622evas_gl_common_shader_textures_bind(Evas_GL_Program *p)
623{
624 struct {
625 const char *name;
626 int enabled;
627 } textures[] = {
628 { "tex", 0 },
629 { "texm", 0 },
630 { "texa", 0 },
631 { "texu", 0 },
632 { "texv", 0 },
633 { "texuv", 0 },
634 { NULL, 0 }
635 };
636 Eina_Bool hastex = 0;
637 GLint loc;
638 int i;
639
640 if (!p || (p->tex_count > 0)) return;
641
642 if ((p->flags & SHADER_FLAG_TEX) != 0)
643 {
644 textures[0].enabled = 1;
645 hastex = 1;
646 }
647 if ((p->flags & SHADER_FLAG_MASK) != 0)
648 {
649 textures[1].enabled = 1;
650 hastex = 1;
651 }
652 if ((p->flags & SHADER_FLAG_RGB_A_PAIR) != 0)
653 {
654 textures[2].enabled = 1;
655 hastex = 1;
656 }
657 if (p->flags & SHADER_FLAG_YUV)
658 {
659 textures[3].enabled = 1;
660 textures[4].enabled = 1;
661 hastex = 1;
662 }
663 else if ((p->flags & SHADER_FLAG_NV12) || (p->flags & SHADER_FLAG_YUY2))
664 {
665 textures[5].enabled = 1;
666 hastex = 1;
667 }
668
669 if (hastex)
670 {
671 glUseProgram(p->prog); // is this necessary??
672 for (i = 0; textures[i].name; i++)
673 {
674 if (!textures[i].enabled) continue;
675 loc = glGetUniformLocation(p->prog, textures[i].name);
676 if (loc < 0)
386 { 677 {
387 idx = _shaders_source[k].sam << 6; // 2 bits 678 ERR("Couldn't find uniform '%s' (shader: %#x)",
388 idx |= _shaders_source[k].masksam << 4; // 2 bits 679 textures[i].name, p->flags);
389 idx |= _shaders_source[k].bgra << 3; // bool
390 idx |= _shaders_source[k].mask << 2; // bool
391 idx |= _shaders_source[k].nomul << 1; // bool
392 idx |= _shaders_source[k].afill; // bool
393 idx += (4 * 2 * 2 * 2 * 2 * 4);
394 _shaders[idx] = _shaders_source[k].id;
395 } 680 }
681 glUniform1i(loc, p->tex_count++);
396 } 682 }
397 } 683 }
398
399 idx = sam << 6;
400 idx |= masksam << 4;
401 idx |= bgra << 3;
402 idx |= mask << 2;
403 idx |= nomul << 1;
404 idx |= afill;
405 if (type == SHD_IMAGENATIVE) idx += (4 * 2 * 2 * 2 * 2 * 4);
406 return _shaders[idx];
407} 684}
408 685
409const char * 686Evas_GL_Program *
410evas_gl_common_shader_name_get(Evas_GL_Shader shd) 687evas_gl_common_shader_program_get(Evas_Engine_GL_Context *gc,
688 Shader_Type type,
689 RGBA_Map_Point *map_points, int npoints,
690 int r, int g, int b, int a,
691 int sw, int sh, int w, int h, Eina_Bool smooth,
692 Evas_GL_Texture *tex, Eina_Bool tex_only,
693 Evas_GL_Texture *mtex, Eina_Bool mask_smooth,
694 int mw, int mh,
695 Shader_Sampling *psam, int *pnomul,
696 Shader_Sampling *pmasksam)
411{ 697{
412 if (shd < (sizeof(_shaders_source) / sizeof(_shaders_source[0]))) 698 unsigned int flags;
413 return _shaders_source[shd].name; 699 Evas_GL_Program *p;
414 return "UNKNOWN"; 700
701 flags = evas_gl_common_shader_flags_get(gc->shared, type, map_points, npoints, r, g, b, a,
702 sw, sh, w, h, smooth, tex, tex_only,
703 mtex, mask_smooth, mw, mh,
704 psam, pnomul, pmasksam);
705 p = eina_hash_find(gc->shared->shaders_hash, &flags);
706 if (!p)
707 {
708 char *vertex, *fragment;
709
710 _evas_gl_common_shader_binary_init(gc->shared);
711 if (gc->shared->shaders_cache)
712 {
713 char pname[32];
714 sprintf(pname, SHADER_PROG_NAME_FMT, flags);
715 p = _evas_gl_common_shader_program_binary_load(gc->shared->shaders_cache, flags);
716 if (p)
717 {
718 eina_hash_add(gc->shared->shaders_hash, &flags, p);
719 goto end;
720 }
721 }
722
723 vertex = evas_gl_common_shader_glsl_get(flags, vertex_glsl);
724 fragment = evas_gl_common_shader_glsl_get(flags, fragment_glsl);
725
726 p = evas_gl_common_shader_compile(flags, vertex, fragment);
727 evas_gl_common_shader_textures_bind(p);
728 eina_hash_add(gc->shared->shaders_hash, &flags, p);
729
730 free(vertex);
731 free(fragment);
732 }
733end:
734 if (p->hitcount < PROGRAM_HITCOUNT_MAX)
735 p->hitcount++;
736 return p;
415} 737}
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
deleted file mode 100644
index 41d372ac74..0000000000
--- a/src/modules/evas/engines/gl_common/shader/evas_gl_enum.x
+++ /dev/null
@@ -1,595 +0,0 @@
1/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */
2/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */
3
4typedef enum {
5 SHADER_RECT,
6 SHADER_RECT_MASK,
7 SHADER_RECT_MASK12,
8 SHADER_RECT_MASK21,
9 SHADER_RECT_MASK22,
10 SHADER_FONT,
11 SHADER_FONT_MASK,
12 SHADER_FONT_MASK12,
13 SHADER_FONT_MASK21,
14 SHADER_FONT_MASK22,
15 SHADER_IMG,
16 SHADER_IMG_BGRA,
17 SHADER_IMG_12,
18 SHADER_IMG_21,
19 SHADER_IMG_22,
20 SHADER_IMG_12_BGRA,
21 SHADER_IMG_21_BGRA,
22 SHADER_IMG_22_BGRA,
23 SHADER_IMG_MASK,
24 SHADER_IMG_BGRA_MASK,
25 SHADER_IMG_12_MASK,
26 SHADER_IMG_21_MASK,
27 SHADER_IMG_22_MASK,
28 SHADER_IMG_12_BGRA_MASK,
29 SHADER_IMG_21_BGRA_MASK,
30 SHADER_IMG_22_BGRA_MASK,
31 SHADER_IMG_NOMUL,
32 SHADER_IMG_BGRA_NOMUL,
33 SHADER_IMG_12_NOMUL,
34 SHADER_IMG_21_NOMUL,
35 SHADER_IMG_22_NOMUL,
36 SHADER_IMG_12_BGRA_NOMUL,
37 SHADER_IMG_21_BGRA_NOMUL,
38 SHADER_IMG_22_BGRA_NOMUL,
39 SHADER_IMG_MASK_NOMUL,
40 SHADER_IMG_BGRA_MASK_NOMUL,
41 SHADER_IMG_12_MASK_NOMUL,
42 SHADER_IMG_21_MASK_NOMUL,
43 SHADER_IMG_22_MASK_NOMUL,
44 SHADER_IMG_12_BGRA_MASK_NOMUL,
45 SHADER_IMG_21_BGRA_MASK_NOMUL,
46 SHADER_IMG_22_BGRA_MASK_NOMUL,
47 SHADER_IMG_MASK12,
48 SHADER_IMG_BGRA_MASK12,
49 SHADER_IMG_12_MASK12,
50 SHADER_IMG_21_MASK12,
51 SHADER_IMG_22_MASK12,
52 SHADER_IMG_12_BGRA_MASK12,
53 SHADER_IMG_21_BGRA_MASK12,
54 SHADER_IMG_22_BGRA_MASK12,
55 SHADER_IMG_MASK12_NOMUL,
56 SHADER_IMG_BGRA_MASK12_NOMUL,
57 SHADER_IMG_12_MASK12_NOMUL,
58 SHADER_IMG_21_MASK12_NOMUL,
59 SHADER_IMG_22_MASK12_NOMUL,
60 SHADER_IMG_12_BGRA_MASK12_NOMUL,
61 SHADER_IMG_21_BGRA_MASK12_NOMUL,
62 SHADER_IMG_22_BGRA_MASK12_NOMUL,
63 SHADER_IMG_MASK21,
64 SHADER_IMG_BGRA_MASK21,
65 SHADER_IMG_12_MASK21,
66 SHADER_IMG_21_MASK21,
67 SHADER_IMG_22_MASK21,
68 SHADER_IMG_12_BGRA_MASK21,
69 SHADER_IMG_21_BGRA_MASK21,
70 SHADER_IMG_22_BGRA_MASK21,
71 SHADER_IMG_MASK21_NOMUL,
72 SHADER_IMG_BGRA_MASK21_NOMUL,
73 SHADER_IMG_12_MASK21_NOMUL,
74 SHADER_IMG_21_MASK21_NOMUL,
75 SHADER_IMG_22_MASK21_NOMUL,
76 SHADER_IMG_12_BGRA_MASK21_NOMUL,
77 SHADER_IMG_21_BGRA_MASK21_NOMUL,
78 SHADER_IMG_22_BGRA_MASK21_NOMUL,
79 SHADER_IMG_MASK22,
80 SHADER_IMG_BGRA_MASK22,
81 SHADER_IMG_12_MASK22,
82 SHADER_IMG_21_MASK22,
83 SHADER_IMG_22_MASK22,
84 SHADER_IMG_12_BGRA_MASK22,
85 SHADER_IMG_21_BGRA_MASK22,
86 SHADER_IMG_22_BGRA_MASK22,
87 SHADER_IMG_MASK22_NOMUL,
88 SHADER_IMG_BGRA_MASK22_NOMUL,
89 SHADER_IMG_12_MASK22_NOMUL,
90 SHADER_IMG_21_MASK22_NOMUL,
91 SHADER_IMG_22_MASK22_NOMUL,
92 SHADER_IMG_12_BGRA_MASK22_NOMUL,
93 SHADER_IMG_21_BGRA_MASK22_NOMUL,
94 SHADER_IMG_22_BGRA_MASK22_NOMUL,
95 SHADER_IMG_AFILL,
96 SHADER_IMG_BGRA_AFILL,
97 SHADER_IMG_NOMUL_AFILL,
98 SHADER_IMG_BGRA_NOMUL_AFILL,
99 SHADER_IMG_12_AFILL,
100 SHADER_IMG_21_AFILL,
101 SHADER_IMG_22_AFILL,
102 SHADER_IMG_12_BGRA_AFILL,
103 SHADER_IMG_21_BGRA_AFILL,
104 SHADER_IMG_22_BGRA_AFILL,
105 SHADER_IMG_12_NOMUL_AFILL,
106 SHADER_IMG_21_NOMUL_AFILL,
107 SHADER_IMG_22_NOMUL_AFILL,
108 SHADER_IMG_12_BGRA_NOMUL_AFILL,
109 SHADER_IMG_21_BGRA_NOMUL_AFILL,
110 SHADER_IMG_22_BGRA_NOMUL_AFILL,
111 SHADER_IMGNAT,
112 SHADER_IMGNAT_BGRA,
113 SHADER_IMGNAT_12,
114 SHADER_IMGNAT_21,
115 SHADER_IMGNAT_22,
116 SHADER_IMGNAT_12_BGRA,
117 SHADER_IMGNAT_21_BGRA,
118 SHADER_IMGNAT_22_BGRA,
119 SHADER_IMGNAT_MASK,
120 SHADER_IMGNAT_BGRA_MASK,
121 SHADER_IMGNAT_12_MASK,
122 SHADER_IMGNAT_21_MASK,
123 SHADER_IMGNAT_22_MASK,
124 SHADER_IMGNAT_12_BGRA_MASK,
125 SHADER_IMGNAT_21_BGRA_MASK,
126 SHADER_IMGNAT_22_BGRA_MASK,
127 SHADER_IMGNAT_NOMUL,
128 SHADER_IMGNAT_BGRA_NOMUL,
129 SHADER_IMGNAT_12_NOMUL,
130 SHADER_IMGNAT_21_NOMUL,
131 SHADER_IMGNAT_22_NOMUL,
132 SHADER_IMGNAT_12_BGRA_NOMUL,
133 SHADER_IMGNAT_21_BGRA_NOMUL,
134 SHADER_IMGNAT_22_BGRA_NOMUL,
135 SHADER_IMGNAT_MASK_NOMUL,
136 SHADER_IMGNAT_BGRA_MASK_NOMUL,
137 SHADER_IMGNAT_12_MASK_NOMUL,
138 SHADER_IMGNAT_21_MASK_NOMUL,
139 SHADER_IMGNAT_22_MASK_NOMUL,
140 SHADER_IMGNAT_12_BGRA_MASK_NOMUL,
141 SHADER_IMGNAT_21_BGRA_MASK_NOMUL,
142 SHADER_IMGNAT_22_BGRA_MASK_NOMUL,
143 SHADER_IMGNAT_MASK12,
144 SHADER_IMGNAT_BGRA_MASK12,
145 SHADER_IMGNAT_12_MASK12,
146 SHADER_IMGNAT_21_MASK12,
147 SHADER_IMGNAT_22_MASK12,
148 SHADER_IMGNAT_12_BGRA_MASK12,
149 SHADER_IMGNAT_21_BGRA_MASK12,
150 SHADER_IMGNAT_22_BGRA_MASK12,
151 SHADER_IMGNAT_MASK12_NOMUL,
152 SHADER_IMGNAT_BGRA_MASK12_NOMUL,
153 SHADER_IMGNAT_12_MASK12_NOMUL,
154 SHADER_IMGNAT_21_MASK12_NOMUL,
155 SHADER_IMGNAT_22_MASK12_NOMUL,
156 SHADER_IMGNAT_12_BGRA_MASK12_NOMUL,
157 SHADER_IMGNAT_21_BGRA_MASK12_NOMUL,
158 SHADER_IMGNAT_22_BGRA_MASK12_NOMUL,
159 SHADER_IMGNAT_MASK21,
160 SHADER_IMGNAT_BGRA_MASK21,
161 SHADER_IMGNAT_12_MASK21,
162 SHADER_IMGNAT_21_MASK21,
163 SHADER_IMGNAT_22_MASK21,
164 SHADER_IMGNAT_12_BGRA_MASK21,
165 SHADER_IMGNAT_21_BGRA_MASK21,
166 SHADER_IMGNAT_22_BGRA_MASK21,
167 SHADER_IMGNAT_MASK21_NOMUL,
168 SHADER_IMGNAT_BGRA_MASK21_NOMUL,
169 SHADER_IMGNAT_12_MASK21_NOMUL,
170 SHADER_IMGNAT_21_MASK21_NOMUL,
171 SHADER_IMGNAT_22_MASK21_NOMUL,
172 SHADER_IMGNAT_12_BGRA_MASK21_NOMUL,
173 SHADER_IMGNAT_21_BGRA_MASK21_NOMUL,
174 SHADER_IMGNAT_22_BGRA_MASK21_NOMUL,
175 SHADER_IMGNAT_MASK22,
176 SHADER_IMGNAT_BGRA_MASK22,
177 SHADER_IMGNAT_12_MASK22,
178 SHADER_IMGNAT_21_MASK22,
179 SHADER_IMGNAT_22_MASK22,
180 SHADER_IMGNAT_12_BGRA_MASK22,
181 SHADER_IMGNAT_21_BGRA_MASK22,
182 SHADER_IMGNAT_22_BGRA_MASK22,
183 SHADER_IMGNAT_MASK22_NOMUL,
184 SHADER_IMGNAT_BGRA_MASK22_NOMUL,
185 SHADER_IMGNAT_12_MASK22_NOMUL,
186 SHADER_IMGNAT_21_MASK22_NOMUL,
187 SHADER_IMGNAT_22_MASK22_NOMUL,
188 SHADER_IMGNAT_12_BGRA_MASK22_NOMUL,
189 SHADER_IMGNAT_21_BGRA_MASK22_NOMUL,
190 SHADER_IMGNAT_22_BGRA_MASK22_NOMUL,
191 SHADER_IMGNAT_AFILL,
192 SHADER_IMGNAT_BGRA_AFILL,
193 SHADER_IMGNAT_NOMUL_AFILL,
194 SHADER_IMGNAT_BGRA_NOMUL_AFILL,
195 SHADER_IMGNAT_12_AFILL,
196 SHADER_IMGNAT_21_AFILL,
197 SHADER_IMGNAT_22_AFILL,
198 SHADER_IMGNAT_12_BGRA_AFILL,
199 SHADER_IMGNAT_21_BGRA_AFILL,
200 SHADER_IMGNAT_22_BGRA_AFILL,
201 SHADER_IMGNAT_12_NOMUL_AFILL,
202 SHADER_IMGNAT_21_NOMUL_AFILL,
203 SHADER_IMGNAT_22_NOMUL_AFILL,
204 SHADER_IMGNAT_12_BGRA_NOMUL_AFILL,
205 SHADER_IMGNAT_21_BGRA_NOMUL_AFILL,
206 SHADER_IMGNAT_22_BGRA_NOMUL_AFILL,
207 SHADER_RGB_A_PAIR,
208 SHADER_RGB_A_PAIR_MASK,
209 SHADER_RGB_A_PAIR_NOMUL,
210 SHADER_RGB_A_PAIR_MASK_NOMUL,
211 SHADER_TEX_EXTERNAL,
212 SHADER_TEX_EXTERNAL_AFILL,
213 SHADER_TEX_EXTERNAL_NOMUL,
214 SHADER_TEX_EXTERNAL_NOMUL_AFILL,
215 SHADER_TEX_EXTERNAL_MASK,
216 SHADER_TEX_EXTERNAL_MASK_NOMUL,
217 SHADER_YUV,
218 SHADER_YUV_NOMUL,
219 SHADER_YUV_MASK,
220 SHADER_YUV_MASK_NOMUL,
221 SHADER_YUY2,
222 SHADER_YUY2_NOMUL,
223 SHADER_YUY2_MASK,
224 SHADER_YUY2_MASK_NOMUL,
225 SHADER_NV12,
226 SHADER_NV12_NOMUL,
227 SHADER_NV12_MASK,
228 SHADER_NV12_MASK_NOMUL,
229 SHADER_YUV_709,
230 SHADER_YUV_709_NOMUL,
231 SHADER_YUV_709_MASK,
232 SHADER_YUV_709_MASK_NOMUL,
233 SHADER_YUY2_709,
234 SHADER_YUY2_709_NOMUL,
235 SHADER_YUY2_709_MASK,
236 SHADER_YUY2_709_MASK_NOMUL,
237 SHADER_NV12_709,
238 SHADER_NV12_709_NOMUL,
239 SHADER_NV12_709_MASK,
240 SHADER_NV12_709_MASK_NOMUL,
241 SHADER_LAST
242} Evas_GL_Shader;
243
244#ifdef _EVAS_GL_CONTEXT_C
245
246static struct {
247 Evas_GL_Shader id;
248 const char *tname;
249} _shaders_textures[] = {
250 { SHADER_FONT_MASK, "tex" },
251 { SHADER_FONT_MASK, "texm" },
252 { SHADER_FONT_MASK12, "tex" },
253 { SHADER_FONT_MASK12, "texm" },
254 { SHADER_FONT_MASK21, "tex" },
255 { SHADER_FONT_MASK21, "texm" },
256 { SHADER_FONT_MASK22, "tex" },
257 { SHADER_FONT_MASK22, "texm" },
258 { SHADER_IMG_MASK, "tex" },
259 { SHADER_IMG_MASK, "texm" },
260 { SHADER_IMG_BGRA_MASK, "tex" },
261 { SHADER_IMG_BGRA_MASK, "texm" },
262 { SHADER_IMG_12_MASK, "tex" },
263 { SHADER_IMG_12_MASK, "texm" },
264 { SHADER_IMG_21_MASK, "tex" },
265 { SHADER_IMG_21_MASK, "texm" },
266 { SHADER_IMG_22_MASK, "tex" },
267 { SHADER_IMG_22_MASK, "texm" },
268 { SHADER_IMG_12_BGRA_MASK, "tex" },
269 { SHADER_IMG_12_BGRA_MASK, "texm" },
270 { SHADER_IMG_21_BGRA_MASK, "tex" },
271 { SHADER_IMG_21_BGRA_MASK, "texm" },
272 { SHADER_IMG_22_BGRA_MASK, "tex" },
273 { SHADER_IMG_22_BGRA_MASK, "texm" },
274 { SHADER_IMG_MASK_NOMUL, "tex" },
275 { SHADER_IMG_MASK_NOMUL, "texm" },
276 { SHADER_IMG_BGRA_MASK_NOMUL, "tex" },
277 { SHADER_IMG_BGRA_MASK_NOMUL, "texm" },
278 { SHADER_IMG_12_MASK_NOMUL, "tex" },
279 { SHADER_IMG_12_MASK_NOMUL, "texm" },
280 { SHADER_IMG_21_MASK_NOMUL, "tex" },
281 { SHADER_IMG_21_MASK_NOMUL, "texm" },
282 { SHADER_IMG_22_MASK_NOMUL, "tex" },
283 { SHADER_IMG_22_MASK_NOMUL, "texm" },
284 { SHADER_IMG_12_BGRA_MASK_NOMUL, "tex" },
285 { SHADER_IMG_12_BGRA_MASK_NOMUL, "texm" },
286 { SHADER_IMG_21_BGRA_MASK_NOMUL, "tex" },
287 { SHADER_IMG_21_BGRA_MASK_NOMUL, "texm" },
288 { SHADER_IMG_22_BGRA_MASK_NOMUL, "tex" },
289 { SHADER_IMG_22_BGRA_MASK_NOMUL, "texm" },
290 { SHADER_IMG_MASK12, "tex" },
291 { SHADER_IMG_MASK12, "texm" },
292 { SHADER_IMG_BGRA_MASK12, "tex" },
293 { SHADER_IMG_BGRA_MASK12, "texm" },
294 { SHADER_IMG_12_MASK12, "tex" },
295 { SHADER_IMG_12_MASK12, "texm" },
296 { SHADER_IMG_21_MASK12, "tex" },
297 { SHADER_IMG_21_MASK12, "texm" },
298 { SHADER_IMG_22_MASK12, "tex" },
299 { SHADER_IMG_22_MASK12, "texm" },
300 { SHADER_IMG_12_BGRA_MASK12, "tex" },
301 { SHADER_IMG_12_BGRA_MASK12, "texm" },
302 { SHADER_IMG_21_BGRA_MASK12, "tex" },
303 { SHADER_IMG_21_BGRA_MASK12, "texm" },
304 { SHADER_IMG_22_BGRA_MASK12, "tex" },
305 { SHADER_IMG_22_BGRA_MASK12, "texm" },
306 { SHADER_IMG_MASK12_NOMUL, "tex" },
307 { SHADER_IMG_MASK12_NOMUL, "texm" },
308 { SHADER_IMG_BGRA_MASK12_NOMUL, "tex" },
309 { SHADER_IMG_BGRA_MASK12_NOMUL, "texm" },
310 { SHADER_IMG_12_MASK12_NOMUL, "tex" },
311 { SHADER_IMG_12_MASK12_NOMUL, "texm" },
312 { SHADER_IMG_21_MASK12_NOMUL, "tex" },
313 { SHADER_IMG_21_MASK12_NOMUL, "texm" },
314 { SHADER_IMG_22_MASK12_NOMUL, "tex" },
315 { SHADER_IMG_22_MASK12_NOMUL, "texm" },
316 { SHADER_IMG_12_BGRA_MASK12_NOMUL, "tex" },
317 { SHADER_IMG_12_BGRA_MASK12_NOMUL, "texm" },
318 { SHADER_IMG_21_BGRA_MASK12_NOMUL, "tex" },
319 { SHADER_IMG_21_BGRA_MASK12_NOMUL, "texm" },
320 { SHADER_IMG_22_BGRA_MASK12_NOMUL, "tex" },
321 { SHADER_IMG_22_BGRA_MASK12_NOMUL, "texm" },
322 { SHADER_IMG_MASK21, "tex" },
323 { SHADER_IMG_MASK21, "texm" },
324 { SHADER_IMG_BGRA_MASK21, "tex" },
325 { SHADER_IMG_BGRA_MASK21, "texm" },
326 { SHADER_IMG_12_MASK21, "tex" },
327 { SHADER_IMG_12_MASK21, "texm" },
328 { SHADER_IMG_21_MASK21, "tex" },
329 { SHADER_IMG_21_MASK21, "texm" },
330 { SHADER_IMG_22_MASK21, "tex" },
331 { SHADER_IMG_22_MASK21, "texm" },
332 { SHADER_IMG_12_BGRA_MASK21, "tex" },
333 { SHADER_IMG_12_BGRA_MASK21, "texm" },
334 { SHADER_IMG_21_BGRA_MASK21, "tex" },
335 { SHADER_IMG_21_BGRA_MASK21, "texm" },
336 { SHADER_IMG_22_BGRA_MASK21, "tex" },
337 { SHADER_IMG_22_BGRA_MASK21, "texm" },
338 { SHADER_IMG_MASK21_NOMUL, "tex" },
339 { SHADER_IMG_MASK21_NOMUL, "texm" },
340 { SHADER_IMG_BGRA_MASK21_NOMUL, "tex" },
341 { SHADER_IMG_BGRA_MASK21_NOMUL, "texm" },
342 { SHADER_IMG_12_MASK21_NOMUL, "tex" },
343 { SHADER_IMG_12_MASK21_NOMUL, "texm" },
344 { SHADER_IMG_21_MASK21_NOMUL, "tex" },
345 { SHADER_IMG_21_MASK21_NOMUL, "texm" },
346 { SHADER_IMG_22_MASK21_NOMUL, "tex" },
347 { SHADER_IMG_22_MASK21_NOMUL, "texm" },
348 { SHADER_IMG_12_BGRA_MASK21_NOMUL, "tex" },
349 { SHADER_IMG_12_BGRA_MASK21_NOMUL, "texm" },
350 { SHADER_IMG_21_BGRA_MASK21_NOMUL, "tex" },
351 { SHADER_IMG_21_BGRA_MASK21_NOMUL, "texm" },
352 { SHADER_IMG_22_BGRA_MASK21_NOMUL, "tex" },
353 { SHADER_IMG_22_BGRA_MASK21_NOMUL, "texm" },
354 { SHADER_IMG_MASK22, "tex" },
355 { SHADER_IMG_MASK22, "texm" },
356 { SHADER_IMG_BGRA_MASK22, "tex" },
357 { SHADER_IMG_BGRA_MASK22, "texm" },
358 { SHADER_IMG_12_MASK22, "tex" },
359 { SHADER_IMG_12_MASK22, "texm" },
360 { SHADER_IMG_21_MASK22, "tex" },
361 { SHADER_IMG_21_MASK22, "texm" },
362 { SHADER_IMG_22_MASK22, "tex" },
363 { SHADER_IMG_22_MASK22, "texm" },
364 { SHADER_IMG_12_BGRA_MASK22, "tex" },
365 { SHADER_IMG_12_BGRA_MASK22, "texm" },
366 { SHADER_IMG_21_BGRA_MASK22, "tex" },
367 { SHADER_IMG_21_BGRA_MASK22, "texm" },
368 { SHADER_IMG_22_BGRA_MASK22, "tex" },
369 { SHADER_IMG_22_BGRA_MASK22, "texm" },
370 { SHADER_IMG_MASK22_NOMUL, "tex" },
371 { SHADER_IMG_MASK22_NOMUL, "texm" },
372 { SHADER_IMG_BGRA_MASK22_NOMUL, "tex" },
373 { SHADER_IMG_BGRA_MASK22_NOMUL, "texm" },
374 { SHADER_IMG_12_MASK22_NOMUL, "tex" },
375 { SHADER_IMG_12_MASK22_NOMUL, "texm" },
376 { SHADER_IMG_21_MASK22_NOMUL, "tex" },
377 { SHADER_IMG_21_MASK22_NOMUL, "texm" },
378 { SHADER_IMG_22_MASK22_NOMUL, "tex" },
379 { SHADER_IMG_22_MASK22_NOMUL, "texm" },
380 { SHADER_IMG_12_BGRA_MASK22_NOMUL, "tex" },
381 { SHADER_IMG_12_BGRA_MASK22_NOMUL, "texm" },
382 { SHADER_IMG_21_BGRA_MASK22_NOMUL, "tex" },
383 { SHADER_IMG_21_BGRA_MASK22_NOMUL, "texm" },
384 { SHADER_IMG_22_BGRA_MASK22_NOMUL, "tex" },
385 { SHADER_IMG_22_BGRA_MASK22_NOMUL, "texm" },
386 { SHADER_IMGNAT_MASK, "tex" },
387 { SHADER_IMGNAT_MASK, "texm" },
388 { SHADER_IMGNAT_BGRA_MASK, "tex" },
389 { SHADER_IMGNAT_BGRA_MASK, "texm" },
390 { SHADER_IMGNAT_12_MASK, "tex" },
391 { SHADER_IMGNAT_12_MASK, "texm" },
392 { SHADER_IMGNAT_21_MASK, "tex" },
393 { SHADER_IMGNAT_21_MASK, "texm" },
394 { SHADER_IMGNAT_22_MASK, "tex" },
395 { SHADER_IMGNAT_22_MASK, "texm" },
396 { SHADER_IMGNAT_12_BGRA_MASK, "tex" },
397 { SHADER_IMGNAT_12_BGRA_MASK, "texm" },
398 { SHADER_IMGNAT_21_BGRA_MASK, "tex" },
399 { SHADER_IMGNAT_21_BGRA_MASK, "texm" },
400 { SHADER_IMGNAT_22_BGRA_MASK, "tex" },
401 { SHADER_IMGNAT_22_BGRA_MASK, "texm" },
402 { SHADER_IMGNAT_MASK_NOMUL, "tex" },
403 { SHADER_IMGNAT_MASK_NOMUL, "texm" },
404 { SHADER_IMGNAT_BGRA_MASK_NOMUL, "tex" },
405 { SHADER_IMGNAT_BGRA_MASK_NOMUL, "texm" },
406 { SHADER_IMGNAT_12_MASK_NOMUL, "tex" },
407 { SHADER_IMGNAT_12_MASK_NOMUL, "texm" },
408 { SHADER_IMGNAT_21_MASK_NOMUL, "tex" },
409 { SHADER_IMGNAT_21_MASK_NOMUL, "texm" },
410 { SHADER_IMGNAT_22_MASK_NOMUL, "tex" },
411 { SHADER_IMGNAT_22_MASK_NOMUL, "texm" },
412 { SHADER_IMGNAT_12_BGRA_MASK_NOMUL, "tex" },
413 { SHADER_IMGNAT_12_BGRA_MASK_NOMUL, "texm" },
414 { SHADER_IMGNAT_21_BGRA_MASK_NOMUL, "tex" },
415 { SHADER_IMGNAT_21_BGRA_MASK_NOMUL, "texm" },
416 { SHADER_IMGNAT_22_BGRA_MASK_NOMUL, "tex" },
417 { SHADER_IMGNAT_22_BGRA_MASK_NOMUL, "texm" },
418 { SHADER_IMGNAT_MASK12, "tex" },
419 { SHADER_IMGNAT_MASK12, "texm" },
420 { SHADER_IMGNAT_BGRA_MASK12, "tex" },
421 { SHADER_IMGNAT_BGRA_MASK12, "texm" },
422 { SHADER_IMGNAT_12_MASK12, "tex" },
423 { SHADER_IMGNAT_12_MASK12, "texm" },
424 { SHADER_IMGNAT_21_MASK12, "tex" },
425 { SHADER_IMGNAT_21_MASK12, "texm" },
426 { SHADER_IMGNAT_22_MASK12, "tex" },
427 { SHADER_IMGNAT_22_MASK12, "texm" },
428 { SHADER_IMGNAT_12_BGRA_MASK12, "tex" },
429 { SHADER_IMGNAT_12_BGRA_MASK12, "texm" },
430 { SHADER_IMGNAT_21_BGRA_MASK12, "tex" },
431 { SHADER_IMGNAT_21_BGRA_MASK12, "texm" },
432 { SHADER_IMGNAT_22_BGRA_MASK12, "tex" },
433 { SHADER_IMGNAT_22_BGRA_MASK12, "texm" },
434 { SHADER_IMGNAT_MASK12_NOMUL, "tex" },
435 { SHADER_IMGNAT_MASK12_NOMUL, "texm" },
436 { SHADER_IMGNAT_BGRA_MASK12_NOMUL, "tex" },
437 { SHADER_IMGNAT_BGRA_MASK12_NOMUL, "texm" },
438 { SHADER_IMGNAT_12_MASK12_NOMUL, "tex" },
439 { SHADER_IMGNAT_12_MASK12_NOMUL, "texm" },
440 { SHADER_IMGNAT_21_MASK12_NOMUL, "tex" },
441 { SHADER_IMGNAT_21_MASK12_NOMUL, "texm" },
442 { SHADER_IMGNAT_22_MASK12_NOMUL, "tex" },
443 { SHADER_IMGNAT_22_MASK12_NOMUL, "texm" },
444 { SHADER_IMGNAT_12_BGRA_MASK12_NOMUL, "tex" },
445 { SHADER_IMGNAT_12_BGRA_MASK12_NOMUL, "texm" },
446 { SHADER_IMGNAT_21_BGRA_MASK12_NOMUL, "tex" },
447 { SHADER_IMGNAT_21_BGRA_MASK12_NOMUL, "texm" },
448 { SHADER_IMGNAT_22_BGRA_MASK12_NOMUL, "tex" },
449 { SHADER_IMGNAT_22_BGRA_MASK12_NOMUL, "texm" },
450 { SHADER_IMGNAT_MASK21, "tex" },
451 { SHADER_IMGNAT_MASK21, "texm" },
452 { SHADER_IMGNAT_BGRA_MASK21, "tex" },
453 { SHADER_IMGNAT_BGRA_MASK21, "texm" },
454 { SHADER_IMGNAT_12_MASK21, "tex" },
455 { SHADER_IMGNAT_12_MASK21, "texm" },
456 { SHADER_IMGNAT_21_MASK21, "tex" },
457 { SHADER_IMGNAT_21_MASK21, "texm" },
458 { SHADER_IMGNAT_22_MASK21, "tex" },
459 { SHADER_IMGNAT_22_MASK21, "texm" },
460 { SHADER_IMGNAT_12_BGRA_MASK21, "tex" },
461 { SHADER_IMGNAT_12_BGRA_MASK21, "texm" },
462 { SHADER_IMGNAT_21_BGRA_MASK21, "tex" },
463 { SHADER_IMGNAT_21_BGRA_MASK21, "texm" },
464 { SHADER_IMGNAT_22_BGRA_MASK21, "tex" },
465 { SHADER_IMGNAT_22_BGRA_MASK21, "texm" },
466 { SHADER_IMGNAT_MASK21_NOMUL, "tex" },
467 { SHADER_IMGNAT_MASK21_NOMUL, "texm" },
468 { SHADER_IMGNAT_BGRA_MASK21_NOMUL, "tex" },
469 { SHADER_IMGNAT_BGRA_MASK21_NOMUL, "texm" },
470 { SHADER_IMGNAT_12_MASK21_NOMUL, "tex" },
471 { SHADER_IMGNAT_12_MASK21_NOMUL, "texm" },
472 { SHADER_IMGNAT_21_MASK21_NOMUL, "tex" },
473 { SHADER_IMGNAT_21_MASK21_NOMUL, "texm" },
474 { SHADER_IMGNAT_22_MASK21_NOMUL, "tex" },
475 { SHADER_IMGNAT_22_MASK21_NOMUL, "texm" },
476 { SHADER_IMGNAT_12_BGRA_MASK21_NOMUL, "tex" },
477 { SHADER_IMGNAT_12_BGRA_MASK21_NOMUL, "texm" },
478 { SHADER_IMGNAT_21_BGRA_MASK21_NOMUL, "tex" },
479 { SHADER_IMGNAT_21_BGRA_MASK21_NOMUL, "texm" },
480 { SHADER_IMGNAT_22_BGRA_MASK21_NOMUL, "tex" },
481 { SHADER_IMGNAT_22_BGRA_MASK21_NOMUL, "texm" },
482 { SHADER_IMGNAT_MASK22, "tex" },
483 { SHADER_IMGNAT_MASK22, "texm" },
484 { SHADER_IMGNAT_BGRA_MASK22, "tex" },
485 { SHADER_IMGNAT_BGRA_MASK22, "texm" },
486 { SHADER_IMGNAT_12_MASK22, "tex" },
487 { SHADER_IMGNAT_12_MASK22, "texm" },
488 { SHADER_IMGNAT_21_MASK22, "tex" },
489 { SHADER_IMGNAT_21_MASK22, "texm" },
490 { SHADER_IMGNAT_22_MASK22, "tex" },
491 { SHADER_IMGNAT_22_MASK22, "texm" },
492 { SHADER_IMGNAT_12_BGRA_MASK22, "tex" },
493 { SHADER_IMGNAT_12_BGRA_MASK22, "texm" },
494 { SHADER_IMGNAT_21_BGRA_MASK22, "tex" },
495 { SHADER_IMGNAT_21_BGRA_MASK22, "texm" },
496 { SHADER_IMGNAT_22_BGRA_MASK22, "tex" },
497 { SHADER_IMGNAT_22_BGRA_MASK22, "texm" },
498 { SHADER_IMGNAT_MASK22_NOMUL, "tex" },
499 { SHADER_IMGNAT_MASK22_NOMUL, "texm" },
500 { SHADER_IMGNAT_BGRA_MASK22_NOMUL, "tex" },
501 { SHADER_IMGNAT_BGRA_MASK22_NOMUL, "texm" },
502 { SHADER_IMGNAT_12_MASK22_NOMUL, "tex" },
503 { SHADER_IMGNAT_12_MASK22_NOMUL, "texm" },
504 { SHADER_IMGNAT_21_MASK22_NOMUL, "tex" },
505 { SHADER_IMGNAT_21_MASK22_NOMUL, "texm" },
506 { SHADER_IMGNAT_22_MASK22_NOMUL, "tex" },
507 { SHADER_IMGNAT_22_MASK22_NOMUL, "texm" },
508 { SHADER_IMGNAT_12_BGRA_MASK22_NOMUL, "tex" },
509 { SHADER_IMGNAT_12_BGRA_MASK22_NOMUL, "texm" },
510 { SHADER_IMGNAT_21_BGRA_MASK22_NOMUL, "tex" },
511 { SHADER_IMGNAT_21_BGRA_MASK22_NOMUL, "texm" },
512 { SHADER_IMGNAT_22_BGRA_MASK22_NOMUL, "tex" },
513 { SHADER_IMGNAT_22_BGRA_MASK22_NOMUL, "texm" },
514 { SHADER_RGB_A_PAIR, "tex" },
515 { SHADER_RGB_A_PAIR, "texa" },
516 { SHADER_RGB_A_PAIR_MASK, "tex" },
517 { SHADER_RGB_A_PAIR_MASK, "texa" },
518 { SHADER_RGB_A_PAIR_MASK, "texm" },
519 { SHADER_RGB_A_PAIR_NOMUL, "tex" },
520 { SHADER_RGB_A_PAIR_NOMUL, "texa" },
521 { SHADER_RGB_A_PAIR_MASK_NOMUL, "tex" },
522 { SHADER_RGB_A_PAIR_MASK_NOMUL, "texa" },
523 { SHADER_RGB_A_PAIR_MASK_NOMUL, "texm" },
524 { SHADER_YUV, "tex" },
525 { SHADER_YUV, "texu" },
526 { SHADER_YUV, "texv" },
527 { SHADER_YUV_NOMUL, "tex" },
528 { SHADER_YUV_NOMUL, "texu" },
529 { SHADER_YUV_NOMUL, "texv" },
530 { SHADER_YUV_MASK, "tex" },
531 { SHADER_YUV_MASK, "texu" },
532 { SHADER_YUV_MASK, "texv" },
533 { SHADER_YUV_MASK, "texm" },
534 { SHADER_YUV_MASK_NOMUL, "tex" },
535 { SHADER_YUV_MASK_NOMUL, "texu" },
536 { SHADER_YUV_MASK_NOMUL, "texv" },
537 { SHADER_YUV_MASK_NOMUL, "texm" },
538 { SHADER_YUY2, "tex" },
539 { SHADER_YUY2, "texuv" },
540 { SHADER_YUY2_NOMUL, "tex" },
541 { SHADER_YUY2_NOMUL, "texuv" },
542 { SHADER_YUY2_MASK, "tex" },
543 { SHADER_YUY2_MASK, "texuv" },
544 { SHADER_YUY2_MASK, "texm" },
545 { SHADER_YUY2_MASK_NOMUL, "tex" },
546 { SHADER_YUY2_MASK_NOMUL, "texuv" },
547 { SHADER_YUY2_MASK_NOMUL, "texm" },
548 { SHADER_NV12, "tex" },
549 { SHADER_NV12, "texuv" },
550 { SHADER_NV12_NOMUL, "tex" },
551 { SHADER_NV12_NOMUL, "texuv" },
552 { SHADER_NV12_MASK, "tex" },
553 { SHADER_NV12_MASK, "texuv" },
554 { SHADER_NV12_MASK, "texm" },
555 { SHADER_NV12_MASK_NOMUL, "tex" },
556 { SHADER_NV12_MASK_NOMUL, "texuv" },
557 { SHADER_NV12_MASK_NOMUL, "texm" },
558 { SHADER_YUV_709, "tex" },
559 { SHADER_YUV_709, "texu" },
560 { SHADER_YUV_709, "texv" },
561 { SHADER_YUV_709_NOMUL, "tex" },
562 { SHADER_YUV_709_NOMUL, "texu" },
563 { SHADER_YUV_709_NOMUL, "texv" },
564 { SHADER_YUV_709_MASK, "tex" },
565 { SHADER_YUV_709_MASK, "texu" },
566 { SHADER_YUV_709_MASK, "texv" },
567 { SHADER_YUV_709_MASK, "texm" },
568 { SHADER_YUV_709_MASK_NOMUL, "tex" },
569 { SHADER_YUV_709_MASK_NOMUL, "texu" },
570 { SHADER_YUV_709_MASK_NOMUL, "texv" },
571 { SHADER_YUV_709_MASK_NOMUL, "texm" },
572 { SHADER_YUY2_709, "tex" },
573 { SHADER_YUY2_709, "texuv" },
574 { SHADER_YUY2_709_NOMUL, "tex" },
575 { SHADER_YUY2_709_NOMUL, "texuv" },
576 { SHADER_YUY2_709_MASK, "tex" },
577 { SHADER_YUY2_709_MASK, "texuv" },
578 { SHADER_YUY2_709_MASK, "texm" },
579 { SHADER_YUY2_709_MASK_NOMUL, "tex" },
580 { SHADER_YUY2_709_MASK_NOMUL, "texuv" },
581 { SHADER_YUY2_709_MASK_NOMUL, "texm" },
582 { SHADER_NV12_709, "tex" },
583 { SHADER_NV12_709, "texuv" },
584 { SHADER_NV12_709_NOMUL, "tex" },
585 { SHADER_NV12_709_NOMUL, "texuv" },
586 { SHADER_NV12_709_MASK, "tex" },
587 { SHADER_NV12_709_MASK, "texuv" },
588 { SHADER_NV12_709_MASK, "texm" },
589 { SHADER_NV12_709_MASK_NOMUL, "tex" },
590 { SHADER_NV12_709_MASK_NOMUL, "texuv" },
591 { SHADER_NV12_709_MASK_NOMUL, "texm" },
592 { SHADER_LAST, NULL }
593};
594
595#endif // _EVAS_GL_CONTEXT_C
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 c9778d69cd..19120e26c3 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
@@ -1,13345 +1,285 @@
1/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */ 1/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED */
2/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */ 2/* IF IT IS CHANGED PLEASE COMMIT THE CHANGES */
3 3
4#include "../evas_gl_private.h" 4static const char fragment_glsl[] =
5 5 "/* General-purpose fragment shader for all operations in Evas.\n"
6static const char rect_frag_src[] = 6 " * This file can either be used directly by evas at runtime to\n"
7 "#ifdef GL_ES\n" 7 " * generate its shaders with the appropriate #defines, or passed\n"
8 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n" 8 " * through cpp first (in which case the precision must be manually added).\n"
9 "precision highp float;\n" 9 " */\n"
10 "#else\n"
11 "precision mediump float;\n"
12 "#endif\n"
13 "#endif\n"
14 "varying vec4 col;\n"
15 "void main()\n"
16 "{\n"
17 " vec4 c;\n"
18 " c = vec4(1, 1, 1, 1);\n"
19 " gl_FragColor =\n"
20 " c\n"
21 " * col\n"
22 " ;\n"
23 "}\n";
24
25static const char rect_vert_src[] =
26 "#ifdef GL_ES\n"
27 "precision highp float;\n"
28 "#endif\n"
29 "attribute vec4 vertex;\n"
30 "uniform mat4 mvp;\n"
31 "attribute vec4 color;\n"
32 "varying vec4 col;\n"
33 "void main()\n"
34 "{\n"
35 " gl_Position = mvp * vertex;\n"
36 " col = color;\n"
37 "}\n";
38
39static const char rect_mask_frag_src[] =
40 "#ifdef GL_ES\n"
41 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
42 "precision highp float;\n"
43 "#else\n"
44 "precision mediump float;\n"
45 "#endif\n"
46 "#endif\n"
47 "varying vec4 col;\n"
48 "uniform sampler2D texm;\n"
49 "varying vec2 tex_m;\n"
50 "void main()\n"
51 "{\n"
52 " vec4 c;\n"
53 " c = vec4(1, 1, 1, 1);\n"
54 " float ma;\n"
55 " ma = texture2D(texm, tex_m).a;\n"
56 " gl_FragColor =\n"
57 " c\n"
58 " * col\n"
59 " * ma\n"
60 " ;\n"
61 "}\n";
62
63static const char rect_mask_vert_src[] =
64 "#ifdef GL_ES\n"
65 "precision highp float;\n"
66 "#endif\n"
67 "attribute vec4 vertex;\n"
68 "uniform mat4 mvp;\n"
69 "attribute vec4 color;\n"
70 "varying vec4 col;\n"
71 "attribute vec4 mask_coord;\n"
72 "varying vec2 tex_m;\n"
73 "void main()\n"
74 "{\n"
75 " gl_Position = mvp * vertex;\n"
76 " col = color;\n"
77 " 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"
78 " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
79 "}\n";
80
81static const char rect_mask12_frag_src[] =
82 "#ifdef GL_ES\n"
83 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
84 "precision highp float;\n"
85 "#else\n"
86 "precision mediump float;\n"
87 "#endif\n"
88 "#endif\n"
89 "varying vec4 col;\n"
90 "uniform sampler2D texm;\n"
91 "varying vec2 tex_m;\n"
92 "varying float maskdiv_s;\n"
93 "varying vec2 masktex_s[2];\n"
94 "void main()\n"
95 "{\n"
96 " vec4 c;\n"
97 " c = vec4(1, 1, 1, 1);\n"
98 " float ma;\n"
99 " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
100 " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
101 " ma = (ma00 + ma01) / maskdiv_s;\n"
102 " gl_FragColor =\n"
103 " c\n"
104 " * col\n"
105 " * ma\n"
106 " ;\n"
107 "}\n";
108
109static const char rect_mask12_vert_src[] =
110 "#ifdef GL_ES\n"
111 "precision highp float;\n"
112 "#endif\n"
113 "attribute vec4 vertex;\n"
114 "uniform mat4 mvp;\n"
115 "attribute vec4 color;\n"
116 "varying vec4 col;\n"
117 "attribute vec4 mask_coord;\n"
118 "varying vec2 tex_m;\n"
119 "attribute vec2 tex_masksample;\n"
120 "varying float maskdiv_s;\n"
121 "varying vec2 masktex_s[2];\n"
122 "void main()\n"
123 "{\n"
124 " gl_Position = mvp * vertex;\n"
125 " col = color;\n"
126 " masktex_s[0] = vec2(0, -tex_masksample.y);\n"
127 " masktex_s[1] = vec2(0, tex_masksample.y);\n"
128 " maskdiv_s = 2.0;\n"
129 " 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"
130 " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
131 "}\n";
132
133static const char rect_mask21_frag_src[] =
134 "#ifdef GL_ES\n"
135 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
136 "precision highp float;\n"
137 "#else\n"
138 "precision mediump float;\n"
139 "#endif\n"
140 "#endif\n"
141 "varying vec4 col;\n"
142 "uniform sampler2D texm;\n"
143 "varying vec2 tex_m;\n"
144 "varying float maskdiv_s;\n"
145 "varying vec2 masktex_s[2];\n"
146 "void main()\n"
147 "{\n"
148 " vec4 c;\n"
149 " c = vec4(1, 1, 1, 1);\n"
150 " float ma;\n"
151 " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
152 " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
153 " ma = (ma00 + ma01) / maskdiv_s;\n"
154 " gl_FragColor =\n"
155 " c\n"
156 " * col\n"
157 " * ma\n"
158 " ;\n"
159 "}\n";
160
161static const char rect_mask21_vert_src[] =
162 "#ifdef GL_ES\n"
163 "precision highp float;\n"
164 "#endif\n"
165 "attribute vec4 vertex;\n"
166 "uniform mat4 mvp;\n"
167 "attribute vec4 color;\n"
168 "varying vec4 col;\n"
169 "attribute vec4 mask_coord;\n"
170 "varying vec2 tex_m;\n"
171 "attribute vec2 tex_masksample;\n"
172 "varying float maskdiv_s;\n"
173 "varying vec2 masktex_s[2];\n"
174 "void main()\n"
175 "{\n"
176 " gl_Position = mvp * vertex;\n"
177 " col = color;\n"
178 " masktex_s[0] = vec2(-tex_masksample.x, 0);\n"
179 " masktex_s[1] = vec2( tex_masksample.x, 0);\n"
180 " maskdiv_s = 2.0;\n"
181 " 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"
182 " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
183 "}\n";
184
185static const char rect_mask22_frag_src[] =
186 "#ifdef GL_ES\n"
187 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
188 "precision highp float;\n"
189 "#else\n"
190 "precision mediump float;\n"
191 "#endif\n"
192 "#endif\n"
193 "varying vec4 col;\n"
194 "uniform sampler2D texm;\n"
195 "varying vec2 tex_m;\n"
196 "varying float maskdiv_s;\n"
197 "varying vec2 masktex_s[4];\n"
198 "void main()\n"
199 "{\n"
200 " vec4 c;\n"
201 " c = vec4(1, 1, 1, 1);\n"
202 " float ma;\n"
203 " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
204 " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
205 " float ma10 = texture2D(texm, tex_m + masktex_s[2]).a;\n"
206 " float ma11 = texture2D(texm, tex_m + masktex_s[3]).a;\n"
207 " ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s;\n"
208 " gl_FragColor =\n"
209 " c\n"
210 " * col\n"
211 " * ma\n"
212 " ;\n"
213 "}\n";
214
215static const char rect_mask22_vert_src[] =
216 "#ifdef GL_ES\n"
217 "precision highp float;\n"
218 "#endif\n"
219 "attribute vec4 vertex;\n"
220 "uniform mat4 mvp;\n"
221 "attribute vec4 color;\n"
222 "varying vec4 col;\n"
223 "attribute vec4 mask_coord;\n"
224 "varying vec2 tex_m;\n"
225 "attribute vec2 tex_masksample;\n"
226 "varying float maskdiv_s;\n"
227 "varying vec2 masktex_s[4];\n"
228 "void main()\n"
229 "{\n"
230 " gl_Position = mvp * vertex;\n"
231 " col = color;\n"
232 " masktex_s[0] = vec2(-tex_masksample.x, -tex_masksample.y);\n"
233 " masktex_s[1] = vec2( tex_masksample.x, -tex_masksample.y);\n"
234 " masktex_s[2] = vec2( tex_masksample.x, tex_masksample.y);\n"
235 " masktex_s[3] = vec2(-tex_masksample.x, tex_masksample.y);\n"
236 " maskdiv_s = 4.0;\n"
237 " 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"
238 " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
239 "}\n";
240
241static const char font_frag_src[] =
242 "#ifdef GL_ES\n"
243 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
244 "precision highp float;\n"
245 "#else\n"
246 "precision mediump float;\n"
247 "#endif\n"
248 "#endif\n"
249 "varying vec4 col;\n"
250 "uniform sampler2D tex;\n"
251 "varying vec2 tex_c;\n"
252 "void main()\n"
253 "{\n"
254 " vec4 c;\n"
255 " c = texture2D(tex, tex_c).aaaa;\n"
256 " gl_FragColor =\n"
257 " c\n"
258 " * col\n"
259 " ;\n"
260 "}\n";
261
262static const char font_vert_src[] =
263 "#ifdef GL_ES\n"
264 "precision highp float;\n"
265 "#endif\n"
266 "attribute vec4 vertex;\n"
267 "uniform mat4 mvp;\n"
268 "attribute vec4 color;\n"
269 "varying vec4 col;\n"
270 "attribute vec2 tex_coord;\n"
271 "varying vec2 tex_c;\n"
272 "void main()\n"
273 "{\n"
274 " gl_Position = mvp * vertex;\n"
275 " col = color;\n"
276 " tex_c = tex_coord;\n"
277 "}\n";
278
279static const char font_mask_frag_src[] =
280 "#ifdef GL_ES\n"
281 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
282 "precision highp float;\n"
283 "#else\n"
284 "precision mediump float;\n"
285 "#endif\n"
286 "#endif\n"
287 "varying vec4 col;\n"
288 "uniform sampler2D tex;\n"
289 "varying vec2 tex_c;\n"
290 "uniform sampler2D texm;\n"
291 "varying vec2 tex_m;\n"
292 "void main()\n"
293 "{\n"
294 " vec4 c;\n"
295 " c = texture2D(tex, tex_c).aaaa;\n"
296 " float ma;\n"
297 " ma = texture2D(texm, tex_m).a;\n"
298 " gl_FragColor =\n"
299 " c\n"
300 " * col\n"
301 " * ma\n"
302 " ;\n"
303 "}\n";
304
305static const char font_mask_vert_src[] =
306 "#ifdef GL_ES\n"
307 "precision highp float;\n"
308 "#endif\n"
309 "attribute vec4 vertex;\n"
310 "uniform mat4 mvp;\n"
311 "attribute vec4 color;\n"
312 "varying vec4 col;\n"
313 "attribute vec2 tex_coord;\n"
314 "varying vec2 tex_c;\n"
315 "attribute vec4 mask_coord;\n"
316 "varying vec2 tex_m;\n"
317 "void main()\n"
318 "{\n"
319 " gl_Position = mvp * vertex;\n"
320 " col = color;\n"
321 " tex_c = tex_coord;\n"
322 " 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"
323 " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
324 "}\n";
325
326static const char font_mask12_frag_src[] =
327 "#ifdef GL_ES\n"
328 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
329 "precision highp float;\n"
330 "#else\n"
331 "precision mediump float;\n"
332 "#endif\n"
333 "#endif\n"
334 "varying vec4 col;\n"
335 "uniform sampler2D tex;\n"
336 "varying vec2 tex_c;\n"
337 "uniform sampler2D texm;\n"
338 "varying vec2 tex_m;\n"
339 "varying float maskdiv_s;\n"
340 "varying vec2 masktex_s[2];\n"
341 "void main()\n"
342 "{\n"
343 " vec4 c;\n"
344 " c = texture2D(tex, tex_c).aaaa;\n"
345 " float ma;\n"
346 " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
347 " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
348 " ma = (ma00 + ma01) / maskdiv_s;\n"
349 " gl_FragColor =\n"
350 " c\n"
351 " * col\n"
352 " * ma\n"
353 " ;\n"
354 "}\n";
355
356static const char font_mask12_vert_src[] =
357 "#ifdef GL_ES\n"
358 "precision highp float;\n"
359 "#endif\n"
360 "attribute vec4 vertex;\n"
361 "uniform mat4 mvp;\n"
362 "attribute vec4 color;\n"
363 "varying vec4 col;\n"
364 "attribute vec2 tex_coord;\n"
365 "varying vec2 tex_c;\n"
366 "attribute vec4 mask_coord;\n"
367 "varying vec2 tex_m;\n"
368 "attribute vec2 tex_masksample;\n"
369 "varying float maskdiv_s;\n"
370 "varying vec2 masktex_s[2];\n"
371 "void main()\n"
372 "{\n"
373 " gl_Position = mvp * vertex;\n"
374 " col = color;\n"
375 " tex_c = tex_coord;\n"
376 " masktex_s[0] = vec2(0, -tex_masksample.y);\n"
377 " masktex_s[1] = vec2(0, tex_masksample.y);\n"
378 " maskdiv_s = 2.0;\n"
379 " 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"
380 " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
381 "}\n";
382
383static const char font_mask21_frag_src[] =
384 "#ifdef GL_ES\n"
385 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
386 "precision highp float;\n"
387 "#else\n"
388 "precision mediump float;\n"
389 "#endif\n"
390 "#endif\n"
391 "varying vec4 col;\n"
392 "uniform sampler2D tex;\n"
393 "varying vec2 tex_c;\n"
394 "uniform sampler2D texm;\n"
395 "varying vec2 tex_m;\n"
396 "varying float maskdiv_s;\n"
397 "varying vec2 masktex_s[2];\n"
398 "void main()\n"
399 "{\n"
400 " vec4 c;\n"
401 " c = texture2D(tex, tex_c).aaaa;\n"
402 " float ma;\n"
403 " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
404 " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
405 " ma = (ma00 + ma01) / maskdiv_s;\n"
406 " gl_FragColor =\n"
407 " c\n"
408 " * col\n"
409 " * ma\n"
410 " ;\n"
411 "}\n";
412
413static const char font_mask21_vert_src[] =
414 "#ifdef GL_ES\n"
415 "precision highp float;\n"
416 "#endif\n"
417 "attribute vec4 vertex;\n"
418 "uniform mat4 mvp;\n"
419 "attribute vec4 color;\n"
420 "varying vec4 col;\n"
421 "attribute vec2 tex_coord;\n"
422 "varying vec2 tex_c;\n"
423 "attribute vec4 mask_coord;\n"
424 "varying vec2 tex_m;\n"
425 "attribute vec2 tex_masksample;\n"
426 "varying float maskdiv_s;\n"
427 "varying vec2 masktex_s[2];\n"
428 "void main()\n"
429 "{\n"
430 " gl_Position = mvp * vertex;\n"
431 " col = color;\n"
432 " tex_c = tex_coord;\n"
433 " masktex_s[0] = vec2(-tex_masksample.x, 0);\n"
434 " masktex_s[1] = vec2( tex_masksample.x, 0);\n"
435 " maskdiv_s = 2.0;\n"
436 " 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"
437 " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
438 "}\n";
439
440static const char font_mask22_frag_src[] =
441 "#ifdef GL_ES\n"
442 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
443 "precision highp float;\n"
444 "#else\n"
445 "precision mediump float;\n"
446 "#endif\n"
447 "#endif\n"
448 "varying vec4 col;\n"
449 "uniform sampler2D tex;\n"
450 "varying vec2 tex_c;\n"
451 "uniform sampler2D texm;\n"
452 "varying vec2 tex_m;\n"
453 "varying float maskdiv_s;\n"
454 "varying vec2 masktex_s[4];\n"
455 "void main()\n"
456 "{\n"
457 " vec4 c;\n"
458 " c = texture2D(tex, tex_c).aaaa;\n"
459 " float ma;\n"
460 " float ma00 = texture2D(texm, tex_m + masktex_s[0]).a;\n"
461 " float ma01 = texture2D(texm, tex_m + masktex_s[1]).a;\n"
462 " float ma10 = texture2D(texm, tex_m + masktex_s[2]).a;\n"
463 " float ma11 = texture2D(texm, tex_m + masktex_s[3]).a;\n"
464 " ma = (ma00 + ma01 + ma10 + ma11) / maskdiv_s;\n"
465 " gl_FragColor =\n"
466 " c\n"
467 " * col\n"
468 " * ma\n"
469 " ;\n"
470 "}\n";
471
472static const char font_mask22_vert_src[] =
473 "#ifdef GL_ES\n"
474 "precision highp float;\n"
475 "#endif\n"
476 "attribute vec4 vertex;\n"
477 "uniform mat4 mvp;\n"
478 "attribute vec4 color;\n"
479 "varying vec4 col;\n"
480 "attribute vec2 tex_coord;\n"
481 "varying vec2 tex_c;\n"
482 "attribute vec4 mask_coord;\n"
483 "varying vec2 tex_m;\n"
484 "attribute vec2 tex_masksample;\n"
485 "varying float maskdiv_s;\n"
486 "varying vec2 masktex_s[4];\n"
487 "void main()\n"
488 "{\n"
489 " gl_Position = mvp * vertex;\n"
490 " col = color;\n"
491 " tex_c = tex_coord;\n"
492 " masktex_s[0] = vec2(-tex_masksample.x, -tex_masksample.y);\n"
493 " masktex_s[1] = vec2( tex_masksample.x, -tex_masksample.y);\n"
494 " masktex_s[2] = vec2( tex_masksample.x, tex_masksample.y);\n"
495 " masktex_s[3] = vec2(-tex_masksample.x, tex_masksample.y);\n"
496 " maskdiv_s = 4.0;\n"
497 " 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"
498 " tex_m = mask_Position.xy * abs(mask_coord.zw) + mask_coord.xy;\n"
499 "}\n";
500
501static const char img_frag_src[] =
502 "#ifdef GL_ES\n"
503 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
504 "precision highp float;\n"
505 "#else\n"
506 "precision mediump float;\n"
507 "#endif\n"
508 "#endif\n"
509 "varying vec4 col;\n"
510 "uniform sampler2D tex;\n"
511 "varying vec2 tex_c;\n"
512 "void main()\n"
513 "{\n"
514 " vec4 c;\n"
515 " c = texture2D(tex, tex_c).bgra;\n"
516 " gl_FragColor =\n"
517 " c\n"
518 " * col\n"
519 " ;\n"
520 "}\n";
521
522static const char img_vert_src[] =
523 "#ifdef GL_ES\n"
524 "precision highp float;\n"
525 "#endif\n"
526 "attribute vec4 vertex;\n"
527 "uniform mat4 mvp;\n"
528 "attribute vec4 color;\n"
529 "varying vec4 col;\n"
530 "attribute vec2 tex_coord;\n"
531 "varying vec2 tex_c;\n"
532 "void main()\n"
533 "{\n"
534 " gl_Position = mvp * vertex;\n"
535 " col = color;\n"
536 " tex_c = tex_coord;\n"
537 "}\n";
538
539static const char img_bgra_frag_src[] =
540 "#ifdef GL_ES\n"
541 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
542 "precision highp float;\n"
543 "#else\n"
544 "precision mediump float;\n"
545 "#endif\n"
546 "#endif\n"
547 "varying vec4 col;\n"
548 "uniform sampler2D tex;\n"
549 "varying vec2 tex_c;\n"
550 "void main()\n"
551 "{\n"
552 " vec4 c;\n"
553 " c = texture2D(tex, tex_c).rgba;\n"
554 " gl_FragColor =\n"
555 " c\n"
556 " * col\n"
557 " ;\n"
558 "}\n";
559
560static const char img_bgra_vert_src[] =
561 "#ifdef GL_ES\n"
562 "precision highp float;\n"
563 "#endif\n"
564 "attribute vec4 vertex;\n"
565 "uniform mat4 mvp;\n"
566 "attribute vec4 color;\n"
567 "varying vec4 col;\n"
568 "attribute vec2 tex_coord;\n"
569 "varying vec2 tex_c;\n"
570 "void main()\n"
571 "{\n"
572 " gl_Position = mvp * vertex;\n"
573 " col = color;\n"
574 " tex_c = tex_coord;\n"
575 "}\n";
576
577static const char img_12_frag_src[] =
578 "#ifdef GL_ES\n"
579 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
580 "precision highp float;\n"
581 "#else\n"
582 "precision mediump float;\n"
583 "#endif\n"
584 "#endif\n"
585 "varying vec4 col;\n"
586 "uniform sampler2D tex;\n"
587 "varying vec2 tex_c;\n"
588 "varying vec4 div_s;\n"
589 "varying vec2 tex_s[2];\n"
590 "void main()\n"
591 "{\n"
592 " vec4 c;\n"
593 " vec4 col00 = texture2D(tex, tex_c + tex_s[0]).bgra;\n"
594 " vec4 col01 = texture2D(tex, tex_c + tex_s[1]).bgra;\n"
595 " c = (col00 + col01) / div_s;\n"
596 " gl_FragColor =\n"
597 " c\n"
598 " * col\n"
599 " ;\n"
600 "}\n";
601
602static const char img_12_vert_src[] =
603 "#ifdef GL_ES\n"
604 "precision highp float;\n"
605 "#endif\n"
606 "attribute vec4 vertex;\n"
607 "uniform mat4 mvp;\n"
608 "attribute vec4 color;\n"
609 "varying vec4 col;\n"
610 "attribute vec2 tex_coord;\n"
611 "varying vec2 tex_c;\n"
612 "attribute vec2 tex_sample;\n"
613 "varying vec4 div_s;\n"
614 "varying vec2 tex_s[2];\n"
615 "void main()\n"
616 "{\n"
617 " gl_Position = mvp * vertex;\n"
618 " col = color;\n"
619 " tex_c = tex_coord;\n"
620 " tex_s[0] = vec2(0, -tex_sample.y);\n"
621 " tex_s[1] = vec2(0, tex_sample.y);\n"
622 " div_s = vec4(2, 2, 2, 2);\n"
623 "}\n";
624
625static const char img_21_frag_src[] =
626 "#ifdef GL_ES\n"
627 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
628 "precision highp float;\n"
629 "#else\n"
630 "precision mediump float;\n"
631 "#endif\n"
632 "#endif\n"
633 "varying vec4 col;\n"
634 "uniform sampler2D tex;\n"
635 "varying vec2 tex_c;\n"
636 "varying vec4 div_s;\n"
637 "varying vec2 tex_s[2];\n"
638 "void main()\n"
639 "{\n"
640 " vec4 c;\n"
641 " vec4 col00 = texture2D(tex, tex_c + tex_s[0]).bgra;\n"
642 " vec4 col01 = texture2D(tex, tex_c + tex_s[1]).bgra;\n"
643 " c = (col00 + col01) / div_s;\n"
644 " gl_FragColor =\n"
645 " c\n"
646 " * col\n"
647 " ;\n"
648 "}\n";
649
650static const char img_21_vert_src[] =
651 "#ifdef GL_ES\n"
652 "precision highp float;\n"
653 "#endif\n"
654 "attribute vec4 vertex;\n"
655 "uniform mat4 mvp;\n"
656 "attribute vec4 color;\n"
657 "varying vec4 col;\n"
658 "attribute vec2 tex_coord;\n"
659 "varying vec2 tex_c;\n"
660 "attribute vec2 tex_sample;\n"
661 "varying vec4 div_s;\n"
662 "varying vec2 tex_s[2];\n"
663 "void main()\n"
664 "{\n"
665 " gl_Position = mvp * vertex;\n"
666 " col = color;\n"
667 " tex_c = tex_coord;\n"
668 " tex_s[0] = vec2(-tex_sample.x, 0);\n"
669 " tex_s[1] = vec2( tex_sample.x, 0);\n"
670 " div_s = vec4(2, 2, 2, 2);\n"
671 "}\n";
672
673static const char img_22_frag_src[] =
674 "#ifdef GL_ES\n"
675 "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
676 "precision highp float;\n"
677 "#else\n"
678 "precision mediump float;\n"
679 "#endif\n"
680 "#endif\n"
681 "varying vec4 col;\n"
682 "uniform sampler2D tex;\n"
683 "varying vec2 tex_c;\n"
684 "varying vec4 div_s;\n"
685 "varying vec2 tex_s[4];\n"
686 "void main()\n"
687 "{\n"
688 " vec4 c;\n"
689 " vec4 col00 = texture2D(tex, tex_c + tex_s[0]).bgra;\n"
690 " vec4 col01 = texture2D(tex, tex_c + tex_s[1]).bgra;\n"
691 " vec4 col10 = texture2D(tex, tex_c + tex_s[2]).bgra;\n"
692 " vec4 col11 = texture2D(tex, tex_c + tex_s[3]).bgra;\n"
693 " c = (col00 + col01 + col10 + col11) / div_s;\n"
694 " gl_FragColor =\n"
695 " c\n"
696 " * col\n"
697 " ;\n"
698 "}\n";
699
700static const char img_22_vert_src[] =
701 "#ifdef GL_ES\n"
702 "precision highp float;\n"
703 "#endif\n"
704 "attribute vec4 vertex;\n"
705 "uniform mat4 mvp;\n"
706 "attribute vec4 color;\n"
707 "varying vec4 col;\n"
708 "attribute vec2 tex_coord;\n"