Abdelrazak Younes wrote:
Juergen Spitzmueller wrote:
The attached patch implements a pref option to enable the pixmap cache on
Windows and the Mac (it is now disabled by default).
I cannot really test, since I'm on Linux. Could someone do this and check
that it works?
-bool const usePixmapCache = USE_PIXMAP_CACHE;
+bool const usePixmapCache = (lyxrc.use_pixmap_cache && USE_PIXMAP_CACHE);
This will require a restart to take the change into account. A static
member in QLPainter that you change in the prefs dialog should do the
trick.
Here is an updated patch that does that (untested).
Abdel.
Index: frontends/qt4/QLPainter.cpp
===================================================================
--- frontends/qt4/QLPainter.cpp (revision 21367)
+++ frontends/qt4/QLPainter.cpp (working copy)
@@ -23,6 +23,7 @@
#include "debug.h"
#include "Language.h"
#include "Color.h"
+#include "LyXRC.h"
#include "support/unicode.h"
@@ -43,9 +44,10 @@
namespace lyx {
namespace frontend {
+QLPainter::use_pixmap_cache_ = USE_PIXMAP_CACHE;
+
namespace {
-bool const usePixmapCache = USE_PIXMAP_CACHE;
QString generateStringSignature(QString const & str, Font const & f)
{
@@ -63,6 +65,8 @@
QLPainter::QLPainter(QPaintDevice * device)
: QPainter(device), Painter()
{
+ use_pixmap_cache_ |= lyxrc.use_pixmap_cache;
+
// new QPainter has default QPen:
current_color_ = Color::black;
current_ls_ = line_solid;
@@ -306,7 +310,7 @@
return textwidth;
}
- if (!usePixmapCache) {
+ if (!use_pixmap_cache_) {
// don't use the pixmap cache,
// draw directly onto the painting device
setQPainterPen(f.realColor());
Index: frontends/qt4/QLPainter.h
===================================================================
--- frontends/qt4/QLPainter.h (revision 21367)
+++ frontends/qt4/QLPainter.h (working copy)
@@ -111,6 +111,8 @@
Color::color current_color_;
Painter::line_style current_ls_;
Painter::line_width current_lw_;
+ ///
+ static bool const use_pixmap_cache_;
};
} // namespace frontend
Index: frontends/qt4/QPrefs.cpp
===================================================================
--- frontends/qt4/QPrefs.cpp (revision 21367)
+++ frontends/qt4/QPrefs.cpp (working copy)
@@ -1813,6 +1813,8 @@
this, SIGNAL(changed()));
connect(lastfilesSB, SIGNAL(valueChanged(int)),
this, SIGNAL(changed()));
+ connect(pixmapCacheCB, SIGNAL(toggled(bool)),
+ this, SIGNAL(changed()));
lastfilesSB->setMaximum(maxlastfiles);
}
@@ -1835,6 +1837,7 @@
rc.autosave = autoSaveSB->value() * 60;
rc.make_backup = autoSaveCB->isChecked();
rc.num_lastfiles = lastfilesSB->value();
+ rc.use_pixmap_cache = pixmapCacheCB->isChecked();
}
@@ -1859,6 +1862,10 @@
autoSaveSB->setValue(mins);
autoSaveCB->setChecked(rc.make_backup);
lastfilesSB->setValue(rc.num_lastfiles);
+ pixmapCacheCB->setChecked(rc.use_pixmap_cache);
+#if (QT_VERSION < 0x040200) || defined(Q_WS_X11)
+ pixmapCacheGB->setEnabled(false);
+#endif
}
Index: frontends/qt4/ui/PrefUi.ui
===================================================================
--- frontends/qt4/ui/PrefUi.ui (revision 21367)
+++ frontends/qt4/ui/PrefUi.ui (working copy)
@@ -5,14 +5,12 @@
<rect>
<x>0</x>
<y>0</y>
- <width>459</width>
- <height>425</height>
+ <width>464</width>
+ <height>497</height>
</rect>
</property>
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>1</vsizetype>
+ <sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -21,70 +19,6 @@
<string/>
</property>
<layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="3" column="2" colspan="2" >
- <widget class="QGroupBox" name="scrollGB" >
- <property name="title" >
- <string>Scrolling</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>11</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QCheckBox" name="cursorFollowsCB" >
- <property name="text" >
- <string>Cursor follows &scrollbar</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item row="4" column="1" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="3" >
- <widget class="QPushButton" name="bindFilePB" >
- <property name="text" >
- <string>B&rowse...</string>
- </property>
- </widget>
- </item>
<item row="0" column="0" >
<widget class="QLabel" name="uiFileLA" >
<property name="text" >
@@ -95,6 +29,16 @@
</property>
</widget>
</item>
+ <item row="0" column="1" colspan="2" >
+ <widget class="QLineEdit" name="uiFileED" />
+ </item>
+ <item row="0" column="3" >
+ <widget class="QPushButton" name="uiFilePB" >
+ <property name="text" >
+ <string>Bro&wse...</string>
+ </property>
+ </widget>
+ </item>
<item row="1" column="0" >
<widget class="QLabel" name="bindFileLA" >
<property name="text" >
@@ -105,25 +49,20 @@
</property>
</widget>
</item>
- <item row="0" column="1" colspan="2" >
- <widget class="QLineEdit" name="uiFileED" />
+ <item row="1" column="1" colspan="2" >
+ <widget class="QLineEdit" name="bindFileED" />
</item>
- <item row="0" column="3" >
- <widget class="QPushButton" name="uiFilePB" >
+ <item row="1" column="3" >
+ <widget class="QPushButton" name="bindFilePB" >
<property name="text" >
- <string>Bro&wse...</string>
+ <string>B&rowse...</string>
</property>
</widget>
</item>
- <item row="1" column="1" colspan="2" >
- <widget class="QLineEdit" name="bindFileED" />
- </item>
<item row="2" column="0" colspan="4" >
<widget class="QGroupBox" name="GeometryGB" >
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>5</vsizetype>
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -132,12 +71,24 @@
<string>Session</string>
</property>
<layout class="QGridLayout" >
- <property name="margin" >
+ <property name="leftMargin" >
<number>9</number>
</property>
- <property name="spacing" >
+ <property name="topMargin" >
+ <number>9</number>
+ </property>
+ <property name="rightMargin" >
+ <number>9</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>9</number>
+ </property>
+ <property name="horizontalSpacing" >
<number>6</number>
</property>
+ <property name="verticalSpacing" >
+ <number>6</number>
+ </property>
<item row="0" column="0" colspan="2" >
<widget class="QCheckBox" name="loadWindowSizeCB" >
<property name="text" >
@@ -190,12 +141,21 @@
</item>
<item row="1" column="0" >
<layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
<property name="spacing" >
<number>6</number>
</property>
+ <property name="leftMargin" >
+ <number>0</number>
+ </property>
+ <property name="topMargin" >
+ <number>0</number>
+ </property>
+ <property name="rightMargin" >
+ <number>0</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>0</number>
+ </property>
<item>
<spacer>
<property name="orientation" >
@@ -227,12 +187,12 @@
<property name="enabled" >
<bool>false</bool>
</property>
+ <property name="minimum" >
+ <number>200</number>
+ </property>
<property name="maximum" >
<number>9999</number>
</property>
- <property name="minimum" >
- <number>200</number>
- </property>
<property name="singleStep" >
<number>10</number>
</property>
@@ -253,12 +213,12 @@
<property name="enabled" >
<bool>false</bool>
</property>
+ <property name="minimum" >
+ <number>200</number>
+ </property>
<property name="maximum" >
<number>9999</number>
</property>
- <property name="minimum" >
- <number>200</number>
- </property>
<property name="singleStep" >
<number>10</number>
</property>
@@ -285,18 +245,27 @@
</layout>
</widget>
</item>
- <item row="3" column="0" colspan="2" >
+ <item rowspan="2" row="3" column="0" colspan="2" >
<widget class="QGroupBox" name="documentsGB" >
<property name="title" >
<string>Documents</string>
</property>
<layout class="QVBoxLayout" >
- <property name="margin" >
- <number>11</number>
- </property>
<property name="spacing" >
<number>6</number>
</property>
+ <property name="leftMargin" >
+ <number>11</number>
+ </property>
+ <property name="topMargin" >
+ <number>11</number>
+ </property>
+ <property name="rightMargin" >
+ <number>11</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>11</number>
+ </property>
<item>
<widget class="QCheckBox" name="autoSaveCB" >
<property name="text" >
@@ -306,12 +275,21 @@
</item>
<item>
<layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
<property name="spacing" >
<number>6</number>
</property>
+ <property name="leftMargin" >
+ <number>0</number>
+ </property>
+ <property name="topMargin" >
+ <number>0</number>
+ </property>
+ <property name="rightMargin" >
+ <number>0</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>0</number>
+ </property>
<item>
<spacer>
<property name="orientation" >
@@ -340,12 +318,12 @@
</item>
<item>
<widget class="QSpinBox" name="autoSaveSB" >
+ <property name="minimum" >
+ <number>1</number>
+ </property>
<property name="maximum" >
<number>300</number>
</property>
- <property name="minimum" >
- <number>1</number>
- </property>
</widget>
</item>
<item>
@@ -359,12 +337,21 @@
</item>
<item>
<layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
<property name="spacing" >
<number>6</number>
</property>
+ <property name="leftMargin" >
+ <number>0</number>
+ </property>
+ <property name="topMargin" >
+ <number>0</number>
+ </property>
+ <property name="rightMargin" >
+ <number>0</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>0</number>
+ </property>
<item>
<widget class="QLabel" name="lastfilesLA" >
<property name="text" >
@@ -387,6 +374,85 @@
</layout>
</widget>
</item>
+ <item row="3" column="2" colspan="2" >
+ <widget class="QGroupBox" name="scrollGB" >
+ <property name="title" >
+ <string>Scrolling</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <layout class="QVBoxLayout" >
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <property name="leftMargin" >
+ <number>11</number>
+ </property>
+ <property name="topMargin" >
+ <number>11</number>
+ </property>
+ <property name="rightMargin" >
+ <number>11</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="cursorFollowsCB" >
+ <property name="text" >
+ <string>Cursor follows &scrollbar</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="4" column="2" colspan="2" >
+ <widget class="QGroupBox" name="pixmapCacheGB" >
+ <property name="title" >
+ <string>Pixmap Cache</string>
+ </property>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QCheckBox" name="pixmapCacheCB" >
+ <property name="toolTip" >
+ <string>Checking this improves the performance, but might reduce the
on-screen display of fonts</string>
+ </property>
+ <property name="text" >
+ <string>Enable Pi&xmap Cache</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="5" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>94</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
<tabstops>
Index: LyXRC.cpp
===================================================================
--- LyXRC.cpp (revision 21367)
+++ LyXRC.cpp (working copy)
@@ -164,6 +164,7 @@
{ "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
{ "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
{ "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
+ { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
// compatibility with versions older than 1.4.0 only
{ "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
{ "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
@@ -278,6 +279,7 @@
preview_hashed_labels = false;
preview_scale_factor = "0.9";
use_converter_cache = true;
+ use_pixmap_cache = false;
converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
user_name = to_utf8(support::user_name());
@@ -893,6 +895,11 @@
isp_use_pers_dict = lexrc.getBool();
}
break;
+ case RC_USE_PIXMAP_CACHE:
+ if (lexrc.next()) {
+ use_pixmap_cache = lexrc.getBool();
+ }
+ break;
case RC_USE_ESC_CHARS:
if (lexrc.next()) {
isp_use_esc_chars = lexrc.getBool();
@@ -1869,6 +1876,13 @@
<< convert<string>(isp_use_pers_dict)
<< '\n';
}
+ 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';
+ }
case RC_PERS_DICT:
if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
string const path = os::external_path(isp_pers_dict);
@@ -2266,6 +2280,10 @@
str = _("Specify an alternate personal dictionary file. E.g.
\".ispell_english\".");
break;
+ case RC_USE_PIXMAP_CHACHE:
+ str = _("Enable the pixmap cache that might improve performance
on Mac and Windows.");
+ break;
+
case RC_PREVIEW:
str = _("Shows a typeset preview of things such as math");
break;
Index: LyXRC.h
===================================================================
--- LyXRC.h (revision 21367)
+++ LyXRC.h (working copy)
@@ -139,6 +139,7 @@
RC_USE_ESC_CHARS,
RC_USE_INP_ENC,
RC_USE_PERS_DICT,
+ RC_USE_PIXMAP_CACHE,
RC_USE_SPELL_LIB,
RC_VIEWDVI_PAPEROPTION,
RC_VIEWER,
@@ -289,6 +290,8 @@
bool isp_use_alt_lang;
/// Use personal dictionary?
bool isp_use_pers_dict;
+ /// Use pixmap cache?
+ bool use_pixmap_cache;
/// Use escape chars?
bool isp_use_esc_chars;
/// Alternate language for ispell