[Development] Something is wrong in QFontEngineFT::loadGlyph
markg85 at gmail.com
Tue Feb 14 19:33:17 CET 2012
On Tue, Feb 14, 2012 at 4:03 PM, <jiang.jiang at nokia.com> wrote:
> Hi Mark,
> On Feb 14, 2012, at 12:03 AM, ext Mark wrote:
> > While using Qt's elidedText function
> http://developer.qt.nokia.com/doc/qt-4.8/qfontmetricsf.html#elidedText i
> noticed the function was dog slow. For just 1000 entries (each 250 chars)
> eliding them to 200px took about 190ms on windows and 100ms on linux. Using
> that for drawing is noticeable slow. I haven't actually tried that, but i
> certainly would notice that and in the longer run that is my intention.
> > So, i started playing with it in an attempt to get it blazing fast. And
> i got there. On windows i have a speedup of 39x (same job only takes 5ms)
> and on Linux i got a speedup of 10x (same job takes 10ms, side effect is
> that linux while 10x faster is now slower then windows.. odd), Those
> speedups are nice but it tasted like more so i went on to profilling. I
> already knew the QFontMetricsF::width was the function dragging everything
> down and a kcachegrind seems to indicate the same.
> > Note for the speedups, i got them mostly by cashing the width of the
> used character thus avoiding the width function as much as possible.
> > This is the path that width() takes till the point of calling the
> freetype functions:
> > QFontEngineFT::stringToCMap
> > QFontEngineFT::recalcAdvances
> > QFontEngineFT::loadGlyph
> > loadGlyph is where i think something odd is going on.
> > Note the last parameter: "fetchMetricsOnly" ... The path it took had
> fetchMetricsOnly set to true :
> That leads me to think that this function is only going to fetch the
> metrics of the glyph, not render it! The opposite is the case. It's
> rendering it and that is the part that takes long.
> > So, am i right here? Is this function doing to much? Remember, we come
> from the "width()" function. All we actually need is the width of the
> glyph, that's it.
> > Actually, if you look in that function for the fetchMetricsOnly
> occurrence you'll see that it's only used in one place and there it doesn't
> seem to do a lot with metrics. It kinda looks like the original implementer
> of this has some idea, but never finished implementing it. Or am i wrong
> Your guess is mostly correct. This fetchMetricsOnly flag was added a while
> ago (Nov 5, 2008) to suppress a warning message but it's actually useful to
> avoid doing rendering in that case. I think we should change
> (set->outline_drawing && fetchMetricsOnly) to (set->outline_drawing ||
> fetchMetricsOnly) if not regression is caused. How is that working for you?
> - Jiang
Right, tested it now.
fixing this seems to make the loadGlyph function about 4x faster! My test
app gets twice as fast with it.
It now does the test as described in my first post in just a mere 5ms.
Could someone please patch this in Qt (4.8.x as well?).. I don't have an
account for review/commit stuff. Feel free to commit :)
Just to be sure, change:
if (set->outline_drawing && fetchMetricsOnly)
if (set->outline_drawing || fetchMetricsOnly)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Development