]> git.lyx.org Git - features.git/commitdiff
Remove support for pixmap cache
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 7 Oct 2018 12:48:05 +0000 (14:48 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 12:39:50 +0000 (14:39 +0200)
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.

lib/RELEASE-NOTES
lib/configure.py
lib/scripts/prefs2prefs_prefs.py
src/LyXRC.cpp
src/LyXRC.h
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiPainter.cpp
src/frontends/qt4/GuiPainter.h
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/ui/PrefScreenFontsUi.ui

index 6e19d292ae7b7ab7b129a1aa41b195ab1001e15a..c834957aed58c72e929e4cca7469a5d9d8e46094 100644 (file)
@@ -29,6 +29,9 @@
 * \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.
index 05ee457c2371b465f4e5cb0302e3c2b34e2fad5e..1aaecb8b5bb01a3ed3b617fc4751aec357d8d633 100644 (file)
@@ -1798,7 +1798,7 @@ if __name__ == '__main__':
     lyx_check_config = True
     lyx_kpsewhich = True
     outfile = 'lyxrc.defaults'
-    lyxrc_fileformat = 27
+    lyxrc_fileformat = 29
     rc_entries = ''
     lyx_keep_temps = False
     version_suffix = ''
index 5e7c0bf62795c1c9ebf8e1bb7799aed73776cd58..06790723768a21f8a368ae934f2fe6b90201310b 100644 (file)
 # 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.
 
@@ -413,6 +416,11 @@ def remove_date_insert_format(line):
                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
 ####################################
 
@@ -455,5 +463,6 @@ conversions = [
        [ 25, [remove_use_qimage]],
        [ 26, [remove_font_encoding]],
        [ 27, []],
-       [ 28, [remove_date_insert_format]]
+       [ 28, [remove_date_insert_format]],
+       [ 29, [remove_use_pixmap_cache]]
 ]
index d11181fcc52c9c60f16018ce3a33673c6213e240..42dfad3731b7c4b057a9cb50ebafe92cf392b29e 100644 (file)
@@ -59,7 +59,7 @@ namespace {
 
 // 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 },
@@ -193,7 +193,6 @@ LexerKeyword lyxrcTags[] = {
        { "\\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 },
@@ -326,7 +325,6 @@ void LyXRC::setDefaults()
        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());
@@ -877,9 +875,6 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                case RC_USE_TOOLTIP:
                        lexrc >> use_tooltip;
                        break;
-               case RC_USE_PIXMAP_CACHE:
-                       lexrc >> use_pixmap_cache;
-                       break;
                case RC_SPELLCHECKER:
                        lexrc >> spellchecker;
                        break;
@@ -2414,16 +2409,6 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                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"
@@ -3005,7 +2990,6 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        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:
@@ -3419,10 +3403,6 @@ string const LyXRC::getDescription(LyXRCTags tag)
                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;
index 8a371d902c88e79d463fc5763c1795688e55c3b1..6e1ccfd7c8aa54b772b00de2ee911f962b31d509 100644 (file)
@@ -173,7 +173,6 @@ public:
                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,
@@ -333,8 +332,6 @@ public:
        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
index cbea58ad1c239f96cf7daf413237e8b5695c0bd8..c47610937bdb777bafc89d2644b8b215ccffd516 100644 (file)
 #include <QMimeData>
 #include <QObject>
 #include <QPixmap>
-#include <QPixmapCache>
 #include <QRegExp>
 #include <QSessionManager>
 #include <QSettings>
@@ -1078,10 +1077,6 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
 
        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());
index 2c6529a9381046fde8a9dfb9ea81cd7083f1c0ce..2f0cc8fa4b67a469d9d3dcf8658bc54c11537b94 100644 (file)
 
 #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;
 
@@ -49,8 +40,7 @@ namespace frontend {
 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();
@@ -93,33 +83,6 @@ void GuiPainter::setQPainterPen(QColor const & col,
 }
 
 
-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));
@@ -396,7 +359,7 @@ void GuiPainter::text(int x, int y, docstring const & s,
 
        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
@@ -404,55 +367,6 @@ void GuiPainter::text(int x, int y, docstring const & s,
 
        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 =
index 7513965ea6ec2df61cb7e49095e6440514980866..54b86e4744135b2165bc8e6049cd9bfe4705f1ad 100644 (file)
@@ -196,8 +196,6 @@ private:
        Painter::line_style current_ls_;
        int current_lw_;
        ///
-       bool const use_pixmap_cache_;
-       ///
        std::stack<QColor> monochrome_min_;
        ///
        std::stack<QColor> monochrome_max_;
@@ -205,9 +203,6 @@ private:
        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
index c08245c858d9c05535c4d36acbeb119dead7a9d8..afbce50e9431a68f5923c7ed0dc98a87d2959852 100644 (file)
@@ -61,7 +61,6 @@
 #include <QHeaderView>
 #include <QLineEdit>
 #include <QMessageBox>
-#include <QPixmapCache>
 #include <QPushButton>
 #include <QSpinBox>
 #include <QString>
@@ -995,8 +994,6 @@ PrefScreenFonts::PrefScreenFonts(GuiPreferences * form)
                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));
@@ -1033,17 +1030,12 @@ void PrefScreenFonts::applyRC(LyXRC & rc) const
        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();
        }
@@ -1065,12 +1057,6 @@ void PrefScreenFonts::updateRC(LyXRC const & rc)
 
        screenZoomSB->setValue(rc.defaultZoom);
        updateScreenFontSizes(rc);
-
-       pixmapCacheCB->setChecked(rc.use_pixmap_cache);
-#if defined(Q_WS_X11) || defined(QPA_XCB)
-       pixmapCacheCB->setEnabled(false);
-#endif
-
 }
 
 
index 2fb58deb846396b7290995b27a55e0e6e877e5ef..56f4f7b4c6d2119af50e1ae7b30d8a94b1a9ba10 100644 (file)
 #include <QMovie>
 #include <QPainter>
 #include <QPixmap>
-#include <QPixmapCache>
 #include <QPoint>
 #include <QPushButton>
 #include <QScrollBar>
@@ -4293,9 +4292,6 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        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;
index 2eaa4533602c23e37de10afb69a4f58aa39cad7b..24b91624d629035d61f55455169e6bdab23d3207 100644 (file)
      </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>&amp;Use pixmap cache to speed up font rendering</string>
-     </property>
-    </widget>
-   </item>
    <item row="4" column="0">
     <spacer>
      <property name="orientation">