Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qopengltexturecache_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists purely as an
9// implementation detail. This header file may change from version to
10// version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef QOPENGLTEXTURECACHE_P_H
16#define QOPENGLTEXTURECACHE_P_H
17
18#include <QtOpenGL/qtopenglglobal.h>
19#include <QHash>
20#include <QObject>
21#include <QCache>
22#include <private/qopenglcontext_p.h>
23#include <private/qopengltextureuploader_p.h>
24#include <QtCore/qmutex.h>
25
27
29
30class Q_OPENGL_EXPORT QOpenGLTextureCache : public QOpenGLSharedResource
31{
32public:
33 static QOpenGLTextureCache *cacheForContext(QOpenGLContext *context);
34
37
38 enum class BindResultFlag : quint8 {
39 NewTexture = 0x01
40 };
41 Q_DECLARE_FLAGS(BindResultFlags, BindResultFlag)
42
43 struct BindResult {
45 BindResultFlags flags;
46 };
47
48 BindResult bindTexture(QOpenGLContext *context, const QPixmap &pixmap,
49 QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption);
50 BindResult bindTexture(QOpenGLContext *context, const QImage &image,
51 QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption);
52
53 void invalidate(qint64 key);
54
55 void invalidateResource() override;
56 void freeResource(QOpenGLContext *ctx) override;
57
58private:
59 BindResult bindTexture(QOpenGLContext *context, qint64 key, const QImage &image, QOpenGLTextureUploader::BindOptions options);
60
61 QMutex m_mutex;
62 QCache<quint64, QOpenGLCachedTexture> m_cache;
63};
64
65Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLTextureCache::BindResultFlags)
66
68{
69public:
70 QOpenGLCachedTexture(GLuint id, QOpenGLTextureUploader::BindOptions options, QOpenGLContext *context);
71 ~QOpenGLCachedTexture() { m_resource->free(); }
72
73 GLuint id() const { return m_resource->id(); }
74 QOpenGLTextureUploader::BindOptions options() const { return m_options; }
75
76private:
78 QOpenGLTextureUploader::BindOptions m_options;
79};
80
82
83#endif
84
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qmutex.h:281
QOpenGLTextureUploader::BindOptions options() const
\inmodule QtGui
The QOpenGLSharedResourceGuard class is a convenience sub-class of QOpenGLSharedResource to be used t...
The QOpenGLSharedResource class is used to keep track of resources that are shared between OpenGL con...
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
EGLContext ctx
Combined button and popup list for selecting options.
Definition image.cpp:4
static void * context
SharedPointerFileDialogOptions m_options
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
GLuint64 key
#define GLuint
long long qint64
Definition qtypes.h:60
unsigned char quint8
Definition qtypes.h:46
widget render & pixmap