Remove resize hook from QSGRenderLoop, exposureChanged is enough.
authorGunnar Sletta <gunnar.sletta@digia.com>
Thu, 21 Feb 2013 10:16:58 +0000 (11:16 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 4 Apr 2013 17:46:51 +0000 (19:46 +0200)
After much back and forth, I think we have settled on the right approach
in QtGui, which is that resizeEvent is pretty much useless as the
action happens on the following exposeEvent().

Change-Id: I5e87bda89853907d041f56acf9a2895e540c41f0
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
src/quick/items/qquickwindow.cpp
src/quick/scenegraph/qsgrenderloop.cpp
src/quick/scenegraph/qsgrenderloop_p.h
src/quick/scenegraph/qsgthreadedrenderloop.cpp
src/quick/scenegraph/qsgthreadedrenderloop_p.h

index 176f46e..4789314 100644 (file)
@@ -207,8 +207,6 @@ void QQuickWindow::exposeEvent(QExposeEvent *)
 /*! \reimp */
 void QQuickWindow::resizeEvent(QResizeEvent *)
 {
-    Q_D(QQuickWindow);
-    d->windowManager->resize(this, size());
 }
 
 /*! \reimp */
index 16af79e..33a99d1 100644 (file)
@@ -95,7 +95,6 @@ public:
     void renderWindow(QQuickWindow *window);
     void exposureChanged(QQuickWindow *window);
     QImage grab(QQuickWindow *window);
-    void resize(QQuickWindow *window, const QSize &size);
 
     void maybeUpdate(QQuickWindow *window);
     void update(QQuickWindow *window) { maybeUpdate(window); } // identical for this implementation.
@@ -335,12 +334,6 @@ QImage QSGGuiThreadRenderLoop::grab(QQuickWindow *window)
 
 
 
-void QSGGuiThreadRenderLoop::resize(QQuickWindow *, const QSize &)
-{
-}
-
-
-
 void QSGGuiThreadRenderLoop::maybeUpdate(QQuickWindow *window)
 {
     if (!m_windows.contains(window))
index 2ec6de9..b18e6f0 100644 (file)
@@ -63,7 +63,6 @@ public:
 
     virtual void exposureChanged(QQuickWindow *window) = 0;
     virtual QImage grab(QQuickWindow *window) = 0;
-    virtual void resize(QQuickWindow *window, const QSize &size) = 0;
 
     virtual void update(QQuickWindow *window) = 0;
     virtual void maybeUpdate(QQuickWindow *window) = 0;
index 637e91d..b457c33 100644 (file)
@@ -168,9 +168,6 @@ const QEvent::Type WM_RequestSync       = QEvent::Type(QEvent::User + 4);
 // typically a result of QQuickWindow::update().
 const QEvent::Type WM_RequestRepaint    = QEvent::Type(QEvent::User + 5);
 
-// Passed by the RL to the RT when a window has changed size.
-const QEvent::Type WM_Resize            = QEvent::Type(QEvent::User + 6);
-
 // Passed by the RL to the RT to free up maybe release SG and GL contexts
 // if no windows are rendering.
 const QEvent::Type WM_TryRelease        = QEvent::Type(QEvent::User + 7);
@@ -213,14 +210,6 @@ public:
     bool inDestructor;
 };
 
-class WMResizeEvent : public WMWindowEvent
-{
-public:
-    WMResizeEvent(QQuickWindow *c, const QSize &s) : WMWindowEvent(c, WM_Resize), size(s) { }
-    QSize size;
-};
-
-
 class WMExposeEvent : public WMWindowEvent
 {
 public:
@@ -374,7 +363,8 @@ bool QSGRenderThread::event(QEvent *e)
 
         pendingUpdate |= RepaintRequest;
 
-        if (windowFor(m_windows, se->window)) {
+        if (Window *w = windowFor(m_windows, se->window)) {
+            w->size = se->size;
             RLDEBUG1("    Render:  - window already added...");
             return true;
         }
@@ -409,14 +399,6 @@ bool QSGRenderThread::event(QEvent *e)
             pendingUpdate |= SyncRequest;
         return true;
 
-    case WM_Resize: {
-        RLDEBUG("    Render: WM_Resize");
-        WMResizeEvent *re = static_cast<WMResizeEvent *>(e);
-        Window *w = windowFor(m_windows, re->window);
-        w->size = re->size;
-        // No need to wake up here as we will get a sync shortly.. (see QSGThreadedRenderLoop::resize());
-        return true; }
-
     case WM_TryRelease:
         RLDEBUG1("    Render: WM_TryRelease");
         mutex.lock();
@@ -1086,27 +1068,6 @@ QImage QSGThreadedRenderLoop::grab(QQuickWindow *window)
     return result;
 }
 
-/*
-    Notify the render thread that the window is now a new size. Then
-    locks GUI until render has adapted.
- */
-
-void QSGThreadedRenderLoop::resize(QQuickWindow *w, const QSize &size)
-{
-    RLDEBUG1("GUI: resize");
-
-    if (!m_thread->isRunning() || !m_windows.size() || !w->isExposed() || windowFor(m_windows, w) == 0) {
-        return;
-    }
-
-    if (size.width() == 0 || size.height() == 0)
-        return;
-
-    RLDEBUG("GUI:  - posting resize event...");
-    m_thread->postEvent(new WMResizeEvent(w, size));
-
-    polishAndSync();
-}
 
 #include "qsgthreadedrenderloop.moc"
 
index 63b2b44..aab0e87 100644 (file)
@@ -69,8 +69,6 @@ public:
 
     QImage grab(QQuickWindow *);
 
-    void resize(QQuickWindow *, const QSize &);
-
     void update(QQuickWindow *window);
     void maybeUpdate(QQuickWindow *window);
     QSGContext *sceneGraphContext() const;