From: Abdelrazak Younes Date: Sun, 23 Oct 2011 06:52:03 +0000 (+0000) Subject: Introduce new USE_QIMAGE macro to optionally use a QImage drawing backend instead... X-Git-Tag: 2.1.0beta1~2531 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=383b31a86881336c012c2706580f319355b0688f;p=features.git Introduce new USE_QIMAGE macro to optionally use a QImage drawing backend instead of a QPixmap. This may help when running locally under X11 with some graphics cards (there were some complain about that in the user list). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39932 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index dcf747bc38..4d5d259177 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -274,7 +274,7 @@ void GuiWorkArea::init() d->cursor_timeout_.setInterval(500); } - d->screen_ = QPixmap(viewport()->width(), viewport()->height()); + d->resetScreen(); // With Qt4.5 a mouse event will happen before the first paint event // so make sure that the buffer view has an up to date metrics. d->buffer_view_->resize(viewport()->width(), viewport()->height()); @@ -1101,7 +1101,7 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev) // << " y: " << rc.y() << " w: " << rc.width() << " h: " << rc.height()); if (d->need_resize_) { - d->screen_ = QPixmap(viewport()->width(), viewport()->height()); + d->resetScreen(); d->resizeBufferView(); if (d->cursor_visible_) { d->hideCursor(); @@ -1110,7 +1110,11 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev) } QPainter pain(viewport()); +#ifdef USE_QIMAGE + pain.drawImage(rc, d->screen_, rc); +#else pain.drawPixmap(rc, d->screen_, rc); +#endif d->cursor_->draw(pain); ev->accept(); } diff --git a/src/frontends/qt4/GuiWorkArea_Private.h b/src/frontends/qt4/GuiWorkArea_Private.h index b53d3d8b38..ee7f1b3473 100644 --- a/src/frontends/qt4/GuiWorkArea_Private.h +++ b/src/frontends/qt4/GuiWorkArea_Private.h @@ -12,6 +12,11 @@ #ifndef 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 "qt_helpers.h" @@ -20,7 +25,11 @@ #include #include +#ifdef USE_QIMAGE +#include +#else #include +#endif #include class QContextMenuEvent; @@ -117,6 +126,23 @@ struct GuiWorkArea::Private void updateCursorShape(); /// void setCursorShape(Qt::CursorShape shape); + +#ifdef USE_QIMAGE + void resetScreen() + { + screen_ = QImage(p->viewport()->width(), p->viewport()->height(), + QImage::Format_ARGB32_Premultiplied); + } + + QImage screen_; +#else + void resetScreen() + { + screen_ = QPixmap(p->viewport()->width(), p->viewport()->height()); + } + + QPixmap screen_; +#endif /// GuiWorkArea * p; @@ -139,8 +165,6 @@ struct GuiWorkArea::Private /// CursorWidget * cursor_; /// - QPixmap screen_; - /// bool need_resize_; /// bool schedule_redraw_;