diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2011-09-26 19:02:57 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-21 16:54:45 +0200 |
commit | ab50b60f5cc237d5620f3ff3b2eb44c857f8f60b (patch) | |
tree | 3544d8230009ad680587582ce1bbacd519aa9f5d /src/gui/image | |
parent | 6a7da1fb581da17d9408f755387a7798336176ae (diff) |
[blitter] Work on tst_QPixmap::clear()
By default QPixmap may not hasAlphaChannel(), only if setMask()
or fill() with a transparent color is called a QPixmap will
hasAlphaChannel().
Make the QBlittablePlatformPixmap remember if there is an alpha
channel, pass this as parameter in createBlittable to make it
clear that this is required and not optional.
Update the DirectFB plugin to handle this parameter to create a
RGB32 or ARGB Surface depending on the alpha value, also only use
PreMultiplied alpha when using ARGB. Separate the two constructors
for the QDirectFbBlitter to either adopt a DirectFB Surface or to
create one.
Change-Id: I8abf82408ecd2d075fc6f241ace8be2a34ac56e7
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qpixmap_blitter.cpp | 15 | ||||
-rw-r--r-- | src/gui/image/qpixmap_blitter_p.h | 3 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 8a72b2930e..2a47a891c7 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -58,6 +58,7 @@ static int global_ser_no = 0; QBlittablePlatformPixmap::QBlittablePlatformPixmap() : QPlatformPixmap(QPlatformPixmap::PixmapType,BlitterClass) + , m_alpha(false) #ifdef QT_BLITTER_RASTEROVERLAY ,m_rasterOverlay(0), m_unmergedCopy(0) #endif //QT_BLITTER_RASTEROVERLAY @@ -77,7 +78,7 @@ QBlittable *QBlittablePlatformPixmap::blittable() const { if (!m_blittable) { QBlittablePlatformPixmap *that = const_cast<QBlittablePlatformPixmap *>(this); - that->m_blittable.reset(this->createBlittable(QSize(w, h))); + that->m_blittable.reset(this->createBlittable(QSize(w, h), m_alpha)); } return m_blittable.data(); @@ -133,7 +134,16 @@ void QBlittablePlatformPixmap::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: @@ -179,6 +189,7 @@ bool QBlittablePlatformPixmap::hasAlphaChannel() const void QBlittablePlatformPixmap::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(); diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index 3c32e8f919..b0a9b7f848 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -55,7 +55,7 @@ public: QBlittablePlatformPixmap(); ~QBlittablePlatformPixmap(); - 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); @@ -85,6 +85,7 @@ public: protected: QScopedPointer<QBlitterPaintEngine> m_engine; QScopedPointer<QBlittable> m_blittable; + bool m_alpha; #ifdef QT_BLITTER_RASTEROVERLAY QImage *m_rasterOverlay; |