src/gui/painting/qwindowsurface_s60.cpp
branchRCL_3
changeset 7 3f74d0d4af4c
parent 4 3b1da2848fc7
--- a/src/gui/painting/qwindowsurface_s60.cpp	Mon Mar 15 12:43:09 2010 +0200
+++ b/src/gui/painting/qwindowsurface_s60.cpp	Thu Apr 08 14:19:33 2010 +0300
@@ -70,13 +70,13 @@
     // We create empty CFbsBitmap here -> it will be resized in setGeometry
     CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap);	// CBase derived object needs check on new
     qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) );
-	
+
     QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType);
     if (data) {
         data->fromSymbianBitmap(bitmap, true);
         d_ptr->device = QPixmap(data);
     }
-        
+
     setStaticContentsSupport(true);
 }
 QS60WindowSurface::~QS60WindowSurface()
@@ -89,24 +89,15 @@
     if (!qt_widget_private(window())->isOpaque) {
         QS60PixmapData *pixmapData = static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data());
         pixmapData->beginDataAccess();
-        QImage &image = pixmapData->image;
-        QRgb *data = reinterpret_cast<QRgb *>(image.bits());
-        const int row_stride = image.bytesPerLine() / 4;
-
-        const QVector<QRect> rects = rgn.rects();
-        for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
-            const int x_start = it->x();
-            const int width = it->width();
 
-            const int y_start = it->y();
-            const int height = it->height();
+        QPainter p(&pixmapData->image);
+        p.setCompositionMode(QPainter::CompositionMode_Source);
+        const QVector<QRect> rects = rgn.rects();
+        const QColor blank = Qt::transparent;
+        for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
+            p.fillRect(*it, blank);
+        }
 
-            QRgb *row = data + row_stride * y_start;
-            for (int y = 0; y < height; ++y) {
-                qt_memfill(row + x_start, 0U, width);
-                row += row_stride;
-            }
-        }
         pixmapData->endDataAccess();
     }
 }
@@ -128,7 +119,7 @@
 
     const QPoint off = offset(widget);
     QImage *img = &(static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data())->image);
-    
+
     QRect rect(off, widget->size());
     rect &= QRect(QPoint(), img->size());
 
@@ -145,12 +136,23 @@
 
 void QS60WindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &)
 {
-    QWExtra *extra = widget->d_func()->extraData();
-    if (extra && !extra->inExpose) {
-        extra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again
-        TRect tr = qt_QRect2TRect(region.boundingRect());
+    QWidget *window = widget->window();
+    Q_ASSERT(window);
+    QTLWExtra *topExtra = window->d_func()->maybeTopData();
+    Q_ASSERT(topExtra);
+    QRect qr = region.boundingRect();
+    if (!topExtra->inExpose) {
+        topExtra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again
+        TRect tr = qt_QRect2TRect(qr);
         widget->winId()->DrawNow(tr);
-        extra->inExpose = false;
+        topExtra->inExpose = false;
+    } else {
+        // This handles the case when syncBackingStore updates content outside of the
+        // original drawing rectangle. This might happen if there are pending update()
+        // events at the same time as we get a Draw() from Symbian.
+        QRect drawRect = qt_TRect2QRect(widget->winId()->DrawableWindow()->GetDrawRect());
+        if (!drawRect.contains(qr))
+            widget->winId()->DrawDeferred();
     }
 }