aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2011-08-15 12:55:26 +0200
committerQt by Nokia <qt-info@nokia.com>2011-08-16 08:16:14 +0200
commitec68295138b3cd4ee45cb28ef604212c4e9a9f50 (patch)
treef1774e9f9dcf03c732a57a0525375afe94525021
parentc5b56564667194b179ebfcc87608d38e9969fade (diff)
Fixed clip on QML2 rectangles to include the borders.
This is related to commit 31ebb4bfb0df83805c5d86b6773f11ba1145c7cd. Task-number: QTBUG-20547 Change-Id: I6a5b6c56d440c7fa7f5546472305f62227b64c29 Reviewed-on: http://codereview.qt.nokia.com/2952 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
-rw-r--r--src/declarative/items/qsgcanvas.cpp3
-rw-r--r--src/declarative/items/qsgrectangle.cpp21
-rw-r--r--src/declarative/items/qsgrectangle_p_p.h12
3 files changed, 23 insertions, 13 deletions
diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp
index b579cc7236..11b3b030ed 100644
--- a/src/declarative/items/qsgcanvas.cpp
+++ b/src/declarative/items/qsgcanvas.cpp
@@ -1725,6 +1725,7 @@ void QSGCanvasPrivate::updateDirtyNode(QSGItem *item)
if (item->clip()) {
Q_ASSERT(itemPriv->clipNode == 0);
itemPriv->clipNode = new QSGDefaultClipNode(item->boundingRect());
+ itemPriv->clipNode->update();
if (child)
parent->removeChildNode(child);
@@ -1809,7 +1810,7 @@ void QSGCanvasPrivate::updateDirtyNode(QSGItem *item)
}
}
- if ((dirty & QSGItemPrivate::Size || clipEffectivelyChanged) && itemPriv->clipNode) {
+ if ((dirty & QSGItemPrivate::Size) && itemPriv->clipNode) {
itemPriv->clipNode->setRect(item->boundingRect());
itemPriv->clipNode->update();
}
diff --git a/src/declarative/items/qsgrectangle.cpp b/src/declarative/items/qsgrectangle.cpp
index b1c26a5a2c..25f0eda5d5 100644
--- a/src/declarative/items/qsgrectangle.cpp
+++ b/src/declarative/items/qsgrectangle.cpp
@@ -330,8 +330,22 @@ QSGRectangle::QSGRectangle(QSGItem *parent)
void QSGRectangle::doUpdate()
{
Q_D(QSGRectangle);
- const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
- d->setPaintMargin((pw+1)/2);
+ qreal penMargin = 0;
+ qreal penOffset = 0;
+ if (d->pen && d->pen->isValid()) {
+ if (d->pen->aligned()) {
+ const int pw = qRound(d->pen->width());
+ penMargin = qreal(0.5) * pw;
+ penOffset = (pw & 1) * qreal(0.5);
+ } else {
+ penMargin = qreal(0.5) * d->pen->width();
+ }
+ }
+ if (penMargin != d->penMargin || penOffset != d->penOffset) {
+ d->penMargin = penMargin;
+ d->penOffset = penOffset;
+ d->dirty(QSGItemPrivate::Size); // update clip
+ }
update();
}
@@ -534,7 +548,8 @@ QSGNode *QSGRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *da
QRectF QSGRectangle::boundingRect() const
{
Q_D(const QSGRectangle);
- return QRectF(-d->paintmargin, -d->paintmargin, width()+d->paintmargin*2, height()+d->paintmargin*2);
+ return QRectF(d->penOffset - d->penMargin, d->penOffset - d->penMargin,
+ d->width + 2 * d->penMargin, d->height + 2 * d->penMargin);
}
QT_END_NAMESPACE
diff --git a/src/declarative/items/qsgrectangle_p_p.h b/src/declarative/items/qsgrectangle_p_p.h
index 6e1beb7bdb..234a029aaf 100644
--- a/src/declarative/items/qsgrectangle_p_p.h
+++ b/src/declarative/items/qsgrectangle_p_p.h
@@ -66,7 +66,7 @@ class QSGRectanglePrivate : public QSGItemPrivate
public:
QSGRectanglePrivate() :
- color(Qt::white), gradient(0), pen(0), radius(0), paintmargin(0)
+ color(Qt::white), gradient(0), pen(0), radius(0), penMargin(0), penOffset(0)
{
}
@@ -79,7 +79,8 @@ public:
QSGGradient *gradient;
QSGPen *pen;
qreal radius;
- qreal paintmargin;
+ qreal penMargin;
+ qreal penOffset;
static int doUpdateSlotIdx;
QSGPen *getPen() {
@@ -95,13 +96,6 @@ public:
}
return pen;
}
-
- void setPaintMargin(qreal margin)
- {
- if (margin == paintmargin)
- return;
- paintmargin = margin;
- }
};
QT_END_NAMESPACE