From 883b10ada42924b179a95eb4d9096c1018867e26 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 17 Dec 2015 15:54:33 +0100 Subject: QQuickPaddedRectangle: fix antialiasing issues Use a transformation node to set the position of the rectangle node. Change-Id: Ic9d8f03d0921236556d363cc66ff2fe66ce296e4 Reviewed-by: J-P Nurmi --- src/controls/qquickpaddedrectangle.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/controls/qquickpaddedrectangle.cpp b/src/controls/qquickpaddedrectangle.cpp index ee66a5a5..9542ca5f 100644 --- a/src/controls/qquickpaddedrectangle.cpp +++ b/src/controls/qquickpaddedrectangle.cpp @@ -180,18 +180,31 @@ void QQuickPaddedRectangle::setBottomPadding(qreal padding, bool has) QSGNode *QQuickPaddedRectangle::updatePaintNode(QSGNode *node, UpdatePaintNodeData *data) { - QSGRectangleNode *rectangle = static_cast(QQuickRectangle::updatePaintNode(node, data)); - if (rectangle) { + QSGTransformNode *transformNode = static_cast(node); + if (!transformNode) + transformNode = new QSGTransformNode; + + QSGRectangleNode *rectNode = static_cast(QQuickRectangle::updatePaintNode(transformNode->firstChild(), data)); + + if (rectNode) { + if (!transformNode->firstChild()) + transformNode->appendChildNode(rectNode); + qreal top = topPadding(); qreal left = leftPadding(); qreal right = rightPadding(); qreal bottom = bottomPadding(); + if (!qFuzzyIsNull(top) || !qFuzzyIsNull(left) || !qFuzzyIsNull(right) || !qFuzzyIsNull(bottom)) { - rectangle->setRect(boundingRect().adjusted(left, top, -right, -bottom)); - rectangle->update(); + QMatrix4x4 m; + m.translate(left, top); + transformNode->setMatrix(m); + + rectNode->setRect(boundingRect().adjusted(0, 0, -left-right, -top-bottom)); + rectNode->update(); } } - return rectangle; + return transformNode; } QT_END_NAMESPACE -- cgit v1.2.3