]> 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>
Mon, 19 Dec 2016 17:47:18 +0000 (18:47 +0100)
commitc5119c97fcf84e8dd2cfcdd605cc0a9ffa8b5bc4
tree29fafa808ae935db6c96406cc7b94f34129b0bcd
parenta95385ab29ef1e18f132b43938232a8c8c3ba3f6
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>.

[NOTE: this version has profiling hooks, enabled by commenting out the line
  #define DISABLE_PMPROF
that should eventually be removed.]
src/frontends/qt4/GuiFontMetrics.cpp
src/frontends/qt4/GuiFontMetrics.h
src/frontends/qt4/GuiPainter.cpp
src/support/convert.cpp