aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/adaptations
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-06-03 13:49:51 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2016-06-22 13:11:14 +0000
commit65c877f40e965c368fe6e7ed730242461b5824b7 (patch)
treef23a8b64b5e3530ba5714ce1a0339302e5336ae8 /src/quick/scenegraph/adaptations
parent702c4247d74ffb7e4fb1aaca96d70f4591203ba2 (diff)
Add cross-backend simple rect, texture, and ninepatch nodes
QSGSimpleRectNode is deprecated -> use QSGRectangleNode via QQuickWindow::createRectangleNode() instead. QSGSimpleTextureNode is deprecated -> use QSGImageNode via QQuickWindow::createImageNode() instead. The OpenGL version of the simple rectangle node is switched over to the vertex color material instead of flat, to allow for better batching. Use the same concept for nine patch nodes. The "style" node from Quick Controls 1 is now QSGNinePatchNode in order to provide a proper cross-backend solution which is already necessary due to the software backend, but now generalize it to apply to the accelerated backends with proper materials as well. QC can now simply call createNinePatchNode() without further ado. Also fixes a bug with the D3D12 texture material not enabling blending when needed. When it comes to the internal class names, QSGRectangleNode and QSGImageNode get the Internal prefix in the adaptation layer in order to differentiate from the public API. This involves quite a lot of renaming, but results in a nice and clean public API. Change-Id: Iddf9f9412377843ea6d652bcf25e68d1d74659ea Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/scenegraph/adaptations')
-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.h (renamed from src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h)63
-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
15 files changed, 246 insertions, 129 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/qsgsoftwareninepatchnode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes_p.h
index bc7aec1b5a..8f5216d03a 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarepublicnodes_p.h
@@ -37,10 +37,13 @@
**
****************************************************************************/
-#ifndef QSGSOFTWARENINEPATCHNODE_H
-#define QSGSOFTWARENINEPATCHNODE_H
+#ifndef QSGSOFTWAREPUBLICNODES_H
+#define QSGSOFTWAREPUBLICNODES_H
-#include <private/qsgadaptationlayer_p.h>
+#include <QtQuick/qsgrectanglenode.h>
+#include <QtQuick/qsgimagenode.h>
+#include <QtQuick/qsgninepatchnode.h>
+#include <QtGui/qpixmap.h>
//
// W A R N I N G
@@ -55,6 +58,58 @@
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:
@@ -79,4 +134,4 @@ private:
QT_END_NAMESPACE
-#endif // QSGSOFTWARENINEPATCHNODE_H
+#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 \