+#define _EVAS_GL_CONTEXT_C
#include "evas_gl_private.h"
#ifdef HAVE_DLSYM
if (!shared)
{
const char *ext;
+ int shd;
shared = calloc(1, sizeof(Evas_GL_Shared));
ext = (const char *) glGetString(GL_EXTENSIONS);
if (!evas_gl_common_shader_program_init(shared)) goto error;
-#define SHADER_TEXTURE_ADD(Shared, Shader, Name) \
- glUseProgram(Shared->shader[SHADER_##Shader].prog); \
- glUniform1i(glGetUniformLocation(Shared->shader[SHADER_##Shader].prog, #Name), Shared->shader[SHADER_##Shader].tex_count++);
-
- SHADER_TEXTURE_ADD(shared, YUV, tex);
- SHADER_TEXTURE_ADD(shared, YUV, texu);
- SHADER_TEXTURE_ADD(shared, YUV, texv);
-
- SHADER_TEXTURE_ADD(shared, YUV_MASK, tex);
- SHADER_TEXTURE_ADD(shared, YUV_MASK, texu);
- SHADER_TEXTURE_ADD(shared, YUV_MASK, texv);
- SHADER_TEXTURE_ADD(shared, YUV_MASK, texm);
-
- SHADER_TEXTURE_ADD(shared, YUY2, tex);
- SHADER_TEXTURE_ADD(shared, YUY2, texuv);
-
- SHADER_TEXTURE_ADD(shared, YUY2_MASK, tex);
- SHADER_TEXTURE_ADD(shared, YUY2_MASK, texuv);
- SHADER_TEXTURE_ADD(shared, YUY2_MASK, texm);
-
- SHADER_TEXTURE_ADD(shared, NV12, tex);
- SHADER_TEXTURE_ADD(shared, NV12, texuv);
-
- SHADER_TEXTURE_ADD(shared, NV12_MASK, tex);
- SHADER_TEXTURE_ADD(shared, NV12_MASK, texuv);
- SHADER_TEXTURE_ADD(shared, NV12_MASK, texm);
-
- SHADER_TEXTURE_ADD(shared, YUV_NOMUL, tex);
- SHADER_TEXTURE_ADD(shared, YUV_NOMUL, texu);
- SHADER_TEXTURE_ADD(shared, YUV_NOMUL, texv);
-
- SHADER_TEXTURE_ADD(shared, YUY2_NOMUL, tex);
- SHADER_TEXTURE_ADD(shared, YUY2_NOMUL, texuv);
-
- SHADER_TEXTURE_ADD(shared, NV12_NOMUL, tex);
- SHADER_TEXTURE_ADD(shared, NV12_NOMUL, texuv);
-
- // Note: there is no nomul version for YUV,YUY2,NV12,RGB+A with MASK
-
- SHADER_TEXTURE_ADD(shared, RGB_A_PAIR, tex);
- SHADER_TEXTURE_ADD(shared, RGB_A_PAIR, texa);
- SHADER_TEXTURE_ADD(shared, RGB_A_PAIR_NOMUL, tex);
- SHADER_TEXTURE_ADD(shared, RGB_A_PAIR_NOMUL, texa);
-
- SHADER_TEXTURE_ADD(shared, RGB_A_PAIR_MASK, tex);
- SHADER_TEXTURE_ADD(shared, RGB_A_PAIR_MASK, texa);
- SHADER_TEXTURE_ADD(shared, RGB_A_PAIR_MASK, texm);
-
- SHADER_TEXTURE_ADD(shared, IMG_MASK, tex);
- SHADER_TEXTURE_ADD(shared, IMG_MASK, texm);
- SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, tex);
- SHADER_TEXTURE_ADD(shared, IMG_MASK_NOMUL, texm);
-
- SHADER_TEXTURE_ADD(shared, IMG_BGRA_MASK, tex);
- SHADER_TEXTURE_ADD(shared, IMG_BGRA_MASK, texm);
- SHADER_TEXTURE_ADD(shared, IMG_BGRA_MASK_NOMUL, tex);
- SHADER_TEXTURE_ADD(shared, IMG_BGRA_MASK_NOMUL, texm);
-
- SHADER_TEXTURE_ADD(shared, FONT_MASK, tex);
- SHADER_TEXTURE_ADD(shared, FONT_MASK, texm);
-
- SHADER_TEXTURE_ADD(shared, RECT_MASK, texm);
+ /* Bind textures */
+ for (shd = 0; _shaders_textures[shd].id != SHADER_LAST; shd++)
+ {
+ GLuint loc;
+ glUseProgram(shared->shader[_shaders_textures[shd].id].prog);
+ loc = glGetUniformLocation(shared->shader[_shaders_textures[shd].id].prog, _shaders_textures[shd].tname);
+ glUniform1i(loc, shared->shader[_shaders_textures[shd].id].tex_count++);
+ }
if (gc->state.current.cur_prog == PRG_INVALID)
glUseProgram(shared->shader[0].prog);
}
// color mul
- if ((a == 255) && (r == 255) && (g == 255) && (b == 255) && p)
+ if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
{
- for (k = 0; k < npoints; k++)
- if (p[k].col != 0xffffffff)
- {
- nomul = 0;
- break;
- }
+ if (p)
+ {
+ for (k = 0; k < npoints; k++)
+ if (p[k].col != 0xffffffff)
+ {
+ nomul = 0;
+ break;
+ }
+ }
}
- else if (!p)
+ else
nomul = 0;
// bgra
gc->state.current.id = gc->pipe[i].shader.id;
gc->state.current.cur_prog = gc->pipe[i].shader.cur_prog;
gc->state.current.cur_tex = gc->pipe[i].shader.cur_tex;
+ gc->state.current.cur_texm = gc->pipe[i].shader.cur_texm;
+ gc->state.current.cur_texa = gc->pipe[i].shader.cur_texa;
+ gc->state.current.cur_texu = gc->pipe[i].shader.cur_texu;
+ gc->state.current.cur_texv = gc->pipe[i].shader.cur_texv;
gc->state.current.render_op = gc->pipe[i].shader.render_op;
// gc->state.current.cx = gc->pipe[i].shader.cx;
// gc->state.current.cy = gc->pipe[i].shader.cy;
gc->pipe[i].array.use_texa = 0;
gc->pipe[i].array.use_texsam = 0;
gc->pipe[i].array.use_mask = 0;
+ gc->pipe[i].array.anti_alias = 0;
gc->pipe[i].array.vertex = NULL;
gc->pipe[i].array.color = NULL;
gc->pipe[i].array.texuv = NULL;
- gc->pipe[i].array.texa = NULL;
gc->pipe[i].array.texuv2 = NULL;
gc->pipe[i].array.texuv3 = NULL;
+ gc->pipe[i].array.texa = NULL;
gc->pipe[i].array.texsam = NULL;
gc->pipe[i].array.mask = NULL;
SHADER_NV12_MASK_NOMUL,
SHADER_LAST
} Evas_GL_Shader;
+
+#ifdef _EVAS_GL_CONTEXT_C
+
+static struct {
+ Evas_GL_Shader id;
+ const char *tname;
+} _shaders_textures[] = {
+ { SHADER_FONT_MASK, "tex" },
+ { SHADER_FONT_MASK, "texm" },
+ { SHADER_IMG_MASK, "tex" },
+ { SHADER_IMG_MASK, "texm" },
+ { SHADER_IMG_BGRA_MASK, "tex" },
+ { SHADER_IMG_BGRA_MASK, "texm" },
+ { SHADER_IMG_12_MASK, "tex" },
+ { SHADER_IMG_12_MASK, "texm" },
+ { SHADER_IMG_21_MASK, "tex" },
+ { SHADER_IMG_21_MASK, "texm" },
+ { SHADER_IMG_22_MASK, "tex" },
+ { SHADER_IMG_22_MASK, "texm" },
+ { SHADER_IMG_12_BGRA_MASK, "tex" },
+ { SHADER_IMG_12_BGRA_MASK, "texm" },
+ { SHADER_IMG_21_BGRA_MASK, "tex" },
+ { SHADER_IMG_21_BGRA_MASK, "texm" },
+ { SHADER_IMG_22_BGRA_MASK, "tex" },
+ { SHADER_IMG_22_BGRA_MASK, "texm" },
+ { SHADER_IMG_MASK_NOMUL, "tex" },
+ { SHADER_IMG_MASK_NOMUL, "texm" },
+ { SHADER_IMG_BGRA_MASK_NOMUL, "tex" },
+ { SHADER_IMG_BGRA_MASK_NOMUL, "texm" },
+ { SHADER_IMG_12_MASK_NOMUL, "tex" },
+ { SHADER_IMG_12_MASK_NOMUL, "texm" },
+ { SHADER_IMG_21_MASK_NOMUL, "tex" },
+ { SHADER_IMG_21_MASK_NOMUL, "texm" },
+ { SHADER_IMG_22_MASK_NOMUL, "tex" },
+ { SHADER_IMG_22_MASK_NOMUL, "texm" },
+ { SHADER_IMG_12_BGRA_MASK_NOMUL, "tex" },
+ { SHADER_IMG_12_BGRA_MASK_NOMUL, "texm" },
+ { SHADER_IMG_21_BGRA_MASK_NOMUL, "tex" },
+ { SHADER_IMG_21_BGRA_MASK_NOMUL, "texm" },
+ { SHADER_IMG_22_BGRA_MASK_NOMUL, "tex" },
+ { SHADER_IMG_22_BGRA_MASK_NOMUL, "texm" },
+ { SHADER_RGB_A_PAIR_MASK, "texa" },
+ { SHADER_RGB_A_PAIR_MASK, "texm" },
+ { SHADER_RGB_A_PAIR_MASK_NOMUL, "texa" },
+ { SHADER_RGB_A_PAIR_MASK_NOMUL, "texm" },
+ { SHADER_YUV, "tex" },
+ { SHADER_YUV, "texu" },
+ { SHADER_YUV, "texv" },
+ { SHADER_YUV_NOMUL, "tex" },
+ { SHADER_YUV_NOMUL, "texu" },
+ { SHADER_YUV_NOMUL, "texv" },
+ { SHADER_YUV_MASK, "tex" },
+ { SHADER_YUV_MASK, "texu" },
+ { SHADER_YUV_MASK, "texv" },
+ { SHADER_YUV_MASK, "texm" },
+ { SHADER_YUV_MASK_NOMUL, "tex" },
+ { SHADER_YUV_MASK_NOMUL, "texu" },
+ { SHADER_YUV_MASK_NOMUL, "texv" },
+ { SHADER_YUV_MASK_NOMUL, "texm" },
+ { SHADER_YUY2, "tex" },
+ { SHADER_YUY2, "texuv" },
+ { SHADER_YUY2_NOMUL, "tex" },
+ { SHADER_YUY2_NOMUL, "texuv" },
+ { SHADER_YUY2_MASK, "tex" },
+ { SHADER_YUY2_MASK, "texuv" },
+ { SHADER_YUY2_MASK, "texm" },
+ { SHADER_YUY2_MASK_NOMUL, "tex" },
+ { SHADER_YUY2_MASK_NOMUL, "texuv" },
+ { SHADER_YUY2_MASK_NOMUL, "texm" },
+ { SHADER_NV12, "tex" },
+ { SHADER_NV12, "texuv" },
+ { SHADER_NV12_NOMUL, "tex" },
+ { SHADER_NV12_NOMUL, "texuv" },
+ { SHADER_NV12_MASK, "tex" },
+ { SHADER_NV12_MASK, "texuv" },
+ { SHADER_NV12_MASK, "texm" },
+ { SHADER_NV12_MASK_NOMUL, "tex" },
+ { SHADER_NV12_MASK_NOMUL, "texuv" },
+ { SHADER_NV12_MASK_NOMUL, "texm" },
+ { SHADER_LAST, NULL }
+};
+
+#endif // _EVAS_GL_CONTEXT_C
shaders_source=""
shaders_enum=""
shaders_type=(frag vert)
+shaders_textures=""
# Generate SHD files
LIST=""
nomul=0
afill=0
sam="SAM11"
+ tex=""
# Urgh. Some fixups
case $TYPE in
UP=`upper $opt`
OPTS="$OPTS -DSHD_${UP}"
case $opt in
+ tex) tex="${tex}tex ";;
+ mask) tex="${tex}texm " ; mask=1;;
+ texa) tex="${tex}texa ";;
+ yuv) tex="${tex}texu texv ";;
+ nv12) tex="${tex}texuv ";;
+ yuy2) tex="${tex}texuv ";;
bgra) bgra=1;;
- mask) mask=1;;
nomul) nomul=1;;
afill) afill=1;;
external) FGM=${FGM_HEADER_OES};;
shaders_source="${shaders_source} { SHADER_${UNAME}, &(shader_${name}_vert_src), &(shader_${name}_frag_src), \"${name}\", SHD_${TYPE}, SHD_${sam}, ${bgra}, ${mask}, ${nomul}, ${afill} },\n"
shaders_enum="${shaders_enum} SHADER_${UNAME},\n"
+
+ # Bind textures to the programs. Only if there is more than 1 texture.
+ textures=(${tex})
+ if [ ${#textures[@]} -ge 2 ] ; then
+ for tname in ${tex} ; do
+ shaders_textures="${shaders_textures} { SHADER_${UNAME}, \"${tname}\" },\n"
+ done
+ fi
done
printf "
typedef enum {
${shaders_enum} SHADER_LAST
} Evas_GL_Shader;
+
+#ifdef _EVAS_GL_CONTEXT_C
+
+static struct {
+ Evas_GL_Shader id;
+ const char *tname;
+} _shaders_textures[] = {
+${shaders_textures} { SHADER_LAST, NULL }
+};
+
+#endif // _EVAS_GL_CONTEXT_C
" >| ${OUTPUT_ENUM}
# You can remove the files now