diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-26 15:31:42 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-27 11:19:25 +0200 |
commit | 08f56c9830c12f6b443649e3e4f51b3cea69d79b (patch) | |
tree | e2a22208f67f064bcd753f6ec752819acd530c47 /src/quick/scenegraph/compressedtexture | |
parent | 16cb9dea7b915b50f4cb0f720eb5fbfa039076ff (diff) |
Adjust QSGTexture comparisonKey type
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 <christian.stromme@qt.io>
Diffstat (limited to 'src/quick/scenegraph/compressedtexture')
-rw-r--r-- | src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp | 6 | ||||
-rw-r--r-- | src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp index 9e3cc83433..5f00da48f2 100644 --- a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp +++ b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp @@ -90,17 +90,17 @@ int QSGCompressedTexture::textureId() const return m_textureId; } -int QSGCompressedTexture::comparisonKey() const +qint64 QSGCompressedTexture::comparisonKey() const { // not textureId() as that would create an id when not yet done - that's not wanted here if (m_textureId) return m_textureId; if (m_texture) - return int(qintptr(m_texture)); + return qint64(m_texture); // two textures (and so materials) with not-yet-created texture underneath are never equal - return int(qintptr(this)); + return qint64(this); } QSize QSGCompressedTexture::textureSize() const diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h index 00e37098b1..228f8dd7b7 100644 --- a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h +++ b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h @@ -73,7 +73,7 @@ public: bool hasAlphaChannel() const override; bool hasMipmaps() const override; - int comparisonKey() const override; + qint64 comparisonKey() const override; int textureId() const override; void bind() override; QRhiTexture *rhiTexture() const override; |