diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-12-13 21:18:20 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-12-13 21:18:20 (GMT) |
commit | f1066ac7a895b028e2459d60bc7e8013a9369cfe (patch) | |
tree | 8e97a2917bc3002722d0cd9b995ceb4a652c4615 /src/gui | |
parent | 443f2df750ac01b3c598d833d5c067798c1e670d (diff) | |
parent | 0e0a3883675ed2943af9810b8354ed406075a6ee (diff) | |
download | Qt-f1066ac7a895b028e2459d60bc7e8013a9369cfe.zip Qt-f1066ac7a895b028e2459d60bc7e8013a9369cfe.tar.gz Qt-f1066ac7a895b028e2459d60bc7e8013a9369cfe.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging:
directfb: Backport the work from QtBase to Qt 4.8
[blitter] Work on tst_QPixmap::clear()
[blitter] Use QScopedPointer for the engine and blittable
[blitter] Generate a new serial number when resizing the
[blitter] Fix memory leak in the blitter paintengine
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qpixmap_blitter.cpp | 34 | ||||
-rw-r--r-- | src/gui/image/qpixmap_blitter_p.h | 7 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_blitter.cpp | 10 |
3 files changed, 30 insertions, 21 deletions
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index f3a4318..c73e6a9 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -57,7 +57,8 @@ QT_BEGIN_NAMESPACE static int global_ser_no = 0; QBlittablePixmapData::QBlittablePixmapData() - : QPixmapData(QPixmapData::PixmapType,BlitterClass), m_engine(0), m_blittable(0) + : QPixmapData(QPixmapData::PixmapType,BlitterClass) + , m_alpha(false) #ifdef QT_BLITTER_RASTEROVERLAY ,m_rasterOverlay(0), m_unmergedCopy(0) #endif //QT_BLITTER_RASTEROVERLAY @@ -67,8 +68,6 @@ QBlittablePixmapData::QBlittablePixmapData() QBlittablePixmapData::~QBlittablePixmapData() { - delete m_blittable; - delete m_engine; #ifdef QT_BLITTER_RASTEROVERLAY delete m_rasterOverlay; delete m_unmergedCopy; @@ -79,31 +78,30 @@ QBlittable *QBlittablePixmapData::blittable() const { if (!m_blittable) { QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this); - that->m_blittable = this->createBlittable(QSize(w,h)); + that->m_blittable.reset(this->createBlittable(QSize(w,h), m_alpha)); } - return m_blittable; + return m_blittable.data(); } void QBlittablePixmapData::setBlittable(QBlittable *blittable) { resize(blittable->size().width(),blittable->size().height()); - m_blittable = blittable; + m_blittable.reset(blittable); } void QBlittablePixmapData::resize(int width, int height) { - delete m_blittable; - m_blittable = 0; - delete m_engine; - m_engine = 0; + m_blittable.reset(0); + m_engine.reset(0); #ifdef Q_WS_QPA d = QApplicationPrivate::platformIntegration()->screens().at(0)->depth(); #endif w = width; h = height; is_null = (w <= 0 || h <= 0); + setSerialNumber(++global_ser_no); } int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const @@ -139,7 +137,16 @@ void QBlittablePixmapData::fill(const QColor &color) if (color.alpha() == 255 && blittable()->capabilities() & QBlittable::SolidRectCapability) { blittable()->unlock(); blittable()->fillRect(QRectF(0,0,w,h),color); - }else { + } else { + // Need to be backed with an alpha channel now. It would be nice + // if we could just change the format, e.g. when going from + // RGB32 -> ARGB8888. + if (color.alpha() != 255 && !hasAlphaChannel()) { + m_blittable.reset(0); + m_engine.reset(0); + m_alpha = true; + } + uint pixel; switch (blittable()->lock()->format()) { case QImage::Format_ARGB32_Premultiplied: @@ -185,6 +192,7 @@ bool QBlittablePixmapData::hasAlphaChannel() const void QBlittablePixmapData::fromImage(const QImage &image, Qt::ImageConversionFlags flags) { + m_alpha = image.hasAlphaChannel(); resize(image.width(),image.height()); markRasterOverlay(QRect(0,0,w,h)); QImage *thisImg = buffer(); @@ -208,9 +216,9 @@ QPaintEngine *QBlittablePixmapData::paintEngine() const { if (!m_engine) { QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this); - that->m_engine = new QBlitterPaintEngine(that); + that->m_engine.reset(new QBlitterPaintEngine(that)); } - return m_engine; + return m_engine.data(); } #ifdef QT_BLITTER_RASTEROVERLAY diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index 07791e5..4742a83 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -55,7 +55,7 @@ public: QBlittablePixmapData(); ~QBlittablePixmapData(); - virtual QBlittable *createBlittable(const QSize &size) const = 0; + virtual QBlittable *createBlittable(const QSize &size, bool alpha) const = 0; QBlittable *blittable() const; void setBlittable(QBlittable *blittable); @@ -83,8 +83,9 @@ public: #endif //QT_BLITTER_RASTEROVERLAY protected: - QBlitterPaintEngine *m_engine; - QBlittable *m_blittable; + QScopedPointer<QBlitterPaintEngine> m_engine; + QScopedPointer<QBlittable> m_blittable; + bool m_alpha; #ifdef QT_BLITTER_RASTEROVERLAY QImage *m_rasterOverlay; diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 75efa20..69f0301 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -198,8 +198,8 @@ public: hasXForm(false) { - raster = new QRasterPaintEngine(p->buffer()); - capabillities = new CapabilitiesToStateMask(pmData->blittable()->capabilities()); + raster.reset(new QRasterPaintEngine(p->buffer())); + capabillities.reset(new CapabilitiesToStateMask(pmData->blittable()->capabilities())); } inline void lock() { @@ -279,12 +279,12 @@ public: raster->d_func()->systemStateChanged(); } - QRasterPaintEngine *raster; + QScopedPointer<QRasterPaintEngine> raster; QBlittablePixmapData *pmData; bool isBlitterLocked; - CapabilitiesToStateMask *capabillities; + QScopedPointer<CapabilitiesToStateMask> capabillities; uint hasXForm; }; @@ -655,7 +655,7 @@ void QBlitterPaintEngine::setState(QPainterState *s) inline QRasterPaintEngine *QBlitterPaintEngine::raster() const { Q_D(const QBlitterPaintEngine); - return d->raster; + return d->raster.data(); } QT_END_NAMESPACE |