aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp39
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h8
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp (renamed from src/quick/scenegraph/adaptations/software/qsgsoftwareimagenode.cpp)34
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h (renamed from src/quick/scenegraph/adaptations/software/qsgsoftwareimagenode_p.h)10
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp (renamed from src/quick/scenegraph/adaptations/software/qsgsoftwarerectanglenode.cpp)30
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode_p.h (renamed from src/quick/scenegraph/adaptations/software/qsgsoftwarerectanglenode_p.h)10
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes.cpp (renamed from src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode.cpp)41
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes_p.h137
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp38
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h18
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp29
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h10
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp23
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h10
-rw-r--r--src/quick/scenegraph/adaptations/software/software.pri12
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.cpp21
-rw-r--r--src/quick/scenegraph/coreapi/qsggeometry.h1
-rw-r--r--src/quick/scenegraph/coreapi/qsgnode.cpp2
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer_p.h32
-rw-r--r--src/quick/scenegraph/qsgbasicinternalimagenode.cpp (renamed from src/quick/scenegraph/qsgbasicimagenode.cpp)28
-rw-r--r--src/quick/scenegraph/qsgbasicinternalimagenode_p.h (renamed from src/quick/scenegraph/qsgbasicimagenode_p.h)8
-rw-r--r--src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp (renamed from src/quick/scenegraph/qsgbasicrectanglenode.cpp)26
-rw-r--r--src/quick/scenegraph/qsgbasicinternalrectanglenode_p.h (renamed from src/quick/scenegraph/qsgbasicrectanglenode_p.h)8
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp4
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h19
-rw-r--r--src/quick/scenegraph/qsgdefaultcontext.cpp43
-rw-r--r--src/quick/scenegraph/qsgdefaultcontext_p.h8
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalimagenode.cpp (renamed from src/quick/scenegraph/qsgdefaultimagenode.cpp)22
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalimagenode_p.h (renamed from src/quick/scenegraph/qsgdefaultimagenode_p.h)10
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp (renamed from src/quick/scenegraph/qsgdefaultrectanglenode.cpp)8
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalrectanglenode_p.h (renamed from src/quick/scenegraph/qsgdefaultrectanglenode_p.h)10
-rw-r--r--src/quick/scenegraph/scenegraph.pri33
-rw-r--r--src/quick/scenegraph/util/qsgdefaultimagenode.cpp190
-rw-r--r--src/quick/scenegraph/util/qsgdefaultimagenode_p.h104
-rw-r--r--src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp136
-rw-r--r--src/quick/scenegraph/util/qsgdefaultninepatchnode_p.h (renamed from src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h)30
-rw-r--r--src/quick/scenegraph/util/qsgdefaultrectanglenode.cpp95
-rw-r--r--src/quick/scenegraph/util/qsgdefaultrectanglenode_p.h79
-rw-r--r--src/quick/scenegraph/util/qsgengine.cpp41
-rw-r--r--src/quick/scenegraph/util/qsgengine.h6
-rw-r--r--src/quick/scenegraph/util/qsgimagenode.cpp175
-rw-r--r--src/quick/scenegraph/util/qsgimagenode.h85
-rw-r--r--src/quick/scenegraph/util/qsgninepatchnode.cpp77
-rw-r--r--src/quick/scenegraph/util/qsgninepatchnode.h62
-rw-r--r--src/quick/scenegraph/util/qsgrectanglenode.cpp86
-rw-r--r--src/quick/scenegraph/util/qsgrectanglenode.h62
-rw-r--r--src/quick/scenegraph/util/qsgsimplerectnode.cpp4
-rw-r--r--src/quick/scenegraph/util/qsgsimpletexturenode.cpp5
48 files changed, 1706 insertions, 263 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
index 15bc32ecb2..921071e32e 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
@@ -39,12 +39,12 @@
#include "qsgsoftwarecontext_p.h"
-#include "qsgsoftwarerectanglenode_p.h"
-#include "qsgsoftwareimagenode_p.h"
+#include "qsgsoftwareinternalrectanglenode_p.h"
+#include "qsgsoftwareinternalimagenode_p.h"
#include "qsgsoftwarepainternode_p.h"
#include "qsgsoftwarepixmaptexture_p.h"
#include "qsgsoftwareglyphnode_p.h"
-#include "qsgsoftwareninepatchnode_p.h"
+#include "qsgsoftwarepublicnodes_p.h"
#include "qsgsoftwarelayer_p.h"
#include "qsgsoftwarerenderer_p.h"
@@ -53,11 +53,6 @@
#include <QtGui/QWindow>
-#include <QtQuick/QSGFlatColorMaterial>
-#include <QtQuick/QSGVertexColorMaterial>
-#include <QtQuick/QSGOpaqueTextureMaterial>
-#include <QtQuick/QSGTextureMaterial>
-
// Used for very high-level info about the renderering and gl context
// Includes GL_VERSION, type of render loop, atlas size, etc.
Q_LOGGING_CATEGORY(QSG_RASTER_LOG_INFO, "qt.scenegraph.info")
@@ -93,14 +88,14 @@ QSGSoftwareContext::QSGSoftwareContext(QObject *parent)
{
}
-QSGRectangleNode *QSGSoftwareContext::createRectangleNode()
+QSGInternalRectangleNode *QSGSoftwareContext::createInternalRectangleNode()
{
- return new QSGSoftwareRectangleNode();
+ return new QSGSoftwareInternalRectangleNode();
}
-QSGImageNode *QSGSoftwareContext::createImageNode()
+QSGInternalImageNode *QSGSoftwareContext::createInternalImageNode()
{
- return new QSGSoftwareImageNode();
+ return new QSGSoftwareInternalImageNode();
}
QSGPainterNode *QSGSoftwareContext::createPainterNode(QQuickPaintedItem *item)
@@ -115,11 +110,6 @@ QSGGlyphNode *QSGSoftwareContext::createGlyphNode(QSGRenderContext *rc, bool pre
return new QSGSoftwareGlyphNode();
}
-QSGNinePatchNode *QSGSoftwareContext::createNinePatchNode()
-{
- return new QSGSoftwareNinePatchNode();
-}
-
QSGLayer *QSGSoftwareContext::createLayer(QSGRenderContext *renderContext)
{
return new QSGSoftwareLayer(renderContext);
@@ -169,6 +159,21 @@ QSGRendererInterface *QSGSoftwareContext::rendererInterface(QSGRenderContext *re
return this;
}
+QSGRectangleNode *QSGSoftwareContext::createRectangleNode()
+{
+ return new QSGSoftwareRectangleNode;
+}
+
+QSGImageNode *QSGSoftwareContext::createImageNode()
+{
+ return new QSGSoftwareImageNode;
+}
+
+QSGNinePatchNode *QSGSoftwareContext::createNinePatchNode()
+{
+ return new QSGSoftwareNinePatchNode;
+}
+
QSGRendererInterface::GraphicsApi QSGSoftwareContext::graphicsApi() const
{
return Software;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h
index 992f6f5677..9a939a0948 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext_p.h
@@ -86,14 +86,16 @@ public:
explicit QSGSoftwareContext(QObject *parent = nullptr);
QSGRenderContext *createRenderContext() override { return new QSGSoftwareRenderContext(this); }
- QSGRectangleNode *createRectangleNode() override;
- QSGImageNode *createImageNode() override;
+ QSGInternalRectangleNode *createInternalRectangleNode() override;
+ QSGInternalImageNode *createInternalImageNode() override;
QSGPainterNode *createPainterNode(QQuickPaintedItem *item) override;
QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode) override;
- QSGNinePatchNode *createNinePatchNode() override;
QSGLayer *createLayer(QSGRenderContext *renderContext) override;
QSurfaceFormat defaultSurfaceFormat() const override;
QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext) override;
+ QSGRectangleNode *createRectangleNode() override;
+ QSGImageNode *createImageNode() override;
+ QSGNinePatchNode *createNinePatchNode() override;
GraphicsApi graphicsApi() const override;
ShaderType shaderType() const override;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareimagenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
index c92a032623..10291b9cb5 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareimagenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qsgsoftwareimagenode_p.h"
+#include "qsgsoftwareinternalimagenode_p.h"
#include "qsgsoftwarepixmaptexture_p.h"
#include "qsgsoftwarelayer_p.h"
@@ -315,7 +315,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
} // QSGSoftwareHelpers namespace
-QSGSoftwareImageNode::QSGSoftwareImageNode()
+QSGSoftwareInternalImageNode::QSGSoftwareInternalImageNode()
: m_innerSourceRect(0, 0, 1, 1)
, m_subSourceRect(0, 0, 1, 1)
, m_texture(0)
@@ -330,7 +330,7 @@ QSGSoftwareImageNode::QSGSoftwareImageNode()
}
-void QSGSoftwareImageNode::setTargetRect(const QRectF &rect)
+void QSGSoftwareInternalImageNode::setTargetRect(const QRectF &rect)
{
if (rect == m_targetRect)
return;
@@ -338,7 +338,7 @@ void QSGSoftwareImageNode::setTargetRect(const QRectF &rect)
markDirty(DirtyGeometry);
}
-void QSGSoftwareImageNode::setInnerTargetRect(const QRectF &rect)
+void QSGSoftwareInternalImageNode::setInnerTargetRect(const QRectF &rect)
{
if (rect == m_innerTargetRect)
return;
@@ -346,7 +346,7 @@ void QSGSoftwareImageNode::setInnerTargetRect(const QRectF &rect)
markDirty(DirtyGeometry);
}
-void QSGSoftwareImageNode::setInnerSourceRect(const QRectF &rect)
+void QSGSoftwareInternalImageNode::setInnerSourceRect(const QRectF &rect)
{
if (rect == m_innerSourceRect)
return;
@@ -354,7 +354,7 @@ void QSGSoftwareImageNode::setInnerSourceRect(const QRectF &rect)
markDirty(DirtyGeometry);
}
-void QSGSoftwareImageNode::setSubSourceRect(const QRectF &rect)
+void QSGSoftwareInternalImageNode::setSubSourceRect(const QRectF &rect)
{
if (rect == m_subSourceRect)
return;
@@ -362,14 +362,14 @@ void QSGSoftwareImageNode::setSubSourceRect(const QRectF &rect)
markDirty(DirtyGeometry);
}
-void QSGSoftwareImageNode::setTexture(QSGTexture *texture)
+void QSGSoftwareInternalImageNode::setTexture(QSGTexture *texture)
{
m_texture = texture;
m_cachedMirroredPixmapIsDirty = true;
markDirty(DirtyMaterial);
}
-void QSGSoftwareImageNode::setMirror(bool mirror)
+void QSGSoftwareInternalImageNode::setMirror(bool mirror)
{
if (m_mirror != mirror) {
m_mirror = mirror;
@@ -378,11 +378,11 @@ void QSGSoftwareImageNode::setMirror(bool mirror)
}
}
-void QSGSoftwareImageNode::setMipmapFiltering(QSGTexture::Filtering /*filtering*/)
+void QSGSoftwareInternalImageNode::setMipmapFiltering(QSGTexture::Filtering /*filtering*/)
{
}
-void QSGSoftwareImageNode::setFiltering(QSGTexture::Filtering filtering)
+void QSGSoftwareInternalImageNode::setFiltering(QSGTexture::Filtering filtering)
{
bool smooth = (filtering == QSGTexture::Linear);
if (smooth == m_smooth)
@@ -392,7 +392,7 @@ void QSGSoftwareImageNode::setFiltering(QSGTexture::Filtering filtering)
markDirty(DirtyMaterial);
}
-void QSGSoftwareImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
+void QSGSoftwareInternalImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
{
bool tileHorizontal = (wrapMode == QSGTexture::Repeat);
if (tileHorizontal == m_tileHorizontal)
@@ -402,7 +402,7 @@ void QSGSoftwareImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
markDirty(DirtyMaterial);
}
-void QSGSoftwareImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
+void QSGSoftwareInternalImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
{
bool tileVertical = (wrapMode == QSGTexture::Repeat);
if (tileVertical == m_tileVertical)
@@ -412,7 +412,7 @@ void QSGSoftwareImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
markDirty(DirtyMaterial);
}
-void QSGSoftwareImageNode::update()
+void QSGSoftwareInternalImageNode::update()
{
if (m_cachedMirroredPixmapIsDirty) {
if (m_mirror) {
@@ -426,7 +426,7 @@ void QSGSoftwareImageNode::update()
}
}
-void QSGSoftwareImageNode::preprocess()
+void QSGSoftwareInternalImageNode::preprocess()
{
bool doDirty = false;
QSGLayer *t = qobject_cast<QSGLayer *>(m_texture);
@@ -450,7 +450,7 @@ static Qt::TileRule getTileRule(qreal factor)
}
-void QSGSoftwareImageNode::paint(QPainter *painter)
+void QSGSoftwareInternalImageNode::paint(QPainter *painter)
{
painter->setRenderHint(QPainter::SmoothPixmapTransform, m_smooth);
@@ -483,12 +483,12 @@ void QSGSoftwareImageNode::paint(QPainter *painter)
}
}
-QRectF QSGSoftwareImageNode::rect() const
+QRectF QSGSoftwareInternalImageNode::rect() const
{
return m_targetRect;
}
-const QPixmap &QSGSoftwareImageNode::pixmap() const
+const QPixmap &QSGSoftwareInternalImageNode::pixmap() const
{
if (QSGSoftwarePixmapTexture *pt = qobject_cast<QSGSoftwarePixmapTexture*>(m_texture)) {
return pt->pixmap();
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareimagenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h
index e42f616757..f21667fdf7 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareimagenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QSGSOFTWAREIMAGENODE_H
-#define QSGSOFTWAREIMAGENODE_H
+#ifndef QSGSOFTWAREINTERNALIMAGENODE_H
+#define QSGSOFTWAREINTERNALIMAGENODE_H
//
// W A R N I N G
@@ -101,10 +101,10 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
} // QSGSoftwareHelpers namespace
-class QSGSoftwareImageNode : public QSGImageNode
+class QSGSoftwareInternalImageNode : public QSGInternalImageNode
{
public:
- QSGSoftwareImageNode();
+ QSGSoftwareInternalImageNode();
void setTargetRect(const QRectF &rect) override;
void setInnerTargetRect(const QRectF &rect) override;
@@ -144,4 +144,4 @@ private:
QT_END_NAMESPACE
-#endif // QSGSOFTWAREIMAGENODE_H
+#endif // QSGSOFTWAREINTERNALIMAGENODE_H
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerectanglenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp
index 7672b14371..ea5124edf9 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerectanglenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode.cpp
@@ -37,14 +37,14 @@
**
****************************************************************************/
-#include "qsgsoftwarerectanglenode_p.h"
+#include "qsgsoftwareinternalrectanglenode_p.h"
#include <qmath.h>
#include <QtGui/QPainter>
QT_BEGIN_NAMESPACE
-QSGSoftwareRectangleNode::QSGSoftwareRectangleNode()
+QSGSoftwareInternalRectangleNode::QSGSoftwareInternalRectangleNode()
: m_penWidth(0)
, m_radius(0)
, m_cornerPixmapIsDirty(true)
@@ -56,7 +56,7 @@ QSGSoftwareRectangleNode::QSGSoftwareRectangleNode()
setGeometry((QSGGeometry*)1);
}
-void QSGSoftwareRectangleNode::setRect(const QRectF &rect)
+void QSGSoftwareInternalRectangleNode::setRect(const QRectF &rect)
{
QRect alignedRect = rect.toAlignedRect();
if (m_rect != alignedRect) {
@@ -65,7 +65,7 @@ void QSGSoftwareRectangleNode::setRect(const QRectF &rect)
}
}
-void QSGSoftwareRectangleNode::setColor(const QColor &color)
+void QSGSoftwareInternalRectangleNode::setColor(const QColor &color)
{
if (m_color != color) {
m_color = color;
@@ -74,7 +74,7 @@ void QSGSoftwareRectangleNode::setColor(const QColor &color)
}
}
-void QSGSoftwareRectangleNode::setPenColor(const QColor &color)
+void QSGSoftwareInternalRectangleNode::setPenColor(const QColor &color)
{
if (m_penColor != color) {
m_penColor = color;
@@ -83,7 +83,7 @@ void QSGSoftwareRectangleNode::setPenColor(const QColor &color)
}
}
-void QSGSoftwareRectangleNode::setPenWidth(qreal width)
+void QSGSoftwareInternalRectangleNode::setPenWidth(qreal width)
{
if (m_penWidth != width) {
m_penWidth = width;
@@ -113,7 +113,7 @@ static QGradientStop interpolateStop(const QGradientStop &firstStop, const QGrad
return newStop;
}
-void QSGSoftwareRectangleNode::setGradientStops(const QGradientStops &stops)
+void QSGSoftwareInternalRectangleNode::setGradientStops(const QGradientStops &stops)
{
//normalize stops
bool needsNormalization = false;
@@ -186,7 +186,7 @@ void QSGSoftwareRectangleNode::setGradientStops(const QGradientStops &stops)
markDirty(DirtyMaterial);
}
-void QSGSoftwareRectangleNode::setRadius(qreal radius)
+void QSGSoftwareInternalRectangleNode::setRadius(qreal radius)
{
if (m_radius != radius) {
m_radius = radius;
@@ -195,11 +195,11 @@ void QSGSoftwareRectangleNode::setRadius(qreal radius)
}
}
-void QSGSoftwareRectangleNode::setAligned(bool /*aligned*/)
+void QSGSoftwareInternalRectangleNode::setAligned(bool /*aligned*/)
{
}
-void QSGSoftwareRectangleNode::update()
+void QSGSoftwareInternalRectangleNode::update()
{
if (!m_penWidth || m_penColor == Qt::transparent) {
m_pen = Qt::NoPen;
@@ -223,7 +223,7 @@ void QSGSoftwareRectangleNode::update()
}
}
-void QSGSoftwareRectangleNode::paint(QPainter *painter)
+void QSGSoftwareInternalRectangleNode::paint(QPainter *painter)
{
//We can only check for a device pixel ratio change when we know what
//paint device is being used.
@@ -265,7 +265,7 @@ void QSGSoftwareRectangleNode::paint(QPainter *painter)
}
-bool QSGSoftwareRectangleNode::isOpaque() const
+bool QSGSoftwareInternalRectangleNode::isOpaque() const
{
if (m_radius > 0.0f)
return false;
@@ -283,13 +283,13 @@ bool QSGSoftwareRectangleNode::isOpaque() const
return true;
}
-QRectF QSGSoftwareRectangleNode::rect() const
+QRectF QSGSoftwareInternalRectangleNode::rect() const
{
//TODO: double check that this is correct.
return m_rect;
}
-void QSGSoftwareRectangleNode::paintRectangle(QPainter *painter, const QRect &rect)
+void QSGSoftwareInternalRectangleNode::paintRectangle(QPainter *painter, const QRect &rect)
{
//Radius should never exceeds half of the width or half of the height
int radius = qFloor(qMin(qMin(rect.width(), rect.height()) * 0.5, m_radius));
@@ -411,7 +411,7 @@ void QSGSoftwareRectangleNode::paintRectangle(QPainter *painter, const QRect &re
painter->setRenderHints(previousRenderHints);
}
-void QSGSoftwareRectangleNode::generateCornerPixmap()
+void QSGSoftwareInternalRectangleNode::generateCornerPixmap()
{
//Generate new corner Pixmap
int radius = qFloor(qMin(qMin(m_rect.width(), m_rect.height()) * 0.5, m_radius));
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerectanglenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode_p.h
index 9cc0823325..f363e279e1 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerectanglenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalrectanglenode_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QSGSOFTWARERECTANGLENODE_H
-#define QSGSOFTWARERECTANGLENODE_H
+#ifndef QSGSOFTWAREINTERNALRECTANGLENODE_H
+#define QSGSOFTWAREINTERNALRECTANGLENODE_H
//
// W A R N I N G
@@ -59,10 +59,10 @@
QT_BEGIN_NAMESPACE
-class QSGSoftwareRectangleNode : public QSGRectangleNode
+class QSGSoftwareInternalRectangleNode : public QSGInternalRectangleNode
{
public:
- QSGSoftwareRectangleNode();
+ QSGSoftwareInternalRectangleNode();
void setRect(const QRectF &rect) override;
void setColor(const QColor &color) override;
@@ -100,4 +100,4 @@ private:
QT_END_NAMESPACE
-#endif // QSGSOFTWARERECTANGLENODE_H
+#endif // QSGSOFTWAREINTERNALRECTANGLENODE_H
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes.cpp
index 36ff1f2229..53974a77bf 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes.cpp
@@ -37,12 +37,49 @@
**
****************************************************************************/
-#include "qsgsoftwareninepatchnode_p.h"
+#include "qsgsoftwarepublicnodes_p.h"
#include "qsgsoftwarepixmaptexture_p.h"
-#include "qsgsoftwareimagenode_p.h"
+#include "qsgsoftwareinternalimagenode_p.h"
QT_BEGIN_NAMESPACE
+QSGSoftwareRectangleNode::QSGSoftwareRectangleNode()
+ : m_color(QColor(255, 255, 255))
+{
+ setMaterial((QSGMaterial*)1);
+ setGeometry((QSGGeometry*)1);
+}
+
+void QSGSoftwareRectangleNode::paint(QPainter *painter)
+{
+ painter->fillRect(m_rect, m_color);
+}
+
+QSGSoftwareImageNode::QSGSoftwareImageNode()
+ : m_texture(nullptr),
+ m_owns(false)
+{
+ setMaterial((QSGMaterial*)1);
+ setGeometry((QSGGeometry*)1);
+}
+
+QSGSoftwareImageNode::~QSGSoftwareImageNode()
+{
+ if (m_owns)
+ delete m_texture;
+}
+
+void QSGSoftwareImageNode::paint(QPainter *painter)
+{
+ if (QSGSoftwarePixmapTexture *pt = dynamic_cast<QSGSoftwarePixmapTexture *>(m_texture)) {
+ const QPixmap &pm = pt->pixmap();
+ painter->drawPixmap(m_rect, pm, QRectF(0, 0, pm.width(), pm.height()));
+ } else if (QSGPlainTexture *pt = dynamic_cast<QSGPlainTexture *>(m_texture)) {
+ const QImage &im = pt->image();
+ painter->drawImage(m_rect, im, QRectF(0, 0, im.width(), im.height()));
+ }
+}
+
QSGSoftwareNinePatchNode::QSGSoftwareNinePatchNode()
{
setMaterial((QSGMaterial*)1);
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes_p.h
new file mode 100644
index 0000000000..8f5216d03a
--- /dev/null
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes_p.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGSOFTWAREPUBLICNODES_H
+#define QSGSOFTWAREPUBLICNODES_H
+
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qsgimagenode.h>
+#include <QtQuick/qsgninepatchnode.h>
+#include <QtGui/qpixmap.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+class QSGSoftwareRectangleNode : public QSGRectangleNode
+{
+public:
+ QSGSoftwareRectangleNode();
+
+ void setRect(const QRectF &rect) override { m_rect = rect; markDirty(DirtyMaterial); }
+ QRectF rect() const override { return m_rect; }
+
+ void setColor(const QColor &color) override { m_color = color; markDirty(DirtyMaterial); }
+ QColor color() const override { return m_color; }
+
+ void paint(QPainter *painter);
+
+private:
+ QRectF m_rect;
+ QColor m_color;
+};
+
+class QSGSoftwareImageNode : public QSGImageNode
+{
+public:
+ QSGSoftwareImageNode();
+ ~QSGSoftwareImageNode();
+
+ void setRect(const QRectF &rect) override { m_rect = rect; markDirty(DirtyMaterial); }
+ QRectF rect() const override { return m_rect; }
+
+ void setSourceRect(const QRectF &r) override { m_sourceRect = r; }
+ QRectF sourceRect() const override { return m_sourceRect; }
+
+ void setTexture(QSGTexture *texture) override { m_texture = texture; markDirty(DirtyMaterial); }
+ QSGTexture *texture() const override { return m_texture; }
+
+ void setFiltering(QSGTexture::Filtering) override { }
+ QSGTexture::Filtering filtering() const override { return QSGTexture::None; }
+
+ void setTextureCoordinatesTransform(TextureCoordinatesTransformMode) override { }
+ TextureCoordinatesTransformMode textureCoordinatesTransform() const override { return NoTransform; }
+
+ void setOwnsTexture(bool owns) override { m_owns = owns; }
+ bool ownsTexture() const override { return m_owns; }
+
+ void paint(QPainter *painter);
+
+private:
+ QPixmap m_pixmap;
+ QSGTexture *m_texture;
+ QRectF m_rect;
+ QRectF m_sourceRect;
+ bool m_owns;
+};
+
+class QSGSoftwareNinePatchNode : public QSGNinePatchNode
+{
+public:
+ QSGSoftwareNinePatchNode();
+
+ void setTexture(QSGTexture *texture) override;
+ void setBounds(const QRectF &bounds) override;
+ void setDevicePixelRatio(qreal ratio) override;
+ void setPadding(qreal left, qreal top, qreal right, qreal bottom) override;
+ void update() override;
+
+ void paint(QPainter *painter);
+
+ QRectF bounds() const;
+
+private:
+ QPixmap m_pixmap;
+ QRectF m_bounds;
+ qreal m_pixelRatio;
+ QMargins m_margins;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGSOFTWAREPUBLICNODES_H
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp
index 063242c63b..571f242b67 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode.cpp
@@ -39,10 +39,10 @@
#include "qsgsoftwarerenderablenode_p.h"
-#include "qsgsoftwareimagenode_p.h"
-#include "qsgsoftwarerectanglenode_p.h"
+#include "qsgsoftwareinternalimagenode_p.h"
+#include "qsgsoftwareinternalrectanglenode_p.h"
#include "qsgsoftwareglyphnode_p.h"
-#include "qsgsoftwareninepatchnode_p.h"
+#include "qsgsoftwarepublicnodes_p.h"
#include "qsgsoftwarepainternode_p.h"
#include "qsgsoftwarepixmaptexture_p.h"
@@ -68,13 +68,13 @@ QSGSoftwareRenderableNode::QSGSoftwareRenderableNode(NodeType type, QSGNode *nod
m_handle.simpleTextureNode = static_cast<QSGSimpleTextureNode*>(node);
break;
case QSGSoftwareRenderableNode::Image:
- m_handle.imageNode = static_cast<QSGSoftwareImageNode*>(node);
+ m_handle.imageNode = static_cast<QSGSoftwareInternalImageNode*>(node);
break;
case QSGSoftwareRenderableNode::Painter:
m_handle.painterNode = static_cast<QSGSoftwarePainterNode*>(node);
break;
case QSGSoftwareRenderableNode::Rectangle:
- m_handle.rectangleNode = static_cast<QSGSoftwareRectangleNode*>(node);
+ m_handle.rectangleNode = static_cast<QSGSoftwareInternalRectangleNode*>(node);
break;
case QSGSoftwareRenderableNode::Glyph:
m_handle.glpyhNode = static_cast<QSGSoftwareGlyphNode*>(node);
@@ -82,6 +82,12 @@ QSGSoftwareRenderableNode::QSGSoftwareRenderableNode(NodeType type, QSGNode *nod
case QSGSoftwareRenderableNode::NinePatch:
m_handle.ninePatchNode = static_cast<QSGSoftwareNinePatchNode*>(node);
break;
+ case QSGSoftwareRenderableNode::SimpleRectangle:
+ m_handle.simpleRectangleNode = static_cast<QSGRectangleNode*>(node);
+ break;
+ case QSGSoftwareRenderableNode::SimpleImage:
+ m_handle.simpleImageNode = static_cast<QSGImageNode*>(node);
+ break;
case QSGSoftwareRenderableNode::Invalid:
m_handle.simpleRectNode = nullptr;
break;
@@ -151,6 +157,22 @@ void QSGSoftwareRenderableNode::update()
boundingRect = m_handle.ninePatchNode->bounds().toRect();
break;
+ case QSGSoftwareRenderableNode::SimpleRectangle:
+ if (m_handle.simpleRectangleNode->color().alpha() == 255 && !m_transform.isRotating())
+ m_isOpaque = true;
+ else
+ m_isOpaque = false;
+
+ boundingRect = m_handle.simpleRectangleNode->rect().toRect();
+ break;
+ case QSGSoftwareRenderableNode::SimpleImage:
+ if (!m_handle.simpleImageNode->texture()->hasAlphaChannel() && !m_transform.isRotating())
+ m_isOpaque = true;
+ else
+ m_isOpaque = false;
+
+ boundingRect = m_handle.simpleImageNode->rect().toRect();
+ break;
default:
break;
}
@@ -223,6 +245,12 @@ QRegion QSGSoftwareRenderableNode::renderNode(QPainter *painter, bool forceOpaqu
case QSGSoftwareRenderableNode::NinePatch:
m_handle.ninePatchNode->paint(painter);
break;
+ case QSGSoftwareRenderableNode::SimpleRectangle:
+ static_cast<QSGSoftwareRectangleNode *>(m_handle.simpleRectangleNode)->paint(painter);
+ break;
+ case QSGSoftwareRenderableNode::SimpleImage:
+ static_cast<QSGSoftwareImageNode *>(m_handle.simpleImageNode)->paint(painter);
+ break;
default:
break;
}
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h
index 9a5e0a5683..d1a71cd580 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h
@@ -54,15 +54,17 @@
#include <QtGui/QRegion>
#include <QtCore/QRect>
#include <QtGui/QTransform>
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qsgimagenode.h>
+#include <QtQuick/qsgninepatchnode.h>
QT_BEGIN_NAMESPACE
-class QSGNode;
class QSGSimpleRectNode;
class QSGSimpleTextureNode;
-class QSGSoftwareImageNode;
+class QSGSoftwareInternalImageNode;
class QSGSoftwarePainterNode;
-class QSGSoftwareRectangleNode;
+class QSGSoftwareInternalRectangleNode;
class QSGSoftwareGlyphNode;
class QSGSoftwareNinePatchNode;
@@ -77,7 +79,9 @@ public:
Painter,
Rectangle,
Glyph,
- NinePatch
+ NinePatch,
+ SimpleRectangle,
+ SimpleImage
};
QSGSoftwareRenderableNode(NodeType type, QSGNode *node);
@@ -112,11 +116,13 @@ private:
union RenderableNodeHandle {
QSGSimpleRectNode *simpleRectNode;
QSGSimpleTextureNode *simpleTextureNode;
- QSGSoftwareImageNode *imageNode;
+ QSGSoftwareInternalImageNode *imageNode;
QSGSoftwarePainterNode *painterNode;
- QSGSoftwareRectangleNode *rectangleNode;
+ QSGSoftwareInternalRectangleNode *rectangleNode;
QSGSoftwareGlyphNode *glpyhNode;
QSGSoftwareNinePatchNode *ninePatchNode;
+ QSGRectangleNode *simpleRectangleNode;
+ QSGImageNode *simpleImageNode;
};
const NodeType m_nodeType;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp
index 3d5fe21f7c..1681f3c06b 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater.cpp
@@ -40,10 +40,10 @@
#include "qsgsoftwarerenderablenodeupdater_p.h"
#include "qsgabstractsoftwarerenderer_p.h"
-#include "qsgsoftwareimagenode_p.h"
-#include "qsgsoftwarerectanglenode_p.h"
+#include "qsgsoftwareinternalimagenode_p.h"
+#include "qsgsoftwareinternalrectanglenode_p.h"
#include "qsgsoftwareglyphnode_p.h"
-#include "qsgsoftwareninepatchnode_p.h"
+#include "qsgsoftwarepublicnodes_p.h"
#include "qsgsoftwarepainternode_p.h"
#include "qsgsoftwarepixmaptexture_p.h"
@@ -100,6 +100,12 @@ bool QSGSoftwareRenderableNodeUpdater::visit(QSGGeometryNode *node)
return updateRenderableNode(QSGSoftwareRenderableNode::SimpleRect, rectNode);
} else if (QSGSimpleTextureNode *tn = dynamic_cast<QSGSimpleTextureNode *>(node)) {
return updateRenderableNode(QSGSoftwareRenderableNode::SimpleTexture, tn);
+ } else if (QSGNinePatchNode *nn = dynamic_cast<QSGNinePatchNode *>(node)) {
+ return updateRenderableNode(QSGSoftwareRenderableNode::NinePatch, nn);
+ } else if (QSGRectangleNode *rn = dynamic_cast<QSGRectangleNode *>(node)) {
+ return updateRenderableNode(QSGSoftwareRenderableNode::SimpleRectangle, rn);
+ } else if (QSGImageNode *n = dynamic_cast<QSGImageNode *>(node)) {
+ return updateRenderableNode(QSGSoftwareRenderableNode::SimpleImage, n);
} else {
// We dont know, so skip
return false;
@@ -122,12 +128,12 @@ void QSGSoftwareRenderableNodeUpdater::endVisit(QSGOpacityNode *)
m_opacityState.pop();
}
-bool QSGSoftwareRenderableNodeUpdater::visit(QSGImageNode *node)
+bool QSGSoftwareRenderableNodeUpdater::visit(QSGInternalImageNode *node)
{
return updateRenderableNode(QSGSoftwareRenderableNode::Image, node);
}
-void QSGSoftwareRenderableNodeUpdater::endVisit(QSGImageNode *)
+void QSGSoftwareRenderableNodeUpdater::endVisit(QSGInternalImageNode *)
{
}
@@ -140,12 +146,12 @@ void QSGSoftwareRenderableNodeUpdater::endVisit(QSGPainterNode *)
{
}
-bool QSGSoftwareRenderableNodeUpdater::visit(QSGRectangleNode *node)
+bool QSGSoftwareRenderableNodeUpdater::visit(QSGInternalRectangleNode *node)
{
return updateRenderableNode(QSGSoftwareRenderableNode::Rectangle, node);
}
-void QSGSoftwareRenderableNodeUpdater::endVisit(QSGRectangleNode *)
+void QSGSoftwareRenderableNodeUpdater::endVisit(QSGInternalRectangleNode *)
{
}
@@ -158,15 +164,6 @@ void QSGSoftwareRenderableNodeUpdater::endVisit(QSGGlyphNode *)
{
}
-bool QSGSoftwareRenderableNodeUpdater::visit(QSGNinePatchNode *node)
-{
- return updateRenderableNode(QSGSoftwareRenderableNode::NinePatch, node);
-}
-
-void QSGSoftwareRenderableNodeUpdater::endVisit(QSGNinePatchNode *)
-{
-}
-
bool QSGSoftwareRenderableNodeUpdater::visit(QSGRootNode *node)
{
m_stateMap[node] = currentState(node);
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h
index 562d15769e..97492d4347 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenodeupdater_p.h
@@ -76,16 +76,14 @@ public:
void endVisit(QSGGeometryNode *) override;
bool visit(QSGOpacityNode *) override;
void endVisit(QSGOpacityNode *) override;
- bool visit(QSGImageNode *) override;
- void endVisit(QSGImageNode *) override;
+ bool visit(QSGInternalImageNode *) override;
+ void endVisit(QSGInternalImageNode *) override;
bool visit(QSGPainterNode *) override;
void endVisit(QSGPainterNode *) override;
- bool visit(QSGRectangleNode *) override;
- void endVisit(QSGRectangleNode *) override;
+ bool visit(QSGInternalRectangleNode *) override;
+ void endVisit(QSGInternalRectangleNode *) override;
bool visit(QSGGlyphNode *) override;
void endVisit(QSGGlyphNode *) override;
- bool visit(QSGNinePatchNode *) override;
- void endVisit(QSGNinePatchNode *) override;
bool visit(QSGRootNode *) override;
void endVisit(QSGRootNode *) override;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp
index af81ff61c3..ede2005918 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder.cpp
@@ -41,10 +41,10 @@
#include "qsgsoftwarerenderablenode_p.h"
#include "qsgabstractsoftwarerenderer_p.h"
-#include "qsgsoftwareimagenode_p.h"
-#include "qsgsoftwarerectanglenode_p.h"
+#include "qsgsoftwareinternalimagenode_p.h"
+#include "qsgsoftwareinternalrectanglenode_p.h"
#include "qsgsoftwareglyphnode_p.h"
-#include "qsgsoftwareninepatchnode_p.h"
+#include "qsgsoftwarepublicnodes_p.h"
#include "qsgsoftwarepainternode_p.h"
#include "qsgsoftwarepixmaptexture_p.h"
@@ -95,12 +95,12 @@ void QSGSoftwareRenderListBuilder::endVisit(QSGOpacityNode *)
{
}
-bool QSGSoftwareRenderListBuilder::visit(QSGImageNode *node)
+bool QSGSoftwareRenderListBuilder::visit(QSGInternalImageNode *node)
{
return addRenderableNode(node);
}
-void QSGSoftwareRenderListBuilder::endVisit(QSGImageNode *)
+void QSGSoftwareRenderListBuilder::endVisit(QSGInternalImageNode *)
{
}
@@ -113,12 +113,12 @@ void QSGSoftwareRenderListBuilder::endVisit(QSGPainterNode *)
{
}
-bool QSGSoftwareRenderListBuilder::visit(QSGRectangleNode *node)
+bool QSGSoftwareRenderListBuilder::visit(QSGInternalRectangleNode *node)
{
return addRenderableNode(node);
}
-void QSGSoftwareRenderListBuilder::endVisit(QSGRectangleNode *)
+void QSGSoftwareRenderListBuilder::endVisit(QSGInternalRectangleNode *)
{
}
@@ -131,15 +131,6 @@ void QSGSoftwareRenderListBuilder::endVisit(QSGGlyphNode *)
{
}
-bool QSGSoftwareRenderListBuilder::visit(QSGNinePatchNode *node)
-{
- return addRenderableNode(node);
-}
-
-void QSGSoftwareRenderListBuilder::endVisit(QSGNinePatchNode *)
-{
-}
-
bool QSGSoftwareRenderListBuilder::visit(QSGRootNode *)
{
return true;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h
index 94b563564d..ce538f835f 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderlistbuilder_p.h
@@ -70,16 +70,14 @@ public:
void endVisit(QSGGeometryNode *) override;
bool visit(QSGOpacityNode *) override;
void endVisit(QSGOpacityNode *) override;
- bool visit(QSGImageNode *) override;
- void endVisit(QSGImageNode *) override;
+ bool visit(QSGInternalImageNode *) override;
+ void endVisit(QSGInternalImageNode *) override;
bool visit(QSGPainterNode *) override;
void endVisit(QSGPainterNode *) override;
- bool visit(QSGRectangleNode *) override;
- void endVisit(QSGRectangleNode *) override;
+ bool visit(QSGInternalRectangleNode *) override;
+ void endVisit(QSGInternalRectangleNode *) override;
bool visit(QSGGlyphNode *) override;
void endVisit(QSGGlyphNode *) override;
- bool visit(QSGNinePatchNode *) override;
- void endVisit(QSGNinePatchNode *) override;
bool visit(QSGRootNode *) override;
void endVisit(QSGRootNode *) override;
diff --git a/src/quick/scenegraph/adaptations/software/software.pri b/src/quick/scenegraph/adaptations/software/software.pri
index b8cdbc4a25..a8ba77c147 100644
--- a/src/quick/scenegraph/adaptations/software/software.pri
+++ b/src/quick/scenegraph/adaptations/software/software.pri
@@ -6,10 +6,10 @@ SOURCES += \
$$PWD/qsgsoftwarecontext.cpp \
$$PWD/qsgabstractsoftwarerenderer.cpp \
$$PWD/qsgsoftwareglyphnode.cpp \
- $$PWD/qsgsoftwareimagenode.cpp \
- $$PWD/qsgsoftwareninepatchnode.cpp \
+ $$PWD/qsgsoftwareinternalimagenode.cpp \
+ $$PWD/qsgsoftwarepublicnodes.cpp \
$$PWD/qsgsoftwarepainternode.cpp \
- $$PWD/qsgsoftwarerectanglenode.cpp \
+ $$PWD/qsgsoftwareinternalrectanglenode.cpp \
$$PWD/qsgsoftwarepixmaprenderer.cpp \
$$PWD/qsgsoftwarepixmaptexture.cpp \
$$PWD/qsgsoftwarerenderablenode.cpp \
@@ -24,12 +24,12 @@ HEADERS += \
$$PWD/qsgsoftwarecontext_p.h \
$$PWD/qsgabstractsoftwarerenderer_p.h \
$$PWD/qsgsoftwareglyphnode_p.h \
- $$PWD/qsgsoftwareimagenode_p.h \
- $$PWD/qsgsoftwareninepatchnode_p.h \
+ $$PWD/qsgsoftwareinternalimagenode_p.h \
+ $$PWD/qsgsoftwarepublicnodes_p.h \
$$PWD/qsgsoftwarepainternode_p.h \
$$PWD/qsgsoftwarepixmaprenderer_p.h \
$$PWD/qsgsoftwarepixmaptexture_p.h \
- $$PWD/qsgsoftwarerectanglenode_p.h \
+ $$PWD/qsgsoftwareinternalrectanglenode_p.h \
$$PWD/qsgsoftwarerenderablenode_p.h \
$$PWD/qsgsoftwarerenderablenodeupdater_p.h \
$$PWD/qsgsoftwarerenderer_p.h \
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp
index 7ec72a6e10..239557d527 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.cpp
+++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp
@@ -726,6 +726,27 @@ void QSGGeometry::updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect,
v[3].ty = textureRect.bottom();
}
+/*!
+ Updates the geometry \a g with the coordinates in \a rect.
+
+ The function assumes the geometry object contains a single triangle strip
+ of QSGGeometry::ColoredPoint2D vertices
+ */
+void QSGGeometry::updateColoredRectGeometry(QSGGeometry *g, const QRectF &rect)
+{
+ ColoredPoint2D *v = g->vertexDataAsColoredPoint2D();
+ v[0].x = rect.left();
+ v[0].y = rect.top();
+
+ v[1].x = rect.left();
+ v[1].y = rect.bottom();
+
+ v[2].x = rect.right();
+ v[2].y = rect.top();
+
+ v[3].x = rect.right();
+ v[3].y = rect.bottom();
+}
/*!
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.h b/src/quick/scenegraph/coreapi/qsggeometry.h
index 1f54b7d81b..ae7b2f494c 100644
--- a/src/quick/scenegraph/coreapi/qsggeometry.h
+++ b/src/quick/scenegraph/coreapi/qsggeometry.h
@@ -182,6 +182,7 @@ public:
static void updateRectGeometry(QSGGeometry *g, const QRectF &rect);
static void updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect, const QRectF &sourceRect);
+ static void updateColoredRectGeometry(QSGGeometry *g, const QRectF &rect);
void setIndexDataPattern(DataPattern p);
DataPattern indexDataPattern() const { return DataPattern(m_index_usage_pattern); }
diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp
index 92f783d500..c0967bcb09 100644
--- a/src/quick/scenegraph/coreapi/qsgnode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgnode.cpp
@@ -1466,8 +1466,6 @@ void QSGNodeVisitor::visitChildren(QSGNode *n)
visitNode(c);
}
-
-
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const QSGGeometryNode *n)
{
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h
index 179ec3e3fa..bdb8ebb0f1 100644
--- a/src/quick/scenegraph/qsgadaptationlayer_p.h
+++ b/src/quick/scenegraph/qsgadaptationlayer_p.h
@@ -76,11 +76,10 @@ class TextureReference;
class QSGDistanceFieldGlyphCacheManager;
class QSGDistanceFieldGlyphNode;
class QOpenGLContext;
-class QSGImageNode;
+class QSGInternalImageNode;
class QSGPainterNode;
-class QSGRectangleNode;
+class QSGInternalRectangleNode;
class QSGGlyphNode;
-class QSGNinePatchNode;
class QSGRootNode;
class Q_QUICK_PRIVATE_EXPORT QSGNodeVisitorEx
@@ -97,16 +96,14 @@ public:
virtual void endVisit(QSGGeometryNode *) = 0;
virtual bool visit(QSGOpacityNode *) = 0;
virtual void endVisit(QSGOpacityNode *) = 0;
- virtual bool visit(QSGImageNode *) = 0;
- virtual void endVisit(QSGImageNode *) = 0;
+ virtual bool visit(QSGInternalImageNode *) = 0;
+ virtual void endVisit(QSGInternalImageNode *) = 0;
virtual bool visit(QSGPainterNode *) = 0;
virtual void endVisit(QSGPainterNode *) = 0;
- virtual bool visit(QSGRectangleNode *) = 0;
- virtual void endVisit(QSGRectangleNode *) = 0;
+ virtual bool visit(QSGInternalRectangleNode *) = 0;
+ virtual void endVisit(QSGInternalRectangleNode *) = 0;
virtual bool visit(QSGGlyphNode *) = 0;
virtual void endVisit(QSGGlyphNode *) = 0;
- virtual bool visit(QSGNinePatchNode *) = 0;
- virtual void endVisit(QSGNinePatchNode *) = 0;
virtual bool visit(QSGRootNode *) = 0;
virtual void endVisit(QSGRootNode *) = 0;
@@ -122,7 +119,7 @@ public:
virtual void accept(QSGNodeVisitorEx *) = 0;
};
-class Q_QUICK_PRIVATE_EXPORT QSGRectangleNode : public QSGVisitableNode
+class Q_QUICK_PRIVATE_EXPORT QSGInternalRectangleNode : public QSGVisitableNode
{
public:
virtual void setRect(const QRectF &rect) = 0;
@@ -140,7 +137,7 @@ public:
};
-class Q_QUICK_PRIVATE_EXPORT QSGImageNode : public QSGVisitableNode
+class Q_QUICK_PRIVATE_EXPORT QSGInternalImageNode : public QSGVisitableNode
{
public:
virtual void setTargetRect(const QRectF &rect) = 0;
@@ -186,19 +183,6 @@ public:
virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
};
-class Q_QUICK_PRIVATE_EXPORT QSGNinePatchNode : public QSGVisitableNode
-{
-public:
- virtual void setTexture(QSGTexture *texture) = 0;
- virtual void setBounds(const QRectF &bounds) = 0;
- virtual void setDevicePixelRatio(qreal ratio) = 0;
- virtual void setPadding(qreal left, qreal top, qreal right, qreal bottom) = 0;
-
- virtual void update() = 0;
-
- virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); }
-};
-
class Q_QUICK_EXPORT QSGLayer : public QSGDynamicTexture
{
Q_OBJECT
diff --git a/src/quick/scenegraph/qsgbasicimagenode.cpp b/src/quick/scenegraph/qsgbasicinternalimagenode.cpp
index 24077cc947..685a51550d 100644
--- a/src/quick/scenegraph/qsgbasicimagenode.cpp
+++ b/src/quick/scenegraph/qsgbasicinternalimagenode.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qsgbasicimagenode_p.h"
+#include "qsgbasicinternalimagenode_p.h"
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qmath.h>
@@ -65,7 +65,7 @@ namespace
}
}
-QSGBasicImageNode::QSGBasicImageNode()
+QSGBasicInternalImageNode::QSGBasicInternalImageNode()
: m_innerSourceRect(0, 0, 1, 1)
, m_subSourceRect(0, 0, 1, 1)
, m_antialiasing(false)
@@ -77,11 +77,11 @@ QSGBasicImageNode::QSGBasicImageNode()
setGeometry(&m_geometry);
#ifdef QSG_RUNTIME_DESCRIPTION
- qsgnode_set_description(this, QLatin1String("image"));
+ qsgnode_set_description(this, QLatin1String("internalimage"));
#endif
}
-void QSGBasicImageNode::setTargetRect(const QRectF &rect)
+void QSGBasicInternalImageNode::setTargetRect(const QRectF &rect)
{
if (rect == m_targetRect)
return;
@@ -89,7 +89,7 @@ void QSGBasicImageNode::setTargetRect(const QRectF &rect)
m_dirtyGeometry = true;
}
-void QSGBasicImageNode::setInnerTargetRect(const QRectF &rect)
+void QSGBasicInternalImageNode::setInnerTargetRect(const QRectF &rect)
{
if (rect == m_innerTargetRect)
return;
@@ -97,7 +97,7 @@ void QSGBasicImageNode::setInnerTargetRect(const QRectF &rect)
m_dirtyGeometry = true;
}
-void QSGBasicImageNode::setInnerSourceRect(const QRectF &rect)
+void QSGBasicInternalImageNode::setInnerSourceRect(const QRectF &rect)
{
if (rect == m_innerSourceRect)
return;
@@ -105,7 +105,7 @@ void QSGBasicImageNode::setInnerSourceRect(const QRectF &rect)
m_dirtyGeometry = true;
}
-void QSGBasicImageNode::setSubSourceRect(const QRectF &rect)
+void QSGBasicInternalImageNode::setSubSourceRect(const QRectF &rect)
{
if (rect == m_subSourceRect)
return;
@@ -113,7 +113,7 @@ void QSGBasicImageNode::setSubSourceRect(const QRectF &rect)
m_dirtyGeometry = true;
}
-void QSGBasicImageNode::setTexture(QSGTexture *texture)
+void QSGBasicInternalImageNode::setTexture(QSGTexture *texture)
{
Q_ASSERT(texture);
@@ -126,7 +126,7 @@ void QSGBasicImageNode::setTexture(QSGTexture *texture)
m_dirtyGeometry = true;
}
-void QSGBasicImageNode::setAntialiasing(bool antialiasing)
+void QSGBasicInternalImageNode::setAntialiasing(bool antialiasing)
{
if (antialiasing == m_antialiasing)
return;
@@ -142,7 +142,7 @@ void QSGBasicImageNode::setAntialiasing(bool antialiasing)
m_dirtyGeometry = true;
}
-void QSGBasicImageNode::setMirror(bool mirror)
+void QSGBasicInternalImageNode::setMirror(bool mirror)
{
if (mirror == m_mirror)
return;
@@ -151,13 +151,13 @@ void QSGBasicImageNode::setMirror(bool mirror)
}
-void QSGBasicImageNode::update()
+void QSGBasicInternalImageNode::update()
{
if (m_dirtyGeometry)
updateGeometry();
}
-void QSGBasicImageNode::preprocess()
+void QSGBasicInternalImageNode::preprocess()
{
bool doDirty = false;
QSGDynamicTexture *t = qobject_cast<QSGDynamicTexture *>(materialTexture());
@@ -200,7 +200,7 @@ static inline void appendQuad(quint16 **indices, quint16 topLeft, quint16 topRig
*(*indices)++ = topLeft;
}
-QSGGeometry *QSGBasicImageNode::updateGeometry(const QRectF &targetRect,
+QSGGeometry *QSGBasicInternalImageNode::updateGeometry(const QRectF &targetRect,
const QRectF &innerTargetRect,
const QRectF &sourceRect,
const QRectF &innerSourceRect,
@@ -458,7 +458,7 @@ QSGGeometry *QSGBasicImageNode::updateGeometry(const QRectF &targetRect,
return geometry;
}
-void QSGBasicImageNode::updateGeometry()
+void QSGBasicInternalImageNode::updateGeometry()
{
Q_ASSERT(!m_targetRect.isEmpty());
const QSGTexture *t = materialTexture();
diff --git a/src/quick/scenegraph/qsgbasicimagenode_p.h b/src/quick/scenegraph/qsgbasicinternalimagenode_p.h
index 4a96e1a9f6..a5689b20aa 100644
--- a/src/quick/scenegraph/qsgbasicimagenode_p.h
+++ b/src/quick/scenegraph/qsgbasicinternalimagenode_p.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QSGBASICIMAGENODE_P_H
-#define QSGBASICIMAGENODE_P_H
+#ifndef QSGBASICINTERNALIMAGENODE_P_H
+#define QSGBASICINTERNALIMAGENODE_P_H
//
// W A R N I N G
@@ -55,10 +55,10 @@
QT_BEGIN_NAMESPACE
-class Q_QUICK_PRIVATE_EXPORT QSGBasicImageNode : public QSGImageNode
+class Q_QUICK_PRIVATE_EXPORT QSGBasicInternalImageNode : public QSGInternalImageNode
{
public:
- QSGBasicImageNode();
+ QSGBasicInternalImageNode();
void setTargetRect(const QRectF &rect) override;
void setInnerTargetRect(const QRectF &rect) override;
diff --git a/src/quick/scenegraph/qsgbasicrectanglenode.cpp b/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp
index 14d2dc9677..8fc850b60c 100644
--- a/src/quick/scenegraph/qsgbasicrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgbasicinternalrectanglenode.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qsgbasicrectanglenode_p.h"
+#include "qsgbasicinternalrectanglenode_p.h"
#include <QtCore/qmath.h>
@@ -96,7 +96,7 @@ namespace
}
}
-QSGBasicRectangleNode::QSGBasicRectangleNode()
+QSGBasicInternalRectangleNode::QSGBasicInternalRectangleNode()
: m_radius(0)
, m_pen_width(0)
, m_aligned(true)
@@ -108,11 +108,11 @@ QSGBasicRectangleNode::QSGBasicRectangleNode()
setGeometry(&m_geometry);
#ifdef QSG_RUNTIME_DESCRIPTION
- qsgnode_set_description(this, QLatin1String("rectangle"));
+ qsgnode_set_description(this, QLatin1String("internalrectangle"));
#endif
}
-void QSGBasicRectangleNode::setRect(const QRectF &rect)
+void QSGBasicInternalRectangleNode::setRect(const QRectF &rect)
{
if (rect == m_rect)
return;
@@ -120,7 +120,7 @@ void QSGBasicRectangleNode::setRect(const QRectF &rect)
m_dirty_geometry = true;
}
-void QSGBasicRectangleNode::setColor(const QColor &color)
+void QSGBasicInternalRectangleNode::setColor(const QColor &color)
{
if (color == m_color)
return;
@@ -129,7 +129,7 @@ void QSGBasicRectangleNode::setColor(const QColor &color)
m_dirty_geometry = true;
}
-void QSGBasicRectangleNode::setPenColor(const QColor &color)
+void QSGBasicInternalRectangleNode::setPenColor(const QColor &color)
{
if (color == m_border_color)
return;
@@ -138,7 +138,7 @@ void QSGBasicRectangleNode::setPenColor(const QColor &color)
m_dirty_geometry = true;
}
-void QSGBasicRectangleNode::setPenWidth(qreal width)
+void QSGBasicInternalRectangleNode::setPenWidth(qreal width)
{
if (width == m_pen_width)
return;
@@ -147,7 +147,7 @@ void QSGBasicRectangleNode::setPenWidth(qreal width)
}
-void QSGBasicRectangleNode::setGradientStops(const QGradientStops &stops)
+void QSGBasicInternalRectangleNode::setGradientStops(const QGradientStops &stops)
{
if (stops.constData() == m_gradient_stops.constData())
return;
@@ -160,7 +160,7 @@ void QSGBasicRectangleNode::setGradientStops(const QGradientStops &stops)
m_dirty_geometry = true;
}
-void QSGBasicRectangleNode::setRadius(qreal radius)
+void QSGBasicInternalRectangleNode::setRadius(qreal radius)
{
if (radius == m_radius)
return;
@@ -168,7 +168,7 @@ void QSGBasicRectangleNode::setRadius(qreal radius)
m_dirty_geometry = true;
}
-void QSGBasicRectangleNode::setAntialiasing(bool antialiasing)
+void QSGBasicInternalRectangleNode::setAntialiasing(bool antialiasing)
{
if (!supportsAntialiasing())
return;
@@ -187,7 +187,7 @@ void QSGBasicRectangleNode::setAntialiasing(bool antialiasing)
m_dirty_geometry = true;
}
-void QSGBasicRectangleNode::setAligned(bool aligned)
+void QSGBasicInternalRectangleNode::setAligned(bool aligned)
{
if (aligned == m_aligned)
return;
@@ -195,7 +195,7 @@ void QSGBasicRectangleNode::setAligned(bool aligned)
m_dirty_geometry = true;
}
-void QSGBasicRectangleNode::update()
+void QSGBasicInternalRectangleNode::update()
{
if (m_dirty_geometry) {
updateGeometry();
@@ -207,7 +207,7 @@ void QSGBasicRectangleNode::update()
}
}
-void QSGBasicRectangleNode::updateGeometry()
+void QSGBasicInternalRectangleNode::updateGeometry()
{
float width = float(m_rect.width());
float height = float(m_rect.height());
diff --git a/src/quick/scenegraph/qsgbasicrectanglenode_p.h b/src/quick/scenegraph/qsgbasicinternalrectanglenode_p.h
index b1d1457590..98e53669ce 100644
--- a/src/quick/scenegraph/qsgbasicrectanglenode_p.h
+++ b/src/quick/scenegraph/qsgbasicinternalrectanglenode_p.h
@@ -38,8 +38,8 @@
****************************************************************************/
-#ifndef QSGBASICRECTANGLENODE_P_H
-#define QSGBASICRECTANGLENODE_P_H
+#ifndef QSGBASICINTERNALRECTANGLENODE_P_H
+#define QSGBASICINTERNALRECTANGLENODE_P_H
//
// W A R N I N G
@@ -56,10 +56,10 @@
QT_BEGIN_NAMESPACE
-class Q_QUICK_PRIVATE_EXPORT QSGBasicRectangleNode : public QSGRectangleNode
+class Q_QUICK_PRIVATE_EXPORT QSGBasicInternalRectangleNode : public QSGInternalRectangleNode
{
public:
- QSGBasicRectangleNode();
+ QSGBasicInternalRectangleNode();
void setRect(const QRectF &rect) override;
void setColor(const QColor &color) override;
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 40d65d99aa..fa77c2d6cc 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -268,9 +268,9 @@ void QSGContext::renderContextInvalidated(QSGRenderContext *)
/*!
Convenience factory function for creating a colored rectangle with the given geometry.
*/
-QSGRectangleNode *QSGContext::createRectangleNode(const QRectF &rect, const QColor &c)
+QSGInternalRectangleNode *QSGContext::createInternalRectangleNode(const QRectF &rect, const QColor &c)
{
- QSGRectangleNode *node = createRectangleNode();
+ QSGInternalRectangleNode *node = createInternalRectangleNode();
node->setRect(rect);
node->setColor(c);
node->update();
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 2527be0480..e34d2c3ebf 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -66,11 +66,10 @@
QT_BEGIN_NAMESPACE
class QSGContextPrivate;
-class QSGRectangleNode;
-class QSGImageNode;
+class QSGInternalRectangleNode;
+class QSGInternalImageNode;
class QSGPainterNode;
class QSGGlyphNode;
-class QSGNinePatchNode;
class QSGRenderer;
class QSGDistanceFieldGlyphCache;
class QQuickWindow;
@@ -85,6 +84,9 @@ class QQuickPaintedItem;
class QSGRendererInterface;
class QSGShaderEffectNode;
class QSGGuiThreadShaderEffectManager;
+class QSGRectangleNode;
+class QSGImageNode;
+class QSGNinePatchNode;
Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERLOOP)
Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_COMPILATION)
@@ -163,12 +165,11 @@ public:
virtual void renderContextInvalidated(QSGRenderContext *renderContext);
virtual QSGRenderContext *createRenderContext() = 0;
- QSGRectangleNode *createRectangleNode(const QRectF &rect, const QColor &c);
- virtual QSGRectangleNode *createRectangleNode() = 0;
- virtual QSGImageNode *createImageNode() = 0;
+ QSGInternalRectangleNode *createInternalRectangleNode(const QRectF &rect, const QColor &c);
+ virtual QSGInternalRectangleNode *createInternalRectangleNode() = 0;
+ virtual QSGInternalImageNode *createInternalImageNode() = 0;
virtual QSGPainterNode *createPainterNode(QQuickPaintedItem *item) = 0;
virtual QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode) = 0;
- virtual QSGNinePatchNode *createNinePatchNode() = 0;
virtual QSGLayer *createLayer(QSGRenderContext *renderContext) = 0;
virtual QSGGuiThreadShaderEffectManager *createGuiThreadShaderEffectManager();
virtual QSGShaderEffectNode *createShaderEffectNode(QSGRenderContext *renderContext,
@@ -180,6 +181,10 @@ public:
virtual QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext);
+ virtual QSGRectangleNode *createRectangleNode() = 0;
+ virtual QSGImageNode *createImageNode() = 0;
+ virtual QSGNinePatchNode *createNinePatchNode() = 0;
+
static QSGContext *createDefaultContext();
static QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image);
static QSGRenderLoop *createWindowManager();
diff --git a/src/quick/scenegraph/qsgdefaultcontext.cpp b/src/quick/scenegraph/qsgdefaultcontext.cpp
index f9978e816c..a33f4b174f 100644
--- a/src/quick/scenegraph/qsgdefaultcontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultcontext.cpp
@@ -40,8 +40,8 @@
#include "qsgdefaultcontext_p.h"
#include <QtQuick/private/qsgdistancefieldutil_p.h>
-#include <QtQuick/private/qsgdefaultrectanglenode_p.h>
-#include <QtQuick/private/qsgdefaultimagenode_p.h>
+#include <QtQuick/private/qsgdefaultinternalrectanglenode_p.h>
+#include <QtQuick/private/qsgdefaultinternalimagenode_p.h>
#include <QtQuick/private/qsgdefaultpainternode_p.h>
#include <QtQuick/private/qsgdefaultglyphnode_p.h>
#include <QtQuick/private/qsgdistancefieldglyphnode_p.h>
@@ -49,6 +49,9 @@
#include <QtQuick/private/qsgrenderloop_p.h>
#include <QtQuick/private/qsgdefaultlayer_p.h>
#include <QtQuick/private/qsgdefaultrendercontext_p.h>
+#include <QtQuick/private/qsgdefaultrectanglenode_p.h>
+#include <QtQuick/private/qsgdefaultimagenode_p.h>
+#include <QtQuick/private/qsgdefaultninepatchnode_p.h>
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLFramebufferObject>
@@ -60,13 +63,13 @@
QT_BEGIN_NAMESPACE
namespace QSGMultisampleAntialiasing {
- class ImageNode : public QSGDefaultImageNode {
+ class ImageNode : public QSGDefaultInternalImageNode {
public:
void setAntialiasing(bool) { }
};
- class RectangleNode : public QSGDefaultRectangleNode {
+ class RectangleNode : public QSGDefaultInternalRectangleNode {
public:
void setAntialiasing(bool) { }
};
@@ -170,18 +173,18 @@ QSGRenderContext *QSGDefaultContext::createRenderContext()
return new QSGDefaultRenderContext(this);
}
-QSGRectangleNode *QSGDefaultContext::createRectangleNode()
+QSGInternalRectangleNode *QSGDefaultContext::createInternalRectangleNode()
{
return m_antialiasingMethod == MsaaAntialiasing
? new QSGMultisampleAntialiasing::RectangleNode
- : new QSGDefaultRectangleNode;
+ : new QSGDefaultInternalRectangleNode;
}
-QSGImageNode *QSGDefaultContext::createImageNode()
+QSGInternalImageNode *QSGDefaultContext::createInternalImageNode()
{
return m_antialiasingMethod == MsaaAntialiasing
? new QSGMultisampleAntialiasing::ImageNode
- : new QSGDefaultImageNode;
+ : new QSGDefaultInternalImageNode;
}
QSGPainterNode *QSGDefaultContext::createPainterNode(QQuickPaintedItem *item)
@@ -200,15 +203,6 @@ QSGGlyphNode *QSGDefaultContext::createGlyphNode(QSGRenderContext *rc, bool pref
}
}
-/*!
- * Factory function for scene graph backends of the QStyle stylable elements. Returns a
- * null pointer if the backend doesn't provide its own node type.
- */
-QSGNinePatchNode *QSGDefaultContext::createNinePatchNode()
-{
- return nullptr;
-}
-
QSGLayer *QSGDefaultContext::createLayer(QSGRenderContext *renderContext)
{
return new QSGDefaultLayer(renderContext);
@@ -246,6 +240,21 @@ QSGRendererInterface *QSGDefaultContext::rendererInterface(QSGRenderContext *ren
return this;
}
+QSGRectangleNode *QSGDefaultContext::createRectangleNode()
+{
+ return new QSGDefaultRectangleNode;
+}
+
+QSGImageNode *QSGDefaultContext::createImageNode()
+{
+ return new QSGDefaultImageNode;
+}
+
+QSGNinePatchNode *QSGDefaultContext::createNinePatchNode()
+{
+ return new QSGDefaultNinePatchNode;
+}
+
QSGRendererInterface::GraphicsApi QSGDefaultContext::graphicsApi() const
{
return OpenGL;
diff --git a/src/quick/scenegraph/qsgdefaultcontext_p.h b/src/quick/scenegraph/qsgdefaultcontext_p.h
index 6686ab98a0..63c817cc7b 100644
--- a/src/quick/scenegraph/qsgdefaultcontext_p.h
+++ b/src/quick/scenegraph/qsgdefaultcontext_p.h
@@ -66,14 +66,16 @@ public:
void renderContextInitialized(QSGRenderContext *renderContext) override;
void renderContextInvalidated(QSGRenderContext *) override;
QSGRenderContext *createRenderContext() override;
- QSGRectangleNode *createRectangleNode() override;
- QSGImageNode *createImageNode() override;
+ QSGInternalRectangleNode *createInternalRectangleNode() override;
+ QSGInternalImageNode *createInternalImageNode() override;
QSGPainterNode *createPainterNode(QQuickPaintedItem *item) override;
QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode) override;
- QSGNinePatchNode *createNinePatchNode() override;
QSGLayer *createLayer(QSGRenderContext *renderContext) override;
QSurfaceFormat defaultSurfaceFormat() const override;
QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext) override;
+ QSGRectangleNode *createRectangleNode() override;
+ QSGImageNode *createImageNode() override;
+ QSGNinePatchNode *createNinePatchNode() override;
void setDistanceFieldEnabled(bool enabled);
bool isDistanceFieldEnabled() const;
diff --git a/src/quick/scenegraph/qsgdefaultimagenode.cpp b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
index 9fed70a7de..1d54628acd 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qsgdefaultimagenode_p.h"
+#include "qsgdefaultinternalimagenode_p.h"
#include <private/qsgmaterialshader_p.h>
#include <private/qsgtexturematerial_p.h>
#include <QtGui/qopenglfunctions.h>
@@ -117,13 +117,13 @@ void SmoothTextureMaterialShader::initialize()
QSGTextureMaterialShader::initialize();
}
-QSGDefaultImageNode::QSGDefaultImageNode()
+QSGDefaultInternalImageNode::QSGDefaultInternalImageNode()
{
setMaterial(&m_materialO);
setOpaqueMaterial(&m_material);
}
-void QSGDefaultImageNode::setFiltering(QSGTexture::Filtering filtering)
+void QSGDefaultInternalImageNode::setFiltering(QSGTexture::Filtering filtering)
{
if (m_material.filtering() == filtering)
return;
@@ -134,7 +134,7 @@ void QSGDefaultImageNode::setFiltering(QSGTexture::Filtering filtering)
markDirty(DirtyMaterial);
}
-void QSGDefaultImageNode::setMipmapFiltering(QSGTexture::Filtering filtering)
+void QSGDefaultInternalImageNode::setMipmapFiltering(QSGTexture::Filtering filtering)
{
if (m_material.mipmapFiltering() == filtering)
return;
@@ -145,7 +145,7 @@ void QSGDefaultImageNode::setMipmapFiltering(QSGTexture::Filtering filtering)
markDirty(DirtyMaterial);
}
-void QSGDefaultImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
+void QSGDefaultInternalImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
{
if (m_material.verticalWrapMode() == wrapMode)
return;
@@ -156,7 +156,7 @@ void QSGDefaultImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode)
markDirty(DirtyMaterial);
}
-void QSGDefaultImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
+void QSGDefaultInternalImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
{
if (m_material.horizontalWrapMode() == wrapMode)
return;
@@ -167,7 +167,7 @@ void QSGDefaultImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
markDirty(DirtyMaterial);
}
-void QSGDefaultImageNode::updateMaterialAntialiasing()
+void QSGDefaultInternalImageNode::updateMaterialAntialiasing()
{
if (m_antialiasing) {
setMaterial(&m_smoothMaterial);
@@ -178,19 +178,19 @@ void QSGDefaultImageNode::updateMaterialAntialiasing()
}
}
-void QSGDefaultImageNode::setMaterialTexture(QSGTexture *texture)
+void QSGDefaultInternalImageNode::setMaterialTexture(QSGTexture *texture)
{
m_material.setTexture(texture);
m_materialO.setTexture(texture);
m_smoothMaterial.setTexture(texture);
}
-QSGTexture *QSGDefaultImageNode::materialTexture() const
+QSGTexture *QSGDefaultInternalImageNode::materialTexture() const
{
return m_material.texture();
}
-bool QSGDefaultImageNode::updateMaterialBlending()
+bool QSGDefaultInternalImageNode::updateMaterialBlending()
{
const bool alpha = m_material.flags() & QSGMaterial::Blending;
if (materialTexture() && alpha != materialTexture()->hasAlphaChannel()) {
@@ -206,7 +206,7 @@ inline static bool isPowerOfTwo(int x)
return x == (x & -x);
}
-bool QSGDefaultImageNode::supportsWrap(const QSize &size) const
+bool QSGDefaultInternalImageNode::supportsWrap(const QSize &size) const
{
bool wrapSupported = true;
diff --git a/src/quick/scenegraph/qsgdefaultimagenode_p.h b/src/quick/scenegraph/qsgdefaultinternalimagenode_p.h
index 688c5a5039..1fc7834bd1 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultinternalimagenode_p.h
@@ -38,8 +38,8 @@
****************************************************************************/
-#ifndef QSGDEFAULTIMAGENODE_P_H
-#define QSGDEFAULTIMAGENODE_P_H
+#ifndef QSGDEFAULTINTERNALIMAGENODE_P_H
+#define QSGDEFAULTINTERNALIMAGENODE_P_H
//
// W A R N I N G
@@ -53,7 +53,7 @@
//
#include <private/qsgadaptationlayer_p.h>
-#include <private/qsgbasicimagenode_p.h>
+#include <private/qsgbasicinternalimagenode_p.h>
#include <QtQuick/qsgtexturematerial.h>
QT_BEGIN_NAMESPACE
@@ -70,10 +70,10 @@ protected:
QSGMaterialShader *createShader() const override;
};
-class Q_QUICK_PRIVATE_EXPORT QSGDefaultImageNode : public QSGBasicImageNode
+class Q_QUICK_PRIVATE_EXPORT QSGDefaultInternalImageNode : public QSGBasicInternalImageNode
{
public:
- QSGDefaultImageNode();
+ QSGDefaultInternalImageNode();
void setMipmapFiltering(QSGTexture::Filtering filtering) override;
void setFiltering(QSGTexture::Filtering filtering) override;
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp
index 117a9272e5..94414444ba 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include "qsgdefaultrectanglenode_p.h"
+#include "qsgdefaultinternalrectanglenode_p.h"
#include <QtQuick/qsgvertexcolormaterial.h>
#include <QtQuick/qsgtexturematerial.h>
@@ -128,12 +128,12 @@ QSGMaterialShader *QSGSmoothColorMaterial::createShader() const
return new SmoothColorMaterialShader;
}
-QSGDefaultRectangleNode::QSGDefaultRectangleNode()
+QSGDefaultInternalRectangleNode::QSGDefaultInternalRectangleNode()
{
setMaterial(&m_material);
}
-void QSGDefaultRectangleNode::updateMaterialAntialiasing()
+void QSGDefaultInternalRectangleNode::updateMaterialAntialiasing()
{
if (m_antialiasing)
setMaterial(&m_smoothMaterial);
@@ -141,7 +141,7 @@ void QSGDefaultRectangleNode::updateMaterialAntialiasing()
setMaterial(&m_material);
}
-void QSGDefaultRectangleNode::updateMaterialBlending(QSGNode::DirtyState *state)
+void QSGDefaultInternalRectangleNode::updateMaterialBlending(QSGNode::DirtyState *state)
{
// smoothed material is always blended, so no change in material state
if (material() == &m_material) {
diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h b/src/quick/scenegraph/qsgdefaultinternalrectanglenode_p.h
index f30a3beed7..941d870c8b 100644
--- a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h
+++ b/src/quick/scenegraph/qsgdefaultinternalrectanglenode_p.h
@@ -38,8 +38,8 @@
****************************************************************************/
-#ifndef QSGDEFAULTRECTANGLENODE_P_H
-#define QSGDEFAULTRECTANGLENODE_P_H
+#ifndef QSGDEFAULTINTERNALRECTANGLENODE_P_H
+#define QSGDEFAULTINTERNALRECTANGLENODE_P_H
//
// W A R N I N G
@@ -53,7 +53,7 @@
//
#include <private/qsgadaptationlayer_p.h>
-#include <private/qsgbasicrectanglenode_p.h>
+#include <private/qsgbasicinternalrectanglenode_p.h>
#include <QtQuick/qsgvertexcolormaterial.h>
QT_BEGIN_NAMESPACE
@@ -72,10 +72,10 @@ protected:
QSGMaterialShader *createShader() const override;
};
-class Q_QUICK_PRIVATE_EXPORT QSGDefaultRectangleNode : public QSGBasicRectangleNode
+class Q_QUICK_PRIVATE_EXPORT QSGDefaultInternalRectangleNode : public QSGBasicInternalRectangleNode
{
public:
- QSGDefaultRectangleNode();
+ QSGDefaultInternalRectangleNode();
private:
void updateMaterialAntialiasing() override;
diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri
index d8dfd01e7a..5b13b7449a 100644
--- a/src/quick/scenegraph/scenegraph.pri
+++ b/src/quick/scenegraph/scenegraph.pri
@@ -52,7 +52,10 @@ HEADERS += \
$$PWD/util/qsgsimplematerial.h \
$$PWD/util/qsgtexturematerial.h \
$$PWD/util/qsgtexturematerial_p.h \
- $$PWD/util/qsgvertexcolormaterial.h
+ $$PWD/util/qsgvertexcolormaterial.h \
+ $$PWD/util/qsgrectanglenode.h \
+ $$PWD/util/qsgimagenode.h \
+ $$PWD/util/qsgninepatchnode.h
SOURCES += \
$$PWD/util/qsgareaallocator.cpp \
@@ -65,7 +68,11 @@ SOURCES += \
$$PWD/util/qsgflatcolormaterial.cpp \
$$PWD/util/qsgsimplematerial.cpp \
$$PWD/util/qsgtexturematerial.cpp \
- $$PWD/util/qsgvertexcolormaterial.cpp
+ $$PWD/util/qsgvertexcolormaterial.cpp \
+ $$PWD/util/qsgrectanglenode.cpp \
+ $$PWD/util/qsgimagenode.cpp \
+ $$PWD/util/qsgninepatchnode.cpp
+
contains(QT_CONFIG, opengl(es1|es2)?) {
HEADERS += \
$$PWD/util/qsgdepthstencilbuffer_p.h \
@@ -83,8 +90,8 @@ HEADERS += \
$$PWD/qsgadaptationlayer_p.h \
$$PWD/qsgcontext_p.h \
$$PWD/qsgcontextplugin_p.h \
- $$PWD/qsgbasicrectanglenode_p.h \
- $$PWD/qsgbasicimagenode_p.h \
+ $$PWD/qsgbasicinternalrectanglenode_p.h \
+ $$PWD/qsgbasicinternalimagenode_p.h \
$$PWD/qsgbasicglyphnode_p.h \
$$PWD/qsgrenderloop_p.h
@@ -92,8 +99,8 @@ SOURCES += \
$$PWD/qsgadaptationlayer.cpp \
$$PWD/qsgcontext.cpp \
$$PWD/qsgcontextplugin.cpp \
- $$PWD/qsgbasicrectanglenode.cpp \
- $$PWD/qsgbasicimagenode.cpp \
+ $$PWD/qsgbasicinternalrectanglenode.cpp \
+ $$PWD/qsgbasicinternalimagenode.cpp \
$$PWD/qsgbasicglyphnode.cpp \
$$PWD/qsgrenderloop.cpp
@@ -104,11 +111,14 @@ contains(QT_CONFIG, opengl(es1|es2)?) {
$$PWD/qsgdefaultdistancefieldglyphcache.cpp \
$$PWD/qsgdistancefieldglyphnode.cpp \
$$PWD/qsgdistancefieldglyphnode_p.cpp \
- $$PWD/qsgdefaultimagenode.cpp \
- $$PWD/qsgdefaultrectanglenode.cpp \
+ $$PWD/qsgdefaultinternalimagenode.cpp \
+ $$PWD/qsgdefaultinternalrectanglenode.cpp \
$$PWD/qsgdefaultrendercontext.cpp \
$$PWD/qsgdefaultcontext.cpp \
$$PWD/util/qsgdefaultpainternode.cpp \
+ $$PWD/util/qsgdefaultrectanglenode.cpp \
+ $$PWD/util/qsgdefaultimagenode.cpp \
+ $$PWD/util/qsgdefaultninepatchnode.cpp \
$$PWD/qsgdefaultlayer.cpp \
$$PWD/qsgthreadedrenderloop.cpp \
$$PWD/qsgwindowsrenderloop.cpp
@@ -118,11 +128,14 @@ contains(QT_CONFIG, opengl(es1|es2)?) {
$$PWD/qsgdistancefieldglyphnode_p.h \
$$PWD/qsgdistancefieldglyphnode_p_p.h \
$$PWD/qsgdefaultglyphnode_p_p.h \
- $$PWD/qsgdefaultimagenode_p.h \
- $$PWD/qsgdefaultrectanglenode_p.h \
+ $$PWD/qsgdefaultinternalimagenode_p.h \
+ $$PWD/qsgdefaultinternalrectanglenode_p.h \
$$PWD/qsgdefaultrendercontext_p.h \
$$PWD/qsgdefaultcontext_p.h \
$$PWD/util/qsgdefaultpainternode_p.h \
+ $$PWD/util/qsgdefaultrectanglenode_p.h \
+ $$PWD/util/qsgdefaultimagenode_p.h \
+ $$PWD/util/qsgdefaultninepatchnode_p.h \
$$PWD/qsgdefaultlayer_p.h \
$$PWD/qsgthreadedrenderloop_p.h \
$$PWD/qsgwindowsrenderloop_p.h
diff --git a/src/quick/scenegraph/util/qsgdefaultimagenode.cpp b/src/quick/scenegraph/util/qsgdefaultimagenode.cpp
new file mode 100644
index 0000000000..ed3d73adb4
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgdefaultimagenode.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgdefaultimagenode_p.h"
+#include <private/qsgnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QSGDefaultImageNode::QSGDefaultImageNode()
+ : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
+ , m_texCoordMode(QSGDefaultImageNode::NoTransform)
+ , m_isAtlasTexture(false)
+ , m_ownsTexture(false)
+{
+ setGeometry(&m_geometry);
+ setMaterial(&m_material);
+ setOpaqueMaterial(&m_opaque_material);
+ m_material.setMipmapFiltering(QSGTexture::None);
+ m_opaque_material.setMipmapFiltering(QSGTexture::None);
+#ifdef QSG_RUNTIME_DESCRIPTION
+ qsgnode_set_description(this, QLatin1String("image"));
+#endif
+}
+
+QSGDefaultImageNode::~QSGDefaultImageNode()
+{
+ if (m_ownsTexture)
+ delete m_material.texture();
+}
+
+void QSGDefaultImageNode::setFiltering(QSGTexture::Filtering filtering)
+{
+ if (m_material.filtering() == filtering)
+ return;
+
+ m_material.setFiltering(filtering);
+ m_opaque_material.setFiltering(filtering);
+ markDirty(DirtyMaterial);
+}
+
+QSGTexture::Filtering QSGDefaultImageNode::filtering() const
+{
+ return m_material.filtering();
+}
+
+void QSGDefaultImageNode::setRect(const QRectF &r)
+{
+ if (m_rect == r)
+ return;
+
+ m_rect = r;
+ rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
+ markDirty(DirtyGeometry);
+}
+
+QRectF QSGDefaultImageNode::rect() const
+{
+ return m_rect;
+}
+
+void QSGDefaultImageNode::setSourceRect(const QRectF &r)
+{
+ if (m_sourceRect == r)
+ return;
+
+ m_sourceRect = r;
+ rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
+ markDirty(DirtyGeometry);
+}
+
+QRectF QSGDefaultImageNode::sourceRect() const
+{
+ return m_sourceRect;
+}
+
+void QSGDefaultImageNode::setTexture(QSGTexture *texture)
+{
+ Q_ASSERT(texture);
+ if (m_ownsTexture)
+ delete m_material.texture();
+ m_material.setTexture(texture);
+ m_opaque_material.setTexture(texture);
+ rebuildGeometry(&m_geometry, texture, m_rect, m_sourceRect, m_texCoordMode);
+
+ DirtyState dirty = DirtyMaterial;
+ // It would be tempting to skip the extra bit here and instead use
+ // m_material.texture to get the old state, but that texture could
+ // have been deleted in the mean time.
+ bool wasAtlas = m_isAtlasTexture;
+ m_isAtlasTexture = texture->isAtlasTexture();
+ if (wasAtlas || m_isAtlasTexture)
+ dirty |= DirtyGeometry;
+ markDirty(dirty);
+}
+
+QSGTexture *QSGDefaultImageNode::texture() const
+{
+ return m_material.texture();
+}
+
+void QSGDefaultImageNode::setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode)
+{
+ if (m_texCoordMode == mode)
+ return;
+ m_texCoordMode = mode;
+ rebuildGeometry(&m_geometry, texture(), m_rect, m_sourceRect, m_texCoordMode);
+ markDirty(DirtyMaterial);
+}
+
+QSGDefaultImageNode::TextureCoordinatesTransformMode QSGDefaultImageNode::textureCoordinatesTransform() const
+{
+ return m_texCoordMode;
+}
+
+void QSGDefaultImageNode::setOwnsTexture(bool owns)
+{
+ m_ownsTexture = owns;
+}
+
+bool QSGDefaultImageNode::ownsTexture() const
+{
+ return m_ownsTexture;
+}
+
+void QSGDefaultImageNode::rebuildGeometry(QSGGeometry *g,
+ QSGTexture *texture,
+ const QRectF &rect,
+ QRectF sourceRect,
+ TextureCoordinatesTransformMode texCoordMode)
+{
+ if (!texture)
+ return;
+
+ if (!sourceRect.width() || !sourceRect.height()) {
+ QSize ts = texture->textureSize();
+ sourceRect = QRectF(0, 0, ts.width(), ts.height());
+ }
+
+ // Maybe transform the texture coordinates
+ if (texCoordMode.testFlag(QSGImageNode::MirrorHorizontally)) {
+ float tmp = sourceRect.left();
+ sourceRect.setLeft(sourceRect.right());
+ sourceRect.setRight(tmp);
+ }
+ if (texCoordMode.testFlag(QSGImageNode::MirrorVertically)) {
+ float tmp = sourceRect.top();
+ sourceRect.setTop(sourceRect.bottom());
+ sourceRect.setBottom(tmp);
+ }
+
+ QSGGeometry::updateTexturedRectGeometry(g, rect, texture->convertToNormalizedSourceRect(sourceRect));
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgdefaultimagenode_p.h b/src/quick/scenegraph/util/qsgdefaultimagenode_p.h
new file mode 100644
index 0000000000..5316542cff
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgdefaultimagenode_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGDEFAULTIMAGENODE_P_H
+#define QSGDEFAULTIMAGENODE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuick/private/qtquickglobal_p.h>
+#include <QtQuick/qsgimagenode.h>
+#include <QtQuick/qsggeometry.h>
+#include <QtQuick/qsgtexturematerial.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICK_PRIVATE_EXPORT QSGDefaultImageNode : public QSGImageNode
+{
+public:
+ QSGDefaultImageNode();
+ ~QSGDefaultImageNode();
+
+ void setRect(const QRectF &rect) override;
+ QRectF rect() const override;
+
+ void setSourceRect(const QRectF &r) override;
+ QRectF sourceRect() const override;
+
+ void setTexture(QSGTexture *texture) override;
+ QSGTexture *texture() const override;
+
+ void setFiltering(QSGTexture::Filtering filtering) override;
+ QSGTexture::Filtering filtering() const override;
+
+ void setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode) override;
+ TextureCoordinatesTransformMode textureCoordinatesTransform() const override;
+
+ void setOwnsTexture(bool owns) override;
+ bool ownsTexture() const override;
+
+ static void rebuildGeometry(QSGGeometry *g,
+ QSGTexture *texture,
+ const QRectF &rect,
+ QRectF sourceRect,
+ TextureCoordinatesTransformMode texCoordMode);
+
+private:
+ QSGGeometry m_geometry;
+ QSGOpaqueTextureMaterial m_opaque_material;
+ QSGTextureMaterial m_material;
+ QRectF m_rect;
+ QRectF m_sourceRect;
+ TextureCoordinatesTransformMode m_texCoordMode;
+ uint m_isAtlasTexture : 1;
+ uint m_ownsTexture : 1;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGDEFAULTIMAGENODE_P_H
diff --git a/src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp b/src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp
new file mode 100644
index 0000000000..e5a53a3617
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgdefaultninepatchnode.cpp
@@ -0,0 +1,136 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgdefaultninepatchnode_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QSGDefaultNinePatchNode::QSGDefaultNinePatchNode()
+ : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
+{
+ m_geometry.setDrawingMode(QSGGeometry::DrawTriangleStrip);
+ setGeometry(&m_geometry);
+ setMaterial(&m_material);
+}
+
+QSGDefaultNinePatchNode::~QSGDefaultNinePatchNode()
+{
+ delete m_material.texture();
+}
+
+void QSGDefaultNinePatchNode::setTexture(QSGTexture *texture)
+{
+ delete m_material.texture();
+ m_material.setTexture(texture);
+}
+
+void QSGDefaultNinePatchNode::setBounds(const QRectF &bounds)
+{
+ m_bounds = bounds;
+}
+
+void QSGDefaultNinePatchNode::setDevicePixelRatio(qreal ratio)
+{
+ m_devicePixelRatio = ratio;
+}
+
+void QSGDefaultNinePatchNode::setPadding(qreal left, qreal top, qreal right, qreal bottom)
+{
+ m_padding = QVector4D(left, top, right, bottom);
+}
+
+void QSGDefaultNinePatchNode::update()
+{
+ rebuildGeometry(m_material.texture(), &m_geometry, m_padding, m_bounds, m_devicePixelRatio);
+ markDirty(QSGNode::DirtyGeometry | QSGNode::DirtyMaterial);
+}
+
+void QSGDefaultNinePatchNode::rebuildGeometry(QSGTexture *texture, QSGGeometry *geometry, const QVector4D &padding,
+ const QRectF &bounds, qreal dpr)
+{
+ if (padding.x() <= 0 && padding.y() <= 0 && padding.z() <= 0 && padding.w() <= 0) {
+ geometry->allocate(4, 0);
+ QSGGeometry::updateTexturedRectGeometry(geometry, bounds, texture->normalizedTextureSubRect());
+ return;
+ }
+
+ QRectF tc = texture->normalizedTextureSubRect();
+ QSize ts = texture->textureSize();
+ ts.setHeight(ts.height() / dpr);
+ ts.setWidth(ts.width() / dpr);
+
+ qreal invtw = tc.width() / ts.width();
+ qreal invth = tc.height() / ts.height();
+
+ struct Coord { qreal p; qreal t; };
+ Coord cx[4] = { { bounds.left(), tc.left() },
+ { bounds.left() + padding.x(), tc.left() + padding.x() * invtw },
+ { bounds.right() - padding.z(), tc.right() - padding.z() * invtw },
+ { bounds.right(), tc.right() }
+ };
+ Coord cy[4] = { { bounds.top(), tc.top() },
+ { bounds.top() + padding.y(), tc.top() + padding.y() * invth },
+ { bounds.bottom() - padding.w(), tc.bottom() - padding.w() * invth },
+ { bounds.bottom(), tc.bottom() }
+ };
+
+ geometry->allocate(16, 28);
+ QSGGeometry::TexturedPoint2D *v = geometry->vertexDataAsTexturedPoint2D();
+ for (int y = 0; y < 4; ++y) {
+ for (int x = 0; x < 4; ++x) {
+ v->set(cx[x].p, cy[y].p, cx[x].t, cy[y].t);
+ ++v;
+ }
+ }
+
+ quint16 *i = geometry->indexDataAsUShort();
+ for (int r = 0; r < 3; ++r) {
+ if (r > 0)
+ *i++ = 4 * r;
+ for (int c = 0; c < 4; ++c) {
+ i[0] = 4 * r + c;
+ i[1] = 4 * r + c + 4;
+ i += 2;
+ }
+ if (r < 2)
+ *i++ = 4 * r + 3 + 4;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h b/src/quick/scenegraph/util/qsgdefaultninepatchnode_p.h
index bc7aec1b5a..675cf48f47 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h
+++ b/src/quick/scenegraph/util/qsgdefaultninepatchnode_p.h
@@ -37,10 +37,8 @@
**
****************************************************************************/
-#ifndef QSGSOFTWARENINEPATCHNODE_H
-#define QSGSOFTWARENINEPATCHNODE_H
-
-#include <private/qsgadaptationlayer_p.h>
+#ifndef QSGDEFAULTNINEPATCHNODE_P_H
+#define QSGDEFAULTNINEPATCHNODE_P_H
//
// W A R N I N G
@@ -53,12 +51,18 @@
// We mean it.
//
+#include <private/qtquickglobal_p.h>
+#include <QtQuick/qsgninepatchnode.h>
+#include <QtQuick/qsggeometry.h>
+#include <QtQuick/qsgtexturematerial.h>
+
QT_BEGIN_NAMESPACE
-class QSGSoftwareNinePatchNode : public QSGNinePatchNode
+class Q_QUICK_PRIVATE_EXPORT QSGDefaultNinePatchNode : public QSGNinePatchNode
{
public:
- QSGSoftwareNinePatchNode();
+ QSGDefaultNinePatchNode();
+ ~QSGDefaultNinePatchNode();
void setTexture(QSGTexture *texture) override;
void setBounds(const QRectF &bounds) override;
@@ -66,17 +70,17 @@ public:
void setPadding(qreal left, qreal top, qreal right, qreal bottom) override;
void update() override;
- void paint(QPainter *painter);
-
- QRectF bounds() const;
+ static void rebuildGeometry(QSGTexture *texture, QSGGeometry *geometry, const QVector4D &padding,
+ const QRectF &bounds, qreal dpr);
private:
- QPixmap m_pixmap;
QRectF m_bounds;
- qreal m_pixelRatio;
- QMargins m_margins;
+ qreal m_devicePixelRatio;
+ QVector4D m_padding;
+ QSGGeometry m_geometry;
+ QSGTextureMaterial m_material;
};
QT_END_NAMESPACE
-#endif // QSGSOFTWARENINEPATCHNODE_H
+#endif // QSGDEFAULTNINEPATCHNODE_P_H
diff --git a/src/quick/scenegraph/util/qsgdefaultrectanglenode.cpp b/src/quick/scenegraph/util/qsgdefaultrectanglenode.cpp
new file mode 100644
index 0000000000..41db4f1c03
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgdefaultrectanglenode.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgdefaultrectanglenode_p.h"
+#include "qsgflatcolormaterial.h"
+
+QT_BEGIN_NAMESPACE
+
+// Unlike our predecessor, QSGSimpleRectNode, use QSGVertexColorMaterial
+// instead of Flat in order to allow better batching in the renderer.
+
+QSGDefaultRectangleNode::QSGDefaultRectangleNode()
+ : m_geometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), 4)
+ , m_color(QColor(255, 255, 255))
+{
+ QSGGeometry::updateColoredRectGeometry(&m_geometry, QRectF());
+ setMaterial(&m_material);
+ setGeometry(&m_geometry);
+#ifdef QSG_RUNTIME_DESCRIPTION
+ qsgnode_set_description(this, QLatin1String("rectangle"));
+#endif
+}
+
+void QSGDefaultRectangleNode::setRect(const QRectF &rect)
+{
+ QSGGeometry::updateColoredRectGeometry(&m_geometry, rect);
+ markDirty(QSGNode::DirtyGeometry);
+}
+
+QRectF QSGDefaultRectangleNode::rect() const
+{
+ const QSGGeometry::ColoredPoint2D *pts = m_geometry.vertexDataAsColoredPoint2D();
+ return QRectF(pts[0].x,
+ pts[0].y,
+ pts[3].x - pts[0].x,
+ pts[3].y - pts[0].y);
+}
+
+void QSGDefaultRectangleNode::setColor(const QColor &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ QSGGeometry::ColoredPoint2D *pts = m_geometry.vertexDataAsColoredPoint2D();
+ for (int i = 0; i < 4; ++i) {
+ pts[i].r = uchar(qRound(m_color.redF() * m_color.alphaF() * 255));
+ pts[i].g = uchar(qRound(m_color.greenF() * m_color.alphaF() * 255));
+ pts[i].b = uchar(qRound(m_color.blueF() * m_color.alphaF() * 255));
+ pts[i].a = uchar(qRound(m_color.alphaF() * 255));
+ }
+ markDirty(QSGNode::DirtyGeometry);
+ }
+}
+
+QColor QSGDefaultRectangleNode::color() const
+{
+ return m_color;
+}
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgdefaultrectanglenode_p.h b/src/quick/scenegraph/util/qsgdefaultrectanglenode_p.h
new file mode 100644
index 0000000000..965aa8dabb
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgdefaultrectanglenode_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGDEFAULTRECTANGLENODE_P_H
+#define QSGDEFAULTRECTANGLENODE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qcolor.h>
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qsgvertexcolormaterial.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSGDefaultRectangleNode : public QSGRectangleNode
+{
+public:
+ QSGDefaultRectangleNode();
+
+ void setRect(const QRectF &rect) override;
+ QRectF rect() const override;
+
+ void setColor(const QColor &color) override;
+ QColor color() const override;
+
+private:
+ QSGVertexColorMaterial m_material;
+ QSGGeometry m_geometry;
+ QColor m_color;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGDEFAULTRECTANGLENODE_P_H
diff --git a/src/quick/scenegraph/util/qsgengine.cpp b/src/quick/scenegraph/util/qsgengine.cpp
index f4d86bba04..988dcffbd8 100644
--- a/src/quick/scenegraph/util/qsgengine.cpp
+++ b/src/quick/scenegraph/util/qsgengine.cpp
@@ -221,4 +221,45 @@ QSGRendererInterface *QSGEngine::rendererInterface() const
: nullptr;
}
+/*!
+ 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 *QSGEngine::createRectangleNode() const
+{
+ Q_D(const QSGEngine);
+ return d->sgRenderContext->isValid() ? d->sgRenderContext->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 *QSGEngine::createImageNode() const
+{
+ Q_D(const QSGEngine);
+ return d->sgRenderContext->isValid() ? d->sgRenderContext->sceneGraphContext()->createImageNode() : nullptr;
+}
+
+/*!
+ Creates a nine patch node. When the scenegraph is not initialized, the return value is null.
+
+ \since 5.8
+ */
+
+QSGNinePatchNode *QSGEngine::createNinePatchNode() const
+{
+ Q_D(const QSGEngine);
+ return d->sgRenderContext->isValid() ? d->sgRenderContext->sceneGraphContext()->createNinePatchNode() : nullptr;
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgengine.h b/src/quick/scenegraph/util/qsgengine.h
index 9d27fb5525..3c8b61852e 100644
--- a/src/quick/scenegraph/util/qsgengine.h
+++ b/src/quick/scenegraph/util/qsgengine.h
@@ -50,6 +50,9 @@ class QSGAbstractRenderer;
class QSGEnginePrivate;
class QSGTexture;
class QSGRendererInterface;
+class QSGRectangleNode;
+class QSGImageNode;
+class QSGNinePatchNode;
class Q_QUICK_EXPORT QSGEngine : public QObject
{
@@ -74,6 +77,9 @@ public:
QSGTexture *createTextureFromImage(const QImage &image, CreateTextureOptions options = CreateTextureOption()) const;
QSGTexture *createTextureFromId(uint id, const QSize &size, CreateTextureOptions options = CreateTextureOption()) const;
QSGRendererInterface *rendererInterface() const;
+ QSGRectangleNode *createRectangleNode() const;
+ QSGImageNode *createImageNode() const;
+ QSGNinePatchNode *createNinePatchNode() const;
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgimagenode.cpp b/src/quick/scenegraph/util/qsgimagenode.cpp
new file mode 100644
index 0000000000..0387efc62b
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgimagenode.cpp
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgimagenode.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QSGImageNode
+ \brief The QSGImageNode class is provided for convenience to easily draw
+ textured content using the QML scene graph.
+
+ \inmodule QtQuick
+ \since 5.8
+
+ \warning The image node class must have a texture before being
+ added to the scene graph to be rendered.
+ */
+
+/*!
+ \fn void QSGImageNode::setRect(const QRectF &rect)
+
+ Sets the target rect of this image node to \a r.
+ */
+
+/*!
+ \fn void QSGImageNode::setRect(qreal x, qreal y, qreal w, qreal h)
+ \overload
+
+ Sets the rectangle of this image node to begin at (\a x, \a y) and have
+ width \a w and height \a h.
+ */
+
+/*!
+ \fn QRectF QSGImageNode::rect() const
+
+ Returns the target rect of this image node.
+ */
+
+/*!
+ \fn void QSGImageNode::setSourceRect(const QRectF &rect)
+
+ Sets the source rect of this image node to \a r.
+ */
+
+/*!
+ \fn void QSGImageNode::setSourceRect(qreal x, qreal y, qreal w, qreal h)
+ \overload
+
+ Sets the rectangle of this image node to show its texture from (\a x, \a y) and
+ have width \a w and height \a h relatively to the QSGTexture::textureSize.
+ */
+
+/*!
+ \fn QRectF QSGImageNode::sourceRect() const
+
+ Returns the source rect of this image node.
+ */
+
+/*!
+ \fn void QSGImageNode::setTexture(QSGTexture *texture)
+
+ Sets the texture of this image node to \a texture.
+
+ Use setOwnsTexture() to set whether the node should take
+ ownership of the texture. By default, the node does not
+ take ownership.
+
+ \warning An image node must have a texture before being added to the
+ scenegraph to be rendered.
+ */
+
+/*!
+ \fn QSGTexture *QSGImageNode::texture() const
+
+ Returns the texture for this image node.
+ */
+
+/*!
+ \fn void QSGImageNode::setFiltering(QSGTexture::Filtering filtering)
+
+ Sets the filtering to be used for this image node to \a filtering.
+
+ For smooth scaling, use QSGTexture::Linear. For normal scaling, use
+ QSGTexture::Nearest.
+ */
+
+/*!
+ \fn QSGTexture::Filtering QSGImageNode::filtering() const
+
+ Returns the filtering for this image node.
+ */
+
+/*!
+ \enum QSGImageNode::TextureCoordinatesTransformFlag
+
+ The TextureCoordinatesTransformFlag enum is used to specify the mode used
+ to generate texture coordinates for a textured quad.
+
+ \value NoTransform Texture coordinates are oriented with window coordinates
+ i.e. with origin at top-left.
+
+ \value MirrorHorizontally Texture coordinates are inverted in the horizontal axis with
+ respect to window coordinates
+
+ \value MirrorVertically Texture coordinates are inverted in the vertical axis with
+ respect to window coordinates
+ */
+
+/*!
+ \fn void QSGImageNode::setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode)
+
+ Sets the method used to generate texture coordinates to \a mode. This can
+ be used to obtain correct orientation of the texture. This is commonly
+ needed when using a third-party OpenGL library to render to texture as
+ OpenGL has an inverted y-axis relative to Qt Quick.
+ */
+
+/*!
+ \fn QSGImageNode::TextureCoordinatesTransformMode textureCoordinatesTransform() const
+
+ Returns the mode used to generate texture coordinates for this node.
+ */
+
+/*!
+ \fn void QSGImageNode::setOwnsTexture(bool owns)
+
+ Sets whether the node takes ownership of the texture to \a owns.
+
+ By default, the node does not take ownership of the texture.
+ */
+
+/*!
+ \fn bool QSGImageNode::ownsTexture() const
+
+ \return \c true if the node takes ownership of the texture; otherwise \c false.
+ */
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgimagenode.h b/src/quick/scenegraph/util/qsgimagenode.h
new file mode 100644
index 0000000000..a094924ac3
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgimagenode.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGIMAGENODE_H
+#define QSGIMAGENODE_H
+
+#include <QtQuick/qsgnode.h>
+#include <QtQuick/qsgtexture.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICK_EXPORT QSGImageNode : public QSGGeometryNode
+{
+public:
+ virtual ~QSGImageNode() { }
+
+ virtual void setRect(const QRectF &rect) = 0;
+ inline void setRect(qreal x, qreal y, qreal w, qreal h) { setRect(QRectF(x, y, w, h)); }
+ virtual QRectF rect() const = 0;
+
+ virtual void setSourceRect(const QRectF &r) = 0;
+ inline void setSourceRect(qreal x, qreal y, qreal w, qreal h) { setSourceRect(QRectF(x, y, w, h)); }
+ virtual QRectF sourceRect() const = 0;
+
+ virtual void setTexture(QSGTexture *texture) = 0;
+ virtual QSGTexture *texture() const = 0;
+
+ virtual void setFiltering(QSGTexture::Filtering filtering) = 0;
+ virtual QSGTexture::Filtering filtering() const = 0;
+
+ enum TextureCoordinatesTransformFlag {
+ NoTransform = 0x00,
+ MirrorHorizontally = 0x01,
+ MirrorVertically = 0x02
+ };
+ Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)
+
+ virtual void setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode) = 0;
+ virtual TextureCoordinatesTransformMode textureCoordinatesTransform() const = 0;
+
+ virtual void setOwnsTexture(bool owns) = 0;
+ virtual bool ownsTexture() const = 0;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QSGImageNode::TextureCoordinatesTransformMode)
+
+QT_END_NAMESPACE
+
+#endif // QSGIMAGENODE_H
diff --git a/src/quick/scenegraph/util/qsgninepatchnode.cpp b/src/quick/scenegraph/util/qsgninepatchnode.cpp
new file mode 100644
index 0000000000..9c167ca76f
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgninepatchnode.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgninepatchnode.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QSGNinePatchNode
+ \inmodule QtQuick
+ \since 5.8
+ \internal
+ */
+
+/*!
+ \fn void QSGNinePatchNode::setTexture(QSGTexture *texture)
+ \internal
+ */
+
+/*!
+ \fn void QSGNinePatchNode::setBounds(const QRectF &bounds)
+ \internal
+ */
+
+/*!
+ \fn void QSGNinePatchNode::setDevicePixelRatio(qreal ratio)
+ \internal
+ */
+
+/*!
+ \fn void QSGNinePatchNode::setPadding(qreal left, qreal top, qreal right, qreal bottom)
+ \internal
+ */
+
+
+/*!
+ \fn void QSGNinePatchNode::update()
+ \internal
+ */
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgninepatchnode.h b/src/quick/scenegraph/util/qsgninepatchnode.h
new file mode 100644
index 0000000000..8677a432ba
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgninepatchnode.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGNINEPATCHNODE_H
+#define QSGNINEPATCHNODE_H
+
+#include <QtQuick/qsgnode.h>
+#include <QtQuick/qsgtexture.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICK_EXPORT QSGNinePatchNode : public QSGGeometryNode
+{
+public:
+ virtual ~QSGNinePatchNode() { }
+
+ virtual void setTexture(QSGTexture *texture) = 0;
+ virtual void setBounds(const QRectF &bounds) = 0;
+ virtual void setDevicePixelRatio(qreal ratio) = 0;
+ virtual void setPadding(qreal left, qreal top, qreal right, qreal bottom) = 0;
+ virtual void update() = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGNINEPATCHNODE_H
diff --git a/src/quick/scenegraph/util/qsgrectanglenode.cpp b/src/quick/scenegraph/util/qsgrectanglenode.cpp
new file mode 100644
index 0000000000..38c1f16a63
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgrectanglenode.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgrectanglenode.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QSGRectangleNode
+
+ \brief The QSGRectangleNode class is a convenience class for drawing
+ solid filled rectangles using scenegraph.
+ \inmodule QtQuick
+ \since 5.8
+ */
+
+/*!
+ \fn void QSGRectangleNode::setRect(const QRectF &rect)
+
+ Sets the rectangle of this rect node to \a rect.
+ */
+
+/*!
+ \fn void QSGRectangleNode::setRect(qreal x, qreal y, qreal w, qreal h)
+ \overload
+
+ Sets the rectangle of this rect node to begin at (\a x, \a y) and have
+ width \a w and height \a h.
+ */
+
+/*!
+ \fn QRectF QSGRectangleNode::rect() const
+
+ Returns the rectangle that this rect node covers.
+ */
+
+/*!
+ \fn void QSGRectangleNode::setColor(const QColor &color)
+
+ Sets the color of this rectangle to \a color. The default color will be
+ white.
+ */
+
+/*!
+ \fn QColor QSGRectangleNode::color() const
+
+ Returns the color of this rectangle.
+ */
+
+QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgrectanglenode.h b/src/quick/scenegraph/util/qsgrectanglenode.h
new file mode 100644
index 0000000000..8e0da1d9c7
--- /dev/null
+++ b/src/quick/scenegraph/util/qsgrectanglenode.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSGRECTANGLENODE_H
+#define QSGRECTANGLENODE_H
+
+#include <QtQuick/qsgnode.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_QUICK_EXPORT QSGRectangleNode : public QSGGeometryNode
+{
+public:
+ virtual ~QSGRectangleNode() { }
+
+ virtual void setRect(const QRectF &rect) = 0;
+ inline void setRect(qreal x, qreal y, qreal w, qreal h) { setRect(QRectF(x, y, w, h)); }
+ virtual QRectF rect() const = 0;
+
+ virtual void setColor(const QColor &color) = 0;
+ virtual QColor color() const = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSGRECTANGLENODE_H
diff --git a/src/quick/scenegraph/util/qsgsimplerectnode.cpp b/src/quick/scenegraph/util/qsgsimplerectnode.cpp
index 3f6b8b0eec..e20c051f9a 100644
--- a/src/quick/scenegraph/util/qsgsimplerectnode.cpp
+++ b/src/quick/scenegraph/util/qsgsimplerectnode.cpp
@@ -49,6 +49,10 @@ QT_BEGIN_NAMESPACE
solid filled rectangles using scenegraph.
\inmodule QtQuick
+ \warning This utility class is only functional when running with the OpenGL
+ or software backends of the Qt Quick scenegraph. For a proper cross-platform
+ alternative prefer using QSGSimpleRectangleNode via
+ QQuickWindow::createSimpleRectangleNode() or QSGEngine::createSimpleRectangleNode().
*/
diff --git a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp
index 1208a6bc72..4ed0445ce1 100644
--- a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp
+++ b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp
@@ -97,6 +97,11 @@ static void qsgsimpletexturenode_update(QSGGeometry *g,
\warning The simple texture node class must have a texture before being
added to the scene graph to be rendered.
+
+ \warning This utility class is only functional when running with the OpenGL
+ or software backends of the Qt Quick scenegraph. For a proper cross-platform
+ alternative prefer using QSGSimpleImageNode via
+ QQuickWindow::createSimpleImageNode() or QSGEngine::createSimpleImageNode().
*/
/*!