]> git.lyx.org Git - lyx.git/commitdiff
Introduce new USE_QIMAGE macro to optionally use a QImage drawing backend instead...
authorAbdelrazak Younes <younes@lyx.org>
Sun, 23 Oct 2011 06:52:03 +0000 (06:52 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 23 Oct 2011 06:52:03 +0000 (06:52 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39932 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea_Private.h

index dcf747bc3800d6a07ec9d160dc8768357c755302..4d5d2591770d7155f843040c825f94a1a1e0986e 100644 (file)
@@ -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();
 }
index b53d3d8b38314d1124bc3c1f0e188d42e5279669..ee7f1b3473056e1c3c3c2015ae80f6854578309a 100644 (file)
 #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"
 
 
 #include <QAbstractScrollArea>
 #include <QMouseEvent>
+#ifdef USE_QIMAGE
+#include <QImage>
+#else
 #include <QPixmap>
+#endif
 #include <QTimer>
 
 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_;