From 08f56c9830c12f6b443649e3e4f51b3cea69d79b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 26 May 2020 15:31:42 +0200 Subject: Adjust QSGTexture comparisonKey type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original choice was int, simply following textureId(). This was later deemed insufficient: instead of a GLuint, the value is now often a 64-bit value (on 64 bit systems), based on a pointer, since the identity of a texture in the RHI world is the QRhiTexture* itself. In a custom texture implementation it is likely that the value here is the value of a native object handle, either a pointer or some 32 or 64 bit integer. Inspired by the recent QSGTexture::NativeTexture struct change (void* -> quint64), switch to a qint64 which is big enough to hold all these without truncation. We choose a signed value here, in order to allow for the following pattern that is widespread in material compare() implementations: if (qint64 diff = m_texture->comparisonKey() - other->texture()->comparisonKey()) return diff; Fixes: QTBUG-83769 Change-Id: I8bdae8cd835282358ded53b3703142b8f26e4400 Reviewed-by: Christian Strømme --- examples/quick/scenegraph/graph/noisynode.cpp | 2 +- examples/quick/scenegraph/twotextureproviders/xorblender.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/quick') diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp index d67110f48a..e85757d426 100644 --- a/examples/quick/scenegraph/graph/noisynode.cpp +++ b/examples/quick/scenegraph/graph/noisynode.cpp @@ -107,7 +107,7 @@ public: if (!state.texture || !other->state.texture) return state.texture ? 1 : -1; - if (int diff = state.texture->comparisonKey() - other->state.texture->comparisonKey()) + if (qint64 diff = state.texture->comparisonKey() - other->state.texture->comparisonKey()) return diff; return 0; diff --git a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp index ad959b723d..276625d908 100644 --- a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp +++ b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp @@ -117,10 +117,10 @@ int XorBlendMaterial::compare(const QSGMaterial *o) const if (!state.texture2 || !other->state.texture2) return state.texture2 ? -1 : 1; - if (int diff = state.texture1->comparisonKey() - other->state.texture1->comparisonKey()) + if (qint64 diff = state.texture1->comparisonKey() - other->state.texture1->comparisonKey()) return diff; - if (int diff = state.texture2->comparisonKey() - other->state.texture2->comparisonKey()) + if (qint64 diff = state.texture2->comparisonKey() - other->state.texture2->comparisonKey()) return diff; return 0; -- cgit v1.2.3