gc->pipe[pn].array.use_texuv2 = (utexture || uvtexture) ? 1 : 0;
gc->pipe[pn].array.use_texuv3 = (utexture) ? 1 : 0;
gc->pipe[pn].array.use_texm = !!mtex;
+ gc->pipe[pn].array.use_texa = !!mtex;
gc->pipe[pn].array.use_texsam = gc->pipe[pn].array.use_texm;
pipe_region_expand(gc, pn, x, y, w, h);
if (mtex)
{
- GLfloat glmdx = 0.f, glmdy = 0.f, glmdw = 1.f, glmdh = 1.f;
+ GLfloat glmdx = 0.f, glmdy = 0.f, glmdw = 1.f, glmdh = 1.f, yinv = -1.f;
+ GLfloat gw = gc->w, gh = gc->h;
// Note: I couldn't write any test case where it was necessary
// to know the mask position in its texture. Thus these unused vars.
(void) mx; (void) my; (void) mw; (void) mh;
- if (gc->w) glmdx = (GLfloat) mdx / (GLfloat) gc->w;
- if (gc->h) glmdy = (GLfloat) mdy / (GLfloat) gc->h;
- if (mdw) glmdw = (GLfloat) gc->w / (GLfloat) mdw;
- if (mdh) glmdh = (GLfloat) gc->h / (GLfloat) mdh ;
+ if (!((gc->pipe[0].shader.surface == gc->def_surface) ||
+ (!gc->pipe[0].shader.surface)))
+ {
+ gw = gc->pipe[0].shader.surface->w;
+ gh = gc->pipe[0].shader.surface->h;
+ yinv = 1.f;
+ }
+ if (gw) glmdx = (GLfloat) mdx / (GLfloat) gw;
+ if (gh) glmdy = (GLfloat) mdy / (GLfloat) gh;
+ if (mdw) glmdw = (GLfloat) gw / (GLfloat) mdw;
+ if (mdh) glmdh = (GLfloat) gh / (GLfloat) mdh;
+
+ // FIXME!!!
// We seriously need uniforms here. Abusing tex_coordm for storage.
// Passing mask x,y (on canvas) to the fragment shader
PUSH_TEXM(pn, glmdx, glmdy);
PUSH_TEXSAM(pn, glmdw, glmdh);
PUSH_TEXSAM(pn, glmdw, glmdh);
+ // Abusing tex_coorda to pass Y-invert flag
+ PUSH_TEXA(pn, 1.f, yinv);
+ PUSH_TEXA(pn, 1.f, yinv);
+ PUSH_TEXA(pn, 1.f, yinv);
+ PUSH_TEXA(pn, 1.f, yinv);
+ PUSH_TEXA(pn, 1.f, yinv);
+ PUSH_TEXA(pn, 1.f, yinv);
+
//DBG("Orig %d,%d - %dx%d --> %f,%f - %f x %f", mdx, mdy, mdw, mdh,
// glmdx, glmdy, glmdw, glmdh);
}
}
/* Alpha plane */
- if (gc->pipe[i].array.use_texa)
+ if (gc->pipe[i].array.use_texa && (gc->pipe[i].region.type != RTYPE_MAP))
{
glEnableVertexAttribArray(SHAD_TEXA);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
MASK_TEXTURE += 1;
}
+ else if (gc->pipe[i].region.type == RTYPE_MAP)
+ {
+ /* FIXME:
+ * This is a workaround as we hijack some tex ids
+ * (namely tex_coordm, tex_coorda and tex_sample) for map masking.
+ * These masking shaders should definitely use uniforms.
+ */
+ glEnableVertexAttribArray(SHAD_TEXA);
+ GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+ glVertexAttribPointer(SHAD_TEXA, 2, GL_FLOAT, GL_FALSE, 0, (void *)texa_ptr);
+ GLERR(__FUNCTION__, __FILE__, __LINE__, "");
+ }
else
{
glDisableVertexAttribArray(SHAD_TEXA);
"precision highp float;\n"
"#endif\n"
"attribute vec4 vertex, color;\n"
- "attribute vec2 tex_coord, tex_coordm, tex_sample;\n"
+ "attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;\n"
"uniform mat4 mvp;\n"
"varying vec2 tex_c;\n"
"varying vec4 mask_Position, col, mask_Absolute;\n"
" gl_Position = mvp * vertex;\n"
" tex_c = tex_coord;\n"
" col = color;\n"
- " // Assume Y-invert on mask, normalize (screen to texture mode coordinates)\n"
- " mask_Position = mvp * vertex * vec4(0.5, -0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n"
+ " // tex_coorda contains the Y-invert flag\n"
+ " // tex_coordm contains the X,Y position of the mask\n"
+ " // tex_sample contains the W,H size of the mask (inverted)\n"
+ " mask_Position = mvp * vertex * vec4(tex_coorda.x * 0.5, tex_coorda.y * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);\n"
" mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas in GL coords\n"
"}\n";
Evas_GL_Program_Source shader_map_mask_bgra_vert_src =
precision highp float;
#endif
attribute vec4 vertex, color;
-attribute vec2 tex_coord, tex_coordm, tex_sample;
+attribute vec2 tex_coord, tex_coordm, tex_sample, tex_coorda;
uniform mat4 mvp;
varying vec2 tex_c;
varying vec4 mask_Position, col, mask_Absolute;
tex_c = tex_coord;
col = color;
- // Assume Y-invert on mask, normalize (screen to texture mode coordinates)
- mask_Position = mvp * vertex * vec4(0.5, -0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);
+ // tex_coorda contains the Y-invert flag
+ // tex_coordm contains the X,Y position of the mask
+ // tex_sample contains the W,H size of the mask (inverted)
+
+ mask_Position = mvp * vertex * vec4(tex_coorda.x * 0.5, tex_coorda.y * 0.5, 0.5, 0.5) + vec4(0.5, 0.5, 0, 0);
mask_Absolute = vec4(tex_coordm, tex_sample); // x, y, 1/w, 1/h on canvas in GL coords
}