src/gui/painting/qbackingstore.cpp
changeset 30 5dc02b23752f
parent 19 fcece45ef507
child 33 3e2da88830cd
--- a/src/gui/painting/qbackingstore.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/gui/painting/qbackingstore.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -263,7 +263,7 @@
 {
     const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft()));
     const QRect tlwRect(QRect(pos, rect.size()));
-    if (dirty.intersects(tlwRect))
+    if (fullUpdatePending || dirty.intersects(tlwRect))
         return false; // We don't want to scroll junk.
     return windowSurface->scroll(tlwRect, dx, dy);
 }
@@ -402,7 +402,7 @@
     const bool widgetDirty = widget && widget != tlw;
     const QRect tlwRect(topLevelRect());
     const QRect surfaceGeometry(windowSurface->geometry());
-    if (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size()) {
+    if (fullUpdatePending || (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size())) {
         if (widgetDirty) {
             const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size());
             const QPoint offset(widget->mapTo(tlw, QPoint()));
@@ -555,6 +555,18 @@
         return;
     }
 
+    if (fullUpdatePending) {
+        if (updateImmediately)
+            sendUpdateRequest(tlw, updateImmediately);
+        return;
+    }
+
+    if (!windowSurface->hasPartialUpdateSupport()) {
+        fullUpdatePending = true;
+        sendUpdateRequest(tlw, updateImmediately);
+        return;
+    }
+
     const QPoint offset = widget->mapTo(tlw, QPoint());
     const QRect widgetRect = widget->d_func()->effectiveRectFor(widget->rect());
     if (qt_region_strictContains(dirty, widgetRect.translated(offset))) {
@@ -638,6 +650,18 @@
         return;
     }
 
+    if (fullUpdatePending) {
+        if (updateImmediately)
+            sendUpdateRequest(tlw, updateImmediately);
+        return;
+    }
+
+    if (!windowSurface->hasPartialUpdateSupport()) {
+        fullUpdatePending = true;
+        sendUpdateRequest(tlw, updateImmediately);
+        return;
+    }
+
     const QRect widgetRect = widget->d_func()->effectiveRectFor(rect);
     const QRect translatedRect(widgetRect.translated(widget->mapTo(tlw, QPoint())));
     if (qt_region_strictContains(dirty, translatedRect)) {
@@ -833,6 +857,7 @@
 
 QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel)
     : tlw(topLevel), dirtyOnScreenWidgets(0), hasDirtyFromPreviousSync(false)
+    , fullUpdatePending(0)
 {
     windowSurface = tlw->windowSurface();
     if (!windowSurface)
@@ -1122,6 +1147,7 @@
             for (int i = 0; i < dirtyWidgets.size(); ++i)
                 resetWidget(dirtyWidgets.at(i));
             dirtyWidgets.clear();
+            fullUpdatePending = false;
         }
         return;
     }
@@ -1132,27 +1158,27 @@
     const QRect surfaceGeometry(windowSurface->geometry());
     bool repaintAllWidgets = false;
 
-    if (inTopLevelResize || surfaceGeometry != tlwRect) {
-        if ((inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
-            if (hasStaticContents()) {
-                // Repaint existing dirty area and newly visible area.
-                const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
-                const QRegion staticRegion(staticContents(0, clipRect));
-                QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height());
-                newVisible -= staticRegion;
-                dirty += newVisible;
-                windowSurface->setStaticContents(staticRegion);
-            } else {
-                // Repaint everything.
-                dirty = QRegion(0, 0, tlwRect.width(), tlwRect.height());
-                for (int i = 0; i < dirtyWidgets.size(); ++i)
-                    resetWidget(dirtyWidgets.at(i));
-                dirtyWidgets.clear();
-                repaintAllWidgets = true;
-            }
+    if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
+        if (hasStaticContents()) {
+            // Repaint existing dirty area and newly visible area.
+            const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
+            const QRegion staticRegion(staticContents(0, clipRect));
+            QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height());
+            newVisible -= staticRegion;
+            dirty += newVisible;
+            windowSurface->setStaticContents(staticRegion);
+        } else {
+            // Repaint everything.
+            dirty = QRegion(0, 0, tlwRect.width(), tlwRect.height());
+            for (int i = 0; i < dirtyWidgets.size(); ++i)
+                resetWidget(dirtyWidgets.at(i));
+            dirtyWidgets.clear();
+            repaintAllWidgets = true;
         }
+    }
+
+    if (inTopLevelResize || surfaceGeometry != tlwRect)
         windowSurface->setGeometry(tlwRect);
-    }
 
     if (updatesDisabled)
         return;
@@ -1212,6 +1238,8 @@
     }
     dirtyWidgets.clear();
 
+    fullUpdatePending = false;
+
     if (toClean.isEmpty()) {
         // Nothing to repaint. However, we might have newly exposed areas on the
         // screen if this function was called from sync(QWidget *, QRegion)), so