linuxfb: don't store window in backingstore
authorGirish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Thu, 5 Jul 2012 15:36:14 +0000 (21:06 +0530)
committerQt by Nokia <qt-info@nokia.com>
Wed, 11 Jul 2012 10:42:52 +0000 (12:42 +0200)
The backing store already knows about the window.

Also, rename surface to backing store in QFbWindow.

Change-Id: I3701b3cdbdc228200da9b93b13037655dc436f53
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Reviewed-by: Thomas Senyk <thomas.senyk@nokia.com>
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
src/platformsupport/fbconvenience/qfbbackingstore.cpp
src/platformsupport/fbconvenience/qfbbackingstore_p.h
src/platformsupport/fbconvenience/qfbscreen.cpp
src/platformsupport/fbconvenience/qfbwindow.cpp
src/platformsupport/fbconvenience/qfbwindow_p.h
src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp

index e7d2bc8..80ba403 100644 (file)
 #include "qfbscreen_p.h"
 
 #include <qpa/qplatformwindow.h>
+#include <QtGui/qscreen.h>
 
 QT_BEGIN_NAMESPACE
 
-QFbBackingStore::QFbBackingStore(QFbScreen *screen, QWindow *window)
-    : QPlatformBackingStore(window),
-      mScreen(screen)
+QFbBackingStore::QFbBackingStore(QWindow *window)
+    : QPlatformBackingStore(window)
 {
-    mImage = QImage(window->size(), mScreen->format());
-
-    platformWindow = static_cast<QFbWindow*>(window->handle());
-    platformWindow->surface = this;
+    mImage = QImage(window->size(), window->screen()->handle()->format());
+    (static_cast<QFbWindow *>(window->handle()))->setBackingStore(this);
 }
 
 QFbBackingStore::~QFbBackingStore()
@@ -66,7 +64,7 @@ void QFbBackingStore::flush(QWindow *window, const QRegion &region, const QPoint
     Q_UNUSED(window);
     Q_UNUSED(offset);
 
-    platformWindow->repaint(region);
+    (static_cast<QFbWindow *>(window->handle()))->repaint(region);
 }
 
 void QFbBackingStore::resize(const QSize &size, const QRegion &region)
@@ -74,7 +72,7 @@ void QFbBackingStore::resize(const QSize &size, const QRegion &region)
     Q_UNUSED(region);
     // change the widget's QImage if this is a resize
     if (mImage.size() != size)
-        mImage = QImage(size, mScreen->format());
+        mImage = QImage(size, window()->screen()->handle()->format());
     // QPlatformBackingStore::resize(size);
 }
 
index 52a154b..a01e356 100644 (file)
@@ -53,7 +53,7 @@ class QWindow;
 class QFbBackingStore : public QPlatformBackingStore
 {
 public:
-    QFbBackingStore(QFbScreen *screen, QWindow *window);
+    QFbBackingStore(QWindow *window);
     ~QFbBackingStore();
 
     virtual QPaintDevice *paintDevice() { return &mImage; }
@@ -63,14 +63,13 @@ public:
     virtual void beginPaint(const QRegion &region);
     virtual void endPaint(const QRegion &region);
 
+    virtual void resize(const QSize &size, const QRegion &region);
+
     const QImage image() { return mImage; }
-    void resize(const QSize &size, const QRegion &region);
 
 protected:
     friend class QFbWindow;
-    QFbWindow *platformWindow;
 
-    QFbScreen *mScreen;
     QImage mImage;
 };
 
index 843300d..6656903 100644 (file)
@@ -223,7 +223,7 @@ QRegion QFbScreen::doRedraw()
                     QRect windowRect = windowStack[layerIndex]->geometry().translated(-screenOffset);
                     QRect windowIntersect = rect.translated(-windowRect.left(),
                                                             -windowRect.top());
-                    compositePainter->drawImage(rect, windowStack[layerIndex]->surface->image(),
+                    compositePainter->drawImage(rect, windowStack[layerIndex]->backingStore()->image(),
                                                 windowIntersect);
                     if (firstLayer) {
                         firstLayer = false;
index 4729f9d..f83f084 100644 (file)
@@ -91,7 +91,7 @@ Qt::WindowFlags QFbWindow::windowFlags() const
 }
 
 QFbWindow::QFbWindow(QWindow *window)
-    : QPlatformWindow(window), visibleFlag(false)
+    : QPlatformWindow(window), mBackingStore(0), visibleFlag(false)
 {
     static QAtomicInt winIdGenerator(1);
     windowId = winIdGenerator.fetchAndAddRelaxed(1);
index 81b6634..9f3b2bb 100644 (file)
@@ -68,13 +68,15 @@ public:
 
     WId winId() const { return windowId; }
 
+    void setBackingStore(QFbBackingStore *store) { mBackingStore = store; }
+    QFbBackingStore *backingStore() const { return mBackingStore; }
+
     virtual void repaint(const QRegion&);
 
 protected:
     friend class QFbScreen;
-    friend class QFbBackingStore;
 
-    QFbBackingStore *surface;
+    QFbBackingStore *mBackingStore;
     QList<QFbScreen *> mScreens;
     QRect oldGeometry;
     bool visibleFlag;
index 08cc02c..cdec49b 100644 (file)
@@ -804,8 +804,7 @@ QPlatformPixmap *QLinuxFbIntegration::createPlatformPixmap(QPlatformPixmap::Pixe
 
 QPlatformBackingStore *QLinuxFbIntegration::createPlatformBackingStore(QWindow *window) const
 {
-    QFbBackingStore *surface = new QFbBackingStore(mPrimaryScreen, window);
-    return surface;
+    return new QFbBackingStore(window);
 }
 
 QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWindow *window) const