Introduce new RC option for QImage backend instead of macro. This can later be changed at runtime though a command line option or by auto detecting the X11 remote status.

This option is set to true by default as this is the most widespread use case.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40515 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2011-12-17 21:53:46 +00:00
parent 38f1106255
commit c5c0c22f6b
4 changed files with 39 additions and 32 deletions

View File

@ -199,6 +199,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE }, { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
{ "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS }, { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
{ "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE }, { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
{ "\\use_qimage", LyXRC::RC_USE_QIMAGE },
// compatibility with versions older than 1.4.0 only // compatibility with versions older than 1.4.0 only
{ "\\use_system_colors", LyXRC::RC_USE_SYSTEM_COLORS }, { "\\use_system_colors", LyXRC::RC_USE_SYSTEM_COLORS },
{ "\\use_tooltip", LyXRC::RC_USE_TOOLTIP }, { "\\use_tooltip", LyXRC::RC_USE_TOOLTIP },
@ -337,6 +338,7 @@ void LyXRC::setDefaults()
use_system_colors = false; use_system_colors = false;
use_tooltip = true; use_tooltip = true;
use_pixmap_cache = false; use_pixmap_cache = false;
use_qimage = true;
converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
user_name = to_utf8(support::user_name()); user_name = to_utf8(support::user_name());
user_email = to_utf8(support::user_email()); user_email = to_utf8(support::user_email());
@ -951,6 +953,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
case RC_USE_PIXMAP_CACHE: case RC_USE_PIXMAP_CACHE:
lexrc >> use_pixmap_cache; lexrc >> use_pixmap_cache;
break; break;
case RC_USE_QIMAGE:
lexrc >> use_qimage;
break;
case RC_SPELLCHECKER: case RC_SPELLCHECKER:
lexrc >> spellchecker; lexrc >> spellchecker;
break; break;
@ -2439,6 +2444,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
} }
if (tag != RC_LAST) if (tag != RC_LAST)
break; break;
case RC_USE_QIMAGE:
if (ignore_system_lyxrc ||
use_qimage != system_lyxrc.use_qimage) {
os << "\\use_qimage "
<< convert<string>(use_qimage)
<< '\n';
}
if (tag != RC_LAST)
break;
os << "\n#\n" os << "\n#\n"
<< "# LANGUAGE SUPPORT SECTION ##########################\n" << "# LANGUAGE SUPPORT SECTION ##########################\n"
@ -2993,6 +3007,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
case LyXRC::RC_USE_SYSTEM_COLORS: case LyXRC::RC_USE_SYSTEM_COLORS:
case LyXRC::RC_USE_TOOLTIP: case LyXRC::RC_USE_TOOLTIP:
case LyXRC::RC_USE_PIXMAP_CACHE: case LyXRC::RC_USE_PIXMAP_CACHE:
case LyXRC::RC_USE_QIMAGE:
case LyXRC::RC_VIEWDVI_PAPEROPTION: case LyXRC::RC_VIEWDVI_PAPEROPTION:
case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON: case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
case LyXRC::RC_SINGLE_INSTANCE: case LyXRC::RC_SINGLE_INSTANCE:

View File

@ -185,6 +185,7 @@ public:
RC_USE_SYSTEM_COLORS, RC_USE_SYSTEM_COLORS,
RC_USE_TOOLTIP, RC_USE_TOOLTIP,
RC_USE_PIXMAP_CACHE, RC_USE_PIXMAP_CACHE,
RC_USE_QIMAGE,
RC_VIEWDVI_PAPEROPTION, RC_VIEWDVI_PAPEROPTION,
RC_VIEWER, RC_VIEWER,
RC_VIEWER_ALTERNATIVES, RC_VIEWER_ALTERNATIVES,
@ -361,6 +362,8 @@ public:
bool use_system_colors; bool use_system_colors;
/// Use pixmap cache? /// Use pixmap cache?
bool use_pixmap_cache; bool use_pixmap_cache;
/// Use QImage backend?
bool use_qimage;
/// Spellchecker engine: aspell, hunspell, etc /// Spellchecker engine: aspell, hunspell, etc
std::string spellchecker; std::string spellchecker;
/// Alternate language for spellchecker /// Alternate language for spellchecker

View File

@ -237,7 +237,7 @@ SyntheticMouseEvent::SyntheticMouseEvent()
GuiWorkArea::Private::Private(GuiWorkArea * parent) GuiWorkArea::Private::Private(GuiWorkArea * parent)
: p(parent), buffer_view_(0), lyx_view_(0), cursor_visible_(false), : p(parent), screen_(0), buffer_view_(0), lyx_view_(0), cursor_visible_(false),
need_resize_(false), schedule_redraw_(false), preedit_lines_(1), need_resize_(false), schedule_redraw_(false), preedit_lines_(1),
completer_(new GuiCompleter(p, p)) completer_(new GuiCompleter(p, p))
{ {
@ -319,6 +319,7 @@ void GuiWorkArea::init()
GuiWorkArea::~GuiWorkArea() GuiWorkArea::~GuiWorkArea()
{ {
d->buffer_view_->buffer().workAreaManager().remove(this); d->buffer_view_->buffer().workAreaManager().remove(this);
delete d->screen_;
delete d->buffer_view_; delete d->buffer_view_;
delete d->cursor_; delete d->cursor_;
// Completer has a QObject parent and is thus automatically destroyed. // Completer has a QObject parent and is thus automatically destroyed.
@ -1120,11 +1121,11 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
} }
QPainter pain(viewport()); QPainter pain(viewport());
#ifdef USE_QIMAGE if (lyxrc.use_qimage) {
pain.drawImage(rc, d->screen_, rc); pain.drawImage(rc, static_cast<QImage const &>(*d->screen_), rc);
#else } else {
pain.drawPixmap(rc, d->screen_, rc); pain.drawPixmap(rc, static_cast<QPixmap const &>(*d->screen_), rc);
#endif }
d->cursor_->draw(pain); d->cursor_->draw(pain);
ev->accept(); ev->accept();
} }
@ -1132,7 +1133,7 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev)
void GuiWorkArea::Private::updateScreen() void GuiWorkArea::Private::updateScreen()
{ {
GuiPainter pain(&screen_); GuiPainter pain(screen_);
buffer_view_->draw(pain); buffer_view_->draw(pain);
} }
@ -1204,7 +1205,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
return; return;
} }
GuiPainter pain(&d->screen_); GuiPainter pain(d->screen_);
d->buffer_view_->updateMetrics(); d->buffer_view_->updateMetrics();
d->buffer_view_->draw(pain); d->buffer_view_->draw(pain);
FontInfo font = d->buffer_view_->cursor().getFont().fontInfo(); FontInfo font = d->buffer_view_->cursor().getFont().fontInfo();

View File

@ -12,24 +12,17 @@
#ifndef WORKAREA_PRIVATE_H #ifndef WORKAREA_PRIVATE_H
#define WORKAREA_PRIVATE_H #define WORKAREA_PRIVATE_H
// Comment out to use QImage backend instead of QPixmap. This won't have any
// effect on Windows, MacOSX and most X11 environment when running locally.
// When running remotely on X11, this may have a big performance penalty.
//#define USE_QIMAGE
#include "FuncRequest.h" #include "FuncRequest.h"
#include "qt_helpers.h" #include "qt_helpers.h"
#include "LyXRC.h"
#include "support/docstring.h" #include "support/docstring.h"
#include "support/Timeout.h" #include "support/Timeout.h"
#include <QAbstractScrollArea> #include <QAbstractScrollArea>
#include <QMouseEvent> #include <QMouseEvent>
#ifdef USE_QIMAGE
#include <QImage> #include <QImage>
#else
#include <QPixmap> #include <QPixmap>
#endif
#include <QTimer> #include <QTimer>
class QContextMenuEvent; class QContextMenuEvent;
@ -109,11 +102,11 @@ struct GuiWorkArea::Private
void resizeBufferView(); void resizeBufferView();
/// paint the cursor and store the background /// paint the cursor and store the background
virtual void showCursor(int x, int y, int h, void showCursor(int x, int y, int h,
bool l_shape, bool rtl, bool completable); bool l_shape, bool rtl, bool completable);
/// hide the cursor /// hide the cursor
virtual void removeCursor(); void removeCursor();
/// ///
void dispatch(FuncRequest const & cmd0, KeyModifier = NoModifier); void dispatch(FuncRequest const & cmd0, KeyModifier = NoModifier);
/// hide the visible cursor, if it is visible /// hide the visible cursor, if it is visible
@ -127,25 +120,20 @@ struct GuiWorkArea::Private
/// ///
void setCursorShape(Qt::CursorShape shape); void setCursorShape(Qt::CursorShape shape);
#ifdef USE_QIMAGE
void resetScreen() void resetScreen()
{ {
screen_ = QImage(p->viewport()->width(), p->viewport()->height(), delete screen_;
QImage::Format_ARGB32_Premultiplied); if (lyxrc.use_qimage) {
screen_ = new QImage(p->viewport()->width(), p->viewport()->height(),
QImage::Format_ARGB32_Premultiplied);
} else {
screen_ = new QPixmap(p->viewport()->width(), p->viewport()->height());
}
} }
QImage screen_;
#else
void resetScreen()
{
screen_ = QPixmap(p->viewport()->width(), p->viewport()->height());
}
QPixmap screen_;
#endif
/// ///
GuiWorkArea * p; GuiWorkArea * p;
///
QPaintDevice * screen_;
/// ///
BufferView * buffer_view_; BufferView * buffer_view_;
/// Read only Buffer status cache. /// Read only Buffer status cache.