| 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 | } | - |
| 37 | | - |
| 38 | QOpenGLTextureGlyphCache::~QOpenGLTextureGlyphCache() | - |
| 39 | { | - |
| 40 | | - |
| 41 | | - |
| 42 | | - |
| 43 | clear(); | - |
| 44 | } | - |
| 45 | | - |
| 46 | | - |
| 47 | static inline bool isCoreProfile() | - |
| 48 | { | - |
| 49 | return QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile; | - |
| 50 | } | - |
| 51 | | - |
| 52 | | - |
| 53 | void QOpenGLTextureGlyphCache::createTextureData(int width, int height) | - |
| 54 | { | - |
| 55 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - |
| 56 | if (ctx == 0) { | - |
| 57 | QMessageLogger(__FILE__, 96102, __PRETTY_FUNCTION__).warning("QOpenGLTextureGlyphCache::createTextureData: Called with no context"); | - |
| 58 | return; | - |
| 59 | } | - |
| 60 | | - |
| 61 | | - |
| 62 | | - |
| 63 | | - |
| 64 | if (ctx->d_func()->workaround_brokenFBOReadBack && image().isNull()) | - |
| 65 | QImageTextureGlyphCache::createTextureData(width, height); | - |
| 66 | | - |
| 67 | | - |
| 68 | if (width < 16) | - |
| 69 | width = 16; | - |
| 70 | if (height < 16) | - |
| 71 | height = 16; | - |
| 72 | | - |
| 73 | if (m_textureResource && !m_textureResource->m_texture) { | - |
| 74 | delete m_textureResource; | - |
| 75 | m_textureResource = 0; | - |
| 76 | } | - |
| 77 | | - |
| 78 | if (!m_textureResource) | - |
| 79 | m_textureResource = new QOpenGLGlyphTexture(ctx); | - |
| 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 || m_format == QFontEngine::Format_ARGB) { | - |
| 89 | QVarLengthArray<uchar> data(width * height * 4); | - |
| 90 | for (int i = 0; i < data.size(); ++i) | - |
| 91 | data[i] = 0; | - |
| 92 | funcs->glTexImage2D(0x0DE1, 0, 0x1908, width, height, 0, 0x1908, 0x1401, &data[0]); | - |
| 93 | } else { | - |
| 94 | QVarLengthArray<uchar> data(width * height); | - |
| 95 | for (int i = 0; i < data.size(); ++i) | - |
| 96 | data[i] = 0; | - |
| 97 | | - |
| 98 | const GLint internalFormat = isCoreProfile() ? 0x8229 : 0x1906; | - |
| 99 | const GLenum format = isCoreProfile() ? 0x1903 : 0x1906; | - |
| 100 | | - |
| 101 | | - |
| 102 | | - |
| 103 | | - |
| 104 | funcs->glTexImage2D(0x0DE1, 0, internalFormat, width, height, 0, format, 0x1401, &data[0]); | - |
| 105 | } | - |
| 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()) { | - |
| 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 | } | - |
| 124 | | - |
| 125 | if (!m_vao.isCreated()) | - |
| 126 | m_vao.create(); | - |
| 127 | } | - |
| 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 | } | - |
| 138 | | - |
| 139 | static void load_glyph_image_to_texture(QOpenGLContext *ctx, | - |
| 140 | QImage &img, | - |
| 141 | GLuint texture, | - |
| 142 | int tx, int ty) | - |
| 143 | { | - |
| 144 | QOpenGLFunctions *funcs = ctx->functions(); | - |
| 145 | | - |
| 146 | const int imgWidth = img.width(); | - |
| 147 | const int imgHeight = img.height(); | - |
| 148 | | - |
| 149 | if (img.format() == QImage::Format_Mono| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 150 | img = img.convertToFormat(QImage::Format_Grayscale8); | - |
| 151 | } never executed: end of block else if (img.depth() == 32| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 152 | if (img.format() == QImage::Format_RGB32| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 153 | | - |
| 154 | | - |
| 155 | | - |
| 156 | | - |
| 157 | | - |
| 158 | || (img.format() == QImage::Format_ARGB32_Premultiplied| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 159 | && ctx->isOpenGLES()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 160 | | - |
| 161 | ) { | - |
| 162 | for (int y = 0; y < imgHeight| TRUE | never evaluated | | FALSE | never evaluated |
; ++y) { | 0 |
| 163 | QRgb *src = (QRgb *) img.scanLine(y); | - |
| 164 | for (int x = 0; x < imgWidth| TRUE | never evaluated | | FALSE | never evaluated |
; ++x) { | 0 |
| 165 | int r = qRed(src[x]); | - |
| 166 | int g = qGreen(src[x]); | - |
| 167 | int b = qBlue(src[x]); | - |
| 168 | int avg; | - |
| 169 | if (img.format() == QImage::Format_RGB32| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 170 | avg = (r + g + b + 1) / 3; never executed: avg = (r + g + b + 1) / 3; | 0 |
| 171 | else | - |
| 172 | avg = qAlpha(src[x]); never executed: avg = qAlpha(src[x]); | 0 |
| 173 | | - |
| 174 | src[x] = qRgba(r, g, b, avg); | - |
| 175 | | - |
| 176 | | - |
| 177 | if (ctx->isOpenGLES()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 178 | | - |
| 179 | src[x] = ARGB2RGBA(src[x]); never executed: src[x] = ARGB2RGBA(src[x]); | 0 |
| 180 | } never executed: end of block | 0 |
| 181 | } never executed: end of block | 0 |
| 182 | } never executed: end of block | 0 |
| 183 | } never executed: end of block | 0 |
| 184 | | - |
| 185 | funcs->glBindTexture(0x0DE1, texture); | - |
| 186 | if (img.depth() == 32| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 187 | | - |
| 188 | | - |
| 189 | | - |
| 190 | GLenum fmt = ctx->isOpenGLES()| TRUE | never evaluated | | FALSE | never evaluated |
? 0x1908 : 0x80E1; | 0 |
| 191 | | - |
| 192 | | - |
| 193 | | - |
| 194 | | - |
| 195 | | - |
| 196 | funcs->glTexSubImage2D(0x0DE1, 0, tx, ty, imgWidth, imgHeight, fmt, 0x1401, img.constBits()); | - |
| 197 | } never executed: end of block else { | 0 |
| 198 | | - |
| 199 | | - |
| 200 | | - |
| 201 | const GLenum format = isCoreProfile()| TRUE | never evaluated | | FALSE | never evaluated |
? 0x1903 : 0x1906; | 0 |
| 202 | | - |
| 203 | | - |
| 204 | | - |
| 205 | funcs->glTexSubImage2D(0x0DE1, 0, tx, ty, imgWidth, imgHeight, format, 0x1401, img.constBits()); | - |
| 206 | } never executed: end of block | 0 |
| 207 | } | - |
| 208 | | - |
| 209 | static void load_glyph_image_region_to_texture(QOpenGLContext *ctx, | - |
| 210 | const QImage &srcImg, | - |
| 211 | int x, int y, | - |
| 212 | int w, int h, | - |
| 213 | GLuint texture, | - |
| 214 | int tx, int ty) | - |
| 215 | { | - |
| 216 | ((!(x + w <= srcImg.width() && y + h <= srcImg.height())) ? qt_assert("x + w <= srcImg.width() && y + h <= srcImg.height()",__FILE__,261) : qt_noop()); | - |
| 217 | | - |
| 218 | QImage img; | - |
| 219 | if (x != 0| TRUE | never evaluated | | FALSE | never evaluated |
|| y != 0| TRUE | never evaluated | | FALSE | never evaluated |
|| w != srcImg.width()| TRUE | never evaluated | | FALSE | never evaluated |
|| h != srcImg.height()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 220 | img = srcImg.copy(x, y, w, h); never executed: img = srcImg.copy(x, y, w, h); | 0 |
| 221 | else | - |
| 222 | img = srcImg; never executed: img = srcImg; | 0 |
| 223 | | - |
| 224 | load_glyph_image_to_texture(ctx, img, texture, tx, ty); | - |
| 225 | } never executed: end of block | 0 |
| 226 | | - |
| 227 | void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) | - |
| 228 | { | - |
| 229 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - |
| 230 | if (ctx == 0| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 231 | QMessageLogger(__FILE__, 182276, __PRETTY_FUNCTION__).warning("QOpenGLTextureGlyphCache::resizeTextureData: Called with no context"); | - |
| 232 | return; never executed: return; | 0 |
| 233 | } | - |
| 234 | | - |
| 235 | QOpenGLFunctions *funcs = ctx->functions(); | - |
| 236 | GLint oldFbo; | - |
| 237 | funcs->glGetIntegerv(0x8CA6, &oldFbo); | - |
| 238 | | - |
| 239 | int oldWidth = m_textureResource->m_width; | - |
| 240 | int oldHeight = m_textureResource->m_height; | - |
| 241 | | - |
| 242 | | - |
| 243 | if (width < 16| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 244 | width = 16; never executed: width = 16; | 0 |
| 245 | if (height < 16| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 246 | height = 16; never executed: height = 16; | 0 |
| 247 | | - |
| 248 | GLuint oldTexture = m_textureResource->m_texture; | - |
| 249 | createTextureData(width, height); | - |
| 250 | | - |
| 251 | if (ctx->d_func()->workaround_brokenFBOReadBack| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 252 | QImageTextureGlyphCache::resizeTextureData(width, height); | - |
| 253 | ((!(image().depth() == 8)) ? qt_assert("image().depth() == 8",__FILE__,204) : qt_noop()); | - |
| funcs->glTexSubImage2Dload_glyph_image_region_to_texture(0x0DE1ctx, image(), 0, 0, 0qMin(oldWidth, width,), qMin(oldHeight, 0x1906, 0x1401, image().constBits()); | |
| funcsheight), | |
| 254 | m_textureResource->glDeleteTextures(1m_texture, &oldTexture0, 0); | - |
| 255 | return; never executed: return; | 0 |
| 256 | } | - |
| 257 | | - |
| 258 | | - |
| 259 | | - |
| 260 | | - |
| 261 | funcs->glBindFramebuffer(0x8D40, m_textureResource->m_fbo); | - |
| 262 | | - |
| 263 | GLuint tmp_texture; | - |
| 264 | funcs->glGenTextures(1, &tmp_texture); | - |
| 265 | funcs->glBindTexture(0x0DE1, tmp_texture); | - |
| 266 | funcs->glTexImage2D(0x0DE1, 0, 0x1908, oldWidth, oldHeight, 0, | - |
| 267 | 0x1908, 0x1401, __null); | - |
| 268 | funcs->glTexParameteri(0x0DE1, 0x2801, 0x2600); | - |
| 269 | funcs->glTexParameteri(0x0DE1, 0x2800, 0x2600); | - |
| 270 | funcs->glTexParameteri(0x0DE1, 0x2802, 0x812F); | - |
| 271 | funcs->glTexParameteri(0x0DE1, 0x2803, 0x812F); | - |
| 272 | m_filterMode = Nearest; | - |
| 273 | funcs->glBindTexture(0x0DE1, 0); | - |
| 274 | funcs->glFramebufferTexture2D(0x8D40, 0x8CE0, | - |
| 275 | 0x0DE1, tmp_texture, 0); | - |
| 276 | | - |
| 277 | funcs->glActiveTexture(0x84C0 + GLuint(0)); | - |
| 278 | funcs->glBindTexture(0x0DE1, oldTexture); | - |
| 279 | | - |
| 280 | if (pex != 0| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 281 | pex->transferMode(BrushDrawingMode); never executed: pex->transferMode(BrushDrawingMode); | 0 |
| 282 | | - |
| 283 | funcs->glDisable(0x0B90); | - |
| 284 | funcs->glDisable(0x0B71); | - |
| 285 | funcs->glDisable(0x0C11); | - |
| 286 | funcs->glDisable(0x0BE2); | - |
| 287 | | - |
| 288 | funcs->glViewport(0, 0, oldWidth, oldHeight); | - |
| 289 | | - |
| 290 | QOpenGLShaderProgram *blitProgram = 0; | - |
| 291 | if (pex == 0| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 292 | if (m_blitProgram == 0| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 293 | m_blitProgram = new QOpenGLShaderProgram; | - |
| 294 | const bool isCoreProfile = ctx->format().profile() == QSurfaceFormat::CoreProfile; | - |
| 295 | | - |
| 296 | { | - |
| 297 | QString source; | - |
| 298 | source.append(QLatin1String(isCoreProfile ? qopenglslMainWithTexCoordsVertexShader_core : qopenglslMainWithTexCoordsVertexShader)); | - |
| 299 | source.append(QLatin1String(isCoreProfile ? qopenglslUntransformedPositionVertexShader_core : qopenglslUntransformedPositionVertexShader)); | - |
| 300 | | - |
| 301 | QOpenGLShader *vertexShader = new QOpenGLShader(QOpenGLShader::Vertex, m_blitProgram); | - |
| 302 | vertexShader->compileSourceCode(source); | - |
| 303 | | - |
| 304 | m_blitProgram->addShader(vertexShader); | - |
| 305 | } | - |
| 306 | | - |
| 307 | { | - |
| 308 | QString source; | - |
| 309 | source.append(QLatin1String(isCoreProfile ? qopenglslMainFragmentShader_core : qopenglslMainFragmentShader)); | - |
| 310 | source.append(QLatin1String(isCoreProfile ? qopenglslImageSrcFragmentShader_core : qopenglslImageSrcFragmentShader)); | - |
| 311 | | - |
| 312 | QOpenGLShader *fragmentShader = new QOpenGLShader(QOpenGLShader::Fragment, m_blitProgram); | - |
| 313 | fragmentShader->compileSourceCode(source); | - |
| 314 | | - |
| 315 | m_blitProgram->addShader(fragmentShader); | - |
| 316 | } | - |
| 317 | | - |
| 318 | m_blitProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); | - |
| 319 | m_blitProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); | - |
| 320 | | - |
| 321 | m_blitProgram->link(); | - |
| 322 | | - |
| 323 | if (m_vao.isCreated()| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 324 | m_vao.bind(); | - |
| 325 | setupVertexAttribs(); | - |
| 326 | } never executed: end of block | 0 |
| 327 | } never executed: end of block | 0 |
| 328 | | - |
| 329 | if (m_vao.isCreated()| TRUE | never evaluated | | FALSE | never evaluated |
) | 0 |
| 330 | m_vao.bind(); never executed: m_vao.bind(); | 0 |
| 331 | else | - |
| 332 | setupVertexAttribs(); never executed: setupVertexAttribs(); | 0 |
| 333 | | - |
| 334 | m_blitProgram->bind(); | - |
| 335 | blitProgram = m_blitProgram; | - |
| 336 | | - |
| 337 | } never executed: end of block else { | 0 |
| 338 | pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, m_vertexCoordinateArray); | - |
| 339 | pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, m_textureCoordinateArray); | - |
| 340 | | - |
| 341 | pex->shaderManager->useBlitProgram(); | - |
| 342 | blitProgram = pex->shaderManager->blitProgram(); | - |
| 343 | } never executed: end of block | 0 |
| 344 | | - |
| 345 | blitProgram->setUniformValue("imageTexture", GLuint(0)); | - |
| 346 | | - |
| 347 | funcs->glDrawArrays(0x0006, 0, 4); | - |
| 348 | | - |
| 349 | funcs->glBindTexture(0x0DE1, m_textureResource->m_texture); | - |
| 350 | | - |
| 351 | funcs->glCopyTexSubImage2D(0x0DE1, 0, 0, 0, 0, 0, oldWidth, oldHeight); | - |
| 352 | | - |
| 353 | funcs->glFramebufferRenderbuffer(0x8D40, 0x8CE0, | - |
| 354 | 0x8D41, 0); | - |
| 355 | funcs->glDeleteTextures(1, &tmp_texture); | - |
| 356 | funcs->glDeleteTextures(1, &oldTexture); | - |
| 357 | | - |
| 358 | funcs->glBindFramebuffer(0x8D40, (GLuint)oldFbo); | - |
| 359 | | - |
| 360 | if (pex != 0| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 361 | funcs->glViewport(0, 0, pex->width, pex->height); | - |
| 362 | pex->updateClipScissorTest(); | - |
| 363 | } never executed: end of block else { | 0 |
| 364 | if (m_vao.isCreated()| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 365 | m_vao.release(); | - |
| 366 | } never executed: end of block else { | 0 |
| 367 | m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR)); | - |
| 368 | m_blitProgram->disableAttributeArray(int(QT_TEXTURE_COORDS_ATTR)); | - |
| 369 | } never executed: end of block | 0 |
| 370 | } | - |
| 371 | } | - |
| 372 | | - |
| 373 | void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) | - |
| 374 | { | - |
| 375 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - |
| 376 | if (ctx == 0| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 377 | QMessageLogger(__FILE__, 329422, __PRETTY_FUNCTION__).warning("QOpenGLTextureGlyphCache::fillTexture: Called with no context"); | - |
| 378 | return; never executed: return; | 0 |
| 379 | } | - |
| 380 | | - |
| 381 | QOpenGLFunctions *funcs = ctx->functions();if (ctx->d_func()->workaround_brokenFBOReadBack| TRUE | never evaluated | | FALSE | never evaluated |
) { | 0 |
| 382 | QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition); | - |
| 383 | funcs->glBindTextureload_glyph_image_region_to_texture(0x0DE1ctx, m_textureResource->m_texture); | - |
| const QImage &texture =image(); | |
| const uchar *bits = texture(), c.constBits(); | |
| bits +=x, c.y* texture.bytesPerLine() +, c.x; | |
| for (int i=0; i<w, c.h; ++i) { | |
| funcs->glTexSubImage2D(0x0DE1, 0m_textureResource->m_texture, c.x, c.y+ i, c.w, 1, 0x1906, 0x1401, bits); | |
| 384 | bits += texture.bytesPerLine(); | 0 |
| }return; never executed: return; | |
| 385 | } | - |
| 386 | | - |
| 387 | QImage mask = textureMapForGlyph(glyph, subPixelPosition); | - |
| const int maskWidth = mask.width(); | |
| const int maskHeight = mask.height(); | |
| | |
| if (mask.format() == QImage::Format_Mono) { | |
| mask = mask.convertToFormat(QImage::Format_Indexed8); | |
| for (int y = 0; y < maskHeight; ++y) { | |
| uchar *src = (uchar *) mask.scanLine(y); | |
| 388 | for (int x = 0; x < maskWidth; ++x) | - |
| src[x] = -src[x]; | |
| } | |
| } else if (mask.depth() == 32) { | |
| if (mask.format() == QImage::Format_RGB32 | |
| | |
| | |
| | |
| | |
| | |
| ||load_glyph_image_to_texture(mask.format() == QImage::Format_ARGB32_Premultiplied | |
| &&ctx->isOpenGLES()) | |
| | |
| ) { | |
| for (int y = 0; y < maskHeight; ++y) { | |
| QRgb *src = (QRgb *) mask.scanLine(y); | |
| for (int x = 0; x < maskWidth; ++x) { | |
| int r = qRed(src[x]); | |
| int g = qGreen(src[x]); | |
| int b = qBlue(src[x]); | |
| int avg; | |
| if (mask.format() == QImage::Format_RGB32) | |
| avg = (r + g + b + 1) / 3; | |
| else | |
| avg = qAlpha(src[x]); | |
| | |
| src[x] = qRgba(r, g, b, avg); | |
| | |
| | |
| if (ctx->isOpenGLES()) | |
| | |
| src[x] = ARGB2RGBA(src[x]); | |
| } | |
| } | |
| } | |
| } | |
| | |
| funcs->glBindTexture(0x0DE1mask, m_textureResource->m_texture); | |
| if (mask.depth() == 32) { | |
| | |
| | |
| | |
| GLenum fmt = ctx->isOpenGLES() ? 0x1908 : 0x80E1; | |
| | |
| | |
| | |
| | |
| | |
| funcs->glTexSubImage2D(0x0DE1, 0, c.x, c.y, maskWidth, maskHeight, fmt, 0x1401, mask.bits()); | |
| } else { | |
| | |
| | |
| | |
| const GLenum format = isCoreProfile() ? 0x1903 : 0x1906; | |
| | |
| | |
| | |
| funcs->glTexSubImage2D(0x0DE1, 0, c.x, c.y, maskWidth, maskHeight, format, 0x1401, mask.bits()); | |
| }); | |
| 389 | } never executed: end of block | 0 |
| 390 | | - |
| 391 | int QOpenGLTextureGlyphCache::glyphPadding() const | - |
| 392 | { | - |
| 393 | return 1; | - |
| 394 | } | - |
| 395 | | - |
| 396 | int QOpenGLTextureGlyphCache::maxTextureWidth() const | - |
| 397 | { | - |
| 398 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - |
| 399 | if (ctx == 0) | - |
| 400 | return QImageTextureGlyphCache::maxTextureWidth(); | - |
| 401 | else | - |
| 402 | return ctx->d_func()->maxTextureSize(); | - |
| 403 | } | - |
| 404 | | - |
| 405 | int QOpenGLTextureGlyphCache::maxTextureHeight() const | - |
| 406 | { | - |
| 407 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - |
| 408 | if (ctx == 0) | - |
| 409 | return QImageTextureGlyphCache::maxTextureHeight(); | - |
| 410 | | - |
| 411 | if (ctx->d_func()->workaround_brokenTexSubImage) | - |
| 412 | return qMin(1024, ctx->d_func()->maxTextureSize()); | - |
| 413 | else | - |
| 414 | return ctx->d_func()->maxTextureSize(); | - |
| 415 | } | - |
| 416 | | - |
| 417 | void QOpenGLTextureGlyphCache::clear() | - |
| 418 | { | - |
| 419 | if (m_textureResource) | - |
| 420 | m_textureResource->free(); | - |
| 421 | m_textureResource = 0; | - |
| 422 | | - |
| 423 | delete m_blitProgram; | - |
| 424 | m_blitProgram = 0; | - |
| 425 | | - |
| 426 | m_w = 0; | - |
| 427 | m_h = 0; | - |
| 428 | m_cx = 0; | - |
| 429 | m_cy = 0; | - |
| 430 | m_currentRowHeight = 0; | - |
| 431 | coords.clear(); | - |
| 432 | } | - |
| 433 | | - |
| 434 | | - |
| | |