]> git.lyx.org Git - features.git/commitdiff
Revert "backing store"
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 25 Jun 2019 14:03:35 +0000 (16:03 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 1 Jul 2019 08:38:16 +0000 (10:38 +0200)
This is not ready yet.

This reverts commit 1a2b1a3bfad7ce48e2a025d3a3dab7103fd0039c.

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

index 5c0ae40e2233c8281c4c626d39f9bb9d29823c4c..7955731ad36ed06432efa1a5df93e56f8ff81840 100644 (file)
@@ -235,27 +235,13 @@ SyntheticMouseEvent::SyntheticMouseEvent()
 
 
 GuiWorkArea::Private::Private(GuiWorkArea * parent)
-: p(parent), buffer_view_(0), lyx_view_(0), caret_(0),
-  caret_visible_(false), need_resize_(false), preedit_lines_(1),
-  last_pixel_ratio_(1.0), completer_(new GuiCompleter(p, p)),
-  dialog_mode_(false), shell_escape_(false), read_only_(false),
-  clean_(true), externally_modified_(false)
-{
-/* Qt on macOS and Wayland does not respect the
- * Qt::WA_OpaquePaintEvent attribute and resets the widget backing
- * store at each update. Therefore, we use our own backing store in
- * these two cases. */
-#if QT_VERSION >= 0x050000
-       use_backingstore_ = guiApp->platformName() == "cocoa"
-                           || guiApp->platformName() == "wayland";
-#else
-#  ifdef Q_OS_MAC
-       use_backingstore_ = true;
-#  else
-       use_backingstore_ = false;
-#  endif
-#endif
-
+: p(parent), buffer_view_(0), lyx_view_(0),
+  caret_(0), caret_visible_(false),
+  need_resize_(false), preedit_lines_(1),
+  last_pixel_ratio_(1.0),
+  completer_(new GuiCompleter(p, p)), dialog_mode_(false), shell_escape_(false),
+  read_only_(false), clean_(true), externally_modified_(false)
+{
        int const time = QApplication::cursorFlashTime() / 2;
        if (time > 0) {
                caret_timeout_.setInterval(time);
@@ -1275,41 +1261,6 @@ void GuiWorkArea::Private::paintPreeditText(GuiPainter & pain)
 }
 
 
-void GuiWorkArea::Private::resetScreen()
-{
-       if (use_backingstore_) {
-               int const pr = p->pixelRatio();
-               screen_ = QImage(static_cast<int>(pr * p->viewport()->width()),
-                                static_cast<int>(pr * p->viewport()->height()),
-                                QImage::Format_ARGB32_Premultiplied);
-#  if QT_VERSION >= 0x050000
-               screen_.setDevicePixelRatio(pr);
-#  endif
-       }
-}
-
-
-QPaintDevice * GuiWorkArea::Private::screenDevice()
-{
-       if (use_backingstore_)
-               return &screen_;
-       else
-               return p->viewport();
-}
-
-
-void GuiWorkArea::Private::updateScreen(QRectF const & rc)
-{
-       if (use_backingstore_) {
-               QPainter qpain(p->viewport());
-               double const pr = p->pixelRatio();
-               QRectF const rcs = QRectF(rc.x() * pr, rc.y() * pr,
-                                         rc.width() * pr, rc.height() * pr);
-               qpain.drawImage(rc, screen_, rcs);
-       }
-}
-
-
 void GuiWorkArea::paintEvent(QPaintEvent * ev)
 {
        // Do not trigger the painting machinery if we are not ready (see
index 6342eaba4ac153fc7b1bf6201453ba39f5bd140b..83012fa99f10123329936de2a27f254a7387d87e 100644 (file)
 #include <QMouseEvent>
 #include <QTimer>
 
+#ifdef Q_OS_MAC
+/* Qt on macOS does not respect the Qt::WA_OpaquePaintEvent attribute
+ * and resets the widget backing store at each update. Therefore, we
+ * use our own backing store in this case */
+#define LYX_BACKINGSTORE 1
+#include <QPainter>
+#endif
+
 namespace lyx {
 
 class Buffer;
@@ -99,12 +107,37 @@ struct GuiWorkArea::Private
 
        void paintPreeditText(GuiPainter & pain);
 
-       /// Prepare screen for next painting
-       void resetScreen();
-       /// Where painting takes place
-       QPaintDevice * screenDevice();
-       /// Put backingstore to screen if necessary
-       void updateScreen(QRectF const & rc);
+       void resetScreen() {
+#ifdef LYX_BACKINGSTORE
+               int const pr = p->pixelRatio();
+               screen_ = QImage(static_cast<int>(pr * p->viewport()->width()),
+                                static_cast<int>(pr * p->viewport()->height()),
+                                QImage::Format_ARGB32_Premultiplied);
+#  if QT_VERSION >= 0x050000
+               screen_.setDevicePixelRatio(pr);
+#  endif
+#endif
+       }
+
+       QPaintDevice * screenDevice() {
+#ifdef LYX_BACKINGSTORE
+               return &screen_;
+#else
+               return p->viewport();
+#endif
+       }
+
+#ifdef LYX_BACKINGSTORE
+       void updateScreen(QRectF const & rc) {
+               QPainter qpain(p->viewport());
+               double const pr = p->pixelRatio();
+               QRectF const rcs = QRectF(rc.x() * pr, rc.y() * pr,
+                                         rc.width() * pr, rc.height() * pr);
+               qpain.drawImage(rc, screen_, rcs);
+       }
+#else
+       void updateScreen(QRectF const & ) {}
+#endif
 
        ///
        GuiWorkArea * p;
@@ -113,11 +146,10 @@ struct GuiWorkArea::Private
        ///
        GuiView * lyx_view_;
 
-       /// Do we need an intermediate image when painting (for now macOS and Wayland)
-       bool use_backingstore_;
+#ifdef LYX_BACKINGSTORE
        ///
        QImage screen_;
-
+#endif
        ///
        CaretWidget * caret_;
        /// is the caret currently displayed