blitter: Kill the isBlitterLocked variable of the QBlitterPaintEngine
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>
Sun, 1 Jan 2012 18:58:20 +0000 (19:58 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 2 Jan 2012 09:44:00 +0000 (10:44 +0100)
It starts with being initialized wrongly, the call to buffer() will
lock the data while we think it is not locked, it can also get out of
sync by someone calling buffer() again. Remove the variable and
check with the QBlittable if we need to lock the resource into memory.

Change-Id: I350375011138d1b4c2c48c100b7b30b8ea2ae460
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/gui/painting/qblittable.cpp
src/gui/painting/qblittable_p.h
src/gui/painting/qpaintengine_blitter.cpp

index 1105858..fe51f7a 100644 (file)
@@ -100,6 +100,12 @@ void QBlittable::unlock()
     }
 }
 
+bool QBlittable::isLocked() const
+{
+    Q_D(const QBlittable);
+    return d->locked;
+}
+
 QT_END_NAMESPACE
 #endif //QT_NO_BLITTABLE
 
index a843733..248183d 100644 (file)
@@ -80,6 +80,8 @@ public:
     QImage *lock();
     void unlock();
 
+    bool isLocked() const;
+
 protected:
     virtual QImage *doLock() = 0;
     virtual void doUnlock() = 0;
index c37355b..a798efb 100644 (file)
@@ -188,7 +188,6 @@ public:
         : QPaintEngineExPrivate()
         , pmData(p)
         , caps(pmData->blittable()->capabilities())
-        , isBlitterLocked(false)
         , hasXForm(false)
 
     {
@@ -196,17 +195,12 @@ public:
     }
 
     inline void lock() {
-        if (!isBlitterLocked) {
-            raster->d_func()->rasterBuffer->prepare(pmData->blittable()->lock());
-            isBlitterLocked = true;
-        }
+        if (!pmData->blittable()->isLocked())
+            raster->d_func()->rasterBuffer->prepare(pmData->buffer());
     }
 
     inline void unlock() {
-        if (isBlitterLocked) {
-            pmData->blittable()->unlock();
-            isBlitterLocked = false;
-        }
+        pmData->blittable()->unlock();
     }
 
     void fillRect(const QRectF &rect, const QColor &color) {
@@ -275,7 +269,6 @@ public:
 
     QBlittablePlatformPixmap *pmData;
     CapabilitiesToStateMask caps;
-    bool isBlitterLocked;
     uint hasXForm;
 };