gl2paintengineex/qtextureglyphcache_gl.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtOpenGL 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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qtextureglyphcache_gl_p.h" -
43#include "qpaintengineex_opengl2_p.h" -
44#include "private/qglengineshadersource_p.h" -
45 -
46QT_BEGIN_NAMESPACE -
47 -
48 -
49QBasicAtomicInt qgltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1); -
50 -
51QGLTextureGlyphCache::QGLTextureGlyphCache(QFontEngineGlyphCache::Type type, const QTransform &matrix) -
52 : QImageTextureGlyphCache(type, matrix) -
53 , m_textureResource(0) -
54 , pex(0) -
55 , m_blitProgram(0) -
56 , m_filterMode(Nearest) -
57 , m_serialNumber(qgltextureglyphcache_serial_number.fetchAndAddRelaxed(1)) -
58{ -
59#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG -
60 qDebug(" -> QGLTextureGlyphCache() %p for context %p.", this, QOpenGLContext::currentContext()); -
61#endif -
62 m_vertexCoordinateArray[0] = -1.0f;
never executed (the execution status of this line is deduced): m_vertexCoordinateArray[0] = -1.0f;
-
63 m_vertexCoordinateArray[1] = -1.0f;
never executed (the execution status of this line is deduced): m_vertexCoordinateArray[1] = -1.0f;
-
64 m_vertexCoordinateArray[2] = 1.0f;
never executed (the execution status of this line is deduced): m_vertexCoordinateArray[2] = 1.0f;
-
65 m_vertexCoordinateArray[3] = -1.0f;
never executed (the execution status of this line is deduced): m_vertexCoordinateArray[3] = -1.0f;
-
66 m_vertexCoordinateArray[4] = 1.0f;
never executed (the execution status of this line is deduced): m_vertexCoordinateArray[4] = 1.0f;
-
67 m_vertexCoordinateArray[5] = 1.0f;
never executed (the execution status of this line is deduced): m_vertexCoordinateArray[5] = 1.0f;
-
68 m_vertexCoordinateArray[6] = -1.0f;
never executed (the execution status of this line is deduced): m_vertexCoordinateArray[6] = -1.0f;
-
69 m_vertexCoordinateArray[7] = 1.0f;
never executed (the execution status of this line is deduced): m_vertexCoordinateArray[7] = 1.0f;
-
70 -
71 m_textureCoordinateArray[0] = 0.0f;
never executed (the execution status of this line is deduced): m_textureCoordinateArray[0] = 0.0f;
-
72 m_textureCoordinateArray[1] = 0.0f;
never executed (the execution status of this line is deduced): m_textureCoordinateArray[1] = 0.0f;
-
73 m_textureCoordinateArray[2] = 1.0f;
never executed (the execution status of this line is deduced): m_textureCoordinateArray[2] = 1.0f;
-
74 m_textureCoordinateArray[3] = 0.0f;
never executed (the execution status of this line is deduced): m_textureCoordinateArray[3] = 0.0f;
-
75 m_textureCoordinateArray[4] = 1.0f;
never executed (the execution status of this line is deduced): m_textureCoordinateArray[4] = 1.0f;
-
76 m_textureCoordinateArray[5] = 1.0f;
never executed (the execution status of this line is deduced): m_textureCoordinateArray[5] = 1.0f;
-
77 m_textureCoordinateArray[6] = 0.0f;
never executed (the execution status of this line is deduced): m_textureCoordinateArray[6] = 0.0f;
-
78 m_textureCoordinateArray[7] = 1.0f;
never executed (the execution status of this line is deduced): m_textureCoordinateArray[7] = 1.0f;
-
79}
never executed: }
0
80 -
81QGLTextureGlyphCache::~QGLTextureGlyphCache() -
82{ -
83#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG -
84 qDebug(" -> ~QGLTextureGlyphCache() %p.", this); -
85#endif -
86 delete m_blitProgram;
never executed (the execution status of this line is deduced): delete m_blitProgram;
-
87}
never executed: }
0
88 -
89void QGLTextureGlyphCache::createTextureData(int width, int height) -
90{ -
91 QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
never executed (the execution status of this line is deduced): QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
-
92 if (ctx == 0) {
never evaluated: ctx == 0
0
93 qWarning("QGLTextureGlyphCache::createTextureData: Called with no context");
never executed (the execution status of this line is deduced): QMessageLogger("gl2paintengineex/qtextureglyphcache_gl.cpp", 93, __PRETTY_FUNCTION__).warning("QGLTextureGlyphCache::createTextureData: Called with no context");
-
94 return;
never executed: return;
0
95 } -
96 -
97 // create in QImageTextureGlyphCache baseclass is meant to be called -
98 // only to create the initial image and does not preserve the content, -
99 // so we don't call when this function is called from resize. -
100 if ((!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) && image().isNull())
never evaluated: !QGLFramebufferObject::hasOpenGLFramebufferObjects()
never evaluated: ctx->d_ptr->workaround_brokenFBOReadBack
never evaluated: image().isNull()
0
101 QImageTextureGlyphCache::createTextureData(width, height);
never executed: QImageTextureGlyphCache::createTextureData(width, height);
0
102 -
103 // Make the lower glyph texture size 16 x 16. -
104 if (width < 16)
never evaluated: width < 16
0
105 width = 16;
never executed: width = 16;
0
106 if (height < 16)
never evaluated: height < 16
0
107 height = 16;
never executed: height = 16;
0
108 -
109 if (m_textureResource && !m_textureResource->m_texture) {
never evaluated: m_textureResource
never evaluated: !m_textureResource->m_texture
0
110 delete m_textureResource;
never executed (the execution status of this line is deduced): delete m_textureResource;
-
111 m_textureResource = 0;
never executed (the execution status of this line is deduced): m_textureResource = 0;
-
112 }
never executed: }
0
113 -
114 if (!m_textureResource)
never evaluated: !m_textureResource
0
115 m_textureResource = new QGLGlyphTexture(ctx);
never executed: m_textureResource = new QGLGlyphTexture(ctx);
0
116 -
117 glGenTextures(1, &m_textureResource->m_texture);
never executed (the execution status of this line is deduced): glGenTextures(1, &m_textureResource->m_texture);
-
118 glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture);
never executed (the execution status of this line is deduced): glBindTexture(0x0DE1, m_textureResource->m_texture);
-
119 -
120 m_textureResource->m_width = width;
never executed (the execution status of this line is deduced): m_textureResource->m_width = width;
-
121 m_textureResource->m_height = height;
never executed (the execution status of this line is deduced): m_textureResource->m_height = height;
-
122 -
123 if (m_type == QFontEngineGlyphCache::Raster_RGBMask) {
never evaluated: m_type == QFontEngineGlyphCache::Raster_RGBMask
0
124 QVarLengthArray<uchar> data(width * height * 4);
never executed (the execution status of this line is deduced): QVarLengthArray<uchar> data(width * height * 4);
-
125 for (int i = 0; i < data.size(); ++i)
never evaluated: i < data.size()
0
126 data[i] = 0;
never executed: data[i] = 0;
0
127 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
never executed (the execution status of this line is deduced): glTexImage2D(0x0DE1, 0, 0x1908, width, height, 0, 0x1908, 0x1401, &data[0]);
-
128 } else {
never executed: }
0
129 QVarLengthArray<uchar> data(width * height);
never executed (the execution status of this line is deduced): QVarLengthArray<uchar> data(width * height);
-
130 for (int i = 0; i < data.size(); ++i)
never evaluated: i < data.size()
0
131 data[i] = 0;
never executed: data[i] = 0;
0
132 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]);
never executed (the execution status of this line is deduced): glTexImage2D(0x0DE1, 0, 0x1906, width, height, 0, 0x1906, 0x1401, &data[0]);
-
133 }
never executed: }
0
134 -
135 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2800, 0x2600);
-
136 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2801, 0x2600);
-
137 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2802, 0x812F);
-
138 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2803, 0x812F);
-
139 m_filterMode = Nearest;
never executed (the execution status of this line is deduced): m_filterMode = Nearest;
-
140}
never executed: }
0
141 -
142void QGLTextureGlyphCache::resizeTextureData(int width, int height) -
143{ -
144 QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
never executed (the execution status of this line is deduced): QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
-
145 if (ctx == 0) {
never evaluated: ctx == 0
0
146 qWarning("QGLTextureGlyphCache::resizeTextureData: Called with no context");
never executed (the execution status of this line is deduced): QMessageLogger("gl2paintengineex/qtextureglyphcache_gl.cpp", 146, __PRETTY_FUNCTION__).warning("QGLTextureGlyphCache::resizeTextureData: Called with no context");
-
147 return;
never executed: return;
0
148 } -
149 -
150 int oldWidth = m_textureResource->m_width;
never executed (the execution status of this line is deduced): int oldWidth = m_textureResource->m_width;
-
151 int oldHeight = m_textureResource->m_height;
never executed (the execution status of this line is deduced): int oldHeight = m_textureResource->m_height;
-
152 -
153 // Make the lower glyph texture size 16 x 16. -
154 if (width < 16)
never evaluated: width < 16
0
155 width = 16;
never executed: width = 16;
0
156 if (height < 16)
never evaluated: height < 16
0
157 height = 16;
never executed: height = 16;
0
158 -
159 GLuint oldTexture = m_textureResource->m_texture;
never executed (the execution status of this line is deduced): GLuint oldTexture = m_textureResource->m_texture;
-
160 createTextureData(width, height);
never executed (the execution status of this line is deduced): createTextureData(width, height);
-
161 -
162 if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) {
never evaluated: !QGLFramebufferObject::hasOpenGLFramebufferObjects()
never evaluated: ctx->d_ptr->workaround_brokenFBOReadBack
0
163 QImageTextureGlyphCache::resizeTextureData(width, height);
never executed (the execution status of this line is deduced): QImageTextureGlyphCache::resizeTextureData(width, height);
-
164 Q_ASSERT(image().depth() == 8);
never executed (the execution status of this line is deduced): qt_noop();
-
165 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits());
never executed (the execution status of this line is deduced): glTexSubImage2D(0x0DE1, 0, 0, 0, width, oldHeight, 0x1906, 0x1401, image().constBits());
-
166 glDeleteTextures(1, &oldTexture);
never executed (the execution status of this line is deduced): glDeleteTextures(1, &oldTexture);
-
167 return;
never executed: return;
0
168 } -
169 -
170 // ### the QTextureGlyphCache API needs to be reworked to allow -
171 // ### resizeTextureData to fail -
172 -
173 glBindFramebuffer(GL_FRAMEBUFFER, m_textureResource->m_fbo);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8D40, m_textureResource->m_fbo);
-
174 -
175 GLuint tmp_texture;
never executed (the execution status of this line is deduced): GLuint tmp_texture;
-
176 glGenTextures(1, &tmp_texture);
never executed (the execution status of this line is deduced): glGenTextures(1, &tmp_texture);
-
177 glBindTexture(GL_TEXTURE_2D, tmp_texture);
never executed (the execution status of this line is deduced): glBindTexture(0x0DE1, tmp_texture);
-
178 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, oldWidth, oldHeight, 0,
never executed (the execution status of this line is deduced): glTexImage2D(0x0DE1, 0, 0x1908, oldWidth, oldHeight, 0,
-
179 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
never executed (the execution status of this line is deduced): 0x1908, 0x1401, __null);
-
180 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2801, 0x2600);
-
181 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2800, 0x2600);
-
182 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2802, 0x812F);
-
183 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
never executed (the execution status of this line is deduced): glTexParameteri(0x0DE1, 0x2803, 0x812F);
-
184 m_filterMode = Nearest;
never executed (the execution status of this line is deduced): m_filterMode = Nearest;
-
185 glBindTexture(GL_TEXTURE_2D, 0);
never executed (the execution status of this line is deduced): glBindTexture(0x0DE1, 0);
-
186 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTexture2D(0x8D40, 0x8CE0,
-
187 GL_TEXTURE_2D, tmp_texture, 0);
never executed (the execution status of this line is deduced): 0x0DE1, tmp_texture, 0);
-
188 -
189 glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(0));
-
190 glBindTexture(GL_TEXTURE_2D, oldTexture);
never executed (the execution status of this line is deduced): glBindTexture(0x0DE1, oldTexture);
-
191 -
192 if (pex != 0)
never evaluated: pex != 0
0
193 pex->transferMode(BrushDrawingMode);
never executed: pex->transferMode(BrushDrawingMode);
0
194 -
195 glDisable(GL_STENCIL_TEST);
never executed (the execution status of this line is deduced): glDisable(0x0B90);
-
196 glDisable(GL_DEPTH_TEST);
never executed (the execution status of this line is deduced): glDisable(0x0B71);
-
197 glDisable(GL_SCISSOR_TEST);
never executed (the execution status of this line is deduced): glDisable(0x0C11);
-
198 glDisable(GL_BLEND);
never executed (the execution status of this line is deduced): glDisable(0x0BE2);
-
199 -
200 glViewport(0, 0, oldWidth, oldHeight);
never executed (the execution status of this line is deduced): glViewport(0, 0, oldWidth, oldHeight);
-
201 -
202 QGLShaderProgram *blitProgram = 0;
never executed (the execution status of this line is deduced): QGLShaderProgram *blitProgram = 0;
-
203 if (pex == 0) {
never evaluated: pex == 0
0
204 if (m_blitProgram == 0) {
never evaluated: m_blitProgram == 0
0
205 m_blitProgram = new QGLShaderProgram(ctx);
never executed (the execution status of this line is deduced): m_blitProgram = new QGLShaderProgram(ctx);
-
206 -
207 { -
208 QString source;
never executed (the execution status of this line is deduced): QString source;
-
209 source.append(QLatin1String(qglslMainWithTexCoordsVertexShader));
never executed (the execution status of this line is deduced): source.append(QLatin1String(qglslMainWithTexCoordsVertexShader));
-
210 source.append(QLatin1String(qglslUntransformedPositionVertexShader));
never executed (the execution status of this line is deduced): source.append(QLatin1String(qglslUntransformedPositionVertexShader));
-
211 -
212 QGLShader *vertexShader = new QGLShader(QGLShader::Vertex, m_blitProgram);
never executed (the execution status of this line is deduced): QGLShader *vertexShader = new QGLShader(QGLShader::Vertex, m_blitProgram);
-
213 vertexShader->compileSourceCode(source);
never executed (the execution status of this line is deduced): vertexShader->compileSourceCode(source);
-
214 -
215 m_blitProgram->addShader(vertexShader);
never executed (the execution status of this line is deduced): m_blitProgram->addShader(vertexShader);
-
216 } -
217 -
218 { -
219 QString source;
never executed (the execution status of this line is deduced): QString source;
-
220 source.append(QLatin1String(qglslMainFragmentShader));
never executed (the execution status of this line is deduced): source.append(QLatin1String(qglslMainFragmentShader));
-
221 source.append(QLatin1String(qglslImageSrcFragmentShader));
never executed (the execution status of this line is deduced): source.append(QLatin1String(qglslImageSrcFragmentShader));
-
222 -
223 QGLShader *fragmentShader = new QGLShader(QGLShader::Fragment, m_blitProgram);
never executed (the execution status of this line is deduced): QGLShader *fragmentShader = new QGLShader(QGLShader::Fragment, m_blitProgram);
-
224 fragmentShader->compileSourceCode(source);
never executed (the execution status of this line is deduced): fragmentShader->compileSourceCode(source);
-
225 -
226 m_blitProgram->addShader(fragmentShader);
never executed (the execution status of this line is deduced): m_blitProgram->addShader(fragmentShader);
-
227 } -
228 -
229 m_blitProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
never executed (the execution status of this line is deduced): m_blitProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
-
230 m_blitProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
never executed (the execution status of this line is deduced): m_blitProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
-
231 -
232 m_blitProgram->link();
never executed (the execution status of this line is deduced): m_blitProgram->link();
-
233 }
never executed: }
0
234 -
235 glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_vertexCoordinateArray);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, 0x1406, 0x0, 0, m_vertexCoordinateArray);
-
236 glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_textureCoordinateArray);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, 0x1406, 0x0, 0, m_textureCoordinateArray);
-
237 -
238 m_blitProgram->bind();
never executed (the execution status of this line is deduced): m_blitProgram->bind();
-
239 m_blitProgram->enableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
never executed (the execution status of this line is deduced): m_blitProgram->enableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
-
240 m_blitProgram->enableAttributeArray(int(QT_TEXTURE_COORDS_ATTR));
never executed (the execution status of this line is deduced): m_blitProgram->enableAttributeArray(int(QT_TEXTURE_COORDS_ATTR));
-
241 m_blitProgram->disableAttributeArray(int(QT_OPACITY_ATTR));
never executed (the execution status of this line is deduced): m_blitProgram->disableAttributeArray(int(QT_OPACITY_ATTR));
-
242 -
243 blitProgram = m_blitProgram;
never executed (the execution status of this line is deduced): blitProgram = m_blitProgram;
-
244 -
245 } else {
never executed: }
0
246 pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, m_vertexCoordinateArray);
never executed (the execution status of this line is deduced): pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, m_vertexCoordinateArray);
-
247 pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, m_textureCoordinateArray);
never executed (the execution status of this line is deduced): pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, m_textureCoordinateArray);
-
248 -
249 pex->shaderManager->useBlitProgram();
never executed (the execution status of this line is deduced): pex->shaderManager->useBlitProgram();
-
250 blitProgram = pex->shaderManager->blitProgram();
never executed (the execution status of this line is deduced): blitProgram = pex->shaderManager->blitProgram();
-
251 }
never executed: }
0
252 -
253 blitProgram->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT);
never executed (the execution status of this line is deduced): blitProgram->setUniformValue("imageTexture", GLuint(0));
-
254 -
255 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
never executed (the execution status of this line is deduced): glDrawArrays(0x0006, 0, 4);
-
256 -
257 glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture);
never executed (the execution status of this line is deduced): glBindTexture(0x0DE1, m_textureResource->m_texture);
-
258 -
259 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight);
never executed (the execution status of this line is deduced): glCopyTexSubImage2D(0x0DE1, 0, 0, 0, 0, 0, oldWidth, oldHeight);
-
260 -
261 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer(0x8D40, 0x8CE0,
-
262 GL_RENDERBUFFER, 0);
never executed (the execution status of this line is deduced): 0x8D41, 0);
-
263 glDeleteTextures(1, &tmp_texture);
never executed (the execution status of this line is deduced): glDeleteTextures(1, &tmp_texture);
-
264 glDeleteTextures(1, &oldTexture);
never executed (the execution status of this line is deduced): glDeleteTextures(1, &oldTexture);
-
265 -
266 glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_ptr->current_fbo);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer(0x8D40, ctx->d_ptr->current_fbo);
-
267 -
268 if (pex != 0) {
never evaluated: pex != 0
0
269 glViewport(0, 0, pex->width, pex->height);
never executed (the execution status of this line is deduced): glViewport(0, 0, pex->width, pex->height);
-
270 pex->updateClipScissorTest();
never executed (the execution status of this line is deduced): pex->updateClipScissorTest();
-
271 }
never executed: }
0
272}
never executed: }
0
273 -
274void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) -
275{ -
276 QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
never executed (the execution status of this line is deduced): QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
-
277 if (ctx == 0) {
never evaluated: ctx == 0
0
278 qWarning("QGLTextureGlyphCache::fillTexture: Called with no context");
never executed (the execution status of this line is deduced): QMessageLogger("gl2paintengineex/qtextureglyphcache_gl.cpp", 278, __PRETTY_FUNCTION__).warning("QGLTextureGlyphCache::fillTexture: Called with no context");
-
279 return;
never executed: return;
0
280 } -
281 -
282 if (!QGLFramebufferObject::hasOpenGLFramebufferObjects() || ctx->d_ptr->workaround_brokenFBOReadBack) {
never evaluated: !QGLFramebufferObject::hasOpenGLFramebufferObjects()
never evaluated: ctx->d_ptr->workaround_brokenFBOReadBack
0
283 QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition);
never executed (the execution status of this line is deduced): QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition);
-
284 -
285 glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture);
never executed (the execution status of this line is deduced): glBindTexture(0x0DE1, m_textureResource->m_texture);
-
286 const QImage &texture = image();
never executed (the execution status of this line is deduced): const QImage &texture = image();
-
287 const uchar *bits = texture.constBits();
never executed (the execution status of this line is deduced): const uchar *bits = texture.constBits();
-
288 bits += c.y * texture.bytesPerLine() + c.x;
never executed (the execution status of this line is deduced): bits += c.y * texture.bytesPerLine() + c.x;
-
289 for (int i=0; i<c.h; ++i) {
never evaluated: i<c.h
0
290 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, c.w, 1, GL_ALPHA, GL_UNSIGNED_BYTE, bits);
never executed (the execution status of this line is deduced): glTexSubImage2D(0x0DE1, 0, c.x, c.y + i, c.w, 1, 0x1906, 0x1401, bits);
-
291 bits += texture.bytesPerLine();
never executed (the execution status of this line is deduced): bits += texture.bytesPerLine();
-
292 }
never executed: }
0
293 return;
never executed: return;
0
294 } -
295 -
296 QImage mask = textureMapForGlyph(glyph, subPixelPosition);
never executed (the execution status of this line is deduced): QImage mask = textureMapForGlyph(glyph, subPixelPosition);
-
297 const int maskWidth = mask.width();
never executed (the execution status of this line is deduced): const int maskWidth = mask.width();
-
298 const int maskHeight = mask.height();
never executed (the execution status of this line is deduced): const int maskHeight = mask.height();
-
299 -
300 if (mask.format() == QImage::Format_Mono) {
never evaluated: mask.format() == QImage::Format_Mono
0
301 mask = mask.convertToFormat(QImage::Format_Indexed8);
never executed (the execution status of this line is deduced): mask = mask.convertToFormat(QImage::Format_Indexed8);
-
302 for (int y = 0; y < maskHeight; ++y) {
never evaluated: y < maskHeight
0
303 uchar *src = (uchar *) mask.scanLine(y);
never executed (the execution status of this line is deduced): uchar *src = (uchar *) mask.scanLine(y);
-
304 for (int x = 0; x < maskWidth; ++x)
never evaluated: x < maskWidth
0
305 src[x] = -src[x]; // convert 0 and 1 into 0 and 255
never executed: src[x] = -src[x];
0
306 }
never executed: }
0
307 } else if (mask.format() == QImage::Format_RGB32) {
never executed: }
never evaluated: mask.format() == QImage::Format_RGB32
0
308 // Make the alpha component equal to the average of the RGB values. -
309 // This is needed when drawing sub-pixel antialiased text on translucent targets. -
310 for (int y = 0; y < maskHeight; ++y) {
never evaluated: y < maskHeight
0
311 quint32 *src = (quint32 *) mask.scanLine(y);
never executed (the execution status of this line is deduced): quint32 *src = (quint32 *) mask.scanLine(y);
-
312 for (int x = 0; x < maskWidth; ++x) {
never evaluated: x < maskWidth
0
313 uchar r = src[x] >> 16;
never executed (the execution status of this line is deduced): uchar r = src[x] >> 16;
-
314 uchar g = src[x] >> 8;
never executed (the execution status of this line is deduced): uchar g = src[x] >> 8;
-
315 uchar b = src[x];
never executed (the execution status of this line is deduced): uchar b = src[x];
-
316 quint32 avg = (quint32(r) + quint32(g) + quint32(b) + 1) / 3; // "+1" for rounding.
never executed (the execution status of this line is deduced): quint32 avg = (quint32(r) + quint32(g) + quint32(b) + 1) / 3;
-
317 src[x] = (src[x] & 0x00ffffff) | (avg << 24);
never executed (the execution status of this line is deduced): src[x] = (src[x] & 0x00ffffff) | (avg << 24);
-
318 }
never executed: }
0
319 }
never executed: }
0
320 }
never executed: }
0
321 -
322 glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture);
never executed (the execution status of this line is deduced): glBindTexture(0x0DE1, m_textureResource->m_texture);
-
323 if (mask.format() == QImage::Format_RGB32) {
never evaluated: mask.format() == QImage::Format_RGB32
0
324#if defined(QT_OPENGL_ES_2) -
325 // ###TODO Ensure extension is actually present on ES2 -
326 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA_EXT, GL_UNSIGNED_BYTE, mask.bits()); -
327#else -
328 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits());
never executed (the execution status of this line is deduced): glTexSubImage2D(0x0DE1, 0, c.x, c.y, maskWidth, maskHeight, 0x80E1, 0x1401, mask.bits());
-
329#endif -
330 } else {
never executed: }
0
331 // glTexSubImage2D() might cause some garbage to appear in the texture if the mask width is -
332 // not a multiple of four bytes. The bug appeared on a computer with 32-bit Windows Vista -
333 // and nVidia GeForce 8500GT. GL_UNPACK_ALIGNMENT is set to four bytes, 'mask' has a -
334 // multiple of four bytes per line, and most of the glyph shows up correctly in the -
335 // texture, which makes me think that this is a driver bug. -
336 // One workaround is to make sure the mask width is a multiple of four bytes, for instance -
337 // by converting it to a format with four bytes per pixel. Another is to copy one line at a -
338 // time. -
339 -
340 if (!ctx->d_ptr->workaround_brokenAlphaTexSubImage_init) {
never evaluated: !ctx->d_ptr->workaround_brokenAlphaTexSubImage_init
0
341 // don't know which driver versions exhibit this bug, so be conservative for now -
342 const QByteArray vendorString(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
never executed (the execution status of this line is deduced): const QByteArray vendorString(reinterpret_cast<const char*>(glGetString(0x1F00)));
-
343 ctx->d_ptr->workaround_brokenAlphaTexSubImage = vendorString.indexOf("NVIDIA") >= 0;
never executed (the execution status of this line is deduced): ctx->d_ptr->workaround_brokenAlphaTexSubImage = vendorString.indexOf("NVIDIA") >= 0;
-
344 ctx->d_ptr->workaround_brokenAlphaTexSubImage_init = true;
never executed (the execution status of this line is deduced): ctx->d_ptr->workaround_brokenAlphaTexSubImage_init = true;
-
345 }
never executed: }
0
346 -
347 if (ctx->d_ptr->workaround_brokenAlphaTexSubImage) {
never evaluated: ctx->d_ptr->workaround_brokenAlphaTexSubImage
0
348 for (int i = 0; i < maskHeight; ++i)
never evaluated: i < maskHeight
0
349 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, maskWidth, 1, GL_ALPHA, GL_UNSIGNED_BYTE, mask.scanLine(i));
never executed: glTexSubImage2D(0x0DE1, 0, c.x, c.y + i, maskWidth, 1, 0x1906, 0x1401, mask.scanLine(i));
0
350 } else {
never executed: }
0
351 glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_ALPHA, GL_UNSIGNED_BYTE, mask.bits());
never executed (the execution status of this line is deduced): glTexSubImage2D(0x0DE1, 0, c.x, c.y, maskWidth, maskHeight, 0x1906, 0x1401, mask.bits());
-
352 }
never executed: }
0
353 } -
354} -
355 -
356int QGLTextureGlyphCache::glyphPadding() const -
357{ -
358 return 1;
never executed: return 1;
0
359} -
360 -
361int QGLTextureGlyphCache::maxTextureWidth() const -
362{ -
363 QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
never executed (the execution status of this line is deduced): QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
-
364 if (ctx == 0)
never evaluated: ctx == 0
0
365 return QImageTextureGlyphCache::maxTextureWidth();
never executed: return QImageTextureGlyphCache::maxTextureWidth();
0
366 else -
367 return ctx->d_ptr->maxTextureSize();
never executed: return ctx->d_ptr->maxTextureSize();
0
368} -
369 -
370int QGLTextureGlyphCache::maxTextureHeight() const -
371{ -
372 QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
never executed (the execution status of this line is deduced): QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
-
373 if (ctx == 0)
never evaluated: ctx == 0
0
374 return QImageTextureGlyphCache::maxTextureHeight();
never executed: return QImageTextureGlyphCache::maxTextureHeight();
0
375 -
376 if (ctx->d_ptr->workaround_brokenTexSubImage)
never evaluated: ctx->d_ptr->workaround_brokenTexSubImage
0
377 return qMin(1024, ctx->d_ptr->maxTextureSize());
never executed: return qMin(1024, ctx->d_ptr->maxTextureSize());
0
378 else -
379 return ctx->d_ptr->maxTextureSize();
never executed: return ctx->d_ptr->maxTextureSize();
0
380} -
381 -
382void QGLTextureGlyphCache::clear() -
383{ -
384 m_textureResource->free();
never executed (the execution status of this line is deduced): m_textureResource->free();
-
385 m_textureResource = 0;
never executed (the execution status of this line is deduced): m_textureResource = 0;
-
386 -
387 m_w = 0;
never executed (the execution status of this line is deduced): m_w = 0;
-
388 m_h = 0;
never executed (the execution status of this line is deduced): m_h = 0;
-
389 m_cx = 0;
never executed (the execution status of this line is deduced): m_cx = 0;
-
390 m_cy = 0;
never executed (the execution status of this line is deduced): m_cy = 0;
-
391 m_currentRowHeight = 0;
never executed (the execution status of this line is deduced): m_currentRowHeight = 0;
-
392 coords.clear();
never executed (the execution status of this line is deduced): coords.clear();
-
393}
never executed: }
0
394 -
395QT_END_NAMESPACE -
396 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial