summaryrefslogtreecommitdiffstats
path: root/src/gui/effects/qgraphicseffect.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-10-30 12:00:12 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-30 12:00:12 (GMT)
commit6edbe2ba4fd231d2fb9de25b861b3e25160ed8ca (patch)
treea44b65b76e5816f1e0a9a4efa0672b8a6e59a0cc /src/gui/effects/qgraphicseffect.cpp
parent5e95f9c3c224b87840e750d4280806a40ed40c92 (diff)
parent85b7896a47f9bb622b394107769cb7c1121a6995 (diff)
downloadQt-6edbe2ba4fd231d2fb9de25b861b3e25160ed8ca.zip
Qt-6edbe2ba4fd231d2fb9de25b861b3e25160ed8ca.tar.gz
Qt-6edbe2ba4fd231d2fb9de25b861b3e25160ed8ca.tar.bz2
Merge commit 'widget/4.6' into origin/4.6
Conflicts: src/gui/effects/qgraphicseffect.cpp
Diffstat (limited to 'src/gui/effects/qgraphicseffect.cpp')
-rw-r--r--src/gui/effects/qgraphicseffect.cpp72
1 files changed, 21 insertions, 51 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index 3a6bab5..3815b60 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -1042,66 +1042,36 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour
return;
}
- painter->save();
- painter->setOpacity(d->opacity);
QPoint offset;
- if (source->isPixmap()) {
- // No point in drawing in device coordinates (pixmap will be scaled anyways).
- if (!d->hasOpacityMask) {
- const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset,
- QGraphicsEffectSource::NoExpandPadMode);
- painter->drawPixmap(offset, pixmap);
- } else {
- QRect srcBrect = source->boundingRect().toAlignedRect();
- offset = srcBrect.topLeft();
- QPixmap pixmap(srcBrect.size());
- pixmap.fill(Qt::transparent);
-
- QPainter pixmapPainter(&pixmap);
- pixmapPainter.setRenderHints(painter->renderHints());
- pixmapPainter.translate(-offset);
- source->draw(&pixmapPainter);
- pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- pixmapPainter.fillRect(srcBrect, d->opacityMask);
- pixmapPainter.end();
-
- painter->drawPixmap(offset, pixmap);
- }
- } else {
- // Draw pixmap in device coordinates to avoid pixmap scaling;
- if (!d->hasOpacityMask) {
- const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset,
- QGraphicsEffectSource::NoExpandPadMode);
- painter->setWorldTransform(QTransform());
- painter->drawPixmap(offset, pixmap);
- } else {
- QTransform worldTransform = painter->worldTransform();
-
- // Calculate source bounding rect in logical and device coordinates.
- QRectF srcBrect = source->boundingRect();
- QRect srcDeviceBrect = worldTransform.mapRect(srcBrect).toAlignedRect();
- srcDeviceBrect &= source->deviceRect();
+ Qt::CoordinateSystem system = source->isPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates;
+ QPixmap pixmap = source->pixmap(system, &offset, QGraphicsEffectSource::NoExpandPadMode);
+ if (pixmap.isNull())
+ return;
- offset = srcDeviceBrect.topLeft();
- worldTransform *= QTransform::fromTranslate(-srcDeviceBrect.x(), -srcDeviceBrect.y());
- QPixmap pixmap(srcDeviceBrect.size());
- pixmap.fill(Qt::transparent);
+ painter->save();
+ painter->setOpacity(d->opacity);
- QPainter pixmapPainter(&pixmap);
- pixmapPainter.setRenderHints(painter->renderHints());
+ if (d->hasOpacityMask) {
+ QPainter pixmapPainter(&pixmap);
+ pixmapPainter.setRenderHints(painter->renderHints());
+ pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+ if (system == Qt::DeviceCoordinates) {
+ QTransform worldTransform = painter->worldTransform();
+ worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y());
pixmapPainter.setWorldTransform(worldTransform);
- source->draw(&pixmapPainter);
- pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- pixmapPainter.fillRect(srcBrect, d->opacityMask);
- pixmapPainter.end();
-
- painter->setWorldTransform(QTransform());
- painter->drawPixmap(offset, pixmap);
+ pixmapPainter.fillRect(source->boundingRect(), d->opacityMask);
+ } else {
+ pixmapPainter.translate(-offset);
+ pixmapPainter.fillRect(pixmap.rect(), d->opacityMask);
}
}
+ if (system == Qt::DeviceCoordinates)
+ painter->setWorldTransform(QTransform());
+
+ painter->drawPixmap(offset, pixmap);
painter->restore();
}