Skip to content

Commit

Permalink
feat: Support Qt 6.8
Browse files Browse the repository at this point in the history
Log: Fix build on Qt 6.8
  • Loading branch information
hillwoodroc authored and kegechen committed Oct 22, 2024
1 parent c4b6f6b commit b296106
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions qt6/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dtk_extend_target(${PLUGIN_NAME} EnableCov ${ENABLE_COV})
qt_add_translations(${LIB_NAME}
TS_FILES ${TS_FILES}
QM_FILES_OUTPUT_VARIABLE QM_FILES
IMMEDIATE_CALL
)

set_target_properties(${LIB_NAME} PROPERTIES
Expand Down
10 changes: 10 additions & 0 deletions src/private/dbackdropnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,13 @@ class Q_DECL_HIDDEN RhiManager : public DataManager<RhiManager, void>
renderer->setDevicePixelRatio(base->devicePixelRatio());
renderer->setDeviceRect(base->deviceRect());
renderer->setViewportRect(base->viewportRect());
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
renderer->setProjectionMatrix(base->projectionMatrix(0));
renderer->setProjectionMatrixWithNativeNDC(base->projectionMatrixWithNativeNDC(0));
#else
renderer->setProjectionMatrix(base->projectionMatrix());
renderer->setProjectionMatrixWithNativeNDC(base->projectionMatrixWithNativeNDC());
#endif
} else {
renderer->setDevicePixelRatio(1.0);
renderer->setDeviceRect(QRect(QPoint(0, 0), pixelSize));
Expand All @@ -336,8 +341,13 @@ class Q_DECL_HIDDEN RhiManager : public DataManager<RhiManager, void>
}

if (Q_UNLIKELY(!matrix.isIdentity())) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
renderer->setProjectionMatrix(renderer->projectionMatrix(0) * matrix);
renderer->setProjectionMatrixWithNativeNDC(renderer->projectionMatrixWithNativeNDC(0) * matrix);
#else
renderer->setProjectionMatrix(renderer->projectionMatrix() * matrix);
renderer->setProjectionMatrixWithNativeNDC(renderer->projectionMatrixWithNativeNDC() * matrix);
#endif
}

renderer->setRootNode(rootNode);
Expand Down
26 changes: 26 additions & 0 deletions src/private/dmaskeffectnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ class OpaqueTextureMaterialShader : public QSGMaterialShader
class OpaqueTextureMaterialShader : public QSGOpaqueTextureMaterialRhiShader
{
public:
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
OpaqueTextureMaterialShader(int viewCount);
#else
OpaqueTextureMaterialShader();
#endif

bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;

Expand All @@ -48,7 +52,11 @@ class OpaqueTextureMaterialShader : public QSGOpaqueTextureMaterialRhiShader
class TextureMaterialShader : public OpaqueTextureMaterialShader
{
public:
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
TextureMaterialShader(int viewCount);
#else
TextureMaterialShader();
#endif

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override;
Expand All @@ -61,7 +69,12 @@ class TextureMaterialShader : public OpaqueTextureMaterialShader
#endif
};

#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
OpaqueTextureMaterialShader::OpaqueTextureMaterialShader(int viewCount)
: QSGOpaqueTextureMaterialRhiShader(viewCount)
#else
OpaqueTextureMaterialShader::OpaqueTextureMaterialShader()
#endif
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#if QT_CONFIG(opengl)
Expand Down Expand Up @@ -236,8 +249,13 @@ bool OpaqueTextureMaterialShader::updateGraphicsPipelineState(RenderState &state
}
#endif

#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
TextureMaterialShader::TextureMaterialShader(int viewCount)
: OpaqueTextureMaterialShader(viewCount)
#else
TextureMaterialShader::TextureMaterialShader()
: OpaqueTextureMaterialShader()
#endif
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // TODO qt6
#if QT_CONFIG(opengl)
Expand Down Expand Up @@ -529,7 +547,11 @@ QSGMaterialShader *TextureMaterial::createShader() const
QSGMaterialShader *TextureMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const

Check warning on line 547 in src/private/dmaskeffectnode.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'createShader' is never used.
{
Q_UNUSED(renderMode)
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
return new TextureMaterialShader(viewCount());
#else
return new TextureMaterialShader;
#endif
}
#endif

Expand All @@ -553,7 +575,11 @@ QSGMaterialShader *OpaqueTextureMaterial::createShader() const
QSGMaterialShader *OpaqueTextureMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const
{
Q_UNUSED(renderMode)
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
return new OpaqueTextureMaterialShader(viewCount());
#else
return new OpaqueTextureMaterialShader;
#endif
}
#endif

Expand Down
9 changes: 9 additions & 0 deletions src/private/drectanglenode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ void CornerColorShader::initialize()
m_idQtOpacity = program->uniformLocation("qt_Opacity");
}
#else
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
CornerColorShader::CornerColorShader(int viewCount)
: QSGOpaqueTextureMaterialRhiShader(viewCount)
#else
CornerColorShader::CornerColorShader()
#endif
{
setShaderFileName(QSGMaterialShader::VertexStage, QStringLiteral(":/dtk/declarative/shaders_ng/cornerscolorshader.vert.qsb"));
setShaderFileName(QSGMaterialShader::FragmentStage, QStringLiteral(":/dtk/declarative/shaders_ng/cornerscolorshader.frag.qsb"));
Expand Down Expand Up @@ -128,7 +133,11 @@ QSGMaterialShader *CornerColorMaterial::createShader() const
QSGMaterialShader *CornerColorMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const
{
Q_UNUSED(renderMode)
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
return new CornerColorShader(viewCount());
#else
return new CornerColorShader;
#endif
}
#endif

Expand Down
4 changes: 4 additions & 0 deletions src/private/drectanglenode_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ class CornerColorShader : public QSGOpaqueTextureMaterialShader
class CornerColorShader : public QSGOpaqueTextureMaterialRhiShader
{
public:
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
CornerColorShader(int viewCount);
#else
CornerColorShader();
#endif
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial);
};
#endif
Expand Down

0 comments on commit b296106

Please sign in to comment.