This code has issues and there is no evidence that it improves performance.
Remove LyXRC variable \use_pixmap_cache and update rc format to 29.
Now the global pixmap cache is only used by GuiCompleter. Therefore
there is no need to reset it when fonts change.
* \use_qimage
This is no longer necessary due to the rewrite of the painter.
+* \use_pixmap_cacheqimage
+ There is no evidence that this painting mode was useful anymore.
+
* \date_insert_format
The function date-insert has been removed and superseded by info-insert date.
The latter does not need a pref value anymore.
lyx_check_config = True
lyx_kpsewhich = True
outfile = 'lyxrc.defaults'
- lyxrc_fileformat = 27
+ lyxrc_fileformat = 29
rc_entries = ''
lyx_keep_temps = False
version_suffix = ''
# Incremented to format 28, by spitz
# Remove date_insert_format
+# Incremented to format 29, by lasgouttes
+# Remove use_pixmap_cache
+
# NOTE: The format should also be updated in LYXRC.cpp and
# in configure.py.
return no_match
return (True, "")
+def remove_use_pixmap_cache(line):
+ if not line.lower().startswith("\\use_pixmap_cache "):
+ return no_match
+ return (True, "")
+
# End conversions for LyX 2.3 to 2.4
####################################
[ 25, [remove_use_qimage]],
[ 26, [remove_font_encoding]],
[ 27, []],
- [ 28, [remove_date_insert_format]]
+ [ 28, [remove_date_insert_format]],
+ [ 29, [remove_use_pixmap_cache]]
]
// The format should also be updated in configure.py, and conversion code
// should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 28; // spitz: remove \\date_insert_format
+static unsigned int const LYXRC_FILEFORMAT = 29; // spitz: remove \\date_insert_format
// when adding something to this array keep it sorted!
LexerKeyword lyxrcTags[] = {
{ "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
{ "\\use_converter_needauth_forbidden", LyXRC::RC_USE_CONVERTER_NEEDAUTH_FORBIDDEN },
{ "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
{ "\\use_native_filedialog", LyXRC::RC_USE_NATIVE_FILEDIALOG },
- { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
// compatibility with versions older than 1.4.0 only
{ "\\use_system_colors", LyXRC::RC_USE_SYSTEM_COLORS },
{ "\\use_system_theme_icons", LyXRC::RC_USE_SYSTEM_THEME_ICONS },
use_converter_needauth = true;
use_system_colors = false;
use_tooltip = true;
- use_pixmap_cache = false;
converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
user_name = to_utf8(support::user_name());
user_email = to_utf8(support::user_email());
case RC_USE_TOOLTIP:
lexrc >> use_tooltip;
break;
- case RC_USE_PIXMAP_CACHE:
- lexrc >> use_pixmap_cache;
- break;
case RC_SPELLCHECKER:
lexrc >> spellchecker;
break;
if (tag != RC_LAST)
break;
// fall through
- case RC_USE_PIXMAP_CACHE:
- if (ignore_system_lyxrc ||
- use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
- os << "\\use_pixmap_cache "
- << convert<string>(use_pixmap_cache)
- << '\n';
- }
- if (tag != RC_LAST)
- break;
- // fall through
os << "\n#\n"
<< "# LANGUAGE SUPPORT SECTION ##########################\n"
case LyXRC::RC_USE_NATIVE_FILEDIALOG:
case LyXRC::RC_USE_SYSTEM_COLORS:
case LyXRC::RC_USE_TOOLTIP:
- case LyXRC::RC_USE_PIXMAP_CACHE:
case LyXRC::RC_USE_SYSTEM_THEME_ICONS:
case LyXRC::RC_VIEWDVI_PAPEROPTION:
case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
str = _("Enable the automatic appearance of tool tips in the work area.");
break;
- case RC_USE_PIXMAP_CACHE:
- str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
- break;
-
case RC_VIEWDVI_PAPEROPTION:
_("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
break;
RC_USE_NATIVE_FILEDIALOG,
RC_USE_SYSTEM_COLORS,
RC_USE_TOOLTIP,
- RC_USE_PIXMAP_CACHE,
RC_USE_SYSTEM_THEME_ICONS,
RC_VIEWDVI_PAPEROPTION,
RC_VIEWER,
bool use_system_colors;
/// use native file dialog or our own ?
bool use_native_filedialog;
- /// Use pixmap cache?
- bool use_pixmap_cache;
/// Spellchecker engine: aspell, hunspell, etc
std::string spellchecker;
/// Alternate language for spellchecker
#include <QMimeData>
#include <QObject>
#include <QPixmap>
-#include <QPixmapCache>
#include <QRegExp>
#include <QSessionManager>
#include <QSettings>
guiApp = this;
- // Set the cache to 5120 kilobytes which corresponds to screen size of
- // 1280 by 1024 pixels with a color depth of 32 bits.
- QPixmapCache::setCacheLimit(5120);
-
// Initialize RC Fonts
if (lyxrc.roman_font_name.empty())
lyxrc.roman_font_name = fromqstr(romanFontName());
#include <algorithm>
-#include <QPixmapCache>
#include <QTextLayout>
-// Set USE_PIXMAP_CACHE to 1 for enabling the use of a Pixmap cache when
-// drawing text. This is especially useful for older PPC/Mac systems.
-#if defined(Q_WS_X11) || defined(QPA_XCB)
-#define USE_PIXMAP_CACHE 0
-#else
-#define USE_PIXMAP_CACHE 1
-#endif
-
using namespace std;
using namespace lyx::support;
const int Painter::thin_line = 1;
GuiPainter::GuiPainter(QPaintDevice * device, double pixel_ratio)
- : QPainter(device), Painter(pixel_ratio),
- use_pixmap_cache_(lyxrc.use_pixmap_cache && USE_PIXMAP_CACHE)
+ : QPainter(device), Painter(pixel_ratio)
{
// set cache correctly
current_color_ = pen().color();
}
-QString GuiPainter::generateStringSignature(QString const & str,
- FontInfo const & f,
- double wordspacing)
-{
- QString sig = str;
- sig.append(QChar(static_cast<short>(f.family())));
- sig.append(QChar(static_cast<short>(f.series())));
- sig.append(QChar(static_cast<short>(f.realShape())));
- sig.append(QChar(static_cast<short>(f.size())));
- Color const & color = f.realColor();
- sig.append(QChar(static_cast<short>(color.baseColor)));
- sig.append(QChar(static_cast<short>(color.mergeColor)));
- sig.append(QString::number(wordspacing));
- if (!monochrome_min_.empty()) {
- QColor const & min = monochrome_min_.top();
- QColor const & max = monochrome_max_.top();
- sig.append(QChar(static_cast<short>(min.red())));
- sig.append(QChar(static_cast<short>(min.green())));
- sig.append(QChar(static_cast<short>(min.blue())));
- sig.append(QChar(static_cast<short>(max.red())));
- sig.append(QChar(static_cast<short>(max.green())));
- sig.append(QChar(static_cast<short>(max.blue())));
- }
- return sig;
-}
-
-
QColor GuiPainter::computeColor(Color col)
{
return filterColor(guiApp->colorCache().get(col));
int textwidth = 0;
if (tw == 0.0)
- // Note that we have to take in account space stretching (word spacing)
+ // Take into account space stretching (word spacing)
textwidth = fm.width(s) +
static_cast<int>(fm.countExpanders(s) * wordspacing);
else
textDecoration(f, x, y, textwidth);
- if (use_pixmap_cache_) {
- QPixmap pm;
- QString key = generateStringSignature(str, f, wordspacing);
-
- // Warning: Left bearing is in general negative! Only the case
- // where left bearing is negative is of interest WRT the
- // pixmap width and the text x-position.
- // Only the left bearing of the first character is important
- // as we always write from left to right, even for
- // right-to-left languages.
- // FIXME: this is probably broken for RTL now that we draw full strings.
- // Morover the first/last element is possibly not the right one since the glyph may have changed.
- int const lb = min(fm.lbearing(s[0]), 0);
- int const mA = fm.maxAscent();
- if (QPixmapCache::find(key, pm)) {
- // Draw the cached pixmap.
- drawPixmap(x + lb, y - mA, pm);
- return;
- }
-
- // Only the right bearing of the last character is
- // important as we always write from left to right,
- // even for right-to-left languages.
- int const rb = fm.rbearing(s[s.size()-1]);
- int const w = textwidth + rb - lb;
- int const mD = fm.maxDescent();
- int const h = mA + mD;
- if (w > 0 && h > 0) {
- pm = QPixmap(static_cast<int>(pixelRatio() * w),
- static_cast<int>(pixelRatio() * h));
-#if QT_VERSION >= 0x050000
- pm.setDevicePixelRatio(pixelRatio());
-#endif
- pm.fill(Qt::transparent);
- GuiPainter p(&pm, pixelRatio());
- p.do_drawText(-lb, mA, str, dir, f, ff);
- QPixmapCache::insert(key, pm);
- //LYXERR(Debug::PAINTING, "h=" << h << " mA=" << mA << " mD=" << mD
- // << " w=" << w << " lb=" << lb << " tw=" << textwidth
- // << " rb=" << rb);
-
- // Draw the new cached pixmap.
- drawPixmap(x + lb, y - mA, pm);
- //rectangle(x-lb, y-mA, w, h, Color_green);
- }
- return;
- }
-
- // don't use the pixmap cache
setQPainterPen(computeColor(f.realColor()));
if (dir != Auto) {
shared_ptr<QTextLayout const> ptl =
Painter::line_style current_ls_;
int current_lw_;
///
- bool const use_pixmap_cache_;
- ///
std::stack<QColor> monochrome_min_;
///
std::stack<QColor> monochrome_max_;
QColor computeColor(Color col);
/// possibly apply monochrome mode
QColor filterColor(QColor const & col);
- ///
- QString generateStringSignature(QString const & str, FontInfo const & f,
- double wordspacing);
};
} // namespace frontend
#include <QHeaderView>
#include <QLineEdit>
#include <QMessageBox>
-#include <QPixmapCache>
#include <QPushButton>
#include <QSpinBox>
#include <QString>
this, SIGNAL(changed()));
connect(screenHugerED, SIGNAL(textChanged(QString)),
this, SIGNAL(changed()));
- connect(pixmapCacheCB, SIGNAL(toggled(bool)),
- this, SIGNAL(changed()));
screenTinyED->setValidator(new QDoubleValidator(screenTinyED));
screenSmallestED->setValidator(new QDoubleValidator(screenSmallestED));
rc.font_sizes[FONT_SIZE_LARGEST] = widgetToDoubleStr(screenLargestED);
rc.font_sizes[FONT_SIZE_HUGE] = widgetToDoubleStr(screenHugeED);
rc.font_sizes[FONT_SIZE_HUGER] = widgetToDoubleStr(screenHugerED);
- rc.use_pixmap_cache = pixmapCacheCB->isChecked();
if (rc.font_sizes != oldrc.font_sizes
|| rc.roman_font_name != oldrc.roman_font_name
|| rc.sans_font_name != oldrc.sans_font_name
|| rc.typewriter_font_name != oldrc.typewriter_font_name
|| rc.defaultZoom != oldrc.defaultZoom) {
- // The global QPixmapCache is used in GuiPainter to cache text
- // painting so we must reset it in case any of the above
- // parameter is changed.
- QPixmapCache::clear();
guiApp->fontLoader().update();
form_->updateScreenFonts();
}
screenZoomSB->setValue(rc.defaultZoom);
updateScreenFontSizes(rc);
-
- pixmapCacheCB->setChecked(rc.use_pixmap_cache);
-#if defined(Q_WS_X11) || defined(QPA_XCB)
- pixmapCacheCB->setEnabled(false);
-#endif
-
}
#include <QMovie>
#include <QPainter>
#include <QPixmap>
-#include <QPixmapCache>
#include <QPoint>
#include <QPushButton>
#include <QScrollBar>
dr.setMessage(bformat(_("Zoom level is now %1$d% (default value: %2$d%)"),
lyxrc.currentZoom, lyxrc.defaultZoom));
- // The global QPixmapCache is used in GuiPainter to cache text
- // painting so we must reset it.
- QPixmapCache::clear();
guiApp->fontLoader().update();
dr.screenUpdate(Update::Force | Update::FitCursor);
break;
</property>
</spacer>
</item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="pixmapCacheCB">
- <property name="toolTip">
- <string>Checking this improves performance, but might decrease the on-screen quality of fonts</string>
- </property>
- <property name="text">
- <string>&Use pixmap cache to speed up font rendering</string>
- </property>
- </widget>
- </item>
<item row="4" column="0">
<spacer>
<property name="orientation">