aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-05-24 14:29:28 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2016-06-22 16:55:55 +0000
commit373f30d86c4288e339f3bd8899061ec2f3eb269d (patch)
treef09c0437410cbd7e5f83e451764bb4cf965b1d04 /src
parent1e8e2148059a83b17cc7c888364f4b27fb7b0391 (diff)
Migrate to new scenegraphng API
Change-Id: I9b0c05edacd4e6f1be6f692e77476097d1f99bc0 Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/material/qquickmaterialprogressring.cpp55
-rw-r--r--src/imports/controls/material/qquickmaterialprogressstrip.cpp19
-rw-r--r--src/imports/controls/qquickbusyindicatorring.cpp19
-rw-r--r--src/imports/controls/qquickprogressstrip.cpp22
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressring.cpp4
-rw-r--r--src/imports/controls/universal/qquickuniversalprogressstrip.cpp12
-rw-r--r--src/quickcontrols2/qquickpaddedrectangle.cpp2
7 files changed, 56 insertions, 77 deletions
diff --git a/src/imports/controls/material/qquickmaterialprogressring.cpp b/src/imports/controls/material/qquickmaterialprogressring.cpp
index cbed6886..aec92631 100644
--- a/src/imports/controls/material/qquickmaterialprogressring.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressring.cpp
@@ -41,8 +41,8 @@
#include <QtCore/qset.h>
#include <QtGui/qpainter.h>
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/qsgsimplerectnode.h>
-#include <QtQuick/qsgsimpletexturenode.h>
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qsgimagenode.h>
#include <QtQuick/qquickwindow.h>
QT_BEGIN_NAMESPACE
@@ -77,18 +77,6 @@ private:
qreal m_devicePixelRatio;
QSGNode *m_containerNode;
QQuickWindow *m_window;
-};
-
-class QQuickMaterialRingTexture : public QSGSimpleTextureNode
-{
-public:
- QQuickMaterialRingTexture();
- ~QQuickMaterialRingTexture();
-
- QColor color() const;
- void setColor(QColor color);
-
-private:
QColor m_color;
};
@@ -104,14 +92,15 @@ QQuickMaterialProgressRing::~QQuickMaterialProgressRing()
QSGNode *QQuickMaterialProgressRing::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *)
{
- if (!oldNode)
- oldNode = new QSGSimpleRectNode(boundingRect(), Qt::transparent);
-
- static_cast<QSGSimpleRectNode *>(oldNode)->setRect(boundingRect());
+ if (!oldNode) {
+ oldNode = window()->createRectangleNode();
+ static_cast<QSGRectangleNode *>(oldNode)->setColor(Qt::transparent);
+ }
+ static_cast<QSGRectangleNode *>(oldNode)->setRect(boundingRect());
- QQuickMaterialRingTexture *textureNode = static_cast<QQuickMaterialRingTexture*>(oldNode->firstChild());
+ QSGImageNode *textureNode = static_cast<QSGImageNode *>(oldNode->firstChild());
if (!textureNode) {
- textureNode = new QQuickMaterialRingTexture;
+ textureNode = window()->createImageNode();
textureNode->setOwnsTexture(true);
oldNode->appendChildNode(textureNode);
}
@@ -120,7 +109,6 @@ QSGNode *QQuickMaterialProgressRing::updatePaintNode(QSGNode *oldNode, QQuickIte
// so just use a blank image.
QImage blankImage(width(), height(), QImage::Format_ARGB32_Premultiplied);
blankImage.fill(Qt::transparent);
- textureNode->setColor(m_color);
textureNode->setRect(boundingRect());
textureNode->setTexture(window()->createTextureFromImage(blankImage));
@@ -190,7 +178,7 @@ void QQuickMaterialRingAnimatorJob::updateCurrentTime(int time)
if (!m_containerNode)
return;
- QSGSimpleRectNode *rectNode = static_cast<QSGSimpleRectNode*>(m_containerNode->firstChild());
+ QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(m_containerNode->firstChild());
if (!rectNode)
return;
@@ -205,8 +193,8 @@ void QQuickMaterialRingAnimatorJob::updateCurrentTime(int time)
painter.setRenderHint(QPainter::Antialiasing);
QPen pen;
- QQuickMaterialRingTexture *textureNode = static_cast<QQuickMaterialRingTexture*>(rectNode->firstChild());
- pen.setColor(textureNode->color());
+ QSGImageNode *textureNode = static_cast<QSGImageNode *>(rectNode->firstChild());
+ pen.setColor(m_color);
pen.setWidth(4 * m_devicePixelRatio);
painter.setPen(pen);
@@ -264,24 +252,7 @@ void QQuickMaterialRingAnimatorJob::nodeWasDestroyed()
void QQuickMaterialRingAnimatorJob::afterNodeSync()
{
m_containerNode = QQuickItemPrivate::get(m_target)->childContainerNode();
-}
-
-QQuickMaterialRingTexture::QQuickMaterialRingTexture()
-{
-}
-
-QQuickMaterialRingTexture::~QQuickMaterialRingTexture()
-{
-}
-
-QColor QQuickMaterialRingTexture::color() const
-{
- return m_color;
-}
-
-void QQuickMaterialRingTexture::setColor(QColor color)
-{
- m_color = color;
+ m_color = static_cast<QQuickMaterialProgressRing *>(m_target.data())->color();
}
QT_END_NAMESPACE
diff --git a/src/imports/controls/material/qquickmaterialprogressstrip.cpp b/src/imports/controls/material/qquickmaterialprogressstrip.cpp
index ce4d676e..542d312f 100644
--- a/src/imports/controls/material/qquickmaterialprogressstrip.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressstrip.cpp
@@ -38,10 +38,11 @@
#include <QtCore/qmath.h>
#include <QtCore/qeasingcurve.h>
-#include <QtQuick/qsgsimplerectnode.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickanimatorjob_p.h>
#include <QtQuick/private/qsgadaptationlayer_p.h>
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qsgimagenode.h>
QT_BEGIN_NAMESPACE
@@ -81,7 +82,7 @@ void QQuickMaterialProgressStripAnimatorJob::updateCurrentTime(int time)
if (!m_node)
return;
- QSGSimpleRectNode *geometryNode = static_cast<QSGSimpleRectNode *>(m_node->firstChild());
+ QSGRectangleNode *geometryNode = static_cast<QSGRectangleNode *>(m_node->firstChild());
Q_ASSERT(!geometryNode || geometryNode->type() == QSGNode::GeometryNodeType);
if (!geometryNode)
return;
@@ -128,7 +129,7 @@ void QQuickMaterialProgressStripAnimatorJob::moveNode(QSGTransformNode *transfor
matrix.translate(x, 0);
transformNode->setMatrix(matrix);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(transformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(transformNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
QRectF r = geometry;
@@ -211,9 +212,11 @@ QSGNode *QQuickMaterialProgressStrip::updatePaintNode(QSGNode *oldNode, UpdatePa
bounds.setHeight(implicitHeight());
bounds.moveTop((height() - bounds.height()) / 2.0);
- if (!oldNode)
- oldNode = new QSGSimpleRectNode(bounds, Qt::transparent);
- static_cast<QSGSimpleRectNode *>(oldNode)->setRect(bounds);
+ if (!oldNode) {
+ oldNode = window()->createRectangleNode();
+ static_cast<QSGRectangleNode *>(oldNode)->setColor(Qt::transparent);
+ }
+ static_cast<QSGRectangleNode *>(oldNode)->setRect(bounds);
const int count = m_indeterminate ? 2 : 1;
const qreal w = m_indeterminate ? 0 : m_progress * width();
@@ -225,14 +228,14 @@ QSGNode *QQuickMaterialProgressStrip::updatePaintNode(QSGNode *oldNode, UpdatePa
transformNode = new QSGTransformNode;
oldNode->appendChildNode(transformNode);
- QSGRectangleNode *rectNode = d->sceneGraphContext()->createRectangleNode();
+ QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setAntialiasing(true);
transformNode->appendChildNode(rectNode);
}
Q_ASSERT(transformNode->type() == QSGNode::TransformNodeType);
static_cast<QSGTransformNode *>(transformNode)->setMatrix(QMatrix4x4());
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(transformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(transformNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
rectNode->setRect(rect);
diff --git a/src/imports/controls/qquickbusyindicatorring.cpp b/src/imports/controls/qquickbusyindicatorring.cpp
index 4f9e9977..d8c035d2 100644
--- a/src/imports/controls/qquickbusyindicatorring.cpp
+++ b/src/imports/controls/qquickbusyindicatorring.cpp
@@ -39,8 +39,9 @@
#include <QtCore/qset.h>
#include <QtGui/qpainter.h>
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/qsgsimplerectnode.h>
+#include <QtQuick/qsgnode.h>
#include <QtQuick/qquickwindow.h>
+#include <QtQuick/qsgrectanglenode.h>
QT_BEGIN_NAMESPACE
@@ -84,9 +85,11 @@ QSGNode *QQuickBusyIndicatorRing::updatePaintNode(QSGNode *oldNode, QQuickItem::
{
QQuickItemPrivate *d = QQuickItemPrivate::get(this);
- if (!oldNode)
- oldNode = new QSGSimpleRectNode(boundingRect(), Qt::transparent);
- static_cast<QSGSimpleRectNode *>(oldNode)->setRect(boundingRect());
+ if (!oldNode) {
+ oldNode = window()->createRectangleNode();
+ static_cast<QSGRectangleNode *>(oldNode)->setColor(Qt::transparent);
+ }
+ static_cast<QSGRectangleNode *>(oldNode)->setRect(boundingRect());
QSGTransformNode *rootTransformNode = static_cast<QSGTransformNode *>(oldNode->firstChild());
if (!rootTransformNode) {
@@ -112,7 +115,7 @@ QSGNode *QQuickBusyIndicatorRing::updatePaintNode(QSGNode *oldNode, QQuickItem::
QSGOpacityNode *opacityNode = new QSGOpacityNode;
transformNode->appendChildNode(opacityNode);
- QSGRectangleNode *rectNode = d->sceneGraphContext()->createRectangleNode();
+ QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setAntialiasing(true);
rectNode->setColor(color);
rectNode->setPenColor(color);
@@ -122,7 +125,7 @@ QSGNode *QQuickBusyIndicatorRing::updatePaintNode(QSGNode *oldNode, QQuickItem::
QSGNode *opacityNode = transformNode->firstChild();
Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(opacityNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
QPointF pos = QPointF(sz / 2 - circleRadius, sz / 2 - circleRadius);
@@ -178,7 +181,7 @@ void QQuickBusyIndicatorAnimatorJob::updateCurrentTime(int time)
if (!m_node)
return;
- QSGSimpleRectNode *rootRectNode = static_cast<QSGSimpleRectNode*>(m_node->firstChild());
+ QSGRectangleNode *rootRectNode = static_cast<QSGRectangleNode *>(m_node->firstChild());
if (!rootRectNode)
return;
@@ -199,7 +202,7 @@ void QQuickBusyIndicatorAnimatorJob::updateCurrentTime(int time)
QSGOpacityNode *opacityNode = static_cast<QSGOpacityNode*>(transformNode->firstChild());
Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode*>(opacityNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(opacityNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
const bool fill = (firstPhaseProgress > qreal(i) / circles) || (secondPhaseProgress > 0 && secondPhaseProgress < qreal(i) / circles);
diff --git a/src/imports/controls/qquickprogressstrip.cpp b/src/imports/controls/qquickprogressstrip.cpp
index 5b50a28d..33a21848 100644
--- a/src/imports/controls/qquickprogressstrip.cpp
+++ b/src/imports/controls/qquickprogressstrip.cpp
@@ -37,7 +37,7 @@
#include "qquickprogressstrip_p.h"
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/qsgsimplerectnode.h>
+#include <QtQuick/qsgrectanglenode.h>
QT_BEGIN_NAMESPACE
@@ -129,9 +129,11 @@ QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::Upda
{
QQuickItemPrivate *d = QQuickItemPrivate::get(this);
- if (!oldNode)
- oldNode = new QSGSimpleRectNode(boundingRect(), Qt::transparent);
- static_cast<QSGSimpleRectNode *>(oldNode)->setRect(boundingRect());
+ if (!oldNode) {
+ oldNode = window()->createRectangleNode();
+ static_cast<QSGRectangleNode *>(oldNode)->setColor(Qt::transparent);
+ }
+ static_cast<QSGRectangleNode *>(oldNode)->setRect(boundingRect());
QSGTransformNode *rootTransformNode = static_cast<QSGTransformNode *>(oldNode->firstChild());
if (!rootTransformNode) {
@@ -155,9 +157,9 @@ QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::Upda
rootTransformNode->appendChildNode(transformNode);
}
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode*>(transformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(transformNode->firstChild());
if (!rectNode) {
- rectNode = d->sceneGraphContext()->createRectangleNode();
+ rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setColor(color);
transformNode->appendChildNode(rectNode);
}
@@ -177,9 +179,9 @@ QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::Upda
rootTransformNode->removeAllChildNodes();
}
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(rootTransformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(rootTransformNode->firstChild());
if (!rectNode) {
- rectNode = d->sceneGraphContext()->createRectangleNode();
+ rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setColor(color);
rootTransformNode->appendChildNode(rectNode);
}
@@ -233,7 +235,7 @@ void QQuickProgressAnimatorJob::updateCurrentTime(int time)
if (!m_node)
return;
- QSGSimpleRectNode *rootRectNode = static_cast<QSGSimpleRectNode*>(m_node->firstChild());
+ QSGRectangleNode *rootRectNode = static_cast<QSGRectangleNode *>(m_node->firstChild());
if (!rootRectNode)
return;
Q_ASSERT(rootRectNode->type() == QSGNode::GeometryNodeType);
@@ -250,7 +252,7 @@ void QQuickProgressAnimatorJob::updateCurrentTime(int time)
const qreal pixelsPerSecond = rootRectNode->rect().width();
for (int i = 0; i < blocks; ++i) {
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode*>(transformNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(transformNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
QMatrix4x4 m;
diff --git a/src/imports/controls/universal/qquickuniversalprogressring.cpp b/src/imports/controls/universal/qquickuniversalprogressring.cpp
index ac087c78..1d733fed 100644
--- a/src/imports/controls/universal/qquickuniversalprogressring.cpp
+++ b/src/imports/controls/universal/qquickuniversalprogressring.cpp
@@ -241,7 +241,7 @@ QSGNode *QQuickUniversalProgressRing::updatePaintNode(QSGNode *oldNode, UpdatePa
QSGOpacityNode *opacityNode = new QSGOpacityNode;
transformNode->appendChildNode(opacityNode);
- QSGRectangleNode *rectNode = d->sceneGraphContext()->createRectangleNode();
+ QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setAntialiasing(true);
opacityNode->appendChildNode(rectNode);
}
@@ -249,7 +249,7 @@ QSGNode *QQuickUniversalProgressRing::updatePaintNode(QSGNode *oldNode, UpdatePa
QSGNode *opacityNode = transformNode->firstChild();
Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(opacityNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
rectNode->setRect(rect);
diff --git a/src/imports/controls/universal/qquickuniversalprogressstrip.cpp b/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
index 16f394f1..32af5113 100644
--- a/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
+++ b/src/imports/controls/universal/qquickuniversalprogressstrip.cpp
@@ -38,10 +38,10 @@
#include <QtCore/qmath.h>
#include <QtCore/qeasingcurve.h>
-#include <QtQuick/qsgsimplerectnode.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickanimatorjob_p.h>
#include <QtQuick/private/qsgadaptationlayer_p.h>
+#include <QtQuick/qsgrectanglenode.h>
QT_BEGIN_NAMESPACE
@@ -106,7 +106,7 @@ void QQuickUniversalProgressStripAnimatorJob::updateCurrentTime(int time)
if (!m_node)
return;
- QSGSimpleRectNode *geometryNode = static_cast<QSGSimpleRectNode *>(m_node->firstChild());
+ QSGRectangleNode *geometryNode = static_cast<QSGRectangleNode *>(m_node->firstChild());
Q_ASSERT(!geometryNode || geometryNode->type() == QSGNode::GeometryNodeType);
if (!geometryNode)
return;
@@ -286,9 +286,9 @@ QSGNode *QQuickUniversalProgressStrip::updatePaintNode(QSGNode *oldNode, UpdateP
if (!m_indeterminate)
bounds.setWidth(m_progress * bounds.width());
- QSGSimpleRectNode *geometryNode = static_cast<QSGSimpleRectNode *>(oldNode);
+ QSGRectangleNode *geometryNode = static_cast<QSGRectangleNode *>(oldNode);
if (!geometryNode)
- geometryNode = new QSGSimpleRectNode(bounds, Qt::transparent);
+ geometryNode = window()->createRectangleNode();
geometryNode->setRect(bounds);
geometryNode->setColor(m_indeterminate ? Qt::transparent : m_color);
@@ -317,7 +317,7 @@ QSGNode *QQuickUniversalProgressStrip::updatePaintNode(QSGNode *oldNode, UpdateP
QSGOpacityNode *opacityNode = new QSGOpacityNode;
ellipseNode->appendChildNode(opacityNode);
- QSGRectangleNode *rectNode = d->sceneGraphContext()->createRectangleNode();
+ QSGInternalRectangleNode *rectNode = d->sceneGraphContext()->createInternalRectangleNode();
rectNode->setAntialiasing(true);
rectNode->setRadius(EllipseDiameter / 2);
opacityNode->appendChildNode(rectNode);
@@ -330,7 +330,7 @@ QSGNode *QQuickUniversalProgressStrip::updatePaintNode(QSGNode *oldNode, UpdateP
QSGNode *opacityNode = ellipseNode->firstChild();
Q_ASSERT(opacityNode->type() == QSGNode::OpacityNodeType);
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(opacityNode->firstChild());
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(opacityNode->firstChild());
Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
rectNode->setRect(QRectF((EllipseCount - i - 1) * (EllipseDiameter + EllipseOffset), (height() - EllipseDiameter) / 2, EllipseDiameter, EllipseDiameter));
diff --git a/src/quickcontrols2/qquickpaddedrectangle.cpp b/src/quickcontrols2/qquickpaddedrectangle.cpp
index 08d74dc6..28423f51 100644
--- a/src/quickcontrols2/qquickpaddedrectangle.cpp
+++ b/src/quickcontrols2/qquickpaddedrectangle.cpp
@@ -184,7 +184,7 @@ QSGNode *QQuickPaddedRectangle::updatePaintNode(QSGNode *node, UpdatePaintNodeDa
if (!transformNode)
transformNode = new QSGTransformNode;
- QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(QQuickRectangle::updatePaintNode(transformNode->firstChild(), data));
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(QQuickRectangle::updatePaintNode(transformNode->firstChild(), data));
if (rectNode) {
if (!transformNode->firstChild())