diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-07-18 14:49:15 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-07-27 12:12:34 +0000 |
commit | ede3791df8330ed8daae6667d025ad40219a9f5f (patch) | |
tree | 0f0c8d8897799b6a7f56c381fe36701795f28f6c /src/gui/opengl/qopengltexturecache_p.h | |
parent | 318b15db15b515675b0b1e7b3319c793b9f1a757 (diff) |
Move texture uploading out of QOpenGLTextureCache
This way the logic can be reused elsewhere.
At the same time a standard OpenGL ES/3 way of handling BGRA is added,
so we don't depend on extensions, and handling of NPOT and max size
which QSGTexture will need.
Change-Id: I475bc7127f44be3964fdb482c9e86a20db1fbca5
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/opengl/qopengltexturecache_p.h')
-rw-r--r-- | src/gui/opengl/qopengltexturecache_p.h | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/gui/opengl/qopengltexturecache_p.h b/src/gui/opengl/qopengltexturecache_p.h index b9d7df91e3..88ef06e744 100644 --- a/src/gui/opengl/qopengltexturecache_p.h +++ b/src/gui/opengl/qopengltexturecache_p.h @@ -56,6 +56,7 @@ #include <QObject> #include <QCache> #include <private/qopenglcontext_p.h> +#include <private/qopengltextureuploader_p.h> #include <QtCore/qmutex.h> QT_BEGIN_NAMESPACE @@ -70,15 +71,10 @@ public: QOpenGLTextureCache(QOpenGLContext *); ~QOpenGLTextureCache(); - enum BindOption { - NoBindOption = 0x0000, - PremultipliedAlphaBindOption = 0x0001, - UseRedFor8BitBindOption = 0x0002, - }; - Q_DECLARE_FLAGS(BindOptions, BindOption) - - GLuint bindTexture(QOpenGLContext *context, const QPixmap &pixmap, QOpenGLTextureCache::BindOptions options = PremultipliedAlphaBindOption); - GLuint bindTexture(QOpenGLContext *context, const QImage &image, QOpenGLTextureCache::BindOptions options = PremultipliedAlphaBindOption); + GLuint bindTexture(QOpenGLContext *context, const QPixmap &pixmap, + QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption); + GLuint bindTexture(QOpenGLContext *context, const QImage &image, + QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption); void invalidate(qint64 key); @@ -86,26 +82,24 @@ public: void freeResource(QOpenGLContext *ctx) override; private: - GLuint bindTexture(QOpenGLContext *context, qint64 key, const QImage &image, QOpenGLTextureCache::BindOptions options); + GLuint bindTexture(QOpenGLContext *context, qint64 key, const QImage &image, QOpenGLTextureUploader::BindOptions options); QMutex m_mutex; QCache<quint64, QOpenGLCachedTexture> m_cache; }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLTextureCache::BindOptions) - class QOpenGLCachedTexture { public: - QOpenGLCachedTexture(GLuint id, QOpenGLTextureCache::BindOptions options, QOpenGLContext *context); + QOpenGLCachedTexture(GLuint id, QOpenGLTextureUploader::BindOptions options, QOpenGLContext *context); ~QOpenGLCachedTexture() { m_resource->free(); } GLuint id() const { return m_resource->id(); } - QOpenGLTextureCache::BindOptions options() const { return m_options; } + QOpenGLTextureUploader::BindOptions options() const { return m_options; } private: QOpenGLSharedResourceGuard *m_resource; - QOpenGLTextureCache::BindOptions m_options; + QOpenGLTextureUploader::BindOptions m_options; }; QT_END_NAMESPACE |