Closed Bug 386895 Opened 15 years ago Closed 15 years ago

speed up gfx text drawing microbenchmark

Categories

(Core :: Graphics, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: vlad, Assigned: vlad)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch speed up gfxFont::Draw a bit (obsolete) — Splinter Review
A microbenchmark of text drawing (basically, load the misc-text testcase from Trender and then launch a redraw() bookmarklet to keep redrawing a thousand times or so) revealed some pretty big hotspots.. one of them was AppendElement(), which it turns out isn't free even with a nsAutoTArray.  It was still constructing each element and doing some other work.

This patch just gets rid of the nsAutoTArray and just uses a stack cairo_glyph_t buffer, drawing glyphs when it becomes full.

Another hotspot on win32 was the _cairo_lround()s in the win32 surface's show_glyphs; a lot of that goes away if we compile cairo with -O2 instead of -O1 (separate patch coming).
Attachment #270957 - Flags: review?(roc)
This would be a little cleaner if the glyph buffer was factored into a helper class with "cairo_glyph_t* AppendGlyph()" and "Flush()" methods.
Like this?
Attachment #270957 - Attachment is obsolete: true
Attachment #271640 - Flags: review?(roc)
Attachment #270957 - Flags: review?(roc)
Comment on attachment 271640 [details] [diff] [review]
speed up gfxFont::Draw a bit, v2

+    cairo_t *mCairo;
+#define GLYPH_BUFFER_SIZE (2048/sizeof(cairo_glyph_t))
+    cairo_glyph_t glyphBuffer[GLYPH_BUFFER_SIZE];
+    unsigned int num_glyphs;
+    PRBool drawToPath;

Choose a naming style? :-) Preferably mDrawToPath, mNumGlyphs, mGlyphBuffer, mCairo.

+    void Flush(PRBool finish = PR_FALSE) {

Make the cairo_t* a parameter to Flush, I think.
Attachment #271640 - Flags: superreview+
Attachment #271640 - Flags: review?(roc)
Attachment #271640 - Flags: review+
Checked in with mNumGlyphs and mGlyphBuffer, and cairo_t and drawToPath args to Flush.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.