Abdelrazak Younes a écrit :
Martin Vermeer a écrit :
On Fri, May 19, 2006 at 11:50:50PM +0200, Abdelrazak Younes wrote:
| | | | + 510.6 ms LyXText::rowBreakPoint(int, Row&) const (lyx)
| | | | | + 457.7 ms font_metrics::width(char, LyXFont const&) (lyx)
| | | | + 2417.1 ms ::RowPainter::paintFromPos(int&) (lyx)
| | | | | + 2394.6 ms ::RowPainter::paintChars(int&, LyXFont, bool,
| | | | | | + 524.7 ms font_metrics::width(char const*, unsigned long,
| | | | | | + 1825.8 ms QLPainter::text(int, int, std::basic_string<
| | | | | | | + 1824.8 ms QLPainter::text(int, int, char const*,
| | | | | | | | - 1710.0 ms QPainter::drawText(int, int, QString const&,

OK, this means that this "drawImage" should definitely not be in the update routine. I'll see to it but the slowest part of "LyXScreen::redraw" is not in there but in "paintText()" or more exactly in "font_metrics::width" and in QPainter::drawText. I am afraid there is not much I can do about that, it is Qt4 API. I'll google a bit to see if there's some solution to that drawText slowness. It seems that font_metrics::width is called two times within LyXText::redoParagraph, once in LyXText::rowBreakPoint and another in ::RowPainter::paintChars; I think this could be optimized out, Martin?
I'm not convinced. How? And isn't this (font metrics) being cached in Qt?
In "qfont_metrics.C: width(char const * s, size_t ls, LyXFont const & f)" I see three lines that could potentially takes some time:

    Encoding const * encoding = fontencoding(f);
   QLFontInfo & fi = fontloader.fontinfo(f);

Hum, this code in "qfont_loader.C" looks suspicious:
______________________

        QLFontInfo & fontinfo(LyXFont const & f) {
                QLFontInfo * & fi =
fontinfo_[f.family()][f.series()][f.realShape()][f.size()];
                if (!fi)
                        fi = new QLFontInfo(f);
                return *fi;
        }

private:
        /// BUTT ugly !
        QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
______________________

Why the '&' in "QLFontInfo * & "?
If this is the cache your are talking about, I guess something is going wrong either in f.series(), f.realShape(), f.size() or in the fontinfo_ multi-dimensional table. Analysing the LyxFont class seems too big a task for a Saturday afternoon; even a rainy one...

Abdel.





   if (ls == 1)
       return fi.width(encoding->ucs(s[0]));

Which one do you think it is?



Reply via email to