diff options
author | Trond Kjernåsen <trond.kjernasen@nokia.com> | 2010-09-23 10:10:59 (GMT) |
---|---|---|
committer | Trond Kjernåsen <trond.kjernasen@nokia.com> | 2010-09-23 10:13:05 (GMT) |
commit | d1817df87461fc071527eb77d3c1259e713b94a4 (patch) | |
tree | 1259e69aa9b6bb1a19ea937cc1b96635c0b6b162 | |
parent | 6397e5bc49f11e20a9d1838d8d8df46dd9486263 (diff) | |
download | Qt-d1817df87461fc071527eb77d3c1259e713b94a4.zip Qt-d1817df87461fc071527eb77d3c1259e713b94a4.tar.gz Qt-d1817df87461fc071527eb77d3c1259e713b94a4.tar.bz2 |
Compile on Symbian - rework the X11 mask patch a bit.
Avoid adding a virtual QPixmapData::hasMask() function, we can
do without it. Made QPixmap::hasAlpha() fast, so we can use that
instead.
Reviewed-by: Samuel
-rw-r--r-- | src/gui/image/qpixmap.cpp | 20 | ||||
-rw-r--r-- | src/gui/image/qpixmap_x11.cpp | 10 | ||||
-rw-r--r-- | src/gui/image/qpixmap_x11_p.h | 1 | ||||
-rw-r--r-- | src/gui/image/qpixmapdata.cpp | 5 | ||||
-rw-r--r-- | src/gui/image/qpixmapdata_p.h | 1 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 |
6 files changed, 19 insertions, 22 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 6a13f49..64d8ed2 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1798,13 +1798,27 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) Returns true if this pixmap has an alpha channel, \e or has a mask, otherwise returns false. - \warning This is potentially an expensive operation. - \sa hasAlphaChannel(), mask() */ bool QPixmap::hasAlpha() const { - return data && (data->hasAlphaChannel() || !data->mask().isNull()); +#if defined(Q_WS_X11) + if (data && data->hasAlphaChannel()) + return true; + QPixmapData *pd = pixmapData(); + if (pd && pd->classId() == QPixmapData::X11Class) { + QX11PixmapData *x11Data = static_cast<QX11PixmapData*>(pd); +#ifndef QT_NO_XRENDER + if (x11Data->picture && x11Data->d == 32) + return true; +#endif + if (x11Data->d == 1 || x11Data->x11_mask) + return true; + } + return false; +#else + return data && data->hasAlphaChannel(); +#endif } /*! diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index 32676ba..01f2c11 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -1321,16 +1321,6 @@ QBitmap QX11PixmapData::mask() const return mask; } -bool QX11PixmapData::hasMask() const -{ - return -#ifndef QT_NO_XRENDER - (picture && d == 32) || -#endif - (d == 1) || x11_mask; -} - - /*! Sets a mask bitmap. diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h index fcad1a2..821fb69 100644 --- a/src/gui/image/qpixmap_x11_p.h +++ b/src/gui/image/qpixmap_x11_p.h @@ -82,7 +82,6 @@ public: void fill(const QColor &color); QBitmap mask() const; - bool hasMask() const; void setMask(const QBitmap &mask); bool hasAlphaChannel() const; void setAlphaChannel(const QPixmap &alphaChannel); diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 2813ed1..ef1f6c4 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -239,11 +239,6 @@ QBitmap QPixmapData::mask() const return QBitmap::fromImage(mask); } -bool QPixmapData::hasMask() const -{ - return hasAlphaChannel(); -} - QPixmap QPixmapData::transformed(const QTransform &matrix, Qt::TransformationMode mode) const { diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h index c341930..ec62b0b 100644 --- a/src/gui/image/qpixmapdata_p.h +++ b/src/gui/image/qpixmapdata_p.h @@ -99,7 +99,6 @@ public: virtual int metric(QPaintDevice::PaintDeviceMetric metric) const = 0; virtual void fill(const QColor &color) = 0; virtual QBitmap mask() const; - virtual bool hasMask() const; virtual void setMask(const QBitmap &mask); virtual bool hasAlphaChannel() const = 0; virtual QPixmap transformed(const QTransform &matrix, diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 6eb5a36..ee59830 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1314,7 +1314,7 @@ void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, c QGLRect srcRect(src.left(), top, src.right(), bottom); bool isBitmap = pixmap.isQBitmap(); - bool isOpaque = !isBitmap && !pixmap.hasAlphaChannel() && !pixmap.pixmapData()->hasMask(); + bool isOpaque = !isBitmap && !pixmap.hasAlpha(); d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, state()->renderHints & QPainter::SmoothPixmapTransform, texture->id); @@ -1765,7 +1765,7 @@ void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragmen transferMode(ImageArrayDrawingMode); bool isBitmap = pixmap.isQBitmap(); - bool isOpaque = !isBitmap && (!pixmap.hasAlphaChannel() || (hints & QPainter::OpaqueHint)) && allOpaque; + bool isOpaque = !isBitmap && (!pixmap.hasAlpha() || (hints & QPainter::OpaqueHint)) && allOpaque; updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, q->state()->renderHints & QPainter::SmoothPixmapTransform, texture->id); |