diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 7 | ||||
-rw-r--r-- | pango/pangox.c | 61 |
6 files changed, 82 insertions, 14 deletions
@@ -1,3 +1,10 @@ +Tue May 27 16:06:34 2003 Owen Taylor <otaylor@redhat.com> + + * pango/pangox.c (pango_x_render): Patch from Morten + Welinder to collect characters into runs of the + same font with natural offsets before drawing them. + (#106892, Morten Welinder) + Tue May 27 15:01:24 2003 Owen Taylor <otaylor@redhat.com> * pango/pangoxft-font.c (pango_xft_font_get_metrics): diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index c90b0bb8..47d4b7f1 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,10 @@ +Tue May 27 16:06:34 2003 Owen Taylor <otaylor@redhat.com> + + * pango/pangox.c (pango_x_render): Patch from Morten + Welinder to collect characters into runs of the + same font with natural offsets before drawing them. + (#106892, Morten Welinder) + Tue May 27 15:01:24 2003 Owen Taylor <otaylor@redhat.com> * pango/pangoxft-font.c (pango_xft_font_get_metrics): diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index c90b0bb8..47d4b7f1 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,10 @@ +Tue May 27 16:06:34 2003 Owen Taylor <otaylor@redhat.com> + + * pango/pangox.c (pango_x_render): Patch from Morten + Welinder to collect characters into runs of the + same font with natural offsets before drawing them. + (#106892, Morten Welinder) + Tue May 27 15:01:24 2003 Owen Taylor <otaylor@redhat.com> * pango/pangoxft-font.c (pango_xft_font_get_metrics): diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index c90b0bb8..47d4b7f1 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,10 @@ +Tue May 27 16:06:34 2003 Owen Taylor <otaylor@redhat.com> + + * pango/pangox.c (pango_x_render): Patch from Morten + Welinder to collect characters into runs of the + same font with natural offsets before drawing them. + (#106892, Morten Welinder) + Tue May 27 15:01:24 2003 Owen Taylor <otaylor@redhat.com> * pango/pangoxft-font.c (pango_xft_font_get_metrics): diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index c90b0bb8..47d4b7f1 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,10 @@ +Tue May 27 16:06:34 2003 Owen Taylor <otaylor@redhat.com> + + * pango/pangox.c (pango_x_render): Patch from Morten + Welinder to collect characters into runs of the + same font with natural offsets before drawing them. + (#106892, Morten Welinder) + Tue May 27 15:01:24 2003 Owen Taylor <otaylor@redhat.com> * pango/pangoxft-font.c (pango_xft_font_get_metrics): diff --git a/pango/pangox.c b/pango/pangox.c index 80151a65..e3036d5b 100644 --- a/pango/pangox.c +++ b/pango/pangox.c @@ -455,6 +455,19 @@ pango_x_load_font (Display *display, return (PangoFont *)result; } + + +#define FLUSH \ + G_STMT_START { \ + if (charcount) \ + { \ + XDrawString16 (display, d, gc, \ + glyph_x0, glyph_y0, \ + xcharbuffer, charcount); \ + charcount = 0; \ + } \ + } G_STMT_END + /** * pango_x_render: @@ -477,15 +490,21 @@ pango_x_render (Display *display, int x, int y) { - /* Slow initial implementation. For speed, it should really - * collect the characters into runs, and draw multiple - * characters with each XDrawString16 call. - */ Font old_fid = None; XFontStruct *fs; int i; int x_off = 0; + /* + * We collect the characters in this buffer as long as the font does not + * change. At that time, or when the buffer runs full, or at the end, + * then we empty the buffer. + */ + XChar2b xcharbuffer[1000]; + int glyph_x0 = 0, expected_x = 0; /* x/y initializations are to quiet GCC */ + int glyph_y0 = 0; + int charcount = 0; + g_return_if_fail (display != NULL); g_return_if_fail (glyphs != NULL); @@ -515,7 +534,9 @@ pango_x_render (Display *display, int stroke_thick; gunichar wc; - + + FLUSH; + x1 = glyph_x; y1 = glyph_y - PANGO_PIXELS (metrics->ascent); x2 = x1 + PANGO_PIXELS (glyphs->glyphs[i].geometry.width); @@ -624,35 +645,47 @@ pango_x_render (Display *display, guint16 subfont_index = PANGO_X_GLYPH_SUBFONT (glyph); PangoXSubfontInfo *subfont; - XChar2b c; - subfont = pango_x_find_subfont (font, subfont_index); if (subfont) { - c.byte1 = index / 256; - c.byte2 = index % 256; - fs = pango_x_get_font_struct (font, subfont); if (!fs) continue; if (fs->fid != old_fid) { + FLUSH; XSetFont (display, gc, fs->fid); old_fid = fs->fid; } - - XDrawString16 (display, d, gc, - glyph_x, glyph_y, - &c, 1); + + if (charcount == G_N_ELEMENTS (xcharbuffer) || + (charcount > 0 && (glyph_y != glyph_y0 || + glyph_x != expected_x))) + FLUSH; + + if (charcount == 0) + { + glyph_x0 = glyph_x; + glyph_y0 = glyph_y; + } + xcharbuffer[charcount].byte1 = index / 256; + xcharbuffer[charcount].byte2 = index % 256; + + expected_x = glyph_x + XTextWidth16 (fs, &xcharbuffer[charcount], 1); + + charcount++; } } next_glyph: x_off += glyphs->glyphs[i].geometry.width; } + FLUSH; } +#undef FLUSH + static void pango_x_font_get_glyph_extents (PangoFont *font, PangoGlyph glyph, |