diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-15 18:38:51 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-04-16 09:59:12 +0200 |
commit | bc1b6e73bb31c7eb9b9f6b4920d2e99ac441bc08 (patch) | |
tree | cb6063f9c1512ebeab1a667413b6542f63c9f54a | |
parent | 76f783c23fa2fd11c5cef6031f59ad5a1a6c7545 (diff) |
textureprovider example: Add comparisonKey() to the custom QSGTexture
This example will likely be removed as it is tied to directly using
OpenGL. In the meantime, make it follow the QSGTexture API change, and
provide the now-mandatory comparisonKey().
Change-Id: I66fb32a10bcec7a868fd264dfb4425a1bed1f4a4
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
-rw-r--r-- | examples/quick/textureprovider/etcprovider.cpp | 9 | ||||
-rw-r--r-- | examples/quick/textureprovider/etcprovider.h | 11 |
2 files changed, 15 insertions, 5 deletions
diff --git a/examples/quick/textureprovider/etcprovider.cpp b/examples/quick/textureprovider/etcprovider.cpp index 65960169e2..f542d510b2 100644 --- a/examples/quick/textureprovider/etcprovider.cpp +++ b/examples/quick/textureprovider/etcprovider.cpp @@ -116,6 +116,15 @@ int EtcTexture::textureId() const return m_texture_id; } +int EtcTexture::comparisonKey() const +{ + if (m_texture_id) + return m_texture_id; + + // two textures (and so materials) with not-yet-created texture underneath are never equal + return int(qintptr(this)); +} + void EtcTexture::bind() { if (m_uploaded && m_texture_id) { diff --git a/examples/quick/textureprovider/etcprovider.h b/examples/quick/textureprovider/etcprovider.h index 44d5d6f53e..7de03e0955 100644 --- a/examples/quick/textureprovider/etcprovider.h +++ b/examples/quick/textureprovider/etcprovider.h @@ -78,13 +78,14 @@ public: EtcTexture(); ~EtcTexture(); - void bind(); + void bind() override; - QSize textureSize() const { return m_size; } - int textureId() const; + QSize textureSize() const override { return m_size; } + int textureId() const override; + int comparisonKey() const override; - bool hasAlphaChannel() const { return false; } - bool hasMipmaps() const { return false; } + bool hasAlphaChannel() const override { return false; } + bool hasMipmaps() const override { return false; } QByteArray m_data; QSize m_size; |