summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-29 04:39:31 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-29 06:43:42 (GMT)
commita79b31aba0405b0a24e210a2479d4b1df729c608 (patch)
tree029472cd6ca2de52a601fea41a8c3ca4e8e8c91f /src/gui
parent8ec8c7f97efc1e5ae6fc5deae4b4d7aeb0a93f31 (diff)
downloadQt-a79b31aba0405b0a24e210a2479d4b1df729c608.zip
Qt-a79b31aba0405b0a24e210a2479d4b1df729c608.tar.gz
Qt-a79b31aba0405b0a24e210a2479d4b1df729c608.tar.bz2
Generalize QGraphicsEffectSource::pixmap.
Before QGraphicsEffectSource::pixmap could only return something useful when called from QGraphicsEffect::draw. This patch removes this limitation. However, we still cannot provide pixmaps in device coordinates when not called from QGraphicsEffect::draw, though.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp52
1 files changed, 39 insertions, 13 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 8c604e1..392fdaa 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -9939,6 +9939,11 @@ QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem syste
void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
{
+ if (!info) {
+ qWarning("QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw");
+ return;
+ }
+
if (painter == info->painter) {
QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
@@ -9956,29 +9961,50 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset) const
{
+ const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
+ if (!info && deviceCoordinates) {
+ // Device coordinates without info not yet supported.
+ qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
+ return QPixmap();
+ }
+
const QRectF sourceRect = boundingRect(system);
const QRect effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
if (offset)
*offset = sourceRect.toAlignedRect().topLeft();
+ QPixmap pixmap(effectRect.size());
+ pixmap.fill(Qt::transparent);
+ QPainter pixmapPainter(&pixmap);
+ pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing);
+
const QTransform translateTransform = QTransform::fromTranslate(-effectRect.x(),
-effectRect.y());
- const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
- QTransform effectTransform = deviceCoordinates ? translateTransform
- : info->transformPtr->inverted();
- if (!deviceCoordinates)
+ if (!info) {
+ // Logical coordinates without info.
+ QTransform sceneTransform = item->sceneTransform();
+ QTransform effectTransform = sceneTransform.inverted();
effectTransform *= translateTransform;
- *info->transformPtr *= effectTransform;
- QPixmap pixmap(effectRect.size());
- pixmap.fill(Qt::transparent);
- QPainter pixmapPainter(&pixmap);
- pixmapPainter.setRenderHints(info->painter->renderHints());
+ QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
+ scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0),
+ &effectTransform, false, true);
+ } else if (deviceCoordinates) {
+ // Device coordinates with info.
+ QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
+ scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, info->exposedRegion,
+ info->widget, info->opacity, &translateTransform, info->wasDirtySceneTransform,
+ info->drawItem);
+ } else {
+ // Item coordinates with info.
+ QTransform effectTransform = info->transformPtr->inverted();
+ effectTransform *= translateTransform;
- QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
- scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, info->exposedRegion,
- info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
- info->drawItem);
+ QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
+ scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, info->exposedRegion,
+ info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
+ info->drawItem);
+ }
return pixmap;
}