Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: tclass.h text.c ttfont.c Log Message: Speed up TT font drawing. =================================================================== RCS file: /cvs/e/e16/e/src/tclass.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- tclass.h 13 May 2006 17:03:22 -0000 1.10 +++ tclass.h 14 May 2006 19:38:51 -0000 1.11 @@ -102,8 +102,7 @@ int *rbearing_return); Efont *Efont_load(const char *file, int size); void Efont_free(Efont * f); -void EFont_draw_string(Win win, Drawable draw, Efont * f, int x, - int y, int r, int g, int b, - const char *text); +void EFont_draw_string(EImage * im, Efont * f, int x, int y, + int r, int g, int b, const char *text); #endif /* _TCLASS_H */ =================================================================== RCS file: /cvs/e/e16/e/src/text.c,v retrieving revision 1.71 retrieving revision 1.72 diff -u -3 -r1.71 -r1.72 --- text.c 14 May 2006 19:33:42 -0000 1.71 +++ text.c 14 May 2006 19:38:51 -0000 1.72 @@ -95,6 +95,66 @@ } } +static EImage * +TextImageGet(Win win __UNUSED__, Drawable src, int x, int y, int w, int h, + TextState * ts) +{ + EImage *im; + int win_w; + + switch (ts->style.orientation) + { + default: + case FONT_TO_RIGHT: + im = EImageGrabDrawable(src, None, x, y, w, h, 0); + break; + case FONT_TO_LEFT: + im = EImageGrabDrawable(src, None, x, y, w, h, 0); + EImageOrientate(im, 2); + break; + case FONT_TO_UP: + im = EImageGrabDrawable(src, 0, y, x, h, w, 0); + EImageOrientate(im, 1); + break; + case FONT_TO_DOWN: + EXGetGeometry(src, NULL, NULL, NULL, &win_w, NULL, NULL, NULL); + im = EImageGrabDrawable(src, None, win_w - y - h, x, h, w, 0); + EImageOrientate(im, 3); + break; + } + + return im; +} + +static void +TextImagePut(EImage * im, Win win, Drawable dst, int x, int y, + int w, int h, TextState * ts) +{ + int win_w; + + switch (ts->style.orientation) + { + default: + case FONT_TO_RIGHT: + EImageRenderOnDrawable(im, win, dst, x, y, w, h, 0); + break; + case FONT_TO_LEFT: + EImageOrientate(im, 2); + EImageRenderOnDrawable(im, win, dst, x, y, w, h, 0); + break; + case FONT_TO_UP: + EImageOrientate(im, 3); + EImageRenderOnDrawable(im, win, dst, y, x, h, w, 0); + break; + case FONT_TO_DOWN: + EXGetGeometry(dst, NULL, NULL, NULL, &win_w, NULL, NULL, NULL); + EImageOrientate(im, 1); + EImageRenderOnDrawable(im, win, dst, win_w - y - h, x, h, w, 0); + break; + } + EImageFree(im); +} + TextState * TextclassGetTextState(TextClass * tclass, int state, int active, int sticky) { @@ -397,6 +457,7 @@ if (ts->efont) { + EImage *im; int r, g, b; for (i = 0; i < num_lines; i++) @@ -440,50 +501,39 @@ yy += ascent; xx = x + (((textwidth_limit - wid) * justification) >> 10); - if (ts->style.orientation != FONT_TO_RIGHT) - drawable = ECreatePixmap(win, wid + 2, ascent + descent + 2, 0); - else - drawable = draw; - TextDrawRotTo(win, draw, drawable, xx - 1, yy - 1 - ascent, - wid + 2, ascent + descent + 2, ts); - if (ts->style.orientation == FONT_TO_RIGHT) - { - offset_x = xx; - offset_y = yy; - } - else - { - offset_x = 1; - offset_y = ascent + 1; - } + im = TextImageGet(win, draw, xx - 1, yy - 1 - ascent, + wid + 2, ascent + descent + 2, ts); + if (!im) + break; + + offset_x = 1; + offset_y = ascent + 1; if (ts->effect == 1) { EGetColor(&(ts->bg_col), &r, &g, &b); - EFont_draw_string(win, drawable, ts->efont, - offset_x + 1, offset_y + 1, - r, g, b, lines[i]); + EFont_draw_string(im, ts->efont, offset_x + 1, + offset_y + 1, r, g, b, lines[i]); } else if (ts->effect == 2) { EGetColor(&(ts->bg_col), &r, &g, &b); - EFont_draw_string(win, drawable, ts->efont, offset_x - 1, + EFont_draw_string(im, ts->efont, offset_x - 1, offset_y, r, g, b, lines[i]); - EFont_draw_string(win, drawable, ts->efont, offset_x + 1, + EFont_draw_string(im, ts->efont, offset_x + 1, offset_y, r, g, b, lines[i]); - EFont_draw_string(win, drawable, ts->efont, offset_x, + EFont_draw_string(im, ts->efont, offset_x, offset_y - 1, r, g, b, lines[i]); - EFont_draw_string(win, drawable, ts->efont, offset_x, + EFont_draw_string(im, ts->efont, offset_x, offset_y + 1, r, g, b, lines[i]); } EGetColor(&(ts->fg_col), &r, &g, &b); - EFont_draw_string(win, drawable, ts->efont, offset_x, offset_y, + EFont_draw_string(im, ts->efont, offset_x, offset_y, r, g, b, lines[i]); - TextDrawRotBack(win, draw, drawable, xx - 1, yy - 1 - ascent, - wid + 2, ascent + descent + 2, ts); - if (drawable != draw) - EFreePixmap(drawable); + TextImagePut(im, win, draw, xx - 1, yy - 1 - ascent, + wid + 2, ascent + descent + 2, ts); + yy += ascent + descent; } } =================================================================== RCS file: /cvs/e/e16/e/src/ttfont.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -3 -r1.50 -r1.51 --- ttfont.c 13 May 2006 17:03:22 -0000 1.50 +++ ttfont.c 14 May 2006 19:38:51 -0000 1.51 @@ -49,6 +49,7 @@ #endif } +#if 0 /* Unused - Remove? */ void EFont_draw_string(Win win, Drawable draw, Efont * f, int x, int y, int r, int g, int b, const char *text) @@ -66,6 +67,17 @@ imlib_text_draw(0, 0, text); EImageRenderOnDrawable(im, win, draw, x, y - ascent, w, h, 0); EImageFree(im); +} +#endif + +void +EFont_draw_string(EImage * im, Efont * f, int x, int y, + int r, int g, int b, const char *text) +{ + imlib_context_set_image(im); + imlib_context_set_color(r, g, b, 255); + imlib_context_set_font(f->face); + imlib_text_draw(x, y - imlib_get_font_ascent(), text); } void ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs