diff options
Diffstat (limited to 'src/quickshapes')
-rw-r--r-- | src/quickshapes/qquickshape.cpp | 77 | ||||
-rw-r--r-- | src/quickshapes/qquickshape_p_p.h | 21 |
2 files changed, 0 insertions, 98 deletions
diff --git a/src/quickshapes/qquickshape.cpp b/src/quickshapes/qquickshape.cpp index 5e2cfc6622..b71e872841 100644 --- a/src/quickshapes/qquickshape.cpp +++ b/src/quickshapes/qquickshape.cpp @@ -1591,83 +1591,6 @@ QSGTexture *QQuickShapeGradientCache::get(const QQuickShapeGradientCacheKey &gra return tx; } -#if QT_CONFIG(opengl) - -// contexts sharing with each other get the same cache instance -class QQuickShapeGradientCacheWrapper -{ -public: - QQuickShapeGradientOpenGLCache *get(QOpenGLContext *context) - { - return m_resource.value<QQuickShapeGradientOpenGLCache>(context); - } - -private: - QOpenGLMultiGroupSharedResource m_resource; -}; - -QQuickShapeGradientOpenGLCache *QQuickShapeGradientOpenGLCache::currentCache() -{ - static QQuickShapeGradientCacheWrapper qt_path_gradient_caches; - return qt_path_gradient_caches.get(QOpenGLContext::currentContext()); -} - -// let QOpenGLContext manage the lifetime of the cached textures -QQuickShapeGradientOpenGLCache::~QQuickShapeGradientOpenGLCache() -{ - m_cache.clear(); -} - -void QQuickShapeGradientOpenGLCache::invalidateResource() -{ - m_cache.clear(); -} - -void QQuickShapeGradientOpenGLCache::freeResource(QOpenGLContext *) -{ - qDeleteAll(m_cache); - m_cache.clear(); -} - -QSGTexture *QQuickShapeGradientOpenGLCache::get(const QQuickShapeGradientCacheKey &grad) -{ - QSGPlainTexture *tx = m_cache[grad]; - if (!tx) { - QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); - GLuint id; - f->glGenTextures(1, &id); - f->glBindTexture(GL_TEXTURE_2D, id); - static const uint W = 1024; // texture size is 1024x1 - uint buf[W]; - generateGradientColorTable(grad, buf, W, 1.0f); - f->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, W, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf); - tx = new QSGPlainTexture; - tx->setTextureId(id); - switch (grad.spread) { - case QQuickShapeGradient::PadSpread: - tx->setHorizontalWrapMode(QSGTexture::ClampToEdge); - tx->setVerticalWrapMode(QSGTexture::ClampToEdge); - break; - case QQuickShapeGradient::RepeatSpread: - tx->setHorizontalWrapMode(QSGTexture::Repeat); - tx->setVerticalWrapMode(QSGTexture::Repeat); - break; - case QQuickShapeGradient::ReflectSpread: - tx->setHorizontalWrapMode(QSGTexture::MirroredRepeat); - tx->setVerticalWrapMode(QSGTexture::MirroredRepeat); - break; - default: - qWarning("Unknown gradient spread mode %d", grad.spread); - break; - } - tx->setFiltering(QSGTexture::Linear); - m_cache[grad] = tx; - } - return tx; -} - -#endif // QT_CONFIG(opengl) - QT_END_NAMESPACE #include "moc_qquickshape_p.cpp" diff --git a/src/quickshapes/qquickshape_p_p.h b/src/quickshapes/qquickshape_p_p.h index 7851137465..3a76f0996b 100644 --- a/src/quickshapes/qquickshape_p_p.h +++ b/src/quickshapes/qquickshape_p_p.h @@ -219,27 +219,6 @@ private: QHash<QQuickShapeGradientCacheKey, QSGPlainTexture *> m_textures; }; -#if QT_CONFIG(opengl) - -class QQuickShapeGradientOpenGLCache : public QOpenGLSharedResource -{ -public: - QQuickShapeGradientOpenGLCache(QOpenGLContext *context) : QOpenGLSharedResource(context->shareGroup()) { } - ~QQuickShapeGradientOpenGLCache(); - - void invalidateResource() override; - void freeResource(QOpenGLContext *) override; - - QSGTexture *get(const QQuickShapeGradientCacheKey &grad); - - static QQuickShapeGradientOpenGLCache *currentCache(); - -private: - QHash<QQuickShapeGradientCacheKey, QSGPlainTexture *> m_cache; -}; - -#endif // QT_CONFIG(opengl) - QT_END_NAMESPACE #endif |