Enlightenment CVS committal
Author : kwo
Project : e16
Module : e
Dir : e16/e/src
Modified Files:
tclass.h text.c ttfont.c
Log Message:
Simplify TT font drawing. Invalidate GC when visual changes.
===================================================================
RCS file: /cvs/e/e16/e/src/tclass.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- tclass.h 8 May 2006 16:26:22 -0000 1.9
+++ tclass.h 13 May 2006 17:03:22 -0000 1.10
@@ -102,8 +102,8 @@
int *rbearing_return);
Efont *Efont_load(const char *file, int size);
void Efont_free(Efont * f);
-void EFont_draw_string(Drawable win, GC gc, int x, int y,
- const char *text, Efont * f,
- Visual * vis, Colormap cm);
+void EFont_draw_string(Win win, Drawable draw, 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.68
retrieving revision 1.69
diff -u -3 -r1.68 -r1.69
--- text.c 13 May 2006 13:25:30 -0000 1.68
+++ text.c 13 May 2006 17:03:22 -0000 1.69
@@ -268,6 +268,28 @@
StrlistFree(lines, num_lines);
}
+static GC
+_get_gc(Win win)
+{
+ static GC gc = None;
+ static Visual *last_vis = NULL;
+ Visual *vis;
+
+ vis = WinGetVisual(win);
+ if (vis != last_vis)
+ {
+ if (gc)
+ EXFreeGC(gc);
+ gc = None;
+ last_vis = vis;
+ }
+
+ if (!gc)
+ gc = EXCreateGC(WinGetXwin(win), 0, NULL);
+
+ return gc;
+}
+
void
TextstateDrawText(TextState * ts, Win win, Drawable draw, const char *text,
int x, int y, int w, int h, int fsize __UNUSED__,
@@ -277,8 +299,8 @@
char **lines;
int i, num_lines;
int xx, yy;
- static GC gc = 0;
int textwidth_limit, offset_x, offset_y;
+ GC gc;
Pixmap drawable;
if (w <= 0 || h <= 0)
@@ -296,9 +318,6 @@
if (draw == None)
draw = WinGetXwin(win);
- if (!gc)
- gc = EXCreateGC(draw, 0, NULL);
-
if (ts->style.orientation == FONT_TO_RIGHT ||
ts->style.orientation == FONT_TO_LEFT)
textwidth_limit = w;
@@ -310,6 +329,8 @@
if (ts->efont)
{
+ int r, g, b;
+
for (i = 0; i < num_lines; i++)
{
int ascent, descent, wid;
@@ -370,28 +391,26 @@
if (ts->effect == 1)
{
- EAllocColor(&ts->bg_col);
- XSetForeground(disp, gc, ts->bg_col.pixel);
- EFont_draw_string(drawable, gc, offset_x + 1, offset_y + 1,
- lines[i], ts->efont, VRoot.vis, VRoot.cmap);
+ 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]);
}
else if (ts->effect == 2)
{
- EAllocColor(&ts->bg_col);
- XSetForeground(disp, gc, ts->bg_col.pixel);
- EFont_draw_string(drawable, gc, offset_x - 1, offset_y,
- lines[i], ts->efont, VRoot.vis, VRoot.cmap);
- EFont_draw_string(drawable, gc, offset_x + 1, offset_y,
- lines[i], ts->efont, VRoot.vis, VRoot.cmap);
- EFont_draw_string(drawable, gc, offset_x, offset_y - 1,
- lines[i], ts->efont, VRoot.vis, VRoot.cmap);
- EFont_draw_string(drawable, gc, offset_x, offset_y + 1,
- lines[i], ts->efont, VRoot.vis, VRoot.cmap);
- }
- EAllocColor(&ts->fg_col);
- XSetForeground(disp, gc, ts->fg_col.pixel);
- EFont_draw_string(drawable, gc, offset_x, offset_y, lines[i],
- ts->efont, VRoot.vis, VRoot.cmap);
+ EGetColor(&(ts->bg_col), &r, &g, &b);
+ EFont_draw_string(win, drawable, ts->efont, offset_x - 1,
+ offset_y, r, g, b, lines[i]);
+ EFont_draw_string(win, drawable, ts->efont, offset_x + 1,
+ offset_y, r, g, b, lines[i]);
+ EFont_draw_string(win, drawable, ts->efont, offset_x,
+ offset_y - 1, r, g, b, lines[i]);
+ EFont_draw_string(win, drawable, 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,
+ r, g, b, lines[i]);
TextDrawRotBack(win, draw, drawable, xx - 1, yy - 1 - ascent,
wid + 2, ascent + descent + 2, ts);
@@ -402,6 +421,8 @@
}
else if (ts->xfontset)
{
+ gc = _get_gc(win);
+
for (i = 0; i < num_lines; i++)
{
XRectangle ret1, ret2;
@@ -547,6 +568,8 @@
else if ((ts->xfont) && (ts->xfont->min_byte1 == 0)
&& (ts->xfont->max_byte1 == 0))
{
+ gc = _get_gc(win);
+
XSetFont(disp, gc, ts->xfont->fid);
for (i = 0; i < num_lines; i++)
{
@@ -640,6 +663,8 @@
}
else if ((ts->xfont))
{
+ gc = _get_gc(win);
+
XSetFont(disp, gc, ts->xfont->fid);
for (i = 0; i < num_lines; i++)
{
===================================================================
RCS file: /cvs/e/e16/e/src/ttfont.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -3 -r1.49 -r1.50
--- ttfont.c 13 May 2006 13:25:30 -0000 1.49
+++ ttfont.c 13 May 2006 17:03:22 -0000 1.50
@@ -33,20 +33,6 @@
};
static void
-ImlibSetFgColorFromGC(GC gc, Colormap cm)
-{
- XGCValues xgcv;
- XColor xclr;
- int r, g, b;
-
- XGetGCValues(disp, gc, GCForeground, &xgcv);
- xclr.pixel = xgcv.foreground;
- XQueryColor(disp, cm, &xclr);
- EGetColor(&xclr, &r, &g, &b);
- imlib_context_set_color(r, g, b, 255);
-}
-
-static void
EFonts_Init(void)
{
#if !TEST_TTFONT
@@ -64,8 +50,8 @@
}
void
-EFont_draw_string(Drawable win, GC gc, int x, int y, const char *text,
- Efont * f, Visual * vis __UNUSED__, Colormap cm)
+EFont_draw_string(Win win, Drawable draw, Efont * f, int x, int y,
+ int r, int g, int b, const char *text)
{
EImage *im;
int w, h, ascent, descent;
@@ -73,12 +59,12 @@
Efont_extents(f, text, &ascent, &descent, &w, NULL, NULL, NULL, NULL);
h = ascent + descent;
- im = EImageGrabDrawable(win, None, x, y - ascent, w, h, 0);
+ im = EImageGrabDrawable(draw, None, x, y - ascent, w, h, 0);
imlib_context_set_image(im);
+ imlib_context_set_color(r, g, b, 255);
imlib_context_set_font(f->face);
- ImlibSetFgColorFromGC(gc, cm);
imlib_text_draw(0, 0, text);
- EImageRenderOnDrawable(im, NULL, win, x, y - ascent, w, h, 0);
+ EImageRenderOnDrawable(im, win, draw, x, y - ascent, w, h, 0);
EImageFree(im);
}
-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs