| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopengltextureglyphcache.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 | - | |||||||||||||||||||||||||
| 47 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | QBasicAtomicInt qopengltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1); | - | ||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||
| 52 | QOpenGLTextureGlyphCache::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 | } | - | ||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||
| 83 | QOpenGLTextureGlyphCache::~QOpenGLTextureGlyphCache() | - | ||||||||||||||||||||||||
| 84 | { | - | ||||||||||||||||||||||||
| 85 | #ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG | - | ||||||||||||||||||||||||
| 86 | qDebug(" -> ~QOpenGLTextureGlyphCache() %p.", this); | - | ||||||||||||||||||||||||
| 87 | #endif | - | ||||||||||||||||||||||||
| 88 | clear(); | - | ||||||||||||||||||||||||
| 89 | } | - | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | #if !defined(QT_OPENGL_ES_2) | - | ||||||||||||||||||||||||
| 92 | static inline bool isCoreProfile() | - | ||||||||||||||||||||||||
| 93 | { | - | ||||||||||||||||||||||||
| 94 | return QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile; | - | ||||||||||||||||||||||||
| 95 | } | - | ||||||||||||||||||||||||
| 96 | #endif | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | void QOpenGLTextureGlyphCache::createTextureData(int width, int height) | - | ||||||||||||||||||||||||
| 99 | { | - | ||||||||||||||||||||||||
| 100 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - | ||||||||||||||||||||||||
| 101 | if (ctx == 0) { | - | ||||||||||||||||||||||||
| 102 | qWarning("QOpenGLTextureGlyphCache::createTextureData: Called with no context"); | - | ||||||||||||||||||||||||
| 103 | return; | - | ||||||||||||||||||||||||
| 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()) | - | ||||||||||||||||||||||||
| 110 | QImageTextureGlyphCache::createTextureData(width, height); | - | ||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | // Make the lower glyph texture size 16 x 16. | - | ||||||||||||||||||||||||
| 113 | if (width < 16) | - | ||||||||||||||||||||||||
| 114 | width = 16; | - | ||||||||||||||||||||||||
| 115 | if (height < 16) | - | ||||||||||||||||||||||||
| 116 | height = 16; | - | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | if (m_textureResource && !m_textureResource->m_texture) { | - | ||||||||||||||||||||||||
| 119 | delete m_textureResource; | - | ||||||||||||||||||||||||
| 120 | m_textureResource = 0; | - | ||||||||||||||||||||||||
| 121 | } | - | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | if (!m_textureResource) | - | ||||||||||||||||||||||||
| 124 | m_textureResource = new QOpenGLGlyphTexture(ctx); | - | ||||||||||||||||||||||||
| 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) { | - | ||||||||||||||||||||||||
| 134 | QVarLengthArray<uchar> data(width * height * 4); | - | ||||||||||||||||||||||||
| 135 | for (int i = 0; i < data.size(); ++i) | - | ||||||||||||||||||||||||
| 136 | data[i] = 0; | - | ||||||||||||||||||||||||
| 137 | funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); | - | ||||||||||||||||||||||||
| 138 | } else { | - | ||||||||||||||||||||||||
| 139 | QVarLengthArray<uchar> data(width * height); | - | ||||||||||||||||||||||||
| 140 | for (int i = 0; i < data.size(); ++i) | - | ||||||||||||||||||||||||
| 141 | data[i] = 0; | - | ||||||||||||||||||||||||
| 142 | #if !defined(QT_OPENGL_ES_2) | - | ||||||||||||||||||||||||
| 143 | const GLint internalFormat = isCoreProfile() ? GL_R8 : GL_ALPHA; | - | ||||||||||||||||||||||||
| 144 | const GLenum format = isCoreProfile() ? GL_RED : GL_ALPHA; | - | ||||||||||||||||||||||||
| 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 | } | - | ||||||||||||||||||||||||
| 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()) { | - | ||||||||||||||||||||||||
| 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 | } | - | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | if (!m_vao.isCreated()) | - | ||||||||||||||||||||||||
| 171 | m_vao.create(); | - | ||||||||||||||||||||||||
| 172 | } | - | ||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||
| 174 | void 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 | } | - | ||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||
| 184 | static 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) {
| 0 | ||||||||||||||||||||||||
| 195 | img = img.convertToFormat(QImage::Format_Grayscale8); | - | ||||||||||||||||||||||||
| 196 | } else if (img.depth() == 32) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 197 | if (img.format() == QImage::Format_RGB32
| 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
| 0 | ||||||||||||||||||||||||
| 204 | && ctx->isOpenGLES())
| 0 | ||||||||||||||||||||||||
| 205 | #endif | - | ||||||||||||||||||||||||
| 206 | ) { | - | ||||||||||||||||||||||||
| 207 | for (int y = 0; y < imgHeight; ++y) {
| 0 | ||||||||||||||||||||||||
| 208 | QRgb *src = (QRgb *) img.scanLine(y); | - | ||||||||||||||||||||||||
| 209 | for (int x = 0; x < imgWidth; ++x) {
| 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)
| 0 | ||||||||||||||||||||||||
| 215 | avg = (r + g + b + 1) / 3; never executed: // "+1" for rounding.avg = (r + g + b + 1) / 3;never executed: avg = (r + g + b + 1) / 3; | 0 | ||||||||||||||||||||||||
| 216 | else // Format_ARGB_Premultiplied | - | ||||||||||||||||||||||||
| 217 | never executed: avg = qAlpha(src[x]);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())
| 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) {
| 0 | ||||||||||||||||||||||||
| 232 | #ifdef QT_OPENGL_ES_2 | - | ||||||||||||||||||||||||
| 233 | GLenum fmt = GL_RGBA; | - | ||||||||||||||||||||||||
| 234 | #else | - | ||||||||||||||||||||||||
| 235 | GLenum fmt = ctx->isOpenGLES() ? GL_RGBA : GL_BGRA;
| 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;
| 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 | - | |||||||||||||||||||||||||
| 254 | static 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())
| 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 | - | |||||||||||||||||||||||||
| 272 | void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) | - | ||||||||||||||||||||||||
| 273 | { | - | ||||||||||||||||||||||||
| 274 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||||||||||||||
| 275 | if (ctx == 0) {
| 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)
| 0 | ||||||||||||||||||||||||
| 289 | width = 16; never executed: width = 16; | 0 | ||||||||||||||||||||||||
| 290 | if (height < 16)
| 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) {
| 0 | ||||||||||||||||||||||||
| 297 | QImageTextureGlyphCache::resizeTextureData(width, height); | - | ||||||||||||||||||||||||
| Q_ASSERT(image().depth() == 8); | ||||||||||||||||||||||||||
| 298 | funcs->glTexSubImage2Dload_glyph_image_region_to_texture(GL_TEXTURE_2Dctx, image(), 0, 0, 0qMin(oldWidth, width,), qMin(oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits()); | - | ||||||||||||||||||||||||
| funcsheight), | ||||||||||||||||||||||||||
| 299 | m_textureResource->glDeleteTextures(1m_texture, &oldTexture0, 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)
| 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) {
| 0 | ||||||||||||||||||||||||
| 337 | if (m_blitProgram == 0) {
| 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()) {
| 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())
| 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) {
| 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()) {
| 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 | - | |||||||||||||||||||||||||
| 418 | void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed subPixelPosition) | - | ||||||||||||||||||||||||
| 419 | { | - | ||||||||||||||||||||||||
| 420 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||||||||||||||
| 421 | if (ctx == 0) {
| 0 | ||||||||||||||||||||||||
| 422 | qWarning("QOpenGLTextureGlyphCache::fillTexture: Called with no context"); | - | ||||||||||||||||||||||||
| 423 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 424 | } | - | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | QOpenGLFunctions *funcs = ctx->functions();if (ctx->d_func()->workaround_brokenFBOReadBack) {
| 0 | ||||||||||||||||||||||||
| 427 | QImageTextureGlyphCache::fillTexture(c, glyph, subPixelPosition); | - | ||||||||||||||||||||||||
| 428 | funcs->glBindTextureload_glyph_image_region_to_texture(GL_TEXTURE_2Dctx, 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(GL_TEXTURE_2D, 0m_textureResource->m_texture, c.x, c.y+ i, c.w, 1, GL_ALPHA, GL_UNSIGNED_BYTE, bits); | ||||||||||||||||||||||||||
| 429 | bits += texture.bytesPerLine(); never executed: return; | 0 | ||||||||||||||||||||||||
| } never executed: return;return;never executed: return; | ||||||||||||||||||||||||||
| 430 | } | - | ||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||
| 432 | 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); | ||||||||||||||||||||||||||
| 433 | for (int x = 0; x < maskWidth; ++x) | - | ||||||||||||||||||||||||
| src[x] = -src[x]; } | ||||||||||||||||||||||||||
| } else if (mask.depth() == 32) { | ||||||||||||||||||||||||||
| if (mask.format() == QImage::Format_RGB32 | ||||||||||||||||||||||||||
| #if Q_BYTE_ORDER == Q_BIG_ENDIAN | ||||||||||||||||||||||||||
| || mask.format() == QImage::Format_ARGB32_Premultiplied | ||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||
| ||load_glyph_image_to_texture(mask.format() == QImage::Format_ARGB32_Premultiplied | ||||||||||||||||||||||||||
| &&ctx->isOpenGLES()) | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||
| 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 Q_BYTE_ORDER != Q_BIG_ENDIAN | ||||||||||||||||||||||||||
| if (ctx->isOpenGLES()) | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
| src[x] = ARGB2RGBA(src[x]); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| funcs->glBindTexture(GL_TEXTURE_2Dmask, m_textureResource->m_texture); | ||||||||||||||||||||||||||
| if (mask.depth() == 32) { | ||||||||||||||||||||||||||
| #ifdef QT_OPENGL_ES_2 | ||||||||||||||||||||||||||
| GLenum fmt = GL_RGBA; | ||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||
| GLenum fmt = ctx->isOpenGLES() ? GL_RGBA : GL_BGRA; | ||||||||||||||||||||||||||
| #endif #if Q_BYTE_ORDER == Q_BIG_ENDIAN | ||||||||||||||||||||||||||
| fmt = GL_RGBA; | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
| funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, fmt, GL_UNSIGNED_BYTE, mask.bits()); | ||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||
| #if !defined(QT_OPENGL_ES_2) | ||||||||||||||||||||||||||
| const GLenum format = isCoreProfile() ? GL_RED : GL_ALPHA; | ||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||
| const GLenum format = GL_ALPHA; | ||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
| funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, format, GL_UNSIGNED_BYTE, mask.bits()); | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
| 434 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | int QOpenGLTextureGlyphCache::glyphPadding() const | - | ||||||||||||||||||||||||
| 437 | { | - | ||||||||||||||||||||||||
| 438 | return 1; | - | ||||||||||||||||||||||||
| 439 | } | - | ||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||
| 441 | int QOpenGLTextureGlyphCache::maxTextureWidth() const | - | ||||||||||||||||||||||||
| 442 | { | - | ||||||||||||||||||||||||
| 443 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - | ||||||||||||||||||||||||
| 444 | if (ctx == 0) | - | ||||||||||||||||||||||||
| 445 | return QImageTextureGlyphCache::maxTextureWidth(); | - | ||||||||||||||||||||||||
| 446 | else | - | ||||||||||||||||||||||||
| 447 | return ctx->d_func()->maxTextureSize(); | - | ||||||||||||||||||||||||
| 448 | } | - | ||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | int QOpenGLTextureGlyphCache::maxTextureHeight() const | - | ||||||||||||||||||||||||
| 451 | { | - | ||||||||||||||||||||||||
| 452 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - | ||||||||||||||||||||||||
| 453 | if (ctx == 0) | - | ||||||||||||||||||||||||
| 454 | return QImageTextureGlyphCache::maxTextureHeight(); | - | ||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | if (ctx->d_func()->workaround_brokenTexSubImage) | - | ||||||||||||||||||||||||
| 457 | return qMin(1024, ctx->d_func()->maxTextureSize()); | - | ||||||||||||||||||||||||
| 458 | else | - | ||||||||||||||||||||||||
| 459 | return ctx->d_func()->maxTextureSize(); | - | ||||||||||||||||||||||||
| 460 | } | - | ||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||
| 462 | void QOpenGLTextureGlyphCache::clear() | - | ||||||||||||||||||||||||
| 463 | { | - | ||||||||||||||||||||||||
| 464 | if (m_textureResource) | - | ||||||||||||||||||||||||
| 465 | m_textureResource->free(); | - | ||||||||||||||||||||||||
| 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 | } | - | ||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |