summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/effects/qgraphicseffect.cpp5
-rw-r--r--src/gui/effects/qgraphicseffect_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp44
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h1
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp25
-rw-r--r--src/gui/image/qpixmapfilter.cpp2
-rw-r--r--src/gui/widgets/qabstractspinbox.cpp2
7 files changed, 61 insertions, 20 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index 90145fe..ad23df3 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -374,6 +374,11 @@ QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate()
invalidateCache();
}
+void QGraphicsEffectSourcePrivate::setCachedOffset(const QPoint &offset)
+{
+ m_cachedOffset = offset;
+}
+
void QGraphicsEffectSourcePrivate::invalidateCache(InvalidateReason reason) const
{
if (m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect
diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h
index 91ad74a..e34dbf9 100644
--- a/src/gui/effects/qgraphicseffect_p.h
+++ b/src/gui/effects/qgraphicseffect_p.h
@@ -129,8 +129,10 @@ public:
QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToTransparentBorder) const = 0;
virtual void effectBoundingRectChanged() = 0;
+ void setCachedOffset(const QPoint &offset);
void invalidateCache(InvalidateReason reason = SourceChanged) const;
Qt::CoordinateSystem currentCachedSystem() const { return m_cachedSystem; }
+ QGraphicsEffect::PixmapPadMode currentCachedMode() const { return m_cachedMode; }
friend class QGraphicsScenePrivate;
friend class QGraphicsItem;
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 168a9a3..cae9660 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -10715,27 +10715,18 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
}
}
-QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
- QGraphicsEffect::PixmapPadMode mode) const
+QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) 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();
- }
- if (!item->d_ptr->scene)
- return QPixmap();
- QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
-
- const QRectF sourceRect = boundingRect(system);
QRectF effectRectF;
- bool unpadded = false;
+ if (unpadded)
+ *unpadded = false;
+
if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
if (info) {
effectRectF = item->graphicsEffect()->boundingRectFor(boundingRect(Qt::DeviceCoordinates));
- unpadded = (effectRectF.size() == sourceRect.size());
+ if (unpadded)
+ *unpadded = (effectRectF.size() == sourceRect.size());
if (info && system == Qt::LogicalCoordinates)
effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
} else {
@@ -10747,10 +10738,29 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5);
} else {
effectRectF = sourceRect;
- unpadded = true;
+ if (unpadded)
+ *unpadded = true;
+ }
+
+ return effectRectF.toAlignedRect();
+}
+
+QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
+ QGraphicsEffect::PixmapPadMode mode) 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();
}
+ if (!item->d_ptr->scene)
+ return QPixmap();
+ QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
- QRect effectRect = effectRectF.toAlignedRect();
+ bool unpadded;
+ const QRectF sourceRect = boundingRect(system);
+ QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded);
if (offset)
*offset = effectRect.topLeft();
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index c8d2061..2d34b80 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -609,6 +609,7 @@ public:
QPixmap pixmap(Qt::CoordinateSystem system,
QPoint *offset,
QGraphicsEffect::PixmapPadMode mode) const;
+ QRect paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = 0) const;
QGraphicsItem *item;
QGraphicsItemPaintInfo *info;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 5c6a8ae..cea723c 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4686,8 +4686,31 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
if (sourced->currentCachedSystem() != Qt::LogicalCoordinates
&& sourced->lastEffectTransform != painter->worldTransform())
{
+ bool unclipped = false;
+ if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate
+ && painter->worldTransform().type() <= QTransform::TxTranslate)
+ {
+ QRectF itemRect = item->boundingRect();
+ if (!item->d_ptr->children.isEmpty())
+ itemRect |= item->childrenBoundingRect();
+
+ QRectF oldSourceRect = sourced->lastEffectTransform.mapRect(itemRect);
+ QRectF newSourceRect = painter->worldTransform().mapRect(itemRect);
+
+ QRect oldEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), oldSourceRect);
+ QRect newEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), newSourceRect);
+
+ QRect deviceRect(0, 0, painter->device()->width(), painter->device()->height());
+ if (deviceRect.contains(oldEffectRect) && deviceRect.contains(newEffectRect)) {
+ sourced->setCachedOffset(newEffectRect.topLeft());
+ unclipped = true;
+ }
+ }
+
sourced->lastEffectTransform = painter->worldTransform();
- sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);
+
+ if (!unclipped)
+ sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);
}
item->d_ptr->graphicsEffect->draw(painter);
diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp
index 30fb7a3..37a6a18 100644
--- a/src/gui/image/qpixmapfilter.cpp
+++ b/src/gui/image/qpixmapfilter.cpp
@@ -953,7 +953,7 @@ static void grayscale(const QImage &image, QImage &dest, const QRect& rect = QRe
srcRect = dest.rect();
destRect = dest.rect();
}
- if (image != dest) {
+ if (&image != &dest) {
destRect.moveTo(QPoint(0, 0));
}
diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp
index 13e67e9..4a6235c 100644
--- a/src/gui/widgets/qabstractspinbox.cpp
+++ b/src/gui/widgets/qabstractspinbox.cpp
@@ -66,7 +66,7 @@
#endif
#if defined(Q_OS_SYMBIAN)
-#include <W32STD.H>
+#include <w32std.h>
#include <private/qt_s60_p.h>
#endif