aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-06-10 21:12:28 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-06-10 21:12:28 +0200
commit0c5a9ff9876cb1af53317720d1de8baae003e21d (patch)
tree333235a9873df74b8e9b3c4232e0f8f87854df11 /src
parentc9d8b85ec9efd90f9bd8071a58dc04f54c2c365d (diff)
parent2a999f870e791d99c5c0463a11be05fc5a14dfcc (diff)
Merge branch 'wip/scenegraphng' into dev
Diffstat (limited to 'src')
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp167
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h26
-rw-r--r--src/plugins/scenegraph/d3d12/shaders/flatcolor.hlsl27
-rw-r--r--src/plugins/scenegraph/d3d12/shaders/shaders.pri11
-rw-r--r--src/quick/items/qquickgraphicsinfo.cpp10
-rw-r--r--src/quick/items/qquickgraphicsinfo_p.h16
-rw-r--r--src/quick/items/qquickshadereffectsource_p.h13
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp3
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture.cpp12
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture_p.h2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp1
-rw-r--r--src/quick/scenegraph/util/qsgflatcolormaterial.cpp3
-rw-r--r--src/quick/scenegraph/util/qsgsimplematerial.cpp5
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp6
-rw-r--r--src/quick/scenegraph/util/qsgvertexcolormaterial.cpp3
16 files changed, 224 insertions, 83 deletions
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp
index f51130deb7..ca92062120 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp
@@ -45,6 +45,8 @@
#include "vs_vertexcolor.hlslh"
#include "ps_vertexcolor.hlslh"
+#include "vs_flatcolor.hlslh"
+#include "ps_flatcolor.hlslh"
#include "vs_smoothcolor.hlslh"
#include "ps_smoothcolor.hlslh"
#include "vs_texture.hlslh"
@@ -66,6 +68,31 @@ QT_BEGIN_NAMESPACE
// importantly, it is packed so that it does not cross a 16-byte (float4)
// boundary. Hence the need for padding in some cases.
+static inline QVector4D qsg_premultiply(const QVector4D &c, float globalOpacity)
+{
+ const float o = c.w() * globalOpacity;
+ return QVector4D(c.x() * o, c.y() * o, c.z() * o, o);
+}
+
+static inline QVector4D qsg_premultiply(const QColor &c, float globalOpacity)
+{
+ const float o = c.alphaF() * globalOpacity;
+ return QVector4D(c.redF() * o, c.greenF() * o, c.blueF() * o, o);
+}
+
+static inline int qsg_colorDiff(const QVector4D &a, const QVector4D &b)
+{
+ if (a.x() != b.x())
+ return a.x() > b.x() ? 1 : -1;
+ if (a.y() != b.y())
+ return a.y() > b.y() ? 1 : -1;
+ if (a.z() != b.z())
+ return a.z() > b.z() ? 1 : -1;
+ if (a.w() != b.w())
+ return a.w() > b.w() ? 1 : -1;
+ return 0;
+}
+
QSGMaterialType QSGD3D12VertexColorMaterial::mtype;
QSGMaterialType *QSGD3D12VertexColorMaterial::type() const
@@ -121,6 +148,67 @@ QSGD3D12Material::UpdateResults QSGD3D12VertexColorMaterial::updatePipeline(cons
return r;
}
+QSGMaterialType QSGD3D12FlatColorMaterial::mtype;
+
+QSGMaterialType *QSGD3D12FlatColorMaterial::type() const
+{
+ return &QSGD3D12FlatColorMaterial::mtype;
+}
+
+int QSGD3D12FlatColorMaterial::compare(const QSGMaterial *other) const
+{
+ Q_ASSERT(other && type() == other->type());
+ const QSGD3D12FlatColorMaterial *o = static_cast<const QSGD3D12FlatColorMaterial *>(other);
+ return m_color.rgba() - o->color().rgba();
+}
+
+static const int FLAT_COLOR_CB_SIZE_0 = 16 * sizeof(float); // float4x4
+static const int FLAT_COLOR_CB_SIZE_1 = 4 * sizeof(float); // float4
+static const int FLAT_COLOR_CB_SIZE = FLAT_COLOR_CB_SIZE_0 + FLAT_COLOR_CB_SIZE_1;
+
+int QSGD3D12FlatColorMaterial::constantBufferSize() const
+{
+ return QSGD3D12Engine::alignedConstantBufferSize(FLAT_COLOR_CB_SIZE);
+}
+
+void QSGD3D12FlatColorMaterial::preparePipeline(QSGD3D12PipelineState *pipelineState)
+{
+ pipelineState->shaders.vs = g_VS_FlatColor;
+ pipelineState->shaders.vsSize = sizeof(g_VS_FlatColor);
+ pipelineState->shaders.ps = g_PS_FlatColor;
+ pipelineState->shaders.psSize = sizeof(g_PS_FlatColor);
+}
+
+QSGD3D12Material::UpdateResults QSGD3D12FlatColorMaterial::updatePipeline(const QSGD3D12MaterialRenderState &state,
+ QSGD3D12PipelineState *,
+ ExtraState *,
+ quint8 *constantBuffer)
+{
+ QSGD3D12Material::UpdateResults r = 0;
+ quint8 *p = constantBuffer;
+
+ if (state.isMatrixDirty()) {
+ memcpy(p, state.combinedMatrix().constData(), FLAT_COLOR_CB_SIZE_0);
+ r |= UpdatedConstantBuffer;
+ }
+ p += FLAT_COLOR_CB_SIZE_0;
+
+ const QVector4D color = qsg_premultiply(m_color, state.opacity());
+ const float f[] = { color.x(), color.y(), color.z(), color.w() };
+ if (state.isOpacityDirty() || memcmp(p, f, FLAT_COLOR_CB_SIZE_1)) {
+ memcpy(p, f, FLAT_COLOR_CB_SIZE_1);
+ r |= UpdatedConstantBuffer;
+ }
+
+ return r;
+}
+
+void QSGD3D12FlatColorMaterial::setColor(const QColor &color)
+{
+ m_color = color;
+ setFlag(Blending, m_color.alpha() != 0xFF);
+}
+
QSGD3D12SmoothColorMaterial::QSGD3D12SmoothColorMaterial()
{
setFlag(RequiresFullMatrixExceptTranslate, true);
@@ -356,25 +444,6 @@ QSGD3D12Material::UpdateResults QSGD3D12SmoothTextureMaterial::updatePipeline(co
return r;
}
-static inline QVector4D qsg_premultiply(const QVector4D &c, float globalOpacity)
-{
- float o = c.w() * globalOpacity;
- return QVector4D(c.x() * o, c.y() * o, c.z() * o, o);
-}
-
-static inline int qsg_colorDiff(const QVector4D &a, const QVector4D &b)
-{
- if (a.x() != b.x())
- return a.x() > b.x() ? 1 : -1;
- if (a.y() != b.y())
- return a.y() > b.y() ? 1 : -1;
- if (a.z() != b.z())
- return a.z() > b.z() ? 1 : -1;
- if (a.w() != b.w())
- return a.w() > b.w() ? 1 : -1;
- return 0;
-}
-
QSGD3D12TextMaterial::QSGD3D12TextMaterial(StyleType styleType, QSGD3D12RenderContext *rc,
const QRawFont &font, QFontEngine::GlyphFormat glyphFormat)
: m_styleType(styleType),
@@ -503,56 +572,60 @@ QSGD3D12Material::UpdateResults QSGD3D12TextMaterial::updatePipeline(const QSGD3
}
p += TEXT_CB_SIZE_0;
- if (state.isCachedMaterialDataDirty() || m_lastGlyphCacheSize != glyphCache()->currentSize()) {
- m_lastGlyphCacheSize = glyphCache()->currentSize();
- const float textureScale[2] = { 1.0f / m_lastGlyphCacheSize.width(),
- 1.0f / m_lastGlyphCacheSize.height() };
+ const QSize sz = glyphCache()->currentSize();
+ const float textureScale[] = { 1.0f / sz.width(), 1.0f / sz.height() };
+ if (state.isCachedMaterialDataDirty() || memcmp(p, textureScale, TEXT_CB_SIZE_1)) {
memcpy(p, textureScale, TEXT_CB_SIZE_1);
r |= UpdatedConstantBuffer;
}
p += TEXT_CB_SIZE_1;
const float dpr = m_rc->engine()->windowDevicePixelRatio();
- if (state.isCachedMaterialDataDirty() || m_lastDpr != dpr) {
- m_lastDpr = dpr;
+ if (state.isCachedMaterialDataDirty() || memcmp(p, &dpr, TEXT_CB_SIZE_2)) {
memcpy(p, &dpr, TEXT_CB_SIZE_2);
r |= UpdatedConstantBuffer;
}
p += TEXT_CB_SIZE_2;
- if (state.isOpacityDirty() || m_lastColor != m_color) {
- m_lastColor = m_color;
- if (glyphCache()->glyphFormat() == QFontEngine::Format_A32) {
- const QVector4D color = qsg_premultiply(m_color, state.opacity());
- const float alpha = color.w();
+ if (glyphCache()->glyphFormat() == QFontEngine::Format_A32) {
+ const QVector4D color = qsg_premultiply(m_color, state.opacity());
+ const float alpha = color.w();
+ if (state.isOpacityDirty() || memcmp(p, &alpha, TEXT_CB_SIZE_3)) {
memcpy(p, &alpha, TEXT_CB_SIZE_3);
- } else if (glyphCache()->glyphFormat() == QFontEngine::Format_ARGB) {
- const float opacity = m_color.w() * state.opacity();
+ r |= UpdatedConstantBuffer;
+ }
+ } else if (glyphCache()->glyphFormat() == QFontEngine::Format_ARGB) {
+ const float opacity = m_color.w() * state.opacity();
+ if (state.isOpacityDirty() || memcmp(p, &opacity, TEXT_CB_SIZE_3)) {
memcpy(p, &opacity, TEXT_CB_SIZE_3);
- } else {
- const QVector4D color = qsg_premultiply(m_color, state.opacity());
- const float f[4] = { color.x(), color.y(), color.z(), color.w() };
+ r |= UpdatedConstantBuffer;
+ }
+ } else {
+ const QVector4D color = qsg_premultiply(m_color, state.opacity());
+ const float f[] = { color.x(), color.y(), color.z(), color.w() };
+ if (state.isOpacityDirty() || memcmp(p, f, TEXT_CB_SIZE_4)) {
memcpy(p + TEXT_CB_SIZE_3, f, TEXT_CB_SIZE_4);
+ r |= UpdatedConstantBuffer;
}
- r |= UpdatedConstantBuffer;
}
p += TEXT_CB_SIZE_3 + TEXT_CB_SIZE_4;
- if (m_styleType == Styled && (state.isCachedMaterialDataDirty() || m_lastStyleShift != m_styleShift)) {
- m_lastStyleShift = m_styleShift;
- const float f[2] = { m_styleShift.x(), m_styleShift.y() };
- memcpy(p, f, TEXT_CB_SIZE_5);
- r |= UpdatedConstantBuffer;
+ if (m_styleType == Styled) {
+ const float f[] = { m_styleShift.x(), m_styleShift.y() };
+ if (state.isCachedMaterialDataDirty() || memcmp(p, f, TEXT_CB_SIZE_5)) {
+ memcpy(p, f, TEXT_CB_SIZE_5);
+ r |= UpdatedConstantBuffer;
+ }
}
p += TEXT_CB_SIZE_5 + TEXT_CB_SIZE_5_PADDING;
- if ((m_styleType == Styled || m_styleType == Outlined)
- && (state.isOpacityDirty() || m_lastStyleColor != m_styleColor)) {
- m_lastStyleColor = m_styleColor;
+ if (m_styleType == Styled || m_styleType == Outlined) {
const QVector4D color = qsg_premultiply(m_styleColor, state.opacity());
- const float f[4] = { color.x(), color.y(), color.z(), color.w() };
- memcpy(p, f, TEXT_CB_SIZE_6);
- r |= UpdatedConstantBuffer;
+ const float f[] = { color.x(), color.y(), color.z(), color.w() };
+ if (state.isOpacityDirty() || memcmp(p, f, TEXT_CB_SIZE_6)) {
+ memcpy(p, f, TEXT_CB_SIZE_6);
+ r |= UpdatedConstantBuffer;
+ }
}
QSGD3D12TextureView &tv(pipelineState->shaders.rootSig.textureViews[0]);
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h
index c64ff52ab0..34ae73d2d6 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h
@@ -77,6 +77,27 @@ private:
static QSGMaterialType mtype;
};
+class QSGD3D12FlatColorMaterial : public QSGD3D12Material
+{
+public:
+ QSGMaterialType *type() const override;
+ int compare(const QSGMaterial *other) const override;
+
+ int constantBufferSize() const override;
+ void preparePipeline(QSGD3D12PipelineState *pipelineState) override;
+ UpdateResults updatePipeline(const QSGD3D12MaterialRenderState &state,
+ QSGD3D12PipelineState *pipelineState,
+ ExtraState *extraState,
+ quint8 *constantBuffer) override;
+
+ void setColor(const QColor &color);
+ QColor color() const { return m_color; }
+
+private:
+ static QSGMaterialType mtype;
+ QColor m_color;
+};
+
class QSGD3D12SmoothColorMaterial : public QSGD3D12Material
{
public:
@@ -224,11 +245,6 @@ private:
QVector4D m_styleColor;
QRawFont m_font;
QExplicitlySharedDataPointer<QFontEngineGlyphCache> m_glyphCache;
- QSize m_lastGlyphCacheSize;
- float m_lastDpr = 0;
- QVector4D m_lastColor;
- QVector2D m_lastStyleShift;
- QVector4D m_lastStyleColor;
};
QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/d3d12/shaders/flatcolor.hlsl b/src/plugins/scenegraph/d3d12/shaders/flatcolor.hlsl
new file mode 100644
index 0000000000..034b51435a
--- /dev/null
+++ b/src/plugins/scenegraph/d3d12/shaders/flatcolor.hlsl
@@ -0,0 +1,27 @@
+struct VSInput
+{
+ float4 position : POSITION;
+};
+
+cbuffer ConstantBuffer : register(b0)
+{
+ float4x4 mvp;
+ float4 color;
+};
+
+struct PSInput
+{
+ float4 position : SV_POSITION;
+};
+
+PSInput VS_FlatColor(VSInput input)
+{
+ PSInput result;
+ result.position = mul(mvp, input.position);
+ return result;
+}
+
+float4 PS_FlatColor(PSInput input) : SV_TARGET
+{
+ return color;
+}
diff --git a/src/plugins/scenegraph/d3d12/shaders/shaders.pri b/src/plugins/scenegraph/d3d12/shaders/shaders.pri
index 41bac334de..41f0ee80f7 100644
--- a/src/plugins/scenegraph/d3d12/shaders/shaders.pri
+++ b/src/plugins/scenegraph/d3d12/shaders/shaders.pri
@@ -8,6 +8,16 @@ vertexcolor_pshader.header = ps_vertexcolor.hlslh
vertexcolor_pshader.entry = PS_VertexColor
vertexcolor_pshader.type = ps_5_0
+flatcolor_VSPS = $$PWD/flatcolor.hlsl
+flatcolor_vshader.input = flatcolor_VSPS
+flatcolor_vshader.header = vs_flatcolor.hlslh
+flatcolor_vshader.entry = VS_FlatColor
+flatcolor_vshader.type = vs_5_0
+flatcolor_pshader.input = flatcolor_VSPS
+flatcolor_pshader.header = ps_flatcolor.hlslh
+flatcolor_pshader.entry = PS_FlatColor
+flatcolor_pshader.type = ps_5_0
+
stencilclip_VSPS = $$PWD/stencilclip.hlsl
stencilclip_vshader.input = stencilclip_VSPS
stencilclip_vshader.header = vs_stencilclip.hlslh
@@ -106,6 +116,7 @@ tdr_cshader.type = cs_5_0
HLSL_SHADERS = \
vertexcolor_vshader vertexcolor_pshader \
+ flatcolor_vshader flatcolor_pshader \
stencilclip_vshader stencilclip_pshader \
smoothcolor_vshader smoothcolor_pshader \
texture_vshader texture_pshader \
diff --git a/src/quick/items/qquickgraphicsinfo.cpp b/src/quick/items/qquickgraphicsinfo.cpp
index 2dbad82acf..79b0edf031 100644
--- a/src/quick/items/qquickgraphicsinfo.cpp
+++ b/src/quick/items/qquickgraphicsinfo.cpp
@@ -70,7 +70,7 @@ QQuickGraphicsInfo::QQuickGraphicsInfo(QQuickItem *item)
, m_shaderSourceType(ShaderSourceType(0))
, m_majorVersion(2)
, m_minorVersion(0)
- , m_profile(NoProfile)
+ , m_profile(OpenGLNoProfile)
, m_renderableType(SurfaceFormatUnspecified)
{
connect(item, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(setWindow(QQuickWindow*)));
@@ -211,9 +211,9 @@ QQuickGraphicsInfo *QQuickGraphicsInfo::qmlAttachedProperties(QObject *object)
The possible values are:
\list
- \li GraphicsInfo.NoProfile (default) - OpenGL version is lower than 3.2 or OpenGL is not in use.
- \li GraphicsInfo.CoreProfile - Functionality deprecated in OpenGL version 3.0 is not available.
- \li GraphicsInfo.CompatibilityProfile - Functionality from earlier OpenGL versions is available.
+ \li GraphicsInfo.OpenGLNoProfile (default) - OpenGL version is lower than 3.2 or OpenGL is not in use.
+ \li GraphicsInfo.OpenGLCoreProfile - Functionality deprecated in OpenGL version 3.0 is not available.
+ \li GraphicsInfo.OpenGLCompatibilityProfile - Functionality from earlier OpenGL versions is available.
\endlist
Reusable QML components will typically use this property in bindings in order to
@@ -275,7 +275,7 @@ void QQuickGraphicsInfo::updateInfo()
m_minorVersion = format.minorVersion();
emit minorVersionChanged();
}
- ContextProfile profile = static_cast<ContextProfile>(format.profile());
+ OpenGLContextProfile profile = static_cast<OpenGLContextProfile>(format.profile());
if (m_profile != profile) {
m_profile = profile;
emit profileChanged();
diff --git a/src/quick/items/qquickgraphicsinfo_p.h b/src/quick/items/qquickgraphicsinfo_p.h
index 0cbfbbddba..9ef7bacb3e 100644
--- a/src/quick/items/qquickgraphicsinfo_p.h
+++ b/src/quick/items/qquickgraphicsinfo_p.h
@@ -72,7 +72,7 @@ class QQuickGraphicsInfo : public QObject
Q_PROPERTY(int majorVersion READ majorVersion NOTIFY majorVersionChanged FINAL)
Q_PROPERTY(int minorVersion READ minorVersion NOTIFY minorVersionChanged FINAL)
- Q_PROPERTY(ContextProfile profile READ profile NOTIFY profileChanged FINAL)
+ Q_PROPERTY(OpenGLContextProfile profile READ profile NOTIFY profileChanged FINAL)
Q_PROPERTY(RenderableType renderableType READ renderableType NOTIFY renderableTypeChanged FINAL)
public:
@@ -104,12 +104,12 @@ public:
};
Q_ENUM(ShaderSourceType)
- enum ContextProfile {
- NoProfile = QSurfaceFormat::NoProfile,
- CoreProfile = QSurfaceFormat::CoreProfile,
- CompatibilityProfile = QSurfaceFormat::CompatibilityProfile
+ enum OpenGLContextProfile {
+ OpenGLNoProfile = QSurfaceFormat::NoProfile,
+ OpenGLCoreProfile = QSurfaceFormat::CoreProfile,
+ OpenGLCompatibilityProfile = QSurfaceFormat::CompatibilityProfile
};
- Q_ENUM(ContextProfile)
+ Q_ENUM(OpenGLContextProfile)
enum RenderableType {
SurfaceFormatUnspecified = QSurfaceFormat::DefaultRenderableType,
@@ -129,7 +129,7 @@ public:
int majorVersion() const { return m_majorVersion; }
int minorVersion() const { return m_minorVersion; }
- ContextProfile profile() const { return m_profile; }
+ OpenGLContextProfile profile() const { return m_profile; }
RenderableType renderableType() const { return m_renderableType; }
Q_SIGNALS:
@@ -155,7 +155,7 @@ private:
ShaderSourceType m_shaderSourceType;
int m_majorVersion;
int m_minorVersion;
- ContextProfile m_profile;
+ OpenGLContextProfile m_profile;
RenderableType m_renderableType;
};
diff --git a/src/quick/items/qquickshadereffectsource_p.h b/src/quick/items/qquickshadereffectsource_p.h
index 5d7ed2ad2d..680ba85aa1 100644
--- a/src/quick/items/qquickshadereffectsource_p.h
+++ b/src/quick/items/qquickshadereffectsource_p.h
@@ -93,19 +93,12 @@ public:
Repeat
};
Q_ENUM(WrapMode)
-#ifndef QT_NO_OPENGL
- enum Format {
- Alpha = GL_ALPHA,
- RGB = GL_RGB,
- RGBA = GL_RGBA
- };
-#else
+ // Equivalents to GL_ALPHA and similar type constants.
enum Format {
Alpha = 0x1906,
- RGB,
- RGBA
+ RGB = 0x1907,
+ RGBA = 0x1908
};
-#endif
Q_ENUM(Format)
enum TextureMirroring {
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
index dee1ac8954..ce726e342b 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarecontext.cpp
@@ -153,8 +153,7 @@ void QSGSoftwareRenderContext::invalidate()
QSGTexture *QSGSoftwareRenderContext::createTexture(const QImage &image, uint flags) const
{
- Q_UNUSED(flags)
- return new QSGSoftwarePixmapTexture(image);
+ return new QSGSoftwarePixmapTexture(image, flags);
}
QSGRenderer *QSGSoftwareRenderContext::createRenderer()
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h
index 62559c933c..bc7aec1b5a 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareninepatchnode_p.h
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
class QSGSoftwareNinePatchNode : public QSGNinePatchNode
{
-public:
+public:
QSGSoftwareNinePatchNode();
void setTexture(QSGTexture *texture) override;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture.cpp
index e04c400af3..534a0a4ec6 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture.cpp
@@ -41,11 +41,17 @@
QT_BEGIN_NAMESPACE
-QSGSoftwarePixmapTexture::QSGSoftwarePixmapTexture(const QImage &image)
+QSGSoftwarePixmapTexture::QSGSoftwarePixmapTexture(const QImage &image, uint flags)
+{
// Prevent pixmap format conversion to reduce memory consumption
// and surprises in calling code. (See QTBUG-47328)
- : m_pixmap(QPixmap::fromImage(image, Qt::NoFormatConversion))
-{
+ if (flags & QSGRenderContext::CreateTexture_Alpha) {
+ //If texture should have an alpha
+ m_pixmap = QPixmap::fromImage(image, Qt::NoFormatConversion);
+ } else {
+ //Force opaque texture
+ m_pixmap = QPixmap::fromImage(image.convertToFormat(QImage::Format_RGB32), Qt::NoFormatConversion);
+ }
}
QSGSoftwarePixmapTexture::QSGSoftwarePixmapTexture(const QPixmap &pixmap)
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture_p.h
index 01bfe19471..034fa25da9 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarepixmaptexture_p.h
@@ -59,7 +59,7 @@ class QSGSoftwarePixmapTexture : public QSGTexture
{
Q_OBJECT
public:
- QSGSoftwarePixmapTexture(const QImage &image);
+ QSGSoftwarePixmapTexture(const QImage &image, uint flags);
QSGSoftwarePixmapTexture(const QPixmap &pixmap);
int textureId() const override;
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp
index 300ce6920c..5292e1371f 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp
@@ -229,6 +229,7 @@ QImage QSGSoftwareRenderLoop::grab(QQuickWindow *window)
renderWindow(window);
QImage grabbed = grabContent;
+ grabbed.detach();
grabContent = QImage();
return grabbed;
}
diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
index b9986c3d11..5d7817163e 100644
--- a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp
@@ -125,6 +125,9 @@ void FlatColorMaterialShader::initialize()
\inmodule QtQuick
\ingroup qtquick-scenegraph-materials
+ \warning This utility class is only functional when running with the OpenGL
+ backend of the Qt Quick scenegraph.
+
The flat color material will fill every pixel in a geometry using
a solid color. The color can contain transparency.
diff --git a/src/quick/scenegraph/util/qsgsimplematerial.cpp b/src/quick/scenegraph/util/qsgsimplematerial.cpp
index 923179071b..7214a255df 100644
--- a/src/quick/scenegraph/util/qsgsimplematerial.cpp
+++ b/src/quick/scenegraph/util/qsgsimplematerial.cpp
@@ -41,11 +41,14 @@
\class QSGSimpleMaterialShader
\brief The QSGSimpleMaterialShader class provides a convenient way of
- building custom materials for the scene graph.
+ building custom OpenGL-based materials for the scene graph.
\inmodule QtQuick
\ingroup qtquick-scenegraph-materials
+ \warning This utility class is only functional when running with the OpenGL
+ backend of the Qt Quick scenegraph.
+
Where the QSGMaterial and QSGMaterialShader API requires a bit of
boilerplate code to create a functioning material, the
QSGSimpleMaterialShader tries to hide some of this through the use
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index 744df5e143..3db8163376 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -127,6 +127,9 @@ void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMa
\inmodule QtQuick
\ingroup qtquick-scenegraph-materials
+ \warning This utility class is only functional when running with the OpenGL
+ backend of the Qt Quick scenegraph.
+
The opaque textured material will fill every pixel in a geometry with
the supplied texture. The material does not respect the opacity of the
QSGMaterialShader::RenderState, so opacity nodes in the parent chain
@@ -321,6 +324,9 @@ int QSGOpaqueTextureMaterial::compare(const QSGMaterial *o) const
\inmodule QtQuick
\ingroup qtquick-scenegraph-materials
+ \warning This utility class is only functional when running with the OpenGL
+ backend of the Qt Quick scenegraph.
+
The textured material will fill every pixel in a geometry with
the supplied texture.
diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
index 18de19b04e..dedbc86385 100644
--- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
+++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp
@@ -107,6 +107,9 @@ void QSGVertexColorMaterialShader::initialize()
\inmodule QtQuick
\ingroup qtquick-scenegraph-materials
+ \warning This utility class is only functional when running with the OpenGL
+ backend of the Qt Quick scenegraph.
+
The vertex color material will give each vertex in a geometry a color. Pixels between
vertices will be linearly interpolated. The colors can contain transparency.