summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-12-13 11:02:32 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2011-12-13 11:02:32 (GMT)
commitee387dcb715ebc21f63b524bb87a8ffaf198f8aa (patch)
tree3adf6ac4929ef98e081f7d61b6897cba5171e933 /src/gui
parente394dd804fa6690f6d4bd270f61ca56331cea63b (diff)
downloadQt-ee387dcb715ebc21f63b524bb87a8ffaf198f8aa.zip
Qt-ee387dcb715ebc21f63b524bb87a8ffaf198f8aa.tar.gz
Qt-ee387dcb715ebc21f63b524bb87a8ffaf198f8aa.tar.bz2
[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. Cherry-picked-from: qtbase:ab50b60f5cc237d5620f3ff3b2eb44c857f8f60b Change-Id: I8abf82408ecd2d075fc6f241ace8be2a34ac56e7 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com> Merge-request: 1492 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qpixmap_blitter.cpp15
-rw-r--r--src/gui/image/qpixmap_blitter_p.h3
2 files changed, 15 insertions, 3 deletions
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
index f8fb538..c73e6a9 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;
QBlittablePixmapData::QBlittablePixmapData()
: QPixmapData(QPixmapData::PixmapType,BlitterClass)
+ , m_alpha(false)
#ifdef QT_BLITTER_RASTEROVERLAY
,m_rasterOverlay(0), m_unmergedCopy(0)
#endif //QT_BLITTER_RASTEROVERLAY
@@ -77,7 +78,7 @@ QBlittable *QBlittablePixmapData::blittable() const
{
if (!m_blittable) {
QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(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();
@@ -136,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:
@@ -182,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();
diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h
index 9b809ca..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);
@@ -85,6 +85,7 @@ public:
protected:
QScopedPointer<QBlitterPaintEngine> m_engine;
QScopedPointer<QBlittable> m_blittable;
+ bool m_alpha;
#ifdef QT_BLITTER_RASTEROVERLAY
QImage *m_rasterOverlay;