diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-02 14:27:13 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-02 15:16:46 +0200 |
commit | b87b3d3d43c200f22f0799ca59ab366d851b5db6 (patch) | |
tree | fb8258e0659a91934d2c77c359295da92e4221cd /src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp | |
parent | 1f0b3a54ffa2ab0dc0cdff1345980ea68d749d24 (diff) |
Make QSGMaterialRhiShader become QSGMaterialShader
After a symbiotic relationship in Qt 5.14 and 5.15, it is time for
QSGMaterialRhiShader to devour its older sibling and take its place.
This makes the direct OpenGL rendering path disfunctional. All
QSGMaterial Qt 6 TODOs are solved, the API is clean and straightforward
again: a QSGMaterial creates a QSGMaterialShader, no special flags and
options needed. (it's just that QSGMaterialShader now has a slightly
different API)
Task-number: QTBUG-79268
Task-number: QTBUG-82997
Change-Id: I545ca8d796c5535e81957c706e7832133be15b7d
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp index 5e4affbf90..5f0932af82 100644 --- a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp +++ b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp @@ -50,63 +50,7 @@ QT_BEGIN_NAMESPACE -class SmoothColorMaterialShader : public QSGMaterialShader -{ -public: - SmoothColorMaterialShader(); - - void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; - char const *const *attributeNames() const override; - -private: - void initialize() override; - - int m_matrixLoc; - int m_opacityLoc; - int m_pixelSizeLoc; -}; - -SmoothColorMaterialShader::SmoothColorMaterialShader() -{ - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothcolor.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/smoothcolor.frag")); -} - -void SmoothColorMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *oldEffect) -{ - if (state.isOpacityDirty()) - program()->setUniformValue(m_opacityLoc, state.opacity()); - - if (state.isMatrixDirty()) - program()->setUniformValue(m_matrixLoc, state.combinedMatrix()); - - if (oldEffect == nullptr) { - // The viewport is constant, so set the pixel size uniform only once. - QRect r = state.viewportRect(); - program()->setUniformValue(m_pixelSizeLoc, 2.0f / r.width(), 2.0f / r.height()); - } -} - -char const *const *SmoothColorMaterialShader::attributeNames() const -{ - static char const *const attributes[] = { - "vertex", - "vertexColor", - "vertexOffset", - nullptr - }; - return attributes; -} - -void SmoothColorMaterialShader::initialize() -{ - m_matrixLoc = program()->uniformLocation("matrix"); - m_opacityLoc = program()->uniformLocation("opacity"); - m_pixelSizeLoc = program()->uniformLocation("pixelSize"); -} - - -class SmoothColorMaterialRhiShader : public QSGMaterialRhiShader +class SmoothColorMaterialRhiShader : public QSGMaterialShader { public: SmoothColorMaterialRhiShader(); @@ -154,7 +98,6 @@ QSGSmoothColorMaterial::QSGSmoothColorMaterial() { setFlag(RequiresFullMatrixExceptTranslate, true); setFlag(Blending, true); - setFlag(SupportsRhiShader, true); } int QSGSmoothColorMaterial::compare(const QSGMaterial *) const @@ -171,10 +114,7 @@ QSGMaterialType *QSGSmoothColorMaterial::type() const QSGMaterialShader *QSGSmoothColorMaterial::createShader() const { - if (flags().testFlag(RhiShaderWanted)) - return new SmoothColorMaterialRhiShader; - else - return new SmoothColorMaterialShader; + return new SmoothColorMaterialRhiShader; } QSGDefaultInternalRectangleNode::QSGDefaultInternalRectangleNode() |