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
qopengltextureglyphcache_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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QOPENGLTEXTUREGLYPHCACHE_P_H
6
#
define
QOPENGLTEXTUREGLYPHCACHE_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtOpenGL
/
qtopenglglobal
.
h
>
20
#
include
<
private
/
qtextureglyphcache_p
.
h
>
21
#
include
<
private
/
qopenglcontext_p
.
h
>
22
#
include
<
qopenglshaderprogram
.
h
>
23
#
include
<
qopenglfunctions
.
h
>
24
#
include
<
qopenglbuffer
.
h
>
25
#
include
<
qopenglvertexarrayobject
.
h
>
26
27
// #define QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
28
29
QT_BEGIN_NAMESPACE
30
31
class
QOpenGL2PaintEngineExPrivate
;
32
33
class
QOpenGLGlyphTexture
:
public
QOpenGLSharedResource
34
{
35
public
:
36
explicit
QOpenGLGlyphTexture
(QOpenGLContext *ctx)
37
:
QOpenGLSharedResource
(
ctx
->
shareGroup
())
38
,
m_width
(0)
39
,
m_height
(0)
40
{
41
if
(!ctx->d_func()->workaround_brokenFBOReadBack)
42
QOpenGLFunctions
(ctx).glGenFramebuffers(1, &m_fbo);
43
44
#
ifdef
QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
45
qDebug(
" -> QOpenGLGlyphTexture() %p for context %p."
,
this
, ctx);
46
#
endif
47
}
48
49
void
freeResource
(QOpenGLContext *context)
override
50
{
51
QOpenGLContext *ctx = context;
52
#
ifdef
QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
53
qDebug(
"~QOpenGLGlyphTexture() %p for context %p."
,
this
, ctx);
54
#
endif
55
if
(!ctx->d_func()->workaround_brokenFBOReadBack)
56
ctx->functions()->glDeleteFramebuffers(1, &m_fbo);
57
if
(
m_width
||
m_height
)
58
ctx->functions()->glDeleteTextures(1, &m_texture);
59
}
60
61
void
invalidateResource
()
override
62
{
63
m_texture = 0;
64
m_fbo = 0;
65
m_width
= 0;
66
m_height
= 0;
67
}
68
69
GLuint
m_texture
;
70
GLuint
m_fbo
;
71
int
m_width
;
72
int
m_height
;
73
};
74
75
class
Q_OPENGL_EXPORT
QOpenGLTextureGlyphCache
:
public
QImageTextureGlyphCache
76
{
77
public
:
78
QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat glyphFormat,
const
QTransform &matrix,
const
QColor &color = QColor());
79
~QOpenGLTextureGlyphCache();
80
81
virtual
void
createTextureData(
int
width,
int
height) override;
82
virtual
void
resizeTextureData(
int
width,
int
height) override;
83
virtual
void
fillTexture(
const
Coord &c,
84
glyph_t glyph,
85
const
QFixedPoint &subPixelPosition) override;
86
virtual
int
glyphPadding()
const
override;
87
virtual
int
maxTextureWidth()
const
override;
88
virtual
int
maxTextureHeight()
const
override;
89
90
inline
GLuint texture()
const
{
91
QOpenGLTextureGlyphCache *that =
const_cast
<QOpenGLTextureGlyphCache *>(
this
);
92
QOpenGLGlyphTexture *glyphTexture = that->m_textureResource;
93
return
glyphTexture ? glyphTexture->m_texture : 0;
94
}
95
96
inline
int
width()
const
{
97
QOpenGLTextureGlyphCache *that =
const_cast
<QOpenGLTextureGlyphCache *>(
this
);
98
QOpenGLGlyphTexture *glyphTexture = that->m_textureResource;
99
return
glyphTexture ? glyphTexture->m_width : 0;
100
}
101
inline
int
height()
const
{
102
QOpenGLTextureGlyphCache *that =
const_cast
<QOpenGLTextureGlyphCache *>(
this
);
103
QOpenGLGlyphTexture *glyphTexture = that->m_textureResource;
104
return
glyphTexture ? glyphTexture->m_height : 0;
105
}
106
107
inline
void
setPaintEnginePrivate(QOpenGL2PaintEngineExPrivate *p) { pex = p; }
108
109
inline
const
QOpenGLContextGroup *contextGroup()
const
{
return
m_textureResource ? m_textureResource->group() :
nullptr
; }
110
111
inline
int
serialNumber()
const
{
return
m_serialNumber; }
112
113
enum
FilterMode {
114
Nearest,
115
Linear
116
};
117
FilterMode filterMode()
const
{
return
m_filterMode; }
118
void
setFilterMode(FilterMode m) { m_filterMode = m; }
119
120
void
clear();
121
122
QOpenGL2PaintEngineExPrivate *paintEnginePrivate()
const
123
{
124
return
pex;
125
}
126
127
private
:
128
void
setupVertexAttribs();
129
130
QOpenGLGlyphTexture *m_textureResource;
131
132
QOpenGL2PaintEngineExPrivate *pex;
133
QOpenGLShaderProgram *m_blitProgram;
134
FilterMode m_filterMode;
135
136
GLfloat m_vertexCoordinateArray[8];
137
GLfloat m_textureCoordinateArray[8];
138
139
int
m_serialNumber;
140
141
QOpenGLBuffer m_buffer;
142
QOpenGLVertexArrayObject m_vao;
143
};
144
145
QT_END_NAMESPACE
146
147
#
endif
// QOPENGLTEXTUREGLYPHCACHE_P_H
QOpenGL2PaintEngineExPrivate
Definition
qopenglpaintengine_p.h:141
QOpenGLFunctions
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
Definition
qopenglfunctions.h:202
QOpenGLGlyphTexture
Definition
qopengltextureglyphcache_p.h:34
QOpenGLGlyphTexture::invalidateResource
void invalidateResource() override
Definition
qopengltextureglyphcache_p.h:61
QOpenGLGlyphTexture::m_height
int m_height
Definition
qopengltextureglyphcache_p.h:72
QOpenGLGlyphTexture::freeResource
void freeResource(QOpenGLContext *context) override
Definition
qopengltextureglyphcache_p.h:49
QOpenGLGlyphTexture::m_texture
GLuint m_texture
Definition
qopengltextureglyphcache_p.h:69
QOpenGLGlyphTexture::QOpenGLGlyphTexture
QOpenGLGlyphTexture(QOpenGLContext *ctx)
Definition
qopengltextureglyphcache_p.h:36
QOpenGLGlyphTexture::m_width
int m_width
Definition
qopengltextureglyphcache_p.h:71
QOpenGLGlyphTexture::m_fbo
GLuint m_fbo
Definition
qopengltextureglyphcache_p.h:70
QOpenGLTextureGlyphCache
Definition
qopengltextureglyphcache_p.h:76
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
load_glyph_image_region_to_texture
static void load_glyph_image_region_to_texture(QOpenGLContext *ctx, const QImage &srcImg, int x, int y, int w, int h, GLuint texture, int tx, int ty)
Definition
qopengltextureglyphcache.cpp:223
load_glyph_image_to_texture
static void load_glyph_image_to_texture(QOpenGLContext *ctx, QImage &img, GLuint texture, int tx, int ty)
Definition
qopengltextureglyphcache.cpp:153
next_qopengltextureglyphcache_serial_number
static QT_BEGIN_NAMESPACE int next_qopengltextureglyphcache_serial_number()
Definition
qopengltextureglyphcache.cpp:15
QRgb
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
Definition
qrgb.h:14
qRed
constexpr int qRed(QRgb rgb)
Definition
qrgb.h:19
qGreen
constexpr int qGreen(QRgb rgb)
Definition
qrgb.h:22
qRgba
constexpr QRgb qRgba(int r, int g, int b, int a)
Definition
qrgb.h:34
qBlue
constexpr int qBlue(QRgb rgb)
Definition
qrgb.h:25
qAlpha
constexpr int qAlpha(QRgb rgb)
Definition
qrgb.h:28
qtbase
src
opengl
qopengltextureglyphcache_p.h
Generated on
for Qt by
1.18.0