and fix gl engine to actually do map for yuv images! :) fix fix.

SVN revision: 51893
This commit is contained in:
Carsten Haitzler 2010-09-05 02:58:30 +00:00
parent d6da81ea66
commit c67a9ac86a
3 changed files with 125 additions and 53 deletions

View File

@ -427,7 +427,8 @@ void evas_gl_common_context_image_map4_push(Evas_GL_Context *gc,
int clip, int cx, int cy, int cw, int ch,
int r, int g, int b, int a,
Eina_Bool smooth,
Eina_Bool tex_only);
Eina_Bool tex_only,
Eina_Bool yuv);
void evas_gl_common_context_flush(Evas_GL_Context *gc);
int evas_gl_common_shader_program_init(Evas_GL_Program *p,

View File

@ -1785,83 +1785,101 @@ evas_gl_common_context_image_map4_push(Evas_GL_Context *gc,
RGBA_Map_Point *p,
int clip, int cx, int cy, int cw, int ch,
int r, int g, int b, int a,
Eina_Bool smooth, Eina_Bool tex_only)
Eina_Bool smooth, Eina_Bool tex_only,
Eina_Bool yuv)
{
int pnum, nv, nc, nu, nu2, nt, i;
int pnum, nv, nc, nu, nu2, nu3, nt, i;
const int points[6] = { 0, 1, 2, 0, 2, 3 };
int x = 0, y = 0, w = 0, h = 0, px = 0, py = 0;
GLfloat tx[4], ty[4];
GLfloat tx[4], ty[4], t2x[4], t2y[4];
Eina_Bool blend = 1;
DATA32 cmul;
GLuint prog = gc->shared->shader.img.prog;
int pn = 0;
if (!tex->alpha) blend = 0;
if (a < 255) blend = 1;
if ((A_VAL(&(p[0].col)) < 0xff) || (A_VAL(&(p[1].col)) < 0xff) ||
(A_VAL(&(p[2].col)) < 0xff) || (A_VAL(&(p[3].col)) < 0xff))
blend = 1;
if (tex_only)
if (yuv)
{
if (tex->pt->dyn.img)
prog = gc->shared->shader.yuv.prog;
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
{
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
(p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
prog = gc->shared->shader.yuv_nomul.prog;
else
prog = gc->shared->shader.yuv.prog;
}
else
prog = gc->shared->shader.yuv.prog;
}
else
{
if (tex_only)
{
if (tex->pt->dyn.img)
{
if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
(p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
prog = gc->shared->shader.img_nomul.prog;
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
{
if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
(p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
prog = gc->shared->shader.img_nomul.prog;
else
prog = gc->shared->shader.img.prog;
}
else
prog = gc->shared->shader.img.prog;
}
else
prog = gc->shared->shader.img.prog;
}
else
{
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
{
if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
(p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
prog = gc->shared->shader.tex_nomul.prog;
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
{
if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
(p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
prog = gc->shared->shader.tex_nomul.prog;
else
prog = gc->shared->shader.tex.prog;
}
else
prog = gc->shared->shader.tex.prog;
}
else
prog = gc->shared->shader.tex.prog;
}
}
else
{
if (tex->gc->shared->info.bgra)
{
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
{
if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
(p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
prog = gc->shared->shader.img_bgra_nomul.prog;
else
prog = gc->shared->shader.img_bgra.prog;
}
else
prog = gc->shared->shader.img_bgra.prog;
}
else
{
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
if (tex->gc->shared->info.bgra)
{
if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
(p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
prog = gc->shared->shader.img_nomul.prog;
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
{
if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
(p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
prog = gc->shared->shader.img_bgra_nomul.prog;
else
prog = gc->shared->shader.img_bgra.prog;
}
else
prog = gc->shared->shader.img.prog;
prog = gc->shared->shader.img_bgra.prog;
}
else
prog = gc->shared->shader.img.prog;
{
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
{
if ((p[0].col == 0xffffffff) && (p[1].col == 0xffffffff) &&
(p[2].col == 0xffffffff) && (p[3].col == 0xffffffff))
prog = gc->shared->shader.img_nomul.prog;
else
prog = gc->shared->shader.img.prog;
}
else
prog = gc->shared->shader.img.prog;
}
}
}
/*xxx*/ shader_array_flush(gc);
// /*xxx*/ shader_array_flush(gc);
again:
pn = gc->state.top_pipe;
#ifdef GLPIPES
@ -1869,6 +1887,11 @@ again:
{
gc->pipe[pn].region.type = RTYPE_MAP;
gc->pipe[pn].shader.cur_tex = tex->pt->texture;
if (yuv)
{
gc->pipe[pn].shader.cur_texu = tex->ptu->texture;
gc->pipe[pn].shader.cur_texv = tex->ptv->texture;
}
gc->pipe[pn].shader.cur_prog = prog;
gc->pipe[pn].shader.smooth = smooth;
gc->pipe[pn].shader.blend = blend;
@ -1882,8 +1905,16 @@ again:
gc->pipe[pn].array.use_vertex = 1;
gc->pipe[pn].array.use_color = 1;
gc->pipe[pn].array.use_texuv = 1;
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
if (yuv)
{
gc->pipe[pn].array.use_texuv2 = 1;
gc->pipe[pn].array.use_texuv3 = 1;
}
else
{
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
}
}
else
{
@ -1921,6 +1952,11 @@ again:
gc->state.top_pipe = pn;
gc->pipe[pn].region.type = RTYPE_MAP;
gc->pipe[pn].shader.cur_tex = tex->pt->texture;
if (yuv)
{
gc->pipe[pn].shader.cur_texu = tex->ptu->texture;
gc->pipe[pn].shader.cur_texv = tex->ptv->texture;
}
gc->pipe[pn].shader.cur_prog = prog;
gc->pipe[pn].shader.smooth = smooth;
gc->pipe[pn].shader.blend = blend;
@ -1934,8 +1970,16 @@ again:
gc->pipe[pn].array.use_vertex = 1;
gc->pipe[pn].array.use_color = 1;
gc->pipe[pn].array.use_texuv = 1;
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
if (yuv)
{
gc->pipe[pn].array.use_texuv2 = 1;
gc->pipe[pn].array.use_texuv3 = 1;
}
else
{
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
}
}
}
if ((tex->im) && (tex->im->native.data))
@ -2005,8 +2049,16 @@ again:
gc->pipe[pn].array.use_vertex = 1;
gc->pipe[pn].array.use_color = 1;
gc->pipe[pn].array.use_texuv = 1;
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
if (yuv)
{
gc->pipe[pn].array.use_texuv2 = 1;
gc->pipe[pn].array.use_texuv3 = 1;
}
else
{
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
}
#endif
x = w = (p[points[0]].x >> FP);
@ -2023,6 +2075,11 @@ again:
py = (p[points[i]].y >> FP);
if (py < y) y = py;
else if (py > h) h = py;
if (yuv)
{
t2x[i] = ((((double)p[i].u / 2) / FP1)) / (double)tex->ptu->w;
t2y[i] = ((((double)p[i].v / 2) / FP1)) / (double)tex->ptu->h;
}
}
w = w - x;
h = h - y;
@ -2031,7 +2088,7 @@ again:
pnum = gc->pipe[pn].array.num;
nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; nu2 = pnum * 2;
nt = pnum * 4;
nu2 = pnum * 2; nu3 = pnum * 2; nt = pnum * 4;
gc->pipe[pn].array.num += 6;
array_alloc(gc, pn);
@ -2052,6 +2109,15 @@ again:
PUSH_TEXUV(pn,
tx[points[i]],
ty[points[i]]);
if (yuv)
{
PUSH_TEXUV2(pn,
t2x[points[i]],
t2y[points[i]]);
PUSH_TEXUV3(pn,
t2x[points[i]],
t2y[points[i]]);
}
PUSH_COLOR(pn,
R_VAL(&cl),
@ -2147,7 +2213,7 @@ shader_array_flush(Evas_GL_Context *gc)
case EVAS_RENDER_MASK: /**< d = d*sa */
case EVAS_RENDER_MUL: /**< d = d*s */
default:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
break;
}

View File

@ -468,6 +468,7 @@ evas_gl_common_image_map4_draw(Evas_GL_Context *gc, Evas_GL_Image *im,
RGBA_Draw_Context *dc;
int r, g, b, a;
int c, cx, cy, cw, ch;
Eina_Bool yuv = 0;
dc = gc->dc;
if (dc->mul.use)
@ -488,9 +489,13 @@ evas_gl_common_image_map4_draw(Evas_GL_Context *gc, Evas_GL_Image *im,
cx = gc->dc->clip.x; cy = gc->dc->clip.y;
cw = gc->dc->clip.w; ch = gc->dc->clip.h;
im->tex->im = im;
if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
(im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
yuv = 1;
evas_gl_common_context_image_map4_push(gc, im->tex, p,
c, cx, cy, cw, ch,
r, g, b, a, smooth, im->tex_only);
r, g, b, a, smooth, im->tex_only,
yuv);
}
void