qopengltextureglyphcache.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopengltextureglyphcache.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qopengltextureglyphcache_p.h"-
41#include "qopenglpaintengine_p.h"-
42#include "private/qopenglengineshadersource_p.h"-
43#include "qopenglextensions_p.h"-
44#include <qrgb.h>-
45#include <private/qdrawhelper_p.h>-
46-
47QT_BEGIN_NAMESPACE-
48-
49-
50QBasicAtomicInt qopengltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);-
51-
52QOpenGLTextureGlyphCache::QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix)-
53 : QImageTextureGlyphCache(format, matrix)-
54 , m_textureResource(0)-
55 , pex(0)-
56 , m_blitProgram(0)-
57 , m_filterMode(Nearest)-
58 , m_serialNumber(qopengltextureglyphcache_serial_number.fetchAndAddRelaxed(1))-
59 , m_buffer(QOpenGLBuffer::VertexBuffer)-
60{-
61#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG-
62 qDebug(" -> QOpenGLTextureGlyphCache() %p for context %p.", this, QOpenGLContext::currentContext());-
63#endif-
64 m_vertexCoordinateArray[0] = -1.0f;-
65 m_vertexCoordinateArray[1] = -1.0f;-
66 m_vertexCoordinateArray[2] = 1.0f;-
67 m_vertexCoordinateArray[3] = -1.0f;-
68 m_vertexCoordinateArray[4] = 1.0f;-
69 m_vertexCoordinateArray[5] = 1.0f;-
70 m_vertexCoordinateArray[6] = -1.0f;-
71 m_vertexCoordinateArray[7] = 1.0f;-
72-
73 m_textureCoordinateArray[0] = 0.0f;-
74 m_textureCoordinateArray[1] = 0.0f;-
75 m_textureCoordinateArray[2] = 1.0f;-
76 m_textureCoordinateArray[3] = 0.0f;-
77 m_textureCoordinateArray[4] = 1.0f;-
78 m_textureCoordinateArray[5] = 1.0f;-
79 m_textureCoordinateArray[6] = 0.0f;-
80 m_textureCoordinateArray[7] = 1.0f;-
81}
never executed: end of block
0
82-
83QOpenGLTextureGlyphCache::~QOpenGLTextureGlyphCache()-
84{-
85#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG-
86 qDebug(" -> ~QOpenGLTextureGlyphCache() %p.", this);-
87#endif-
88 clear();-
89}
never executed: end of block
0
90-
91#if !defined(QT_OPENGL_ES_2)-
92static inline bool isCoreProfile()-
93{-
94 return QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile;
never executed: return QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile;
0
95}-
96#endif-
97-
98void QOpenGLTextureGlyphCache::createTextureData(int width, int height)-
99{-
100 QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());-
101 if (ctx == 0) {
ctx == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
102 qWarning("QOpenGLTextureGlyphCache::createTextureData: Called with no context");-
103 return;
never executed: return;
0
104 }-
105-
106 // create in QImageTextureGlyphCache baseclass is meant to be called-
107 // only to create the initial image and does not preserve the content,-
108 // so we don't call when this function is called from resize.-
109 if (ctx->d_func()->workaround_brokenFBOReadBack && image().isNull())
ctx->d_func()-...kenFBOReadBackDescription
TRUEnever evaluated
FALSEnever evaluated
image().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
110 QImageTextureGlyphCache::createTextureData(width, height);
never executed: QImageTextureGlyphCache::createTextureData(width, height);
0
111-
112 // Make the lower glyph texture size 16 x 16.-
113 if (width < 16)
width < 16Description
TRUEnever evaluated
FALSEnever evaluated
0
114 width = 16;
never executed: width = 16;
0
115 if (height < 16)
height < 16Description
TRUEnever evaluated
FALSEnever evaluated
0
116 height = 16;
never executed: height = 16;
0
117-
118 if (m_textureResource && !m_textureResource->m_texture) {
m_textureResourceDescription
TRUEnever evaluated
FALSEnever evaluated
!m_textureResource->m_textureDescription
TRUEnever evaluated
FALSEnever evaluated
0
119 delete m_textureResource;-
120 m_textureResource = 0;-
121 }
never executed: end of block
0
122-
123 if (!m_textureResource)
!m_textureResourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
124 m_textureResource = new QOpenGLGlyphTexture(ctx);
never executed: m_textureResource = new QOpenGLGlyphTexture(ctx);
0
125-
126 QOpenGLFunctions *funcs = ctx->functions();-
127 funcs->glGenTextures(1, &m_textureResource->m_texture);-
128 funcs->glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture);-
129-
130 m_textureResource->m_width = width;-
131 m_textureResource->m_height = height;-
132-
133 if (m_format == QFontEngine::Format_A32 || m_format == QFontEngine::Format_ARGB) {
m_format == QF...ne::Format_A32Description
TRUEnever evaluated
FALSEnever evaluated
m_format == QF...e::Format_ARGBDescription
TRUEnever evaluated
FALSEnever evaluated
0
134 QVarLengthArray<uchar> data(width * height * 4);-
135 for (int i = 0; i < data.size(); ++i)
i < data.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
136 data[i] = 0;
never executed: data[i] = 0;
0
137 funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);-
138 } else {
never executed: end of block
0
139 QVarLengthArray<uchar> data(width * height);-
140 for (int i = 0; i < data.size(); ++i)
i < data.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
141 data[i] = 0;
never executed: data[i] = 0;
0
142#if !defined(QT_OPENGL_ES_2)-
143 const GLint internalFormat = isCoreProfile() ? GL_R8 : GL_ALPHA;
isCoreProfile()Description
TRUEnever evaluated
FALSEnever evaluated
0
144 const GLenum format = isCoreProfile() ? GL_RED : GL_ALPHA;
isCoreProfile()Description
TRUEnever evaluated
FALSEnever evaluated
0
145#else-
146 const GLint internalFormat = GL_ALPHA;-
147 const GLenum format = GL_ALPHA;-
148#endif-
149 funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, &data[0]);-
150 }
never executed: end of block
0
151-
152 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);-
153 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);-
154 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);-
155 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);-
156 m_filterMode = Nearest;-
157-
158 if (!m_buffer.isCreated()) {
!m_buffer.isCreated()Description
TRUEnever evaluated
FALSEnever evaluated
0
159 m_buffer.create();-
160 m_buffer.bind();-
161 static GLfloat buf[sizeof(m_vertexCoordinateArray) + sizeof(m_textureCoordinateArray)];-
162 memcpy(buf, m_vertexCoordinateArray, sizeof(m_vertexCoordinateArray));-
163 memcpy(buf + (sizeof(m_vertexCoordinateArray) / sizeof(GLfloat)),-
164 m_textureCoordinateArray,-
165 sizeof(m_textureCoordinateArray));-
166 m_buffer.allocate(buf, sizeof(buf));-
167 m_buffer.release();-
168 }
never executed: end of block
0
169-
170 if (!m_vao.isCreated())
!m_vao.isCreated()Description
TRUEnever evaluated
FALSEnever evaluated
0
171 m_vao.create();
never executed: m_vao.create();
0
172}
never executed: end of block
0
173-
174void QOpenGLTextureGlyphCache::setupVertexAttribs()-
175{-
176 m_buffer.bind();-
177 m_blitProgram->setAttributeBuffer(int(QT_VERTEX_COORDS_ATTR), GL_FLOAT, 0, 2);-
178 m_blitProgram->setAttributeBuffer(int(QT_TEXTURE_COORDS_ATTR), GL_FLOAT, sizeof(m_vertexCoordinateArray), 2);-
179 m_blitProgram->enableAttributeArray(int(QT_VERTEX_COORDS_ATTR));-
180 m_blitProgram->enableAttributeArray(int(QT_TEXTURE_COORDS_ATTR));-
181 m_buffer.release();-
182}
never executed: end of block
0
183-
184static void load_glyph_image_to_texture(QOpenGLContext *ctx,-
185 QImage &img,-
186 GLuint texture,-
187 int tx, int ty)-
188{-
189 QOpenGLFunctions *funcs = ctx->functions();-
190-
191 const int imgWidth = img.width();-
192 const int imgHeight = img.height();-
193-
194 if (img.format() == QImage::Format_Mono) {
img.format() =...e::Format_MonoDescription
TRUEnever evaluated
FALSEnever evaluated
0
195 img = img.convertToFormat(QImage::Format_Grayscale8);-
196 } else if (img.depth() == 32) {
never executed: end of block
img.depth() == 32Description
TRUEnever evaluated
FALSEnever evaluated
0
197 if (img.format() == QImage::Format_RGB32
img.format() =...::Format_RGB32Description
TRUEnever evaluated
FALSEnever evaluated
0
198 // We need to make the alpha component equal to the average of the RGB values.-
199 // This is needed when drawing sub-pixel antialiased text on translucent targets.-
200#if Q_BYTE_ORDER == Q_BIG_ENDIAN-
201 || img.format() == QImage::Format_ARGB32_Premultiplied-
202#else-
203 || (img.format() == QImage::Format_ARGB32_Premultiplied
img.format() =..._PremultipliedDescription
TRUEnever evaluated
FALSEnever evaluated
0
204 && ctx->isOpenGLES())
ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
205#endif-
206 ) {-
207 for (int y = 0; y < imgHeight; ++y) {
y < imgHeightDescription
TRUEnever evaluated
FALSEnever evaluated
0
208 QRgb *src = (QRgb *) img.scanLine(y);-
209 for (int x = 0; x < imgWidth; ++x) {
x < imgWidthDescription
TRUEnever evaluated
FALSEnever evaluated
0
210 int r = qRed(src[x]);-
211 int g = qGreen(src[x]);-
212 int b = qBlue(src[x]);-
213 int avg;-
214 if (img.format() == QImage::Format_RGB32)
img.format() =...::Format_RGB32Description
TRUEnever evaluated
FALSEnever evaluated
0
215 avg = (r + g + b + 1) / 3; // "+1" for rounding.
never executed: avg = (r + g + b + 1) / 3;
0
216 else // Format_ARGB_Premultiplied-
217 avg = qAlpha(src[x]);
never executed: avg = qAlpha(src[x]);
0
218-
219 src[x] = qRgba(r, g, b, avg);-
220 // swizzle the bits to accommodate for the GL_RGBA upload.-
221#if Q_BYTE_ORDER != Q_BIG_ENDIAN-
222 if (ctx->isOpenGLES())
ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
223#endif-
224 src[x] = ARGB2RGBA(src[x]);
never executed: src[x] = ARGB2RGBA(src[x]);
0
225 }
never executed: end of block
0
226 }
never executed: end of block
0
227 }
never executed: end of block
0
228 }
never executed: end of block
0
229-
230 funcs->glBindTexture(GL_TEXTURE_2D, texture);-
231 if (img.depth() == 32) {
img.depth() == 32Description
TRUEnever evaluated
FALSEnever evaluated
0
232#ifdef QT_OPENGL_ES_2-
233 GLenum fmt = GL_RGBA;-
234#else-
235 GLenum fmt = ctx->isOpenGLES() ? GL_RGBA : GL_BGRA;
ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
236#endif // QT_OPENGL_ES_2-
237-
238#if Q_BYTE_ORDER == Q_BIG_ENDIAN-
239 fmt = GL_RGBA;-
240#endif-
241 funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, tx, ty, imgWidth, imgHeight, fmt, GL_UNSIGNED_BYTE, img.constBits());-
242 } else {
never executed: end of block
0
243 // The scanlines in image are 32-bit aligned, even for mono or 8-bit formats. This-
244 // is good because it matches the default of 4 bytes for GL_UNPACK_ALIGNMENT.-
245#if !defined(QT_OPENGL_ES_2)-
246 const GLenum format = isCoreProfile() ? GL_RED : GL_ALPHA;
isCoreProfile()Description
TRUEnever evaluated
FALSEnever evaluated
0
247#else-
248 const GLenum format = GL_ALPHA;-
249#endif-
250 funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, tx, ty, imgWidth, imgHeight, format, GL_UNSIGNED_BYTE, img.constBits());-
251 }
never executed: end of block
0
252}-
253-
254static void load_glyph_image_region_to_texture(QOpenGLContext *ctx,-
255 const QImage &srcImg,-
256 int x, int y,-
257 int w, int h,-
258 GLuint texture,-
259 int tx, int ty)-
260{-
261 Q_ASSERT(x + w <= srcImg.width() && y + h <= srcImg.height());-
262-
263 QImage img;-
264 if (x != 0 || y != 0 || w != srcImg.width() || h != srcImg.height())
x != 0Description
TRUEnever evaluated
FALSEnever evaluated
y != 0Description
TRUEnever evaluated
FALSEnever evaluated
w != srcImg.width()Description
TRUEnever evaluated
FALSEnever evaluated
h != srcImg.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
265 img = srcImg.copy(x, y, w, h);
never executed: img = srcImg.copy(x, y, w, h);
0
266 else-
267 img = srcImg;
never executed: img = srcImg;
0
268-
269 load_glyph_image_to_texture(ctx, img, texture, tx, ty);-
270}
never executed: end of block
0
271-
272void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)-
273{-
274 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
275 if (ctx == 0) {
ctx == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
276 qWarning("QOpenGLTextureGlyphCache::resizeTextureData: Called with no context");-
277 return;
never executed: return;
0
278 }-
279-
280 QOpenGLFunctions *funcs = ctx->functions();-
281 GLint oldFbo;-
282 funcs->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFbo);-
283-
284 int oldWidth = m_textureResource->m_width;-
285 int oldHeight = m_textureResource->m_height;-
286-
287 // Make the lower glyph texture size 16 x 16.-
288 if (width < 16)
width < 16Description
TRUEnever evaluated
FALSEnever evaluated
0
289 width = 16;
never executed: width = 16;
0
290 if (height < 16)
height < 16Description
TRUEnever evaluated
FALSEnever evaluated
0
291 height = 16;
never executed: height = 16;
0
292-
293 GLuint oldTexture = m_textureResource->m_texture;-
294 createTextureData(width, height);-
295-
296 if (ctx->d_func()->workaround_brokenFBOReadBack) {
ctx->d_func()-...kenFBOReadBackDescription
TRUEnever evaluated
FALSEnever evaluated
0
297 QImageTextureGlyphCache::resizeTextureData(width, height);-
298 load_glyph_image_region_to_texture(ctx, image(), 0, 0, qMin(oldWidth, width), qMin(oldHeight, height),-
299 m_textureResource->m_texture, 0, 0);-
300 return;
never executed: return;
0
301 }-
302-
303 // ### the QTextureGlyphCache API needs to be reworked to allow-
304 // ### resizeTextureData to fail-
305-
306 funcs->glBindFramebuffer(GL_FRAMEBUFFER, m_textureResource->m_fbo);-
307-
308 GLuint tmp_texture;-
309 funcs->glGenTextures(1, &tmp_texture);-
310 funcs->glBindTexture(GL_TEXTURE_2D, tmp_texture);-
311 funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0,-
312 GL_RGBA, GL_UNSIGNED_BYTE, NULL);-
313 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);-
314 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);-
315 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);-
316 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);-
317 m_filterMode = Nearest;-
318 funcs->glBindTexture(GL_TEXTURE_2D, 0);-
319 funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,-
320 GL_TEXTURE_2D, tmp_texture, 0);-
321-
322 funcs->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);-
323 funcs->glBindTexture(GL_TEXTURE_2D, oldTexture);-
324-
325 if (pex != 0)
pex != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
326 pex->transferMode(BrushDrawingMode);
never executed: pex->transferMode(BrushDrawingMode);
0
327-
328 funcs->glDisable(GL_STENCIL_TEST);-
329 funcs->glDisable(GL_DEPTH_TEST);-
330 funcs->glDisable(GL_SCISSOR_TEST);-
331 funcs->glDisable(GL_BLEND);-
332-
333 funcs->glViewport(0, 0, oldWidth, oldHeight);-
334-
335 QOpenGLShaderProgram *blitProgram = 0;-
336 if (pex == 0) {
pex == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
337 if (m_blitProgram == 0) {
m_blitProgram == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
338 m_blitProgram = new QOpenGLShaderProgram;-
339 const bool isCoreProfile = ctx->format().profile() == QSurfaceFormat::CoreProfile;-
340-
341 {-
342 QString source;-
343 source.append(QLatin1String(isCoreProfile ? qopenglslMainWithTexCoordsVertexShader_core : qopenglslMainWithTexCoordsVertexShader));-
344 source.append(QLatin1String(isCoreProfile ? qopenglslUntransformedPositionVertexShader_core : qopenglslUntransformedPositionVertexShader));-
345-
346 QOpenGLShader *vertexShader = new QOpenGLShader(QOpenGLShader::Vertex, m_blitProgram);-
347 vertexShader->compileSourceCode(source);-
348-
349 m_blitProgram->addShader(vertexShader);-
350 }-
351-
352 {-
353 QString source;-
354 source.append(QLatin1String(isCoreProfile ? qopenglslMainFragmentShader_core : qopenglslMainFragmentShader));-
355 source.append(QLatin1String(isCoreProfile ? qopenglslImageSrcFragmentShader_core : qopenglslImageSrcFragmentShader));-
356-
357 QOpenGLShader *fragmentShader = new QOpenGLShader(QOpenGLShader::Fragment, m_blitProgram);-
358 fragmentShader->compileSourceCode(source);-
359-
360 m_blitProgram->addShader(fragmentShader);-
361 }-
362-
363 m_blitProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);-
364 m_blitProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);-
365-
366 m_blitProgram->link();-
367-
368 if (m_vao.isCreated()) {
m_vao.isCreated()Description
TRUEnever evaluated
FALSEnever evaluated
0
369 m_vao.bind();-
370 setupVertexAttribs();-
371 }
never executed: end of block
0
372 }
never executed: end of block
0
373-
374 if (m_vao.isCreated())
m_vao.isCreated()Description
TRUEnever evaluated
FALSEnever evaluated
0
375 m_vao.bind();
never executed: m_vao.bind();
0
376 else-
377 setupVertexAttribs();
never executed: setupVertexAttribs();
0
378-
379 m_blitProgram->bind();-
380 blitProgram = m_blitProgram;-
381-
382 } else {
never executed: end of block
0
383 pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, m_vertexCoordinateArray);-
384 pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, m_textureCoordinateArray);-
385-
386 pex->shaderManager->useBlitProgram();-
387 blitProgram = pex->shaderManager->blitProgram();-
388 }
never executed: end of block
0
389-
390 blitProgram->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT);-
391-
392 funcs->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);-
393-
394 funcs->glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture);-
395-
396 funcs->glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight);-
397-
398 funcs->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,-
399 GL_RENDERBUFFER, 0);-
400 funcs->glDeleteTextures(1, &tmp_texture);-
401 funcs->glDeleteTextures(1, &oldTexture);-
402-
403 funcs->glBindFramebuffer(GL_FRAMEBUFFER, (GLuint)oldFbo);-
404-
405 if (pex != 0) {
pex != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
406 funcs->glViewport(0, 0, pex->width, pex->height);-
407 pex->updateClipScissorTest();-
408 } else {
never executed: end of block
0
409 if (m_vao.isCreated()) {
m_vao.isCreated()Description
TRUEnever evaluated
FALSEnever evaluated
0
410 m_vao.release();-
411 } else {
never executed: end of block
0
412 m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR));-
413 m_blitProgram->disableAttributeArray(int(QT_TEXTURE_COORDS_ATTR));-
414 }
never executed: end of block
0
415 }-
416}-
417-
418void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition)-
419{-
420 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
421 if (ctx == 0) {
ctx == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
422 qWarning("QOpenGLTextureGlyphCache::fillTexture: Called with no context");-
423 return;
never executed: return;
0
424 }-
425-
426 if (ctx->d_func()->workaround_brokenFBOReadBack) {
ctx->d_func()-...kenFBOReadBackDescription
TRUEnever evaluated
FALSEnever evaluated
0
427 QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition);-
428 load_glyph_image_region_to_texture(ctx, image(), c.x, c.y, c.w, c.h, m_textureResource->m_texture, c.x, c.y);-
429 return;
never executed: return;
0
430 }-
431-
432 QImage mask = textureMapForGlyph(glyph, subPixelPosition);-
433 load_glyph_image_to_texture(ctx, mask, m_textureResource->m_texture, c.x, c.y);-
434}
never executed: end of block
0
435-
436int QOpenGLTextureGlyphCache::glyphPadding() const-
437{-
438 return 1;
never executed: return 1;
0
439}-
440-
441int QOpenGLTextureGlyphCache::maxTextureWidth() const-
442{-
443 QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());-
444 if (ctx == 0)
ctx == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
445 return QImageTextureGlyphCache::maxTextureWidth();
never executed: return QImageTextureGlyphCache::maxTextureWidth();
0
446 else-
447 return ctx->d_func()->maxTextureSize();
never executed: return ctx->d_func()->maxTextureSize();
0
448}-
449-
450int QOpenGLTextureGlyphCache::maxTextureHeight() const-
451{-
452 QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());-
453 if (ctx == 0)
ctx == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
454 return QImageTextureGlyphCache::maxTextureHeight();
never executed: return QImageTextureGlyphCache::maxTextureHeight();
0
455-
456 if (ctx->d_func()->workaround_brokenTexSubImage)
ctx->d_func()-...kenTexSubImageDescription
TRUEnever evaluated
FALSEnever evaluated
0
457 return qMin(1024, ctx->d_func()->maxTextureSize());
never executed: return qMin(1024, ctx->d_func()->maxTextureSize());
0
458 else-
459 return ctx->d_func()->maxTextureSize();
never executed: return ctx->d_func()->maxTextureSize();
0
460}-
461-
462void QOpenGLTextureGlyphCache::clear()-
463{-
464 if (m_textureResource)
m_textureResourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
465 m_textureResource->free();
never executed: m_textureResource->free();
0
466 m_textureResource = 0;-
467-
468 delete m_blitProgram;-
469 m_blitProgram = 0;-
470-
471 m_w = 0;-
472 m_h = 0;-
473 m_cx = 0;-
474 m_cy = 0;-
475 m_currentRowHeight = 0;-
476 coords.clear();-
477}
never executed: end of block
0
478-
479QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9