From 35bc104729abf2653a23618603b55e2c316a870f Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Thu, 16 Sep 2010 15:58:37 +0200 Subject: Ensure building of WebKit and QtConcurrent are disabled with SunCC. As there are versions of SunCC > 5.9 Reviewed-by: TrustMe --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 1ad0181..b933ac1 100755 --- a/configure +++ b/configure @@ -7051,7 +7051,7 @@ case "$XPLATFORM" in canBuildQtXmlPatterns="no" canBuildQtConcurrent="no" ;; - 5.9) + 5.*) canBuildWebKit="no" canBuildQtConcurrent="no" ;; -- cgit v0.12 From 3d7ef01963f2e15b7fd8fd23ffe22198ced00c87 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 16 Sep 2010 15:40:42 +0200 Subject: Compile on Mac Extern missing symbol Reviewed-by: Fabien Freling --- src/gui/kernel/qwidget_mac.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 159c45d..1e2aa9f 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -114,6 +114,9 @@ QT_BEGIN_NAMESPACE +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + #define XCOORD_MAX 16383 #define WRECT_MAX 8191 -- cgit v0.12 From e76564e8a3b305f4fe69135bebb409e357f29f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 16 Sep 2010 12:38:51 +0200 Subject: Wrong bounding rect returned by QGraphicsEffect::boundingRect(). Regression after: f5c5e20a Problem was that the cached bounding rect was never invalidated. We can also remove the cached bounding rect in QGraphicsEffectSource because QGraphicsItem::childrenBoundingRect now clips by default. This basically means partially reverting above commit and invalidate whenever ItemClipsChildrenToShape flag changes. Auto test included. Task-number: Discovered while investigating QT-3633 Reviewed-by: samuel --- src/gui/graphicsview/qgraphicsitem.cpp | 18 +++++++-------- src/gui/graphicsview/qgraphicsitem_p.h | 14 ++++-------- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 26 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 2600d06..364fdbb 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1272,7 +1272,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q Returns the bounding rect of this item's children (excluding itself). */ -void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, bool doClip) +void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect) { Q_Q(QGraphicsItem); @@ -1302,7 +1302,7 @@ void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rec } } - if (doClip && (flags & QGraphicsItem::ItemClipsChildrenToShape)){ + if (flags & QGraphicsItem::ItemClipsChildrenToShape){ if (x) *rect &= x->mapRect(q->boundingRect()); else @@ -1870,6 +1870,10 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) // Item children clipping changes. Propagate the ancestor flag to // all children. d_ptr->updateAncestorFlag(ItemClipsChildrenToShape); + // The childrenBoundingRect is clipped to the boundingRect in case of ItemClipsChildrenToShape, + // which means we have to invalidate the cached childrenBoundingRect whenever this flag changes. + d_ptr->dirtyChildrenBoundingRect = 1; + d_ptr->markParentDirty(true); } if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) { @@ -11168,14 +11172,8 @@ QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem syste } QRectF rect = item->boundingRect(); - if (!item->d_ptr->children.isEmpty()) { - if (dirtyChildrenBoundingRect) { - childrenBoundingRect = QRectF(); - item->d_ptr->childrenBoundingRectHelper(0, &childrenBoundingRect, true); - dirtyChildrenBoundingRect = false; - } - rect |= childrenBoundingRect; - } + if (!item->d_ptr->children.isEmpty()) + rect |= item->childrenBoundingRect(); if (deviceCoordinates) { Q_ASSERT(info->painter); diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index cce9439..bc5e5ad 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -300,7 +300,7 @@ public: QDeclarativeListProperty childrenList(); void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant); - void childrenBoundingRectHelper(QTransform *x, QRectF *rect, bool doClip = true); + void childrenBoundingRectHelper(QTransform *x, QRectF *rect); void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems = false) const; QRectF effectiveBoundingRect() const; @@ -661,7 +661,7 @@ class QGraphicsItemEffectSourcePrivate : public QGraphicsEffectSourcePrivate { public: QGraphicsItemEffectSourcePrivate(QGraphicsItem *i) - : QGraphicsEffectSourcePrivate(), dirtyChildrenBoundingRect(true), item(i), info(0) + : QGraphicsEffectSourcePrivate(), item(i), info(0) {} inline void detach() @@ -712,9 +712,6 @@ public: QGraphicsEffect::PixmapPadMode mode) const; QRect paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = 0) const; - mutable bool dirtyChildrenBoundingRect; - mutable QRectF childrenBoundingRect; - QGraphicsItem *item; QGraphicsItemPaintInfo *info; QTransform lastEffectTransform; @@ -872,12 +869,9 @@ inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) #ifndef QT_NO_GRAPHICSEFFECT if (parentp->graphicsEffect) { if (updateBoundingRect) { - QGraphicsItemEffectSourcePrivate *sourcep = - static_cast(parentp->graphicsEffect->d_func() - ->source->d_func()); - parentp->dirtyChildrenBoundingRect = 1; + static_cast(parentp->graphicsEffect->d_func() + ->source->d_func())->invalidateCache(); parentp->notifyInvalidated = 1; - sourcep->invalidateCache(); } if (parentp->scene && parentp->graphicsEffect->isEnabled()) { parentp->dirty = 1; diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index e1bfb79..985d466 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -66,6 +66,7 @@ private slots: void source(); void boundingRectFor(); void boundingRect(); + void boundingRect2(); void draw(); void opacity(); void grayscale(); @@ -264,6 +265,31 @@ void tst_QGraphicsEffect::boundingRect() delete item; } +void tst_QGraphicsEffect::boundingRect2() +{ + CustomEffect *effect = new CustomEffect; + QGraphicsRectItem *root = new QGraphicsRectItem; + root->setGraphicsEffect(effect); + + QGraphicsRectItem *child = new QGraphicsRectItem; + QRectF childRect(0, 0, 100, 100); + child->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + child->setRect(childRect); + child->setParentItem(root); + + QGraphicsRectItem *grandChild = new QGraphicsRectItem; + QRectF grandChildRect(0, 0, 200, 200); + grandChild->setRect(grandChildRect); + grandChild->setParentItem(child); + + // Make sure the effect's bounding rect is clipped to the child's bounding rect. + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect)); + + // Disable ItemClipsChildrenToShape; effect's bounding rect is no longer clipped. + child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect)); +} + void tst_QGraphicsEffect::draw() { QGraphicsScene scene; -- cgit v0.12 From 9601abf3b03cfef589c092182bec3672fab6cde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 16 Sep 2010 16:37:24 +0200 Subject: QGraphicsItem::childrenBoundingRect behavior breaks QGraphicsEffect::sourceBoundingRect(). Context: QGraphicsEffect::sourceBoundingRect() returns: item->boundingRect() | item->childrenBoundingRect(); Problem was that item->childrenBoundingRect() adjusted the children's bounding rect with the children's ancestor effects (child -> root item), which means the source bounding rect was bigger than needed. We should only account for effects downwards in the hierarchy. root (has effect) | item (has effect) | child | grandChild Auto test included. Task-number: QT-3633, QT-3828 Reviewed-by: samuel --- src/gui/graphicsview/qgraphicsitem.cpp | 27 ++++++++++++++-------- src/gui/graphicsview/qgraphicsitem_p.h | 4 ++-- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 26 +++++++++++++++++++++ 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 364fdbb..b404692 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1272,33 +1272,36 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q Returns the bounding rect of this item's children (excluding itself). */ -void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect) +void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem) { Q_Q(QGraphicsItem); QRectF childrenRect; QRectF *result = rect; rect = &childrenRect; + const bool setTopMostEffectItem = !topMostEffectItem; for (int i = 0; i < children.size(); ++i) { QGraphicsItem *child = children.at(i); QGraphicsItemPrivate *childd = child->d_ptr.data(); + if (setTopMostEffectItem) + topMostEffectItem = child; bool hasPos = !childd->pos.isNull(); if (hasPos || childd->transformData) { // COMBINE QTransform matrix = childd->transformToParent(); if (x) matrix *= *x; - *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect()); + *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem)); if (!childd->children.isEmpty()) - childd->childrenBoundingRectHelper(&matrix, rect); + childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem); } else { if (x) - *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect()); + *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem)); else - *rect |= child->d_ptr->effectiveBoundingRect(); + *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem); if (!childd->children.isEmpty()) - childd->childrenBoundingRectHelper(x, rect); + childd->childrenBoundingRectHelper(x, rect, topMostEffectItem); } } @@ -2804,6 +2807,8 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const Q_Q(const QGraphicsItem); QGraphicsEffect *effect = graphicsEffect; if (scene && effect && effect->isEnabled()) { + if (scene->d_func()->views.isEmpty()) + return effect->boundingRectFor(rect); QRectF sceneRect = q->mapRectToScene(rect); QRectF sceneEffectRect; foreach (QGraphicsView *view, scene->views()) { @@ -2827,12 +2832,12 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const \sa boundingRect() */ -QRectF QGraphicsItemPrivate::effectiveBoundingRect() const +QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const { #ifndef QT_NO_GRAPHICSEFFECT Q_Q(const QGraphicsItem); QRectF brect = effectiveBoundingRect(q_ptr->boundingRect()); - if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) + if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren || topMostEffectItem == q) return brect; const QGraphicsItem *effectParent = parent; @@ -2843,8 +2848,10 @@ QRectF QGraphicsItemPrivate::effectiveBoundingRect() const const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace); brect = effectParent->mapRectToItem(q, effectRectInParentSpace); } - if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) + if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren + || topMostEffectItem == effectParent) { return brect; + } effectParent = effectParent->d_ptr->parent; } @@ -4719,7 +4726,7 @@ QRectF QGraphicsItem::childrenBoundingRect() const return d_ptr->childrenBoundingRect; d_ptr->childrenBoundingRect = QRectF(); - d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect); + d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0); d_ptr->dirtyChildrenBoundingRect = 0; return d_ptr->childrenBoundingRect; } diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index bc5e5ad..77e4054 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -300,10 +300,10 @@ public: QDeclarativeListProperty childrenList(); void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant); - void childrenBoundingRectHelper(QTransform *x, QRectF *rect); + void childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem); void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems = false) const; - QRectF effectiveBoundingRect() const; + QRectF effectiveBoundingRect(QGraphicsItem *topMostEffectItem = 0) const; QRectF sceneEffectiveBoundingRect() const; QRectF effectiveBoundingRect(const QRectF &rect) const; diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index 985d466..07fa630 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -288,6 +288,32 @@ void tst_QGraphicsEffect::boundingRect2() // Disable ItemClipsChildrenToShape; effect's bounding rect is no longer clipped. child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect)); + + // Add root item to a scene, do the same tests as above. Results should be the same. + QGraphicsScene scene; + scene.addItem(root); + + child->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect)); + + child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect)); + + // Now add the scene to a view, results should be the same. + QGraphicsView view(&scene); + + child->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect)); + + child->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect)); + + CustomEffect *childEffect = new CustomEffect; + child->setGraphicsEffect(childEffect); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childEffect->boundingRectFor(childRect | grandChildRect))); + + child->setGraphicsEffect(0); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(childRect | grandChildRect)); } void tst_QGraphicsEffect::draw() -- cgit v0.12