Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
15
16
#
ifndef
QOPENGLTEXTURECACHE_P_H
17
#
define
QOPENGLTEXTURECACHE_P_H
18
19
#
include
<
QtOpenGL
/
qtopenglglobal
.
h
>
20
#
include
<
QHash
>
21
#
include
<
QObject
>
22
#
include
<
QCache
>
23
#
include
<
private
/
qopenglcontext_p
.
h
>
24
#
include
<
private
/
qopengltextureuploader_p
.
h
>
25
#
include
<
QtCore
/
qmutex
.
h
>
26
27
QT_BEGIN_NAMESPACE
28
29
class
QOpenGLCachedTexture;
30
31
class
Q_OPENGL_EXPORT
QOpenGLTextureCache
:
public
QOpenGLSharedResource
32
{
33
public
:
34
static
QOpenGLTextureCache *cacheForContext(QOpenGLContext *context);
35
36
QOpenGLTextureCache(QOpenGLContext *);
37
~QOpenGLTextureCache();
38
39
enum
class
BindResultFlag : quint8 {
40
NewTexture = 0x01
41
};
42
Q_DECLARE_FLAGS(BindResultFlags, BindResultFlag)
43
44
struct
BindResult {
45
GLuint id;
46
BindResultFlags flags;
47
};
48
49
BindResult bindTexture(QOpenGLContext *context,
const
QPixmap &pixmap,
50
QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption);
51
BindResult bindTexture(QOpenGLContext *context,
const
QImage &image,
52
QOpenGLTextureUploader::BindOptions options = QOpenGLTextureUploader::PremultipliedAlphaBindOption);
53
54
void
invalidate(qint64 key);
55
56
void
invalidateResource() override;
57
void
freeResource(QOpenGLContext *ctx) override;
58
59
private
:
60
BindResult bindTexture(QOpenGLContext *context, qint64 key,
const
QImage &image, QOpenGLTextureUploader::BindOptions options);
61
62
QMutex m_mutex;
63
QCache<quint64, QOpenGLCachedTexture> m_cache;
64
};
65
66
Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLTextureCache::BindResultFlags)
67
68
class
QOpenGLCachedTexture
69
{
70
public
:
71
QOpenGLCachedTexture(GLuint id, QOpenGLTextureUploader::BindOptions options, QOpenGLContext *context);
72
~QOpenGLCachedTexture() { m_resource->free(); }
73
74
GLuint id()
const
{
return
m_resource->id(); }
75
QOpenGLTextureUploader::BindOptions options()
const
{
return
m_options; }
76
77
private
:
78
QOpenGLSharedResourceGuard *m_resource;
79
QOpenGLTextureUploader::BindOptions m_options;
80
};
81
82
QT_END_NAMESPACE
83
84
#
endif
QOpenGLTextureCacheWrapper
Definition
qopengltexturecache.cpp:17
QOpenGLTextureCacheWrapper::cleanupTexturesForPixmapData
static void cleanupTexturesForPixmapData(QPlatformPixmap *pmd)
Definition
qopengltexturecache.cpp:60
QOpenGLTextureCacheWrapper::~QOpenGLTextureCacheWrapper
~QOpenGLTextureCacheWrapper()
Definition
qopengltexturecache.cpp:26
QOpenGLTextureCacheWrapper::cacheForContext
QOpenGLTextureCache * cacheForContext(QOpenGLContext *context)
Definition
qopengltexturecache.cpp:33
QOpenGLTextureCacheWrapper::QOpenGLTextureCacheWrapper
QOpenGLTextureCacheWrapper()
Definition
qopengltexturecache.cpp:19
QOpenGLTextureCacheWrapper::cleanupTexturesForCacheKey
static void cleanupTexturesForCacheKey(qint64 key)
Definition
qopengltexturecache.cpp:53
QOpenGLTextureCache
Definition
qopengltexturecache_p.h:32
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
Q_TRACE_POINT
Q_TRACE_POINT(qtcore, QCoreApplication_postEvent_exit)
freeTexture
static void freeTexture(QOpenGLFunctions *funcs, GLuint id)
Definition
qopengltexturecache.cpp:177
qtbase
src
opengl
qopengltexturecache_p.h
Generated on
for Qt by
1.18.0