]> git.lyx.org Git - features.git/commit
Add caching for the QTextLayout objects we use
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 5 Jul 2016 12:06:22 +0000 (14:06 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 6 Jan 2017 21:47:32 +0000 (22:47 +0100)
commitd76309913f44fae1cf550a35e7fde43f40d2425a
treee26359015636686181471b9eb795ba8b94d2d3dd
parent54fa0d51da514e2ac8b66b632116a1d5ec3dd5aa
Add caching for the QTextLayout objects we use

The QTextLayout handling is terribly slow on Qt 4.8.7, but some
caching has been added in Qt5 that makes it much faster. For some
reason, it is not that slow with Qt 4.8.1.

Caches are introduced for the three following methods

* width(doctring), controlled by CACHE_METRICS_WIDTH. This cache already
  existed, but the code has been cleaned up

* getTextLayout, controlled by CACHE_METRICS_QTEXTLAYOUT (disabled by
  default on Qt5, which does its own caching). This is used for pos2x
  and x2pos and now for drawing of text too. The previous code used a
  trivial caching scheme of the last used QTextLayout, but now they
  are properly kept in a QCache. Moreover, the cacheEnabled() property
  is enabled for these QTextLayout object (not sure what this does).

* breakAt, controlled by CACHE_METRICS_BREAKAT. This is the only user
  of QTextLayout which did not have some kind of caching already.

For some weird reasons related to Argument-dependent look-up, the
qHash(docstring) function has to be defined in std namespace, since
lyx::docstring is actually std::basic_string<wchar_t>.

(cherry picked from c5119c97fcf84e8)
src/frontends/qt4/GuiFontMetrics.cpp
src/frontends/qt4/GuiFontMetrics.h
src/frontends/qt4/GuiPainter.cpp
src/support/convert.cpp
status.22x