diff options
7 files changed, 19 insertions, 22 deletions
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp index e85757d426..c39e775e98 100644 --- a/examples/quick/scenegraph/graph/noisynode.cpp +++ b/examples/quick/scenegraph/graph/noisynode.cpp @@ -107,10 +107,8 @@ public: if (!state.texture || !other->state.texture) return state.texture ? 1 : -1; - if (qint64 diff = state.texture->comparisonKey() - other->state.texture->comparisonKey()) - return diff; - - return 0; + const qint64 diff = state.texture->comparisonKey() - other->state.texture->comparisonKey(); + return diff < 0 ? -1 : (diff > 0 ? 1 : 0); } struct { diff --git a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp index 276625d908..9971f202a7 100644 --- a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp +++ b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp @@ -117,13 +117,12 @@ int XorBlendMaterial::compare(const QSGMaterial *o) const if (!state.texture2 || !other->state.texture2) return state.texture2 ? -1 : 1; - if (qint64 diff = state.texture1->comparisonKey() - other->state.texture1->comparisonKey()) - return diff; + qint64 diff = state.texture1->comparisonKey() - other->state.texture1->comparisonKey(); + if (diff != 0) + return diff < 0 ? -1 : 1; - if (qint64 diff = state.texture2->comparisonKey() - other->state.texture2->comparisonKey()) - return diff; - - return 0; + diff = state.texture2->comparisonKey() - other->state.texture2->comparisonKey(); + return diff < 0 ? -1 : (diff > 0 ? 1 : 0); } XorBlendRhiShader::XorBlendRhiShader() diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp index 087c3c4cbf..7984547ef1 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp @@ -255,7 +255,8 @@ void QSGMaterial::setFlag(Flags flags, bool on) int QSGMaterial::compare(const QSGMaterial *other) const { Q_ASSERT(other && type() == other->type()); - return qint64(this) - qint64(other); + const qintptr diff = qintptr(this) - qintptr(other); + return diff < 0 ? -1 : (diff > 0 ? 1 : 0); } diff --git a/src/quick/scenegraph/qsgdefaultspritenode.cpp b/src/quick/scenegraph/qsgdefaultspritenode.cpp index b179838576..573c6e7a5d 100644 --- a/src/quick/scenegraph/qsgdefaultspritenode.cpp +++ b/src/quick/scenegraph/qsgdefaultspritenode.cpp @@ -65,10 +65,6 @@ public: ~QQuickSpriteMaterial(); QSGMaterialType *type() const override { static QSGMaterialType type; return &type; } QSGMaterialShader *createShader() const override; - int compare(const QSGMaterial *other) const override - { - return this - static_cast<const QQuickSpriteMaterial *>(other); - } QSGTexture *texture = nullptr; diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp index a25daa6070..30e17bbe04 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp @@ -381,9 +381,10 @@ int QSGDistanceFieldTextMaterial::compare(const QSGMaterial *o) const } if (m_color != other->m_color) return &m_color < &other->m_color ? -1 : 1; - int t0 = m_texture ? (m_texture->rhiBased ? qintptr(m_texture->texture) : m_texture->textureId) : 0; - int t1 = other->m_texture ? (other->m_texture->rhiBased ? qintptr(other->m_texture->texture) : other->m_texture->textureId) : 0; - return t0 - t1; + qintptr t0 = m_texture ? (m_texture->rhiBased ? qintptr(m_texture->texture) : qintptr(m_texture->textureId)) : 0; + qintptr t1 = other->m_texture ? (other->m_texture->rhiBased ? qintptr(other->m_texture->texture) : qintptr(other->m_texture->textureId)) : 0; + const qintptr diff = t0 - t1; + return diff < 0 ? -1 : (diff > 0 ? 1 : 0); } diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp index 2afb40a61e..f4477918c0 100644 --- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp +++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp @@ -494,8 +494,9 @@ int QSGRhiShaderEffectMaterial::compare(const QSGMaterial *other) const QSGTexture *t1 = tp1->texture(); QSGTexture *t2 = tp2->texture(); if (t1 && t2) { - if (qint64 diff = t1->comparisonKey() - t2->comparisonKey()) - return diff; + const qint64 diff = t1->comparisonKey() - t2->comparisonKey(); + if (diff != 0) + return diff < 0 ? -1 : 1; } else { if (!t1 && t2) return -1; diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp index c2fe0364b3..0e70d0638b 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial.cpp +++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp @@ -378,8 +378,9 @@ int QSGOpaqueTextureMaterial::compare(const QSGMaterial *o) const { Q_ASSERT(o && type() == o->type()); const QSGOpaqueTextureMaterial *other = static_cast<const QSGOpaqueTextureMaterial *>(o); - if (qint64 diff = m_texture->comparisonKey() - other->texture()->comparisonKey()) - return diff; + const qint64 diff = m_texture->comparisonKey() - other->texture()->comparisonKey(); + if (diff != 0) + return diff < 0 ? -1 : 1; return int(m_filtering) - int(other->m_filtering); } |