Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopengltextureglyphcache.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | QBasicAtomicInt qopengltextureglyphcache_serial_number = { 1 }; | - | ||||||||||||
6 | - | |||||||||||||
7 | QOpenGLTextureGlyphCache::QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) | - | ||||||||||||
8 | : QImageTextureGlyphCache(format, matrix) | - | ||||||||||||
9 | , m_textureResource(0) | - | ||||||||||||
10 | , pex(0) | - | ||||||||||||
11 | , m_blitProgram(0) | - | ||||||||||||
12 | , m_filterMode(Nearest) | - | ||||||||||||
13 | , m_serialNumber(qopengltextureglyphcache_serial_number.fetchAndAddRelaxed(1)) | - | ||||||||||||
14 | , m_buffer(QOpenGLBuffer::VertexBuffer) | - | ||||||||||||
15 | { | - | ||||||||||||
16 | - | |||||||||||||
17 | - | |||||||||||||
18 | - | |||||||||||||
19 | m_vertexCoordinateArray[0] = -1.0f; | - | ||||||||||||
20 | m_vertexCoordinateArray[1] = -1.0f; | - | ||||||||||||
21 | m_vertexCoordinateArray[2] = 1.0f; | - | ||||||||||||
22 | m_vertexCoordinateArray[3] = -1.0f; | - | ||||||||||||
23 | m_vertexCoordinateArray[4] = 1.0f; | - | ||||||||||||
24 | m_vertexCoordinateArray[5] = 1.0f; | - | ||||||||||||
25 | m_vertexCoordinateArray[6] = -1.0f; | - | ||||||||||||
26 | m_vertexCoordinateArray[7] = 1.0f; | - | ||||||||||||
27 | - | |||||||||||||
28 | m_textureCoordinateArray[0] = 0.0f; | - | ||||||||||||
29 | m_textureCoordinateArray[1] = 0.0f; | - | ||||||||||||
30 | m_textureCoordinateArray[2] = 1.0f; | - | ||||||||||||
31 | m_textureCoordinateArray[3] = 0.0f; | - | ||||||||||||
32 | m_textureCoordinateArray[4] = 1.0f; | - | ||||||||||||
33 | m_textureCoordinateArray[5] = 1.0f; | - | ||||||||||||
34 | m_textureCoordinateArray[6] = 0.0f; | - | ||||||||||||
35 | m_textureCoordinateArray[7] = 1.0f; | - | ||||||||||||
36 | } never executed: end of block | 0 | ||||||||||||
37 | - | |||||||||||||
38 | QOpenGLTextureGlyphCache::~QOpenGLTextureGlyphCache() | - | ||||||||||||
39 | { | - | ||||||||||||
40 | - | |||||||||||||
41 | - | |||||||||||||
42 | - | |||||||||||||
43 | clear(); | - | ||||||||||||
44 | } never executed: end of block | 0 | ||||||||||||
45 | - | |||||||||||||
46 | - | |||||||||||||
47 | static inline bool isCoreProfile() | - | ||||||||||||
48 | { | - | ||||||||||||
49 | return never executed: QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile;return QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile; never executed: return QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile; | 0 | ||||||||||||
50 | } | - | ||||||||||||
51 | - | |||||||||||||
52 | - | |||||||||||||
53 | void QOpenGLTextureGlyphCache::createTextureData(int width, int height) | - | ||||||||||||
54 | { | - | ||||||||||||
55 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - | ||||||||||||
56 | if (ctx == 0
| 0 | ||||||||||||
57 | QMessageLogger(__FILE__, 96, __PRETTY_FUNCTION__).warning("QOpenGLTextureGlyphCache::createTextureData: Called with no context"); | - | ||||||||||||
58 | return; never executed: return; | 0 | ||||||||||||
59 | } | - | ||||||||||||
60 | - | |||||||||||||
61 | - | |||||||||||||
62 | - | |||||||||||||
63 | - | |||||||||||||
64 | if (ctx->d_func()->workaround_brokenFBOReadBack
| 0 | ||||||||||||
65 | QImageTextureGlyphCache::createTextureData(width, height); never executed: QImageTextureGlyphCache::createTextureData(width, height); | 0 | ||||||||||||
66 | - | |||||||||||||
67 | - | |||||||||||||
68 | if (width < 16
| 0 | ||||||||||||
69 | width = 16; never executed: width = 16; | 0 | ||||||||||||
70 | if (height < 16
| 0 | ||||||||||||
71 | height = 16; never executed: height = 16; | 0 | ||||||||||||
72 | - | |||||||||||||
73 | if (m_textureResource
| 0 | ||||||||||||
74 | delete m_textureResource; | - | ||||||||||||
75 | m_textureResource = 0; | - | ||||||||||||
76 | } never executed: end of block | 0 | ||||||||||||
77 | - | |||||||||||||
78 | if (!m_textureResource
| 0 | ||||||||||||
79 | m_textureResource = new QOpenGLGlyphTexture(ctx); never executed: m_textureResource = new QOpenGLGlyphTexture(ctx); | 0 | ||||||||||||
80 | - | |||||||||||||
81 | QOpenGLFunctions *funcs = ctx->functions(); | - | ||||||||||||
82 | funcs->glGenTextures(1, &m_textureResource->m_texture); | - | ||||||||||||
83 | funcs->glBindTexture(0x0DE1, m_textureResource->m_texture); | - | ||||||||||||
84 | - | |||||||||||||
85 | m_textureResource->m_width = width; | - | ||||||||||||
86 | m_textureResource->m_height = height; | - | ||||||||||||
87 | - | |||||||||||||
88 | if (m_format == QFontEngine::Format_A32
| 0 | ||||||||||||
89 | QVarLengthArray<uchar> data(width * height * 4); | - | ||||||||||||
90 | for (int i = 0; i < data.size()
| 0 | ||||||||||||
91 | data[i] = 0; never executed: data[i] = 0; | 0 | ||||||||||||
92 | funcs->glTexImage2D(0x0DE1, 0, 0x1908, width, height, 0, 0x1908, 0x1401, &data[0]); | - | ||||||||||||
93 | } never executed: else {end of block | 0 | ||||||||||||
94 | QVarLengthArray<uchar> data(width * height); | - | ||||||||||||
95 | for (int i = 0; i < data.size()
| 0 | ||||||||||||
96 | data[i] = 0; never executed: data[i] = 0; | 0 | ||||||||||||
97 | - | |||||||||||||
98 | const GLint internalFormat = isCoreProfile()
| 0 | ||||||||||||
99 | const GLenum format = isCoreProfile()
| 0 | ||||||||||||
100 | - | |||||||||||||
101 | - | |||||||||||||
102 | - | |||||||||||||
103 | - | |||||||||||||
104 | funcs->glTexImage2D(0x0DE1, 0, internalFormat, width, height, 0, format, 0x1401, &data[0]); | - | ||||||||||||
105 | } never executed: end of block | 0 | ||||||||||||
106 | - | |||||||||||||
107 | funcs->glTexParameteri(0x0DE1, 0x2800, 0x2600); | - | ||||||||||||
108 | funcs->glTexParameteri(0x0DE1, 0x2801, 0x2600); | - | ||||||||||||
109 | funcs->glTexParameteri(0x0DE1, 0x2802, 0x812F); | - | ||||||||||||
110 | funcs->glTexParameteri(0x0DE1, 0x2803, 0x812F); | - | ||||||||||||
111 | m_filterMode = Nearest; | - | ||||||||||||
112 | - | |||||||||||||
113 | if (!m_buffer.isCreated()
| 0 | ||||||||||||
114 | m_buffer.create(); | - | ||||||||||||
115 | m_buffer.bind(); | - | ||||||||||||
116 | static GLfloat buf[sizeof(m_vertexCoordinateArray) + sizeof(m_textureCoordinateArray)]; | - | ||||||||||||
117 | memcpy(buf, m_vertexCoordinateArray, sizeof(m_vertexCoordinateArray)); | - | ||||||||||||
118 | memcpy(buf + (sizeof(m_vertexCoordinateArray) / sizeof(GLfloat)), | - | ||||||||||||
119 | m_textureCoordinateArray, | - | ||||||||||||
120 | sizeof(m_textureCoordinateArray)); | - | ||||||||||||
121 | m_buffer.allocate(buf, sizeof(buf)); | - | ||||||||||||
122 | m_buffer.release(); | - | ||||||||||||
123 | } never executed: end of block | 0 | ||||||||||||
124 | - | |||||||||||||
125 | if (!m_vao.isCreated()
| 0 | ||||||||||||
126 | m_vao.create(); never executed: m_vao.create(); | 0 | ||||||||||||
127 | } never executed: end of block | 0 | ||||||||||||
128 | - | |||||||||||||
129 | void QOpenGLTextureGlyphCache::setupVertexAttribs() | - | ||||||||||||
130 | { | - | ||||||||||||
131 | m_buffer.bind(); | - | ||||||||||||
132 | m_blitProgram->setAttributeBuffer(int(QT_VERTEX_COORDS_ATTR), 0x1406, 0, 2); | - | ||||||||||||
133 | m_blitProgram->setAttributeBuffer(int(QT_TEXTURE_COORDS_ATTR), 0x1406, sizeof(m_vertexCoordinateArray), 2); | - | ||||||||||||
134 | m_blitProgram->enableAttributeArray(int(QT_VERTEX_COORDS_ATTR)); | - | ||||||||||||
135 | m_blitProgram->enableAttributeArray(int(QT_TEXTURE_COORDS_ATTR)); | - | ||||||||||||
136 | m_buffer.release(); | - | ||||||||||||
137 | } never executed: end of block | 0 | ||||||||||||
138 | - | |||||||||||||
139 | void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) | - | ||||||||||||
140 | { | - | ||||||||||||
141 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||
142 | if (ctx == 0
| 0 | ||||||||||||
143 | QMessageLogger(__FILE__, 182, __PRETTY_FUNCTION__).warning("QOpenGLTextureGlyphCache::resizeTextureData: Called with no context"); | - | ||||||||||||
144 | return; never executed: return; | 0 | ||||||||||||
145 | } | - | ||||||||||||
146 | - | |||||||||||||
147 | QOpenGLFunctions *funcs = ctx->functions(); | - | ||||||||||||
148 | GLint oldFbo; | - | ||||||||||||
149 | funcs->glGetIntegerv(0x8CA6, &oldFbo); | - | ||||||||||||
150 | - | |||||||||||||
151 | int oldWidth = m_textureResource->m_width; | - | ||||||||||||
152 | int oldHeight = m_textureResource->m_height; | - | ||||||||||||
153 | - | |||||||||||||
154 | - | |||||||||||||
155 | if (width < 16
| 0 | ||||||||||||
156 | width = 16; never executed: width = 16; | 0 | ||||||||||||
157 | if (height < 16
| 0 | ||||||||||||
158 | height = 16; never executed: height = 16; | 0 | ||||||||||||
159 | - | |||||||||||||
160 | GLuint oldTexture = m_textureResource->m_texture; | - | ||||||||||||
161 | createTextureData(width, height); | - | ||||||||||||
162 | - | |||||||||||||
163 | if (ctx->d_func()->workaround_brokenFBOReadBack
| 0 | ||||||||||||
164 | QImageTextureGlyphCache::resizeTextureData(width, height); | - | ||||||||||||
165 | ((!(image().depth() == 8)) ? qt_assert("image().depth() == 8",__FILE__,204) : qt_noop()); | - | ||||||||||||
166 | funcs->glTexSubImage2D(0x0DE1, 0, 0, 0, width, oldHeight, 0x1906, 0x1401, image().constBits()); | - | ||||||||||||
167 | funcs->glDeleteTextures(1, &oldTexture); | - | ||||||||||||
168 | return; never executed: return; | 0 | ||||||||||||
169 | } | - | ||||||||||||
170 | - | |||||||||||||
171 | - | |||||||||||||
172 | - | |||||||||||||
173 | - | |||||||||||||
174 | funcs->glBindFramebuffer(0x8D40, m_textureResource->m_fbo); | - | ||||||||||||
175 | - | |||||||||||||
176 | GLuint tmp_texture; | - | ||||||||||||
177 | funcs->glGenTextures(1, &tmp_texture); | - | ||||||||||||
178 | funcs->glBindTexture(0x0DE1, tmp_texture); | - | ||||||||||||
179 | funcs->glTexImage2D(0x0DE1, 0, 0x1908, oldWidth, oldHeight, 0, | - | ||||||||||||
180 | 0x1908, 0x1401, __null); | - | ||||||||||||
181 | funcs->glTexParameteri(0x0DE1, 0x2801, 0x2600); | - | ||||||||||||
182 | funcs->glTexParameteri(0x0DE1, 0x2800, 0x2600); | - | ||||||||||||
183 | funcs->glTexParameteri(0x0DE1, 0x2802, 0x812F); | - | ||||||||||||
184 | funcs->glTexParameteri(0x0DE1, 0x2803, 0x812F); | - | ||||||||||||
185 | m_filterMode = Nearest; | - | ||||||||||||
186 | funcs->glBindTexture(0x0DE1, 0); | - | ||||||||||||
187 | funcs->glFramebufferTexture2D(0x8D40, 0x8CE0, | - | ||||||||||||
188 | 0x0DE1, tmp_texture, 0); | - | ||||||||||||
189 | - | |||||||||||||
190 | funcs->glActiveTexture(0x84C0 + GLuint(0)); | - | ||||||||||||
191 | funcs->glBindTexture(0x0DE1, oldTexture); | - | ||||||||||||
192 | - | |||||||||||||
193 | if (pex != 0
| 0 | ||||||||||||
194 | pex->transferMode(BrushDrawingMode); never executed: pex->transferMode(BrushDrawingMode); | 0 | ||||||||||||
195 | - | |||||||||||||
196 | funcs->glDisable(0x0B90); | - | ||||||||||||
197 | funcs->glDisable(0x0B71); | - | ||||||||||||
198 | funcs->glDisable(0x0C11); | - | ||||||||||||
199 | funcs->glDisable(0x0BE2); | - | ||||||||||||
200 | - | |||||||||||||
201 | funcs->glViewport(0, 0, oldWidth, oldHeight); | - | ||||||||||||
202 | - | |||||||||||||
203 | QOpenGLShaderProgram *blitProgram = 0; | - | ||||||||||||
204 | if (pex == 0
| 0 | ||||||||||||
205 | if (m_blitProgram == 0
| 0 | ||||||||||||
206 | m_blitProgram = new QOpenGLShaderProgram; | - | ||||||||||||
207 | const bool isCoreProfile = ctx->format().profile() == QSurfaceFormat::CoreProfile; | - | ||||||||||||
208 | - | |||||||||||||
209 | { | - | ||||||||||||
210 | QString source; | - | ||||||||||||
211 | source.append(QLatin1String(isCoreProfile ? qopenglslMainWithTexCoordsVertexShader_core : qopenglslMainWithTexCoordsVertexShader)); | - | ||||||||||||
212 | source.append(QLatin1String(isCoreProfile ? qopenglslUntransformedPositionVertexShader_core : qopenglslUntransformedPositionVertexShader)); | - | ||||||||||||
213 | - | |||||||||||||
214 | QOpenGLShader *vertexShader = new QOpenGLShader(QOpenGLShader::Vertex, m_blitProgram); | - | ||||||||||||
215 | vertexShader->compileSourceCode(source); | - | ||||||||||||
216 | - | |||||||||||||
217 | m_blitProgram->addShader(vertexShader); | - | ||||||||||||
218 | } | - | ||||||||||||
219 | - | |||||||||||||
220 | { | - | ||||||||||||
221 | QString source; | - | ||||||||||||
222 | source.append(QLatin1String(isCoreProfile ? qopenglslMainFragmentShader_core : qopenglslMainFragmentShader)); | - | ||||||||||||
223 | source.append(QLatin1String(isCoreProfile ? qopenglslImageSrcFragmentShader_core : qopenglslImageSrcFragmentShader)); | - | ||||||||||||
224 | - | |||||||||||||
225 | QOpenGLShader *fragmentShader = new QOpenGLShader(QOpenGLShader::Fragment, m_blitProgram); | - | ||||||||||||
226 | fragmentShader->compileSourceCode(source); | - | ||||||||||||
227 | - | |||||||||||||
228 | m_blitProgram->addShader(fragmentShader); | - | ||||||||||||
229 | } | - | ||||||||||||
230 | - | |||||||||||||
231 | m_blitProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); | - | ||||||||||||
232 | m_blitProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); | - | ||||||||||||
233 | - | |||||||||||||
234 | m_blitProgram->link(); | - | ||||||||||||
235 | - | |||||||||||||
236 | if (m_vao.isCreated()
| 0 | ||||||||||||
237 | m_vao.bind(); | - | ||||||||||||
238 | setupVertexAttribs(); | - | ||||||||||||
239 | } never executed: end of block | 0 | ||||||||||||
240 | } never executed: end of block | 0 | ||||||||||||
241 | - | |||||||||||||
242 | if (m_vao.isCreated()
| 0 | ||||||||||||
243 | m_vao.bind(); never executed: m_vao.bind(); | 0 | ||||||||||||
244 | else | - | ||||||||||||
245 | setupVertexAttribs(); never executed: setupVertexAttribs(); | 0 | ||||||||||||
246 | - | |||||||||||||
247 | m_blitProgram->bind(); | - | ||||||||||||
248 | blitProgram = m_blitProgram; | - | ||||||||||||
249 | - | |||||||||||||
250 | } never executed: else {end of block | 0 | ||||||||||||
251 | pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, m_vertexCoordinateArray); | - | ||||||||||||
252 | pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, m_textureCoordinateArray); | - | ||||||||||||
253 | - | |||||||||||||
254 | pex->shaderManager->useBlitProgram(); | - | ||||||||||||
255 | blitProgram = pex->shaderManager->blitProgram(); | - | ||||||||||||
256 | } never executed: end of block | 0 | ||||||||||||
257 | - | |||||||||||||
258 | blitProgram->setUniformValue("imageTexture", GLuint(0)); | - | ||||||||||||
259 | - | |||||||||||||
260 | funcs->glDrawArrays(0x0006, 0, 4); | - | ||||||||||||
261 | - | |||||||||||||
262 | funcs->glBindTexture(0x0DE1, m_textureResource->m_texture); | - | ||||||||||||
263 | - | |||||||||||||
264 | funcs->glCopyTexSubImage2D(0x0DE1, 0, 0, 0, 0, 0, oldWidth, oldHeight); | - | ||||||||||||
265 | - | |||||||||||||
266 | funcs->glFramebufferRenderbuffer(0x8D40, 0x8CE0, | - | ||||||||||||
267 | 0x8D41, 0); | - | ||||||||||||
268 | funcs->glDeleteTextures(1, &tmp_texture); | - | ||||||||||||
269 | funcs->glDeleteTextures(1, &oldTexture); | - | ||||||||||||
270 | - | |||||||||||||
271 | funcs->glBindFramebuffer(0x8D40, (GLuint)oldFbo); | - | ||||||||||||
272 | - | |||||||||||||
273 | if (pex != 0
| 0 | ||||||||||||
274 | funcs->glViewport(0, 0, pex->width, pex->height); | - | ||||||||||||
275 | pex->updateClipScissorTest(); | - | ||||||||||||
276 | } never executed: else {end of block | 0 | ||||||||||||
277 | if (m_vao.isCreated()
| 0 | ||||||||||||
278 | m_vao.release(); | - | ||||||||||||
279 | } never executed: else {end of block | 0 | ||||||||||||
280 | m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR)); | - | ||||||||||||
281 | m_blitProgram->disableAttributeArray(int(QT_TEXTURE_COORDS_ATTR)); | - | ||||||||||||
282 | } never executed: end of block | 0 | ||||||||||||
283 | } | - | ||||||||||||
284 | } | - | ||||||||||||
285 | - | |||||||||||||
286 | void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) | - | ||||||||||||
287 | { | - | ||||||||||||
288 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||
289 | if (ctx == 0
| 0 | ||||||||||||
290 | QMessageLogger(__FILE__, 329, __PRETTY_FUNCTION__).warning("QOpenGLTextureGlyphCache::fillTexture: Called with no context"); | - | ||||||||||||
291 | return; never executed: return; | 0 | ||||||||||||
292 | } | - | ||||||||||||
293 | - | |||||||||||||
294 | QOpenGLFunctions *funcs = ctx->functions(); | - | ||||||||||||
295 | if (ctx->d_func()->workaround_brokenFBOReadBack
| 0 | ||||||||||||
296 | QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition); | - | ||||||||||||
297 | - | |||||||||||||
298 | funcs->glBindTexture(0x0DE1, m_textureResource->m_texture); | - | ||||||||||||
299 | const QImage &texture = image(); | - | ||||||||||||
300 | const uchar *bits = texture.constBits(); | - | ||||||||||||
301 | bits += c.y * texture.bytesPerLine() + c.x; | - | ||||||||||||
302 | for (int i=0; i<c.h
| 0 | ||||||||||||
303 | funcs->glTexSubImage2D(0x0DE1, 0, c.x, c.y + i, c.w, 1, 0x1906, 0x1401, bits); | - | ||||||||||||
304 | bits += texture.bytesPerLine(); | - | ||||||||||||
305 | } never executed: end of block | 0 | ||||||||||||
306 | return; never executed: return; | 0 | ||||||||||||
307 | } | - | ||||||||||||
308 | - | |||||||||||||
309 | QImage mask = textureMapForGlyph(glyph, subPixelPosition); | - | ||||||||||||
310 | const int maskWidth = mask.width(); | - | ||||||||||||
311 | const int maskHeight = mask.height(); | - | ||||||||||||
312 | - | |||||||||||||
313 | if (mask.format() == QImage::Format_Mono
| 0 | ||||||||||||
314 | mask = mask.convertToFormat(QImage::Format_Indexed8); | - | ||||||||||||
315 | for (int y = 0; y < maskHeight
| 0 | ||||||||||||
316 | uchar *src = (uchar *) mask.scanLine(y); | - | ||||||||||||
317 | for (int x = 0; x < maskWidth
| 0 | ||||||||||||
318 | src[x] = -src[x]; never executed: src[x] = -src[x]; | 0 | ||||||||||||
319 | } never executed: end of block | 0 | ||||||||||||
320 | } never executed: else if (mask.depth() == 32end of block
| 0 | ||||||||||||
321 | if (mask.format() == QImage::Format_RGB32
| 0 | ||||||||||||
322 | - | |||||||||||||
323 | - | |||||||||||||
324 | - | |||||||||||||
325 | - | |||||||||||||
326 | - | |||||||||||||
327 | || (mask.format() == QImage::Format_ARGB32_Premultiplied
| 0 | ||||||||||||
328 | && ctx->isOpenGLES()
| 0 | ||||||||||||
329 | - | |||||||||||||
330 | ) { | - | ||||||||||||
331 | for (int y = 0; y < maskHeight
| 0 | ||||||||||||
332 | QRgb *src = (QRgb *) mask.scanLine(y); | - | ||||||||||||
333 | for (int x = 0; x < maskWidth
| 0 | ||||||||||||
334 | int r = qRed(src[x]); | - | ||||||||||||
335 | int g = qGreen(src[x]); | - | ||||||||||||
336 | int b = qBlue(src[x]); | - | ||||||||||||
337 | int avg; | - | ||||||||||||
338 | if (mask.format() == QImage::Format_RGB32
| 0 | ||||||||||||
339 | avg = (r + g + b + 1) / 3; never executed: avg = (r + g + b + 1) / 3; | 0 | ||||||||||||
340 | else | - | ||||||||||||
341 | avg = qAlpha(src[x]); never executed: avg = qAlpha(src[x]); | 0 | ||||||||||||
342 | - | |||||||||||||
343 | src[x] = qRgba(r, g, b, avg); | - | ||||||||||||
344 | - | |||||||||||||
345 | - | |||||||||||||
346 | if (ctx->isOpenGLES()
| 0 | ||||||||||||
347 | - | |||||||||||||
348 | src[x] = ARGB2RGBA(src[x]); never executed: src[x] = ARGB2RGBA(src[x]); | 0 | ||||||||||||
349 | } never executed: end of block | 0 | ||||||||||||
350 | } never executed: end of block | 0 | ||||||||||||
351 | } never executed: end of block | 0 | ||||||||||||
352 | } never executed: end of block | 0 | ||||||||||||
353 | - | |||||||||||||
354 | funcs->glBindTexture(0x0DE1, m_textureResource->m_texture); | - | ||||||||||||
355 | if (mask.depth() == 32
| 0 | ||||||||||||
356 | - | |||||||||||||
357 | - | |||||||||||||
358 | - | |||||||||||||
359 | GLenum fmt = ctx->isOpenGLES()
| 0 | ||||||||||||
360 | - | |||||||||||||
361 | - | |||||||||||||
362 | - | |||||||||||||
363 | - | |||||||||||||
364 | - | |||||||||||||
365 | funcs->glTexSubImage2D(0x0DE1, 0, c.x, c.y, maskWidth, maskHeight, fmt, 0x1401, mask.bits()); | - | ||||||||||||
366 | } never executed: else {end of block | 0 | ||||||||||||
367 | - | |||||||||||||
368 | - | |||||||||||||
369 | - | |||||||||||||
370 | const GLenum format = isCoreProfile()
| 0 | ||||||||||||
371 | - | |||||||||||||
372 | - | |||||||||||||
373 | - | |||||||||||||
374 | funcs->glTexSubImage2D(0x0DE1, 0, c.x, c.y, maskWidth, maskHeight, format, 0x1401, mask.bits()); | - | ||||||||||||
375 | } never executed: end of block | 0 | ||||||||||||
376 | } | - | ||||||||||||
377 | - | |||||||||||||
378 | int QOpenGLTextureGlyphCache::glyphPadding() const | - | ||||||||||||
379 | { | - | ||||||||||||
380 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
381 | } | - | ||||||||||||
382 | - | |||||||||||||
383 | int QOpenGLTextureGlyphCache::maxTextureWidth() const | - | ||||||||||||
384 | { | - | ||||||||||||
385 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - | ||||||||||||
386 | if (ctx == 0
| 0 | ||||||||||||
387 | return never executed: QImageTextureGlyphCache::maxTextureWidth();return QImageTextureGlyphCache::maxTextureWidth(); never executed: return QImageTextureGlyphCache::maxTextureWidth(); | 0 | ||||||||||||
388 | else | - | ||||||||||||
389 | return never executed: ctx->d_func()->maxTextureSize();return ctx->d_func()->maxTextureSize(); never executed: return ctx->d_func()->maxTextureSize(); | 0 | ||||||||||||
390 | } | - | ||||||||||||
391 | - | |||||||||||||
392 | int QOpenGLTextureGlyphCache::maxTextureHeight() const | - | ||||||||||||
393 | { | - | ||||||||||||
394 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - | ||||||||||||
395 | if (ctx == 0
| 0 | ||||||||||||
396 | return never executed: QImageTextureGlyphCache::maxTextureHeight();return QImageTextureGlyphCache::maxTextureHeight(); never executed: return QImageTextureGlyphCache::maxTextureHeight(); | 0 | ||||||||||||
397 | - | |||||||||||||
398 | if (ctx->d_func()->workaround_brokenTexSubImage
| 0 | ||||||||||||
399 | return never executed: qMin(1024, ctx->d_func()->maxTextureSize());return qMin(1024, ctx->d_func()->maxTextureSize()); never executed: return qMin(1024, ctx->d_func()->maxTextureSize()); | 0 | ||||||||||||
400 | else | - | ||||||||||||
401 | return never executed: ctx->d_func()->maxTextureSize();return ctx->d_func()->maxTextureSize(); never executed: return ctx->d_func()->maxTextureSize(); | 0 | ||||||||||||
402 | } | - | ||||||||||||
403 | - | |||||||||||||
404 | void QOpenGLTextureGlyphCache::clear() | - | ||||||||||||
405 | { | - | ||||||||||||
406 | if (m_textureResource
| 0 | ||||||||||||
407 | m_textureResource->free(); never executed: m_textureResource->free(); | 0 | ||||||||||||
408 | m_textureResource = 0; | - | ||||||||||||
409 | - | |||||||||||||
410 | delete m_blitProgram; | - | ||||||||||||
411 | m_blitProgram = 0; | - | ||||||||||||
412 | - | |||||||||||||
413 | m_w = 0; | - | ||||||||||||
414 | m_h = 0; | - | ||||||||||||
415 | m_cx = 0; | - | ||||||||||||
416 | m_cy = 0; | - | ||||||||||||
417 | m_currentRowHeight = 0; | - | ||||||||||||
418 | coords.clear(); | - | ||||||||||||
419 | } never executed: end of block | 0 | ||||||||||||
420 | - | |||||||||||||
421 | - | |||||||||||||
Switch to Source code | Preprocessed file |