diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-06-03 13:49:51 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-22 13:11:14 +0000 |
commit | 65c877f40e965c368fe6e7ed730242461b5824b7 (patch) | |
tree | f23a8b64b5e3530ba5714ce1a0339302e5336ae8 /src/quick/items | |
parent | 702c4247d74ffb7e4fb1aaca96d70f4591203ba2 (diff) |
Add cross-backend simple rect, texture, and ninepatch nodes
QSGSimpleRectNode is deprecated -> use
QSGRectangleNode via QQuickWindow::createRectangleNode() instead.
QSGSimpleTextureNode is deprecated -> use
QSGImageNode via QQuickWindow::createImageNode() instead.
The OpenGL version of the simple rectangle node is switched over to
the vertex color material instead of flat, to allow for better batching.
Use the same concept for nine patch nodes. The "style" node from Quick Controls 1
is now QSGNinePatchNode in order to provide a proper cross-backend solution which
is already necessary due to the software backend, but now generalize it to apply
to the accelerated backends with proper materials as well. QC can now simply call
createNinePatchNode() without further ado.
Also fixes a bug with the D3D12 texture material not enabling blending
when needed.
When it comes to the internal class names, QSGRectangleNode and
QSGImageNode get the Internal prefix in the adaptation layer in order to
differentiate from the public API. This involves quite a lot of renaming,
but results in a nice and clean public API.
Change-Id: Iddf9f9412377843ea6d652bcf25e68d1d74659ea
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/context2d/qquickcanvasitem.cpp | 6 | ||||
-rw-r--r-- | src/quick/items/qquickborderimage.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquickimage.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquickmousearea.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquickmultipointtoucharea.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquickrectangle.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquickshadereffectmesh.cpp | 6 | ||||
-rw-r--r-- | src/quick/items/qquickshadereffectsource.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquickshadereffectsource_p.h | 2 | ||||
-rw-r--r-- | src/quick/items/qquicktextedit.cpp | 8 | ||||
-rw-r--r-- | src/quick/items/qquicktextnode.cpp | 6 | ||||
-rw-r--r-- | src/quick/items/qquicktextnode_p.h | 6 | ||||
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 39 | ||||
-rw-r--r-- | src/quick/items/qquickwindow.h | 7 |
14 files changed, 75 insertions, 29 deletions
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 9d5ddab155..8d91df5a74 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -174,7 +174,7 @@ public: QUrl baseUrl; QMap<int, QV4::PersistentValue> animationCallbacks; mutable QQuickCanvasTextureProvider *textureProvider; - QSGImageNode *node; + QSGInternalImageNode *node; QSGTexture *nodeTexture; }; @@ -743,9 +743,9 @@ QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData return 0; } - QSGImageNode *node = static_cast<QSGImageNode *>(oldNode); + QSGInternalImageNode *node = static_cast<QSGInternalImageNode *>(oldNode); if (!node) { - node = QQuickWindowPrivate::get(window())->context->sceneGraphContext()->createImageNode(); + node = QQuickWindowPrivate::get(window())->context->sceneGraphContext()->createInternalImageNode(); d->node = node; } diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp index b3a35e6219..ca5ad8dbbd 100644 --- a/src/quick/items/qquickborderimage.cpp +++ b/src/quick/items/qquickborderimage.cpp @@ -631,12 +631,12 @@ QSGNode *QQuickBorderImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat return 0; } - QSGImageNode *node = static_cast<QSGImageNode *>(oldNode); + QSGInternalImageNode *node = static_cast<QSGInternalImageNode *>(oldNode); bool updatePixmap = d->pixmapChanged; d->pixmapChanged = false; if (!node) { - node = d->sceneGraphContext()->createImageNode(); + node = d->sceneGraphContext()->createInternalImageNode(); updatePixmap = true; } diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp index a168b43fd1..e36c070248 100644 --- a/src/quick/items/qquickimage.cpp +++ b/src/quick/items/qquickimage.cpp @@ -614,10 +614,10 @@ QSGNode *QQuickImage::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) return 0; } - QSGImageNode *node = static_cast<QSGImageNode *>(oldNode); + QSGInternalImageNode *node = static_cast<QSGInternalImageNode *>(oldNode); if (!node) { d->pixmapChanged = true; - node = d->sceneGraphContext()->createImageNode(); + node = d->sceneGraphContext()->createInternalImageNode(); } QRectF targetRect; diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index 297a57e672..33cc6c9a63 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -1354,8 +1354,8 @@ QSGNode *QQuickMouseArea::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData if (!qmlVisualTouchDebugging()) return 0; - QSGRectangleNode *rectangle = static_cast<QSGRectangleNode *>(oldNode); - if (!rectangle) rectangle = d->sceneGraphContext()->createRectangleNode(); + QSGInternalRectangleNode *rectangle = static_cast<QSGInternalRectangleNode *>(oldNode); + if (!rectangle) rectangle = d->sceneGraphContext()->createInternalRectangleNode(); rectangle->setRect(QRectF(0, 0, width(), height())); rectangle->setColor(QColor(255, 0, 0, 50)); diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp index 9d8e7aedd4..ac5598767a 100644 --- a/src/quick/items/qquickmultipointtoucharea.cpp +++ b/src/quick/items/qquickmultipointtoucharea.cpp @@ -940,8 +940,8 @@ QSGNode *QQuickMultiPointTouchArea::updatePaintNode(QSGNode *oldNode, UpdatePain if (!qmlVisualTouchDebugging()) return 0; - QSGRectangleNode *rectangle = static_cast<QSGRectangleNode *>(oldNode); - if (!rectangle) rectangle = QQuickItemPrivate::get(this)->sceneGraphContext()->createRectangleNode(); + QSGInternalRectangleNode *rectangle = static_cast<QSGInternalRectangleNode *>(oldNode); + if (!rectangle) rectangle = QQuickItemPrivate::get(this)->sceneGraphContext()->createInternalRectangleNode(); rectangle->setRect(QRectF(0, 0, width(), height())); rectangle->setColor(QColor(255, 0, 0, 50)); diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp index b8c680433e..223976c32f 100644 --- a/src/quick/items/qquickrectangle.cpp +++ b/src/quick/items/qquickrectangle.cpp @@ -482,8 +482,8 @@ QSGNode *QQuickRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData return 0; } - QSGRectangleNode *rectangle = static_cast<QSGRectangleNode *>(oldNode); - if (!rectangle) rectangle = d->sceneGraphContext()->createRectangleNode(); + QSGInternalRectangleNode *rectangle = static_cast<QSGInternalRectangleNode *>(oldNode); + if (!rectangle) rectangle = d->sceneGraphContext()->createInternalRectangleNode(); rectangle->setRect(QRectF(0, 0, width(), height())); rectangle->setColor(d->color); diff --git a/src/quick/items/qquickshadereffectmesh.cpp b/src/quick/items/qquickshadereffectmesh.cpp index f5cc19c877..8616bf8022 100644 --- a/src/quick/items/qquickshadereffectmesh.cpp +++ b/src/quick/items/qquickshadereffectmesh.cpp @@ -42,7 +42,7 @@ #include "qquickshadereffect_p.h" #include "qquickscalegrid_p_p.h" #include "qquickborderimage_p_p.h" -#include <QtQuick/private/qsgbasicimagenode_p.h> +#include <QtQuick/private/qsgbasicinternalimagenode_p.h> QT_BEGIN_NAMESPACE @@ -335,8 +335,8 @@ QSGGeometry *QQuickBorderImageMesh::updateGeometry(QSGGeometry *geometry, int at innerSourceRect.width() * sourceRect.width(), innerSourceRect.height() * sourceRect.height()); - geometry = QSGBasicImageNode::updateGeometry(targetRect, innerTargetRect, sourceRect, - modifiedInnerSourceRect, subSourceRect, geometry); + geometry = QSGBasicInternalImageNode::updateGeometry(targetRect, innerTargetRect, sourceRect, + modifiedInnerSourceRect, subSourceRect, geometry); return geometry; } diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp index 338e4dc3a7..d74dd99fe8 100644 --- a/src/quick/items/qquickshadereffectsource.cpp +++ b/src/quick/items/qquickshadereffectsource.cpp @@ -708,9 +708,9 @@ QSGNode *QQuickShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaint return 0; } - QSGImageNode *node = static_cast<QSGImageNode *>(oldNode); + QSGInternalImageNode *node = static_cast<QSGInternalImageNode *>(oldNode); if (!node) { - node = d->sceneGraphContext()->createImageNode(); + node = d->sceneGraphContext()->createInternalImageNode(); node->setFlag(QSGNode::UsePreprocess); node->setTexture(m_texture); QQuickShaderSourceAttachedNode *attached = new QQuickShaderSourceAttachedNode; diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h index 680ba85aa1..de62c21488 100644 --- a/src/quick/items/qquickshadereffectsource_p.h +++ b/src/quick/items/qquickshadereffectsource_p.h @@ -55,7 +55,7 @@ #include <QtQuick/qsgtextureprovider.h> #include <private/qsgadaptationlayer_p.h> #include <QtQuick/private/qsgcontext_p.h> -#include <private/qsgdefaultimagenode_p.h> +#include <private/qsgdefaultinternalimagenode_p.h> #include <private/qquickitemchangelistener_p.h> #include "qpointer.h" diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 36eb5d3cde..eb568c48d4 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -153,7 +153,7 @@ namespace { newNode->setFlag(QSGNode::OwnedByParent); } - void resetCursorNode(QSGRectangleNode* newNode) + void resetCursorNode(QSGInternalRectangleNode* newNode) { if (cursorNode) removeChildNode(cursorNode); @@ -165,7 +165,7 @@ namespace { } } - QSGRectangleNode *cursorNode; + QSGInternalRectangleNode *cursorNode; QQuickTextNode* frameDecorationsNode; }; @@ -2125,9 +2125,9 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData * } if (d->cursorComponent == 0) { - QSGRectangleNode* cursor = 0; + QSGInternalRectangleNode* cursor = 0; if (!isReadOnly() && d->cursorVisible && d->control->cursorOn()) - cursor = d->sceneGraphContext()->createRectangleNode(d->control->cursorRect(), d->color); + cursor = d->sceneGraphContext()->createInternalRectangleNode(d->control->cursorRect(), d->color); rootNode->resetCursorNode(cursor); } diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp index 7ee01b5398..0e9d1e3951 100644 --- a/src/quick/items/qquicktextnode.cpp +++ b/src/quick/items/qquicktextnode.cpp @@ -136,7 +136,7 @@ void QQuickTextNode::setCursor(const QRectF &rect, const QColor &color) delete m_cursorNode; QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext(); - m_cursorNode = sg->sceneGraphContext()->createRectangleNode(rect, color); + m_cursorNode = sg->sceneGraphContext()->createInternalRectangleNode(rect, color); appendChildNode(m_cursorNode); } @@ -151,14 +151,14 @@ void QQuickTextNode::clearCursor() void QQuickTextNode::addRectangleNode(const QRectF &rect, const QColor &color) { QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext(); - appendChildNode(sg->sceneGraphContext()->createRectangleNode(rect, color)); + appendChildNode(sg->sceneGraphContext()->createInternalRectangleNode(rect, color)); } void QQuickTextNode::addImage(const QRectF &rect, const QImage &image) { QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext(); - QSGImageNode *node = sg->sceneGraphContext()->createImageNode(); + QSGInternalImageNode *node = sg->sceneGraphContext()->createInternalImageNode(); QSGTexture *texture = sg->createTexture(image); m_textures.append(texture); node->setTargetRect(rect); diff --git a/src/quick/items/qquicktextnode_p.h b/src/quick/items/qquicktextnode_p.h index 0006cf1156..fb30956fea 100644 --- a/src/quick/items/qquicktextnode_p.h +++ b/src/quick/items/qquicktextnode_p.h @@ -68,7 +68,7 @@ class QColor; class QTextDocument; class QSGContext; class QRawFont; -class QSGRectangleNode; +class QSGInternalRectangleNode; class QSGClipNode; class QSGTexture; @@ -106,7 +106,7 @@ public: void setCursor(const QRectF &rect, const QColor &color); void clearCursor(); - QSGRectangleNode *cursorNode() const { return m_cursorNode; } + QSGInternalRectangleNode *cursorNode() const { return m_cursorNode; } QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color, QQuickText::TextStyle style = QQuickText::Normal, const QColor &styleColor = QColor(), @@ -118,7 +118,7 @@ public: void setUseNativeRenderer(bool on) { m_useNativeRenderer = on; } private: - QSGRectangleNode *m_cursorNode; + QSGInternalRectangleNode *m_cursorNode; QList<QSGTexture *> m_textures; QQuickItem *m_ownerElement; bool m_useNativeRenderer; diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 98e450abdb..10b769b5b0 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -4513,6 +4513,45 @@ void QQuickWindow::setSceneGraphBackend(const QString &backend) QSGContext::setBackend(backend); } +/*! + Creates a simple rectangle node. When the scenegraph is not initialized, the return value is null. + + This is cross-backend alternative to constructing a QSGSimpleRectNode directly. + + \since 5.8 + \sa QSGRectangleNode + */ +QSGRectangleNode *QQuickWindow::createRectangleNode() const +{ + Q_D(const QQuickWindow); + return isSceneGraphInitialized() ? d->context->sceneGraphContext()->createRectangleNode() : nullptr; +} + +/*! + Creates a simple image node. When the scenegraph is not initialized, the return value is null. + + This is cross-backend alternative to constructing a QSGSimpleTextureNode directly. + + \since 5.8 + \sa QSGImageNode + */ +QSGImageNode *QQuickWindow::createImageNode() const +{ + Q_D(const QQuickWindow); + return isSceneGraphInitialized() ? d->context->sceneGraphContext()->createImageNode() : nullptr; +} + +/*! + Creates a nine patch node. When the scenegraph is not initialized, the return value is null. + + \since 5.8 + */ +QSGNinePatchNode *QQuickWindow::createNinePatchNode() const +{ + Q_D(const QQuickWindow); + return isSceneGraphInitialized() ? d->context->sceneGraphContext()->createNinePatchNode() : nullptr; +} + #include "moc_qquickwindow.cpp" QT_END_NAMESPACE diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h index c741772253..cfadadec2d 100644 --- a/src/quick/items/qquickwindow.h +++ b/src/quick/items/qquickwindow.h @@ -61,6 +61,9 @@ class QQmlIncubationController; class QInputMethodEvent; class QQuickCloseEvent; class QQuickRenderControl; +class QSGRectangleNode; +class QSGImageNode; +class QSGNinePatchNode; class Q_QUICK_EXPORT QQuickWindow : public QWindow { @@ -159,6 +162,10 @@ public: static void setSceneGraphBackend(QSGRendererInterface::GraphicsApi api); static void setSceneGraphBackend(const QString &backend); + QSGRectangleNode *createRectangleNode() const; + QSGImageNode *createImageNode() const; + QSGNinePatchNode *createNinePatchNode() const; + Q_SIGNALS: void frameSwapped(); Q_REVISION(2) void openglContextCreated(QOpenGLContext *context); |