improve optimal nature of code.. get some more speed....
SVN revision: 7438
This commit is contained in:
parent
3b808bac45
commit
527058ae9f
|
@ -59,7 +59,8 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
|
|||
int ext_x, ext_y, ext_w, ext_h;
|
||||
DATA32 *im;
|
||||
int im_w, im_h;
|
||||
|
||||
int c;
|
||||
|
||||
im = dst->image->data;
|
||||
im_w = dst->image->w;
|
||||
im_h = dst->image->h;
|
||||
|
@ -94,7 +95,7 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
|
|||
use_kerning = FT_HAS_KERNING(fn->ft.face);
|
||||
prev_index = 0;
|
||||
func = evas_common_draw_func_blend_alpha_get(dst);
|
||||
for (chr = 0; text[chr];)
|
||||
for (c = 0, chr = 0; text[chr];)
|
||||
{
|
||||
FT_UInt index;
|
||||
RGBA_Font_Glyph *fg;
|
||||
|
@ -144,7 +145,7 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
|
|||
{
|
||||
/* ext glyph draw */
|
||||
dc->font_ext.func.gl_draw(dc->font_ext.data,
|
||||
NULL,
|
||||
(void *)c,
|
||||
dc, fg,
|
||||
chr_x,
|
||||
y - (chr_y - y)
|
||||
|
@ -183,6 +184,7 @@ evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Font *fn, int
|
|||
}
|
||||
}
|
||||
}
|
||||
c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,6 +183,7 @@ evas_gl_common_context_font_texture_set(Evas_GL_Context *gc, Evas_GL_Font_Textur
|
|||
gc->font_texture_not_power_of_two = ft->pool->not_power_of_two;
|
||||
gc->change.texture = 1;
|
||||
}
|
||||
if (!gc->change.texture) return;
|
||||
if (_evas_gl_common_context == gc) _evas_gl_common_texture_set(gc);
|
||||
}
|
||||
|
||||
|
@ -282,7 +283,7 @@ _evas_gl_common_texture_set(Evas_GL_Context *gc)
|
|||
{
|
||||
if (gc->font_texture_not_power_of_two)
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, gc->font_texture);
|
||||
}
|
||||
|
@ -298,14 +299,14 @@ _evas_gl_common_texture_set(Evas_GL_Context *gc)
|
|||
{
|
||||
if (gc->texture->not_power_of_two)
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, gc->texture->texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gc->ext.nv_texture_rectangle) glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, gc->texture->texture);
|
||||
}
|
||||
if (gc->texture->not_power_of_two)
|
||||
|
@ -319,18 +320,34 @@ _evas_gl_common_texture_set(Evas_GL_Context *gc)
|
|||
{
|
||||
if (gc->texture->changed)
|
||||
{
|
||||
if (gc->texture->smooth)
|
||||
if (gc->texture->not_power_of_two)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
if (gc->texture->have_mipmaps)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
if (gc->texture->smooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
}
|
||||
else
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
if (gc->texture->smooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
if (gc->texture->have_mipmaps)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
else
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
}
|
||||
}
|
||||
gc->texture->changed = 0;
|
||||
}
|
||||
|
|
|
@ -91,6 +91,20 @@ evas_gl_font_texture_new(Evas_GL_Context *gc, RGBA_Font_Glyph *fg)
|
|||
gc->font_texture = ft->texture;
|
||||
gc->font_texture_not_power_of_two = ft->pool->not_power_of_two;
|
||||
gc->change.texture = 1;
|
||||
if (ft->pool->not_power_of_two)
|
||||
{
|
||||
ft->tx1 = ft->x;
|
||||
ft->ty1 = ft->y;
|
||||
ft->tx2 = ft->x + ft->w;
|
||||
ft->ty2 = ft->y + ft->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
ft->tx1 = (double)(ft->x ) / (double)(ft->pool->w);
|
||||
ft->ty1 = (double)(ft->y ) / (double)(ft->pool->h);
|
||||
ft->tx2 = (double)(ft->x + ft->w) / (double)(ft->pool->w);
|
||||
ft->ty2 = (double)(ft->y + ft->h) / (double)(ft->pool->h);
|
||||
}
|
||||
|
||||
return ft;
|
||||
}
|
||||
|
@ -110,51 +124,41 @@ evas_gl_font_texture_free(Evas_GL_Font_Texture *ft)
|
|||
void
|
||||
evas_gl_font_texture_draw(Evas_GL_Context *gc, void *surface, RGBA_Draw_Context *dc, RGBA_Font_Glyph *fg, int x, int y)
|
||||
{
|
||||
int r, g, b, a;
|
||||
Evas_GL_Font_Texture *ft;
|
||||
|
||||
|
||||
/* 35 */
|
||||
ft = fg->ext_dat;
|
||||
if (!ft) return;
|
||||
a = (dc->col.col >> 24) & 0xff;
|
||||
r = (dc->col.col >> 16) & 0xff;
|
||||
g = (dc->col.col >> 8 ) & 0xff;
|
||||
b = (dc->col.col ) & 0xff;
|
||||
evas_gl_common_context_color_set(gc, r, g, b, a);
|
||||
if (dc->clip.use)
|
||||
evas_gl_common_context_clip_set(gc, 1,
|
||||
dc->clip.x, dc->clip.y,
|
||||
dc->clip.w, dc->clip.h);
|
||||
else
|
||||
evas_gl_common_context_clip_set(gc, 0,
|
||||
0, 0, 0, 0);
|
||||
evas_gl_common_context_font_texture_set(gc, ft);
|
||||
evas_gl_common_context_blend_set(gc, 1);
|
||||
evas_gl_common_context_read_buf_set(gc, GL_BACK);
|
||||
evas_gl_common_context_write_buf_set(gc, GL_BACK);
|
||||
if (surface == 0)
|
||||
{
|
||||
double tx1, ty1, tx2, ty2;
|
||||
int r, g, b, a;
|
||||
|
||||
if (ft->pool->not_power_of_two)
|
||||
{
|
||||
tx1 = ft->x;
|
||||
ty1 = ft->y;
|
||||
tx2 = ft->x + ft->w;
|
||||
ty2 = ft->y + ft->h;
|
||||
}
|
||||
a = (dc->col.col >> 24) & 0xff;
|
||||
r = (dc->col.col >> 16) & 0xff;
|
||||
g = (dc->col.col >> 8 ) & 0xff;
|
||||
b = (dc->col.col ) & 0xff;
|
||||
evas_gl_common_context_color_set(gc, r, g, b, a);
|
||||
if (dc->clip.use)
|
||||
evas_gl_common_context_clip_set(gc, 1,
|
||||
dc->clip.x, dc->clip.y,
|
||||
dc->clip.w, dc->clip.h);
|
||||
else
|
||||
{
|
||||
tx1 = (double)(ft->x ) / (double)(ft->pool->w);
|
||||
ty1 = (double)(ft->y ) / (double)(ft->pool->h);
|
||||
tx2 = (double)(ft->x + ft->w) / (double)(ft->pool->w);
|
||||
ty2 = (double)(ft->y + ft->h) / (double)(ft->pool->h);
|
||||
}
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2d(tx1, ty1); glVertex2i(x , y );
|
||||
glTexCoord2d(tx2, ty1); glVertex2i(x + ft->w, y );
|
||||
glTexCoord2d(tx2, ty2); glVertex2i(x + ft->w, y + ft->h);
|
||||
glTexCoord2d(tx1, ty2); glVertex2i(x , y + ft->h);
|
||||
glEnd();
|
||||
evas_gl_common_context_clip_set(gc, 0,
|
||||
0, 0, 0, 0);
|
||||
evas_gl_common_context_blend_set(gc, 1);
|
||||
evas_gl_common_context_read_buf_set(gc, GL_BACK);
|
||||
evas_gl_common_context_write_buf_set(gc, GL_BACK);
|
||||
}
|
||||
/* 32 */
|
||||
evas_gl_common_context_font_texture_set(gc, ft);
|
||||
/* 32 */
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2d(ft->tx1, ft->ty1); glVertex2i(x , y );
|
||||
glTexCoord2d(ft->tx2, ft->ty1); glVertex2i(x + ft->w, y );
|
||||
glTexCoord2d(ft->tx2, ft->ty2); glVertex2i(x + ft->w, y + ft->h);
|
||||
glTexCoord2d(ft->tx1, ft->ty2); glVertex2i(x , y + ft->h);
|
||||
glEnd();
|
||||
/* 28 */
|
||||
}
|
||||
|
||||
static Evas_GL_Font_Texture_Pool_Allocation *
|
||||
|
@ -220,7 +224,7 @@ _evas_gl_font_texture_pool_request(Evas_GL_Context *gc, int w, int h)
|
|||
/* we dont want this mipmapped if sgis_generate_mipmap will mipmap it */
|
||||
if (gc->ext.sgis_generate_mipmap)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
if (fp->not_power_of_two)
|
||||
{
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
|
@ -228,17 +232,18 @@ _evas_gl_font_texture_pool_request(Evas_GL_Context *gc, int w, int h)
|
|||
/* FIXME check gl error */
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, fp->texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0,
|
||||
GL_ALPHA8, fp->w, fp->h, 0,
|
||||
GL_ALPHA4, fp->w, fp->h, 0,
|
||||
GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||
/* FIXME check gl error */
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glGenTextures(1, &(fp->texture));
|
||||
/* FIXME check gl error */
|
||||
|
||||
|
@ -248,7 +253,7 @@ _evas_gl_font_texture_pool_request(Evas_GL_Context *gc, int w, int h)
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0,
|
||||
GL_ALPHA8, fp->w, fp->h, 0,
|
||||
GL_ALPHA4, fp->w, fp->h, 0,
|
||||
GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||
/* FIXME check gl error */
|
||||
}
|
||||
|
|
|
@ -22,13 +22,23 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth)
|
|||
tex->tw = im->image->w;
|
||||
tex->th = im->image->h;
|
||||
tex->references = 0;
|
||||
tex->smooth = 0;
|
||||
tex->smooth = smooth;
|
||||
tex->changed = 1;
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glGenTextures(1, &(tex->texture));
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, tex->texture);
|
||||
if (smooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
}
|
||||
|
||||
if (gc->texture) gc->texture->references--;
|
||||
gc->texture = tex;
|
||||
|
@ -140,7 +150,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
|
|||
{
|
||||
void *tmp = NULL, *data;
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_NV, tex->texture);
|
||||
|
||||
|
@ -188,7 +198,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
|
|||
tex->changed = 1;
|
||||
tex->have_mipmaps = 0;
|
||||
if (tex->gc->ext.nv_texture_rectangle) glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
// glEnable(GL_TEXTURE_2D);
|
||||
if (tex->not_power_of_two)
|
||||
{
|
||||
glEnable(GL_TEXTURE_RECTANGLE_NV);
|
||||
|
@ -197,6 +207,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
|
|||
else
|
||||
{
|
||||
glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glEnable(GL_TEXTURE_2D);//
|
||||
target = GL_TEXTURE_2D;
|
||||
}
|
||||
|
||||
|
@ -221,6 +232,7 @@ evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im, int smooth)
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
tex->smooth = 0;
|
||||
|
||||
im_data = im->image->data;
|
||||
im_w = im->image->w;
|
||||
|
@ -311,7 +323,6 @@ evas_gl_common_texture_mipmaps_build(Evas_GL_Texture *tex, RGBA_Image *im, int s
|
|||
else texfmt = GL_RGB8;
|
||||
pixfmt = NATIVE_PIX_FORMAT;
|
||||
|
||||
printf("building mipmaps... [%i x %i]\n", tw, th);
|
||||
if (tex->gc->ext.nv_texture_rectangle) glDisable(GL_TEXTURE_RECTANGLE_NV);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, tex->texture);
|
||||
|
|
|
@ -373,7 +373,7 @@ evas_engine_gl_x11_output_flush(void *data)
|
|||
re->win->draw.y2 - re->win->draw.y1 + 1);
|
||||
*/
|
||||
glXSwapBuffers(re->win->disp, re->win->win);
|
||||
glFlush();
|
||||
// glFlush();
|
||||
// glXWaitGL();
|
||||
// XSync(re->win->disp, False);
|
||||
// printf("SYNC! %i\n", fr++);
|
||||
|
@ -957,27 +957,31 @@ evas_engine_gl_x11_font_draw(void *data, void *context, void *surface, void *fon
|
|||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
/* text renderign takes benchmark from 40 to 27 on gf4-ti4400 */
|
||||
{
|
||||
RGBA_Image *im;
|
||||
static RGBA_Image *im = NULL;
|
||||
|
||||
im = evas_common_image_new();
|
||||
im->image = evas_common_image_surface_new();
|
||||
if (!im)
|
||||
{
|
||||
im = evas_common_image_new();
|
||||
im->image = evas_common_image_surface_new();
|
||||
im->image->no_free = 1;
|
||||
}
|
||||
im->image->w = re->win->w;
|
||||
im->image->h = re->win->h;
|
||||
im->image->data = NULL;
|
||||
im->image->no_free = 1;
|
||||
evas_common_draw_context_font_ext_set(context,
|
||||
re->win->gl_context,
|
||||
evas_gl_font_texture_new,
|
||||
evas_gl_font_texture_free,
|
||||
evas_gl_font_texture_draw);
|
||||
/* 40 */
|
||||
evas_common_font_draw(im, context, font, x, y, text);
|
||||
evas_common_draw_context_font_ext_set(context,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
evas_common_image_free(im);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,6 +131,7 @@ struct _Evas_GL_Font_Texture
|
|||
{
|
||||
Evas_GL_Context *gc;
|
||||
int x, y, w, h;
|
||||
double tx1, ty1, tx2, ty2;
|
||||
int aw, ah;
|
||||
GLuint texture;
|
||||
Evas_GL_Font_Texture_Pool *pool;
|
||||
|
|
Loading…
Reference in New Issue