diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-04 21:32:01 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-08 09:55:53 +0200 |
commit | 3f5e21a0cc9f41f1747e5c431695e7798ee489db (patch) | |
tree | ccd9f02554d16f68fb66a8f2dd59368dd1a43c30 /src/quickshapes | |
parent | c8dd51333f14941d9a5c2d3798768df342aa48d4 (diff) |
Remove OpenGL dependency from QSGTexture
The QSGTexture API is now clean, the OpenGL-specific functions are
removed.
Docs are to be updated in a separate patch.
QSGPlainTexture, and a number of texture related places have to follow
suit.
The OpenGL atlas texture implementation is now removed.
Task-number: QTBUG-84717
Task-number: QTBUG-84623
Change-Id: I1aab3b8b9145bb74ad39ef836ce540fc851292c5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
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 |