evas: upload the right texture size whatever rounding the hardware require.

SVN revision: 65138
This commit is contained in:
Cedric BAIL 2011-11-13 22:21:58 +00:00
parent 3d139c9888
commit e0df29b4f2
5 changed files with 62 additions and 30 deletions

View File

@ -1057,17 +1057,7 @@ evas_gl_common_texture_yuv_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsigne
tex->gc = gc;
tex->references = 1;
tex->pt = _pool_tex_new(gc, w + 1, h + 1, lum_ifmt, lum_fmt);
if (!tex->pt)
{
free(tex);
return NULL;
}
gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, tex->pt);
tex->pt->slot = -1;
tex->pt->fslot = -1;
tex->pt->whole = 1;
tex->ptu = _pool_tex_new(gc, (w / 2) + 1, (h / 2) + 1, lum_ifmt, lum_fmt);
tex->ptu = _pool_tex_new(gc, w / 2 + 1, h / 2 + 1, lum_ifmt, lum_fmt);
if (!tex->ptu)
{
free(tex);
@ -1077,7 +1067,7 @@ evas_gl_common_texture_yuv_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsigne
tex->ptu->slot = -1;
tex->ptu->fslot = -1;
tex->ptu->whole = 1;
tex->ptv = _pool_tex_new(gc, (w / 2) + 1, (h / 2) + 1, lum_ifmt, lum_fmt);
tex->ptv = _pool_tex_new(gc, tex->ptu->w, tex->ptu->h, lum_ifmt, lum_fmt);
if (!tex->ptv)
{
pt_unref(tex->pt);
@ -1089,6 +1079,16 @@ evas_gl_common_texture_yuv_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsigne
tex->ptv->slot = -1;
tex->ptv->fslot = -1;
tex->ptv->whole = 1;
tex->pt = _pool_tex_new(gc, tex->ptu->w * 2, tex->ptu->h * 2, lum_ifmt, lum_fmt);
if (!tex->pt)
{
free(tex);
return NULL;
}
gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, tex->pt);
tex->pt->slot = -1;
tex->pt->fslot = -1;
tex->pt->whole = 1;
tex->x = 0;
tex->y = 0;
tex->w = w;
@ -1177,7 +1177,7 @@ evas_gl_common_texture_yuv_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned i
static Evas_GL_Texture *
_evas_gl_common_texture_y2uv_new(Evas_Engine_GL_Context *gc,
unsigned int yw, unsigned int yh,
unsigned int uvw, unsigned int uvh,
Eina_Bool uv2w, Eina_Bool uv2h,
GLenum y_ifmt, GLenum y_fmt,
GLenum uv_ifmt, GLenum uv_fmt,
Eina_Bool dynamic)
@ -1185,27 +1185,53 @@ _evas_gl_common_texture_y2uv_new(Evas_Engine_GL_Context *gc,
Evas_GL_Texture_Pool *pt[2] = { NULL, NULL };
Evas_GL_Texture_Pool *ptuv[2] = { NULL, NULL };
Evas_GL_Texture *tex;
unsigned int uvw, uvh;
uvw = uv2w ? yw / 2 + 1 : yw + 1;
uvh = uv2h ? yh / 2 + 1 : yh + 1;
if (!dynamic)
{
pt[0] = _pool_tex_new(gc, yw + 1, yh + 1, y_ifmt, y_fmt);
pt[1] = _pool_tex_new(gc, yw + 1, yh + 1, y_ifmt, y_fmt);
ptuv[0] = _pool_tex_new(gc, uvw, uvh, uv_ifmt, uv_fmt);
ptuv[1] = _pool_tex_new(gc, uvw, uvh, uv_ifmt, uv_fmt);
ptuv[0] = _pool_tex_new(gc, uvw + 1, uvh + 1, uv_ifmt, uv_fmt);
ptuv[1] = _pool_tex_new(gc, uvw + 1, uvh + 1, uv_ifmt, uv_fmt);
if (ptuv[0] && ptuv[1])
{
pt[0] = _pool_tex_new(gc,
ptuv[0]->w * (uv2w ? 2 : 1),
ptuv[0]->h * (uv2h ? 2 : 1),
y_ifmt, y_fmt);
pt[1] = _pool_tex_new(gc,
ptuv[1]->w * (uv2w ? 2 : 1),
ptuv[1]->h * (uv2h ? 2 : 1),
y_ifmt, y_fmt);
}
}
else
{
pt[0] = _pool_tex_dynamic_new(gc, yw + 1, yh + 1, y_ifmt, y_fmt);
pt[1] = _pool_tex_dynamic_new(gc, yw + 1, yh + 1, y_ifmt, y_fmt);
ptuv[0] = _pool_tex_dynamic_new(gc, uvw, uvh, uv_ifmt, uv_fmt);
ptuv[1] = _pool_tex_dynamic_new(gc, uvw, uvh, uv_ifmt, uv_fmt);
ptuv[0] = _pool_tex_dynamic_new(gc, uvw + 1, uvh + 1, uv_ifmt, uv_fmt);
ptuv[1] = _pool_tex_dynamic_new(gc, uvw + 1, uvh + 1, uv_ifmt, uv_fmt);
if (ptuv[0] && ptuv[1])
{
pt[0] = _pool_tex_dynamic_new(gc,
ptuv[0]->w * (uv2w ? 2 : 1),
ptuv[0]->h * (uv2h ? 2 : 1),
y_ifmt, y_fmt);
pt[1] = _pool_tex_dynamic_new(gc,
ptuv[1]->w * (uv2w ? 2 : 1),
ptuv[1]->h * (uv2h ? 2 : 1),
y_ifmt, y_fmt);
}
}
if (!pt[0] || !pt[1] || !ptuv[0] || !ptuv[1])
goto on_error;
INF("YUV [%i, %i] => Y[%i, %i], UV[%i, %i]",
yw, yh,
pt[0]->w, pt[0]->h,
ptuv[0]->w, ptuv[0]->h);
tex = calloc(1, sizeof(Evas_GL_Texture));
if (!tex)
goto on_error;
@ -1244,7 +1270,7 @@ evas_gl_common_texture_yuy2_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsign
{
Evas_GL_Texture *tex;
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, w / 2, h, lum_alpha_ifmt, lum_alpha_fmt, rgba8_ifmt, rgba8_fmt, 0);
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, EINA_TRUE, EINA_FALSE, lum_alpha_ifmt, lum_alpha_fmt, rgba8_ifmt, rgba8_fmt, 0);
evas_gl_common_texture_yuy2_update(tex, rows, w, h);
return tex;
}
@ -1255,10 +1281,10 @@ evas_gl_common_texture_nv12_new(Evas_Engine_GL_Context *gc, DATA8 **rows, unsign
Evas_GL_Texture *tex;
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, w / 2, h / 2, lum_ifmt, lum_fmt, lum_alpha_ifmt, lum_alpha_fmt, 1);
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, EINA_TRUE, EINA_TRUE, lum_ifmt, lum_fmt, lum_alpha_ifmt, lum_alpha_fmt, 1);
if (!tex)
#endif
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, w / 2, h / 2, lum_ifmt, lum_fmt, lum_alpha_ifmt, lum_alpha_fmt, 0);
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, EINA_TRUE, EINA_TRUE, lum_ifmt, lum_fmt, lum_alpha_ifmt, lum_alpha_fmt, 0);
evas_gl_common_texture_nv12_update(tex, rows, w, h);
return tex;
@ -1270,10 +1296,10 @@ evas_gl_common_texture_nv12tiled_new(Evas_Engine_GL_Context *gc, DATA8 **rows, u
Evas_GL_Texture *tex = NULL;
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, w, h, lum_ifmt, lum_fmt, lum_alpha_ifmt, lum_alpha_fmt, 1);
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, EINA_TRUE, EINA_TRUE, lum_ifmt, lum_fmt, lum_alpha_ifmt, lum_alpha_fmt, 1);
if (!tex)
#endif
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, w, h, lum_ifmt, lum_fmt, lum_alpha_ifmt, lum_alpha_fmt, 0);
tex = _evas_gl_common_texture_y2uv_new(gc, w, h, EINA_TRUE, EINA_TRUE, lum_ifmt, lum_fmt, lum_alpha_ifmt, lum_alpha_fmt, 0);
evas_gl_common_texture_nv12tiled_update(tex, rows, w, h);
return tex;
@ -1306,9 +1332,15 @@ evas_gl_common_texture_yuy2_update(Evas_GL_Texture *tex, DATA8 **rows, unsigned
glBindTexture(GL_TEXTURE_2D, tex->ptuv->texture);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
_tex_2d(tex->ptuv->intformat, w / 2, h, tex->ptuv->format, tex->ptuv->dataformat);
#if 0
/*
FIXME: this piece of code doesn't work anymore since texture width
is not anymore exactly w / 2. I don't understand why.
*/
if ((rows[1] - rows[0]) == (int)(w * 2))
_tex_sub_2d(0, 0, w / 2, h, tex->ptuv->format, tex->ptuv->dataformat, rows[0]);
else
#endif
{
for (y = 0; y < h; y++)
_tex_sub_2d(0, y, w / 2, 1, tex->ptuv->format, tex->ptuv->dataformat, rows[y]);

View File

@ -10,5 +10,5 @@
"{\n"
" gl_Position = mvp * vertex;\n"
" tex_c = tex_coord;\n"
" tex_cuv = tex_coord2 * 0.5;\n"
" tex_cuv = tex_coord2 * 0.25;\n"
"}\n"

View File

@ -10,5 +10,5 @@ void main()
{
gl_Position = mvp * vertex;
tex_c = tex_coord;
tex_cuv = tex_coord2 * 0.5;
tex_cuv = tex_coord2 * 0.25;
}

View File

@ -12,5 +12,5 @@
" gl_Position = mvp * vertex;\n"
" col = color;\n"
" tex_c = tex_coord;\n"
" tex_cuv = tex_coord2 * 0.5;\n"
" tex_cuv = tex_coord2 * 0.25;\n"
"}\n"

View File

@ -12,5 +12,5 @@ void main()
gl_Position = mvp * vertex;
col = color;
tex_c = tex_coord;
tex_cuv = tex_coord2 * 0.5;
tex_cuv = tex_coord2 * 0.25;
}