| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopenglpaintengine.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||||||||
| 11 | __attribute__((visibility("default"))) QImage qt_imageForBrush(int brushStyle, bool invert); | - | ||||||||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||||||||
| 15 | QOpenGL2PaintEngineExPrivate::~QOpenGL2PaintEngineExPrivate() | - | ||||||||||||||||||||||||||||||
| 16 | { | - | ||||||||||||||||||||||||||||||
| 17 | delete shaderManager; | - | ||||||||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||||||||
| 19 | if (elementIndicesVBOId != 0
| 0 | ||||||||||||||||||||||||||||||
| 20 | funcs.glDeleteBuffers(1, &elementIndicesVBOId); | - | ||||||||||||||||||||||||||||||
| 21 | elementIndicesVBOId = 0; | - | ||||||||||||||||||||||||||||||
| 22 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 23 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||||||||
| 25 | inline QColor qt_premultiplyColor(QColor c, GLfloat opacity) | - | ||||||||||||||||||||||||||||||
| 26 | { | - | ||||||||||||||||||||||||||||||
| 27 | qreal alpha = c.alphaF() * opacity; | - | ||||||||||||||||||||||||||||||
| 28 | c.setAlphaF(alpha); | - | ||||||||||||||||||||||||||||||
| 29 | c.setRedF(c.redF() * alpha); | - | ||||||||||||||||||||||||||||||
| 30 | c.setGreenF(c.greenF() * alpha); | - | ||||||||||||||||||||||||||||||
| 31 | c.setBlueF(c.blueF() * alpha); | - | ||||||||||||||||||||||||||||||
| 32 | return never executed: c;return c;never executed: return c; | 0 | ||||||||||||||||||||||||||||||
| 33 | } | - | ||||||||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||||||||
| 36 | void QOpenGL2PaintEngineExPrivate::setBrush(const QBrush& brush) | - | ||||||||||||||||||||||||||||||
| 37 | { | - | ||||||||||||||||||||||||||||||
| 38 | if (qbrush_fast_equals(currentBrush, brush)
| 0 | ||||||||||||||||||||||||||||||
| 39 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||||||||
| 41 | const Qt::BrushStyle newStyle = qbrush_style(brush); | - | ||||||||||||||||||||||||||||||
| 42 | ((!(newStyle != Qt::NoBrush)) ? qt_assert("newStyle != Qt::NoBrush",__FILE__,125) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||||||||
| 44 | currentBrush = brush; | - | ||||||||||||||||||||||||||||||
| 45 | if (!currentBrushImage.isNull()
| 0 | ||||||||||||||||||||||||||||||
| 46 | currentBrushImage = QImage(); never executed: currentBrushImage = QImage(); | 0 | ||||||||||||||||||||||||||||||
| 47 | brushUniformsDirty = true; | - | ||||||||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||||||||
| 49 | if (newStyle > Qt::SolidPattern
| 0 | ||||||||||||||||||||||||||||||
| 50 | brushTextureDirty = true; never executed: brushTextureDirty = true; | 0 | ||||||||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||||||||
| 52 | if (currentBrush.style() == Qt::TexturePattern
| 0 | ||||||||||||||||||||||||||||||
| 53 | && qHasPixmapTexture(brush)
| 0 | ||||||||||||||||||||||||||||||
| 54 | { | - | ||||||||||||||||||||||||||||||
| 55 | shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::TextureSrcWithPattern); | - | ||||||||||||||||||||||||||||||
| 56 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 57 | shaderManager->setSrcPixelType(newStyle); | - | ||||||||||||||||||||||||||||||
| 58 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 59 | shaderManager->optimiseForBrushTransform(currentBrush.transform().type()); | - | ||||||||||||||||||||||||||||||
| 60 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||||||||
| 63 | void QOpenGL2PaintEngineExPrivate::useSimpleShader() | - | ||||||||||||||||||||||||||||||
| 64 | { | - | ||||||||||||||||||||||||||||||
| 65 | shaderManager->useSimpleProgram(); | - | ||||||||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||||||||
| 67 | if (matrixDirty
| 0 | ||||||||||||||||||||||||||||||
| 68 | updateMatrix(); never executed: updateMatrix(); | 0 | ||||||||||||||||||||||||||||||
| 69 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 70 | template<typename T> | - | ||||||||||||||||||||||||||||||
| 71 | void QOpenGL2PaintEngineExPrivate::updateTexture(GLenum textureUnit, const T &texture, GLenum wrapMode, GLenum filterMode, TextureUpdateMode updateMode) | - | ||||||||||||||||||||||||||||||
| 72 | { | - | ||||||||||||||||||||||||||||||
| 73 | static const GLenum target = 0x0DE1; | - | ||||||||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||||||||
| 75 | activateTextureUnit(textureUnit); | - | ||||||||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||||||||
| 77 | GLuint textureId = bindTexture(texture); | - | ||||||||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||||||||
| 79 | if (updateMode == UpdateIfNeeded
| 0 | ||||||||||||||||||||||||||||||
| 80 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||||||||
| 82 | lastTextureUsed = textureId; | - | ||||||||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||||||||
| 84 | funcs.glTexParameteri(target, 0x2802, wrapMode); | - | ||||||||||||||||||||||||||||||
| 85 | funcs.glTexParameteri(target, 0x2803, wrapMode); | - | ||||||||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||||||||
| 87 | funcs.glTexParameteri(target, 0x2800, filterMode); | - | ||||||||||||||||||||||||||||||
| 88 | funcs.glTexParameteri(target, 0x2801, filterMode); | - | ||||||||||||||||||||||||||||||
| 89 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||||||||
| 91 | void QOpenGL2PaintEngineExPrivate::activateTextureUnit(GLenum textureUnit) | - | ||||||||||||||||||||||||||||||
| 92 | { | - | ||||||||||||||||||||||||||||||
| 93 | if (textureUnit != lastTextureUnitUsed
| 0 | ||||||||||||||||||||||||||||||
| 94 | funcs.glActiveTexture(0x84C0 + textureUnit); | - | ||||||||||||||||||||||||||||||
| 95 | lastTextureUnitUsed = textureUnit; | - | ||||||||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||||||||
| 101 | lastTextureUsed = GLuint(-1); | - | ||||||||||||||||||||||||||||||
| 102 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 103 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||||||||
| 105 | template<> | - | ||||||||||||||||||||||||||||||
| 106 | GLuint QOpenGL2PaintEngineExPrivate::bindTexture(const GLuint &textureId) | - | ||||||||||||||||||||||||||||||
| 107 | { | - | ||||||||||||||||||||||||||||||
| 108 | if (textureId != lastTextureUsed
| 0 | ||||||||||||||||||||||||||||||
| 109 | funcs.glBindTexture(0x0DE1, textureId); never executed: funcs.glBindTexture(0x0DE1, textureId); | 0 | ||||||||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||||||||
| 111 | return never executed: textureId;return textureId;never executed: return textureId; | 0 | ||||||||||||||||||||||||||||||
| 112 | } | - | ||||||||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||||||||
| 114 | template<> | - | ||||||||||||||||||||||||||||||
| 115 | GLuint QOpenGL2PaintEngineExPrivate::bindTexture(const QImage &image) | - | ||||||||||||||||||||||||||||||
| 116 | { | - | ||||||||||||||||||||||||||||||
| 117 | return never executed: QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, image);return QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, image);never executed: return QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, image); | 0 | ||||||||||||||||||||||||||||||
| 118 | } | - | ||||||||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||||||||
| 120 | template<> | - | ||||||||||||||||||||||||||||||
| 121 | GLuint QOpenGL2PaintEngineExPrivate::bindTexture(const QPixmap &pixmap) | - | ||||||||||||||||||||||||||||||
| 122 | { | - | ||||||||||||||||||||||||||||||
| 123 | return never executed: QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, pixmap);return QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, pixmap);never executed: return QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, pixmap); | 0 | ||||||||||||||||||||||||||||||
| 124 | } | - | ||||||||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||||||||
| 126 | template<> | - | ||||||||||||||||||||||||||||||
| 127 | GLuint QOpenGL2PaintEngineExPrivate::bindTexture(const QGradient &gradient) | - | ||||||||||||||||||||||||||||||
| 128 | { | - | ||||||||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||||||||
| 131 | GLuint textureId = QOpenGL2GradientCache::cacheForContext(ctx)->getBuffer(gradient, 1.0); | - | ||||||||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||||||||
| 136 | - | |||||||||||||||||||||||||||||||
| 137 | return never executed: bindTexture(textureId);return bindTexture(textureId);never executed: return bindTexture(textureId); | 0 | ||||||||||||||||||||||||||||||
| 138 | } | - | ||||||||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||||||||
| 140 | struct ImageWithBindOptions | - | ||||||||||||||||||||||||||||||
| 141 | { | - | ||||||||||||||||||||||||||||||
| 142 | const QImage ℑ | - | ||||||||||||||||||||||||||||||
| 143 | QOpenGLTextureCache::BindOptions options; | - | ||||||||||||||||||||||||||||||
| 144 | }; | - | ||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||
| 146 | template<> | - | ||||||||||||||||||||||||||||||
| 147 | GLuint QOpenGL2PaintEngineExPrivate::bindTexture(const ImageWithBindOptions &imageWithOptions) | - | ||||||||||||||||||||||||||||||
| 148 | { | - | ||||||||||||||||||||||||||||||
| 149 | return never executed: QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, imageWithOptions.image, imageWithOptions.options);return QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, imageWithOptions.image, imageWithOptions.options);never executed: return QOpenGLTextureCache::cacheForContext(ctx)->bindTexture(ctx, imageWithOptions.image, imageWithOptions.options); | 0 | ||||||||||||||||||||||||||||||
| 150 | } | - | ||||||||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||||||||
| 152 | void QOpenGL2PaintEngineExPrivate::updateBrushTexture() | - | ||||||||||||||||||||||||||||||
| 153 | { | - | ||||||||||||||||||||||||||||||
| 154 | QOpenGL2PaintEngineEx * const q = q_func(); | - | ||||||||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||||||||
| 156 | Qt::BrushStyle style = currentBrush.style(); | - | ||||||||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||||||||
| 158 | bool smoothPixmapTransform = q->state()->renderHints & QPainter::SmoothPixmapTransform; | - | ||||||||||||||||||||||||||||||
| 159 | GLenum filterMode = smoothPixmapTransform
| 0 | ||||||||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||||||||
| 161 | if ( (
| 0 | ||||||||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||||||||
| 163 | QImage textureImage = qt_imageForBrush(style, false); | - | ||||||||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||||||||
| 165 | updateTexture(GLuint(0), textureImage, 0x2901, filterMode, ForceUpdate); | - | ||||||||||||||||||||||||||||||
| 166 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 167 | else if (style >= Qt::LinearGradientPattern
| 0 | ||||||||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||||||||
| 170 | const QGradient *gradient = currentBrush.gradient(); | - | ||||||||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||||||||
| 172 | GLenum wrapMode = 0x812F; | - | ||||||||||||||||||||||||||||||
| 173 | if (gradient->spread() == QGradient::RepeatSpread
| 0 | ||||||||||||||||||||||||||||||
| 174 | wrapMode = 0x2901; never executed: wrapMode = 0x2901; | 0 | ||||||||||||||||||||||||||||||
| 175 | else if (gradient->spread() == QGradient::ReflectSpread
| 0 | ||||||||||||||||||||||||||||||
| 176 | wrapMode = 0x8370; never executed: wrapMode = 0x8370; | 0 | ||||||||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||||||||
| 178 | updateTexture(GLuint(0), *gradient, wrapMode, filterMode, ForceUpdate); | - | ||||||||||||||||||||||||||||||
| 179 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 180 | else if (style == Qt::TexturePattern
| 0 | ||||||||||||||||||||||||||||||
| 181 | currentBrushImage = currentBrush.textureImage(); | - | ||||||||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||||||||
| 183 | int max_texture_size = ctx->d_func()->maxTextureSize(); | - | ||||||||||||||||||||||||||||||
| 184 | if (currentBrushImage.width() > max_texture_size
| 0 | ||||||||||||||||||||||||||||||
| 185 | currentBrushImage = currentBrushImage.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); never executed: currentBrushImage = currentBrushImage.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); | 0 | ||||||||||||||||||||||||||||||
| 186 | - | |||||||||||||||||||||||||||||||
| 187 | GLuint wrapMode = 0x2901; | - | ||||||||||||||||||||||||||||||
| 188 | if (QOpenGLContext::currentContext()->isOpenGLES()
| 0 | ||||||||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||||||||
| 192 | wrapMode = 0x812F; | - | ||||||||||||||||||||||||||||||
| 193 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||||||||
| 195 | updateTexture(GLuint(0), currentBrushImage, wrapMode, filterMode, ForceUpdate); | - | ||||||||||||||||||||||||||||||
| 196 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 197 | brushTextureDirty = false; | - | ||||||||||||||||||||||||||||||
| 198 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||||||||
| 201 | void QOpenGL2PaintEngineExPrivate::updateBrushUniforms() | - | ||||||||||||||||||||||||||||||
| 202 | { | - | ||||||||||||||||||||||||||||||
| 203 | - | |||||||||||||||||||||||||||||||
| 204 | Qt::BrushStyle style = currentBrush.style(); | - | ||||||||||||||||||||||||||||||
| 205 | - | |||||||||||||||||||||||||||||||
| 206 | if (style == Qt::NoBrush
| 0 | ||||||||||||||||||||||||||||||
| 207 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||||||||
| 209 | QTransform brushQTransform = currentBrush.transform(); | - | ||||||||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||||||||
| 211 | if (style == Qt::SolidPattern
| 0 | ||||||||||||||||||||||||||||||
| 212 | QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity); | - | ||||||||||||||||||||||||||||||
| 213 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::FragmentColor), col); | - | ||||||||||||||||||||||||||||||
| 214 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 215 | else { | - | ||||||||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||||||||
| 217 | QPointF translationPoint; | - | ||||||||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||||||||
| 219 | if (style <= Qt::DiagCrossPattern
| 0 | ||||||||||||||||||||||||||||||
| 220 | QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity); | - | ||||||||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||||||||
| 222 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::PatternColor), col); | - | ||||||||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||||||||
| 224 | QVector2D halfViewportSize(width*0.5, height*0.5); | - | ||||||||||||||||||||||||||||||
| 225 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::HalfViewportSize), halfViewportSize); | - | ||||||||||||||||||||||||||||||
| 226 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 227 | else if (style == Qt::LinearGradientPattern
| 0 | ||||||||||||||||||||||||||||||
| 228 | const QLinearGradient *g = static_cast<const QLinearGradient *>(currentBrush.gradient()); | - | ||||||||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||||||||
| 230 | QPointF realStart = g->start(); | - | ||||||||||||||||||||||||||||||
| 231 | QPointF realFinal = g->finalStop(); | - | ||||||||||||||||||||||||||||||
| 232 | translationPoint = realStart; | - | ||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 | QPointF l = realFinal - realStart; | - | ||||||||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||||||||
| 236 | QVector3D linearData( | - | ||||||||||||||||||||||||||||||
| 237 | l.x(), | - | ||||||||||||||||||||||||||||||
| 238 | l.y(), | - | ||||||||||||||||||||||||||||||
| 239 | 1.0f / (l.x() * l.x() + l.y() * l.y()) | - | ||||||||||||||||||||||||||||||
| 240 | ); | - | ||||||||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||||||||
| 242 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::LinearData), linearData); | - | ||||||||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||||||||
| 244 | QVector2D halfViewportSize(width*0.5, height*0.5); | - | ||||||||||||||||||||||||||||||
| 245 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::HalfViewportSize), halfViewportSize); | - | ||||||||||||||||||||||||||||||
| 246 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 247 | else if (style == Qt::ConicalGradientPattern
| 0 | ||||||||||||||||||||||||||||||
| 248 | const QConicalGradient *g = static_cast<const QConicalGradient *>(currentBrush.gradient()); | - | ||||||||||||||||||||||||||||||
| 249 | translationPoint = g->center(); | - | ||||||||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||||||||
| 251 | GLfloat angle = -qDegreesToRadians(g->angle()); | - | ||||||||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||||||||
| 253 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::Angle), angle); | - | ||||||||||||||||||||||||||||||
| 254 | - | |||||||||||||||||||||||||||||||
| 255 | QVector2D halfViewportSize(width*0.5, height*0.5); | - | ||||||||||||||||||||||||||||||
| 256 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::HalfViewportSize), halfViewportSize); | - | ||||||||||||||||||||||||||||||
| 257 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 258 | else if (style == Qt::RadialGradientPattern
| 0 | ||||||||||||||||||||||||||||||
| 259 | const QRadialGradient *g = static_cast<const QRadialGradient *>(currentBrush.gradient()); | - | ||||||||||||||||||||||||||||||
| 260 | QPointF realCenter = g->center(); | - | ||||||||||||||||||||||||||||||
| 261 | QPointF realFocal = g->focalPoint(); | - | ||||||||||||||||||||||||||||||
| 262 | qreal realRadius = g->centerRadius() - g->focalRadius(); | - | ||||||||||||||||||||||||||||||
| 263 | translationPoint = realFocal; | - | ||||||||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||||||||
| 265 | QPointF fmp = realCenter - realFocal; | - | ||||||||||||||||||||||||||||||
| 266 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::Fmp), fmp); | - | ||||||||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||||||||
| 268 | GLfloat fmp2_m_radius2 = -fmp.x() * fmp.x() - fmp.y() * fmp.y() + realRadius*realRadius; | - | ||||||||||||||||||||||||||||||
| 269 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::Fmp2MRadius2), fmp2_m_radius2); | - | ||||||||||||||||||||||||||||||
| 270 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::Inverse2Fmp2MRadius2), | - | ||||||||||||||||||||||||||||||
| 271 | GLfloat(1.0 / (2.0*fmp2_m_radius2))); | - | ||||||||||||||||||||||||||||||
| 272 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::SqrFr), | - | ||||||||||||||||||||||||||||||
| 273 | GLfloat(g->focalRadius() * g->focalRadius())); | - | ||||||||||||||||||||||||||||||
| 274 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::BRadius), | - | ||||||||||||||||||||||||||||||
| 275 | GLfloat(2 * (g->centerRadius() - g->focalRadius()) * g->focalRadius()), | - | ||||||||||||||||||||||||||||||
| 276 | g->focalRadius(), | - | ||||||||||||||||||||||||||||||
| 277 | g->centerRadius() - g->focalRadius()); | - | ||||||||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||||||||
| 279 | QVector2D halfViewportSize(width*0.5, height*0.5); | - | ||||||||||||||||||||||||||||||
| 280 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::HalfViewportSize), halfViewportSize); | - | ||||||||||||||||||||||||||||||
| 281 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 282 | else if (style == Qt::TexturePattern
| 0 | ||||||||||||||||||||||||||||||
| 283 | const QPixmap& texPixmap = currentBrush.texture(); | - | ||||||||||||||||||||||||||||||
| 284 | - | |||||||||||||||||||||||||||||||
| 285 | if (qHasPixmapTexture(currentBrush)
| 0 | ||||||||||||||||||||||||||||||
| 286 | QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity); | - | ||||||||||||||||||||||||||||||
| 287 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::PatternColor), col); | - | ||||||||||||||||||||||||||||||
| 288 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||||||||
| 290 | QSizeF invertedTextureSize(1.0 / texPixmap.width(), 1.0 / texPixmap.height()); | - | ||||||||||||||||||||||||||||||
| 291 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::InvertedTextureSize), invertedTextureSize); | - | ||||||||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||||||||
| 293 | QVector2D halfViewportSize(width*0.5, height*0.5); | - | ||||||||||||||||||||||||||||||
| 294 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::HalfViewportSize), halfViewportSize); | - | ||||||||||||||||||||||||||||||
| 295 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 296 | else | - | ||||||||||||||||||||||||||||||
| 297 | QMessageLogger(__FILE__, 395, __PRETTY_FUNCTION__).warning("QOpenGL2PaintEngineEx: Unimplemented fill style"); never executed: QMessageLogger(__FILE__, 395, __PRETTY_FUNCTION__).warning("QOpenGL2PaintEngineEx: Unimplemented fill style"); | 0 | ||||||||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||||||||
| 299 | const QPointF &brushOrigin = q->state()->brushOrigin; | - | ||||||||||||||||||||||||||||||
| 300 | QTransform matrix = q->state()->matrix; | - | ||||||||||||||||||||||||||||||
| 301 | matrix.translate(brushOrigin.x(), brushOrigin.y()); | - | ||||||||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||||||||
| 303 | QTransform translate(1, 0, 0, 1, -translationPoint.x(), -translationPoint.y()); | - | ||||||||||||||||||||||||||||||
| 304 | qreal m22 = -1; | - | ||||||||||||||||||||||||||||||
| 305 | qreal dy = height; | - | ||||||||||||||||||||||||||||||
| 306 | if (device->paintFlipped()
| 0 | ||||||||||||||||||||||||||||||
| 307 | m22 = 1; | - | ||||||||||||||||||||||||||||||
| 308 | dy = 0; | - | ||||||||||||||||||||||||||||||
| 309 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 310 | QTransform gl_to_qt(1, 0, 0, m22, 0, dy); | - | ||||||||||||||||||||||||||||||
| 311 | QTransform inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate; | - | ||||||||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||||||||
| 313 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::BrushTransform), inv_matrix); | - | ||||||||||||||||||||||||||||||
| 314 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::BrushTexture), GLuint(0)); | - | ||||||||||||||||||||||||||||||
| 315 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 316 | brushUniformsDirty = false; | - | ||||||||||||||||||||||||||||||
| 317 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||||||||
| 320 | - | |||||||||||||||||||||||||||||||
| 321 | void QOpenGL2PaintEngineExPrivate::updateMatrix() | - | ||||||||||||||||||||||||||||||
| 322 | { | - | ||||||||||||||||||||||||||||||
| 323 | - | |||||||||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||||||||
| 325 | const QTransform& transform = q->state()->matrix; | - | ||||||||||||||||||||||||||||||
| 326 | const GLfloat wfactor = 2.0f / width; | - | ||||||||||||||||||||||||||||||
| 327 | GLfloat hfactor = -2.0f / height; | - | ||||||||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||||||||
| 329 | GLfloat dx = transform.dx(); | - | ||||||||||||||||||||||||||||||
| 330 | GLfloat dy = transform.dy(); | - | ||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||
| 332 | if (device->paintFlipped()
| 0 | ||||||||||||||||||||||||||||||
| 333 | hfactor *= -1; | - | ||||||||||||||||||||||||||||||
| 334 | dy -= height; | - | ||||||||||||||||||||||||||||||
| 335 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||||||||
| 339 | if (snapToPixelGrid
| 0 | ||||||||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||||||||
| 341 | dx = std::ceil(dx - 0.5f); | - | ||||||||||||||||||||||||||||||
| 342 | dy = std::ceil(dy - 0.5f); | - | ||||||||||||||||||||||||||||||
| 343 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 344 | pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13(); | - | ||||||||||||||||||||||||||||||
| 345 | pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23(); | - | ||||||||||||||||||||||||||||||
| 346 | pmvMatrix[2][0] = (wfactor * dx) - transform.m33(); | - | ||||||||||||||||||||||||||||||
| 347 | pmvMatrix[0][1] = (hfactor * transform.m12()) + transform.m13(); | - | ||||||||||||||||||||||||||||||
| 348 | pmvMatrix[1][1] = (hfactor * transform.m22()) + transform.m23(); | - | ||||||||||||||||||||||||||||||
| 349 | pmvMatrix[2][1] = (hfactor * dy) + transform.m33(); | - | ||||||||||||||||||||||||||||||
| 350 | pmvMatrix[0][2] = transform.m13(); | - | ||||||||||||||||||||||||||||||
| 351 | pmvMatrix[1][2] = transform.m23(); | - | ||||||||||||||||||||||||||||||
| 352 | pmvMatrix[2][2] = transform.m33(); | - | ||||||||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||||||||
| 355 | - | |||||||||||||||||||||||||||||||
| 356 | inverseScale = qMax(1 / qMax( qMax(qAbs(transform.m11()), qAbs(transform.m22())), | - | ||||||||||||||||||||||||||||||
| 357 | qMax(qAbs(transform.m12()), qAbs(transform.m21())) ), | - | ||||||||||||||||||||||||||||||
| 358 | qreal(0.0001)); | - | ||||||||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||||||||
| 360 | matrixDirty = false; | - | ||||||||||||||||||||||||||||||
| 361 | matrixUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||||||||
| 363 | - | |||||||||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||||||||
| 365 | funcs.glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]); | - | ||||||||||||||||||||||||||||||
| 366 | funcs.glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]); | - | ||||||||||||||||||||||||||||||
| 367 | funcs.glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]); | - | ||||||||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||||||||
| 369 | dasher.setInvScale(inverseScale); | - | ||||||||||||||||||||||||||||||
| 370 | stroker.setInvScale(inverseScale); | - | ||||||||||||||||||||||||||||||
| 371 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||||||||
| 374 | void QOpenGL2PaintEngineExPrivate::updateCompositionMode() | - | ||||||||||||||||||||||||||||||
| 375 | { | - | ||||||||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||||||||
| 379 | switch(q->state()->composition_mode) { | - | ||||||||||||||||||||||||||||||
| 380 | case never executed: QPainter::CompositionMode_SourceOver:case QPainter::CompositionMode_SourceOver:never executed: case QPainter::CompositionMode_SourceOver: | 0 | ||||||||||||||||||||||||||||||
| 381 | funcs.glBlendFunc(1, 0x0303); | - | ||||||||||||||||||||||||||||||
| 382 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 383 | case never executed: QPainter::CompositionMode_DestinationOver:case QPainter::CompositionMode_DestinationOver:never executed: case QPainter::CompositionMode_DestinationOver: | 0 | ||||||||||||||||||||||||||||||
| 384 | funcs.glBlendFunc(0x0305, 1); | - | ||||||||||||||||||||||||||||||
| 385 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 386 | case never executed: QPainter::CompositionMode_Clear:case QPainter::CompositionMode_Clear:never executed: case QPainter::CompositionMode_Clear: | 0 | ||||||||||||||||||||||||||||||
| 387 | funcs.glBlendFunc(0, 0); | - | ||||||||||||||||||||||||||||||
| 388 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 389 | case never executed: QPainter::CompositionMode_Source:case QPainter::CompositionMode_Source:never executed: case QPainter::CompositionMode_Source: | 0 | ||||||||||||||||||||||||||||||
| 390 | funcs.glBlendFunc(1, 0); | - | ||||||||||||||||||||||||||||||
| 391 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 392 | case never executed: QPainter::CompositionMode_Destination:case QPainter::CompositionMode_Destination:never executed: case QPainter::CompositionMode_Destination: | 0 | ||||||||||||||||||||||||||||||
| 393 | funcs.glBlendFunc(0, 1); | - | ||||||||||||||||||||||||||||||
| 394 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 395 | case never executed: QPainter::CompositionMode_SourceIn:case QPainter::CompositionMode_SourceIn:never executed: case QPainter::CompositionMode_SourceIn: | 0 | ||||||||||||||||||||||||||||||
| 396 | funcs.glBlendFunc(0x0304, 0); | - | ||||||||||||||||||||||||||||||
| 397 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 398 | case never executed: QPainter::CompositionMode_DestinationIn:case QPainter::CompositionMode_DestinationIn:never executed: case QPainter::CompositionMode_DestinationIn: | 0 | ||||||||||||||||||||||||||||||
| 399 | funcs.glBlendFunc(0, 0x0302); | - | ||||||||||||||||||||||||||||||
| 400 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 401 | case never executed: QPainter::CompositionMode_SourceOut:case QPainter::CompositionMode_SourceOut:never executed: case QPainter::CompositionMode_SourceOut: | 0 | ||||||||||||||||||||||||||||||
| 402 | funcs.glBlendFunc(0x0305, 0); | - | ||||||||||||||||||||||||||||||
| 403 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 404 | case never executed: QPainter::CompositionMode_DestinationOut:case QPainter::CompositionMode_DestinationOut:never executed: case QPainter::CompositionMode_DestinationOut: | 0 | ||||||||||||||||||||||||||||||
| 405 | funcs.glBlendFunc(0, 0x0303); | - | ||||||||||||||||||||||||||||||
| 406 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 407 | case never executed: QPainter::CompositionMode_SourceAtop:case QPainter::CompositionMode_SourceAtop:never executed: case QPainter::CompositionMode_SourceAtop: | 0 | ||||||||||||||||||||||||||||||
| 408 | funcs.glBlendFunc(0x0304, 0x0303); | - | ||||||||||||||||||||||||||||||
| 409 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 410 | case never executed: QPainter::CompositionMode_DestinationAtop:case QPainter::CompositionMode_DestinationAtop:never executed: case QPainter::CompositionMode_DestinationAtop: | 0 | ||||||||||||||||||||||||||||||
| 411 | funcs.glBlendFunc(0x0305, 0x0302); | - | ||||||||||||||||||||||||||||||
| 412 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 413 | case never executed: QPainter::CompositionMode_Xor:case QPainter::CompositionMode_Xor:never executed: case QPainter::CompositionMode_Xor: | 0 | ||||||||||||||||||||||||||||||
| 414 | funcs.glBlendFunc(0x0305, 0x0303); | - | ||||||||||||||||||||||||||||||
| 415 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 416 | case never executed: QPainter::CompositionMode_Plus:case QPainter::CompositionMode_Plus:never executed: case QPainter::CompositionMode_Plus: | 0 | ||||||||||||||||||||||||||||||
| 417 | funcs.glBlendFunc(1, 1); | - | ||||||||||||||||||||||||||||||
| 418 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 419 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 420 | QMessageLogger(__FILE__, 536, __PRETTY_FUNCTION__).warning("Unsupported composition mode"); | - | ||||||||||||||||||||||||||||||
| 421 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 422 | } | - | ||||||||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||||||||
| 424 | compositionModeDirty = false; | - | ||||||||||||||||||||||||||||||
| 425 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||||||||
| 427 | static inline void setCoords(GLfloat *coords, const QOpenGLRect &rect) | - | ||||||||||||||||||||||||||||||
| 428 | { | - | ||||||||||||||||||||||||||||||
| 429 | coords[0] = rect.left; | - | ||||||||||||||||||||||||||||||
| 430 | coords[1] = rect.top; | - | ||||||||||||||||||||||||||||||
| 431 | coords[2] = rect.right; | - | ||||||||||||||||||||||||||||||
| 432 | coords[3] = rect.top; | - | ||||||||||||||||||||||||||||||
| 433 | coords[4] = rect.right; | - | ||||||||||||||||||||||||||||||
| 434 | coords[5] = rect.bottom; | - | ||||||||||||||||||||||||||||||
| 435 | coords[6] = rect.left; | - | ||||||||||||||||||||||||||||||
| 436 | coords[7] = rect.bottom; | - | ||||||||||||||||||||||||||||||
| 437 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||||||||
| 439 | void QOpenGL2PaintEngineExPrivate::drawTexture(const QOpenGLRect& dest, const QOpenGLRect& src, const QSize &textureSize, bool opaque, bool pattern) | - | ||||||||||||||||||||||||||||||
| 440 | { | - | ||||||||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||||||||
| 442 | currentBrush = noBrush; | - | ||||||||||||||||||||||||||||||
| 443 | - | |||||||||||||||||||||||||||||||
| 444 | if (snapToPixelGrid
| 0 | ||||||||||||||||||||||||||||||
| 445 | snapToPixelGrid = false; | - | ||||||||||||||||||||||||||||||
| 446 | matrixDirty = true; | - | ||||||||||||||||||||||||||||||
| 447 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||||||||
| 449 | if (prepareForDraw(opaque)
| 0 | ||||||||||||||||||||||||||||||
| 450 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::ImageTexture), GLuint(0)); never executed: shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::ImageTexture), GLuint(0)); | 0 | ||||||||||||||||||||||||||||||
| 451 | - | |||||||||||||||||||||||||||||||
| 452 | if (pattern
| 0 | ||||||||||||||||||||||||||||||
| 453 | QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity); | - | ||||||||||||||||||||||||||||||
| 454 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::PatternColor), col); | - | ||||||||||||||||||||||||||||||
| 455 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||||||||
| 457 | GLfloat dx = 1.0 / textureSize.width(); | - | ||||||||||||||||||||||||||||||
| 458 | GLfloat dy = 1.0 / textureSize.height(); | - | ||||||||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||||||||
| 460 | QOpenGLRect srcTextureRect(src.left*dx, src.top*dy, src.right*dx, src.bottom*dy); | - | ||||||||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||||||||
| 462 | setCoords(staticVertexCoordinateArray, dest); | - | ||||||||||||||||||||||||||||||
| 463 | setCoords(staticTextureCoordinateArray, srcTextureRect); | - | ||||||||||||||||||||||||||||||
| 464 | - | |||||||||||||||||||||||||||||||
| 465 | funcs.glDrawArrays(0x0006, 0, 4); | - | ||||||||||||||||||||||||||||||
| 466 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||||||||
| 468 | void QOpenGL2PaintEngineEx::beginNativePainting() | - | ||||||||||||||||||||||||||||||
| 469 | { | - | ||||||||||||||||||||||||||||||
| 470 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 471 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 472 | d->transferMode(BrushDrawingMode); | - | ||||||||||||||||||||||||||||||
| 473 | - | |||||||||||||||||||||||||||||||
| 474 | d->nativePaintingActive = true; | - | ||||||||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||||||||
| 476 | d->funcs.glUseProgram(0); | - | ||||||||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||||||||
| 479 | for (int i = 0; i < 3
| 0 | ||||||||||||||||||||||||||||||
| 480 | d->funcs.glDisableVertexAttribArray(i); never executed: d->funcs.glDisableVertexAttribArray(i); | 0 | ||||||||||||||||||||||||||||||
| 481 | - | |||||||||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||||||||
| 483 | ((!(QOpenGLContext::currentContext())) ? qt_assert("QOpenGLContext::currentContext()",__FILE__,599) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 484 | const QOpenGLContext *ctx = d->ctx; | - | ||||||||||||||||||||||||||||||
| 485 | const QSurfaceFormat &fmt = d->device->context()->format(); | - | ||||||||||||||||||||||||||||||
| 486 | if (fmt.majorVersion() < 3
| 0 | ||||||||||||||||||||||||||||||
| 487 | || (fmt.majorVersion() == 3
| 0 | ||||||||||||||||||||||||||||||
| 488 | || fmt.profile() == QSurfaceFormat::CompatibilityProfile
| 0 | ||||||||||||||||||||||||||||||
| 489 | { | - | ||||||||||||||||||||||||||||||
| 490 | - | |||||||||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||||||||
| 493 | const QTransform& mtx = state()->matrix; | - | ||||||||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||||||||
| 495 | float mv_matrix[4][4] = | - | ||||||||||||||||||||||||||||||
| 496 | { | - | ||||||||||||||||||||||||||||||
| 497 | { float(mtx.m11()), float(mtx.m12()), 0, float(mtx.m13()) }, | - | ||||||||||||||||||||||||||||||
| 498 | { float(mtx.m21()), float(mtx.m22()), 0, float(mtx.m23()) }, | - | ||||||||||||||||||||||||||||||
| 499 | { 0, 0, 1, 0 }, | - | ||||||||||||||||||||||||||||||
| 500 | { float(mtx.dx()), float(mtx.dy()), 0, float(mtx.m33()) } | - | ||||||||||||||||||||||||||||||
| 501 | }; | - | ||||||||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||||||||
| 503 | const QSize sz = d->device->size(); | - | ||||||||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||||||||
| 505 | glMatrixMode(0x1701); | - | ||||||||||||||||||||||||||||||
| 506 | glLoadIdentity(); | - | ||||||||||||||||||||||||||||||
| 507 | glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999); | - | ||||||||||||||||||||||||||||||
| 508 | - | |||||||||||||||||||||||||||||||
| 509 | glMatrixMode(0x1700); | - | ||||||||||||||||||||||||||||||
| 510 | glLoadMatrixf(&mv_matrix[0][0]); | - | ||||||||||||||||||||||||||||||
| 511 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||||||||
| 514 | d->resetGLState(); | - | ||||||||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||||||||
| 516 | - | |||||||||||||||||||||||||||||||
| 517 | - | |||||||||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||||||||
| 519 | d->lastTextureUnitUsed = GLuint(-1); | - | ||||||||||||||||||||||||||||||
| 520 | d->lastTextureUsed = GLuint(-1); | - | ||||||||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||||||||
| 522 | d->dirtyStencilRegion = QRect(0, 0, d->width, d->height); | - | ||||||||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||||||||
| 524 | d->shaderManager->setDirty(); | - | ||||||||||||||||||||||||||||||
| 525 | - | |||||||||||||||||||||||||||||||
| 526 | d->needsSync = true; | - | ||||||||||||||||||||||||||||||
| 527 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||||||||
| 529 | void QOpenGL2PaintEngineExPrivate::resetGLState() | - | ||||||||||||||||||||||||||||||
| 530 | { | - | ||||||||||||||||||||||||||||||
| 531 | activateTextureUnit(GLuint(0)); | - | ||||||||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||||||||
| 533 | funcs.glDisable(0x0BE2); | - | ||||||||||||||||||||||||||||||
| 534 | funcs.glDisable(0x0B90); | - | ||||||||||||||||||||||||||||||
| 535 | funcs.glDisable(0x0B71); | - | ||||||||||||||||||||||||||||||
| 536 | funcs.glDisable(0x0C11); | - | ||||||||||||||||||||||||||||||
| 537 | funcs.glDepthMask(true); | - | ||||||||||||||||||||||||||||||
| 538 | funcs.glDepthFunc(0x0201); | - | ||||||||||||||||||||||||||||||
| 539 | funcs.glClearDepthf(1); | - | ||||||||||||||||||||||||||||||
| 540 | funcs.glStencilMask(0xff); | - | ||||||||||||||||||||||||||||||
| 541 | funcs.glStencilOp(0x1E00, 0x1E00, 0x1E00); | - | ||||||||||||||||||||||||||||||
| 542 | funcs.glStencilFunc(0x0207, 0, 0xff); | - | ||||||||||||||||||||||||||||||
| 543 | setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false); | - | ||||||||||||||||||||||||||||||
| 544 | setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, false); | - | ||||||||||||||||||||||||||||||
| 545 | setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); | - | ||||||||||||||||||||||||||||||
| 546 | if (!QOpenGLContext::currentContext()->isOpenGLES()
| 0 | ||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||
| 548 | float color[] = { 1.0f, 1.0f, 1.0f, 1.0f }; | - | ||||||||||||||||||||||||||||||
| 549 | funcs.glVertexAttrib4fv(3, color); | - | ||||||||||||||||||||||||||||||
| 550 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 551 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 552 | - | |||||||||||||||||||||||||||||||
| 553 | void QOpenGL2PaintEngineEx::endNativePainting() | - | ||||||||||||||||||||||||||||||
| 554 | { | - | ||||||||||||||||||||||||||||||
| 555 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 556 | d->needsSync = true; | - | ||||||||||||||||||||||||||||||
| 557 | d->nativePaintingActive = false; | - | ||||||||||||||||||||||||||||||
| 558 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 559 | - | |||||||||||||||||||||||||||||||
| 560 | void QOpenGL2PaintEngineEx::invalidateState() | - | ||||||||||||||||||||||||||||||
| 561 | { | - | ||||||||||||||||||||||||||||||
| 562 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 563 | d->needsSync = true; | - | ||||||||||||||||||||||||||||||
| 564 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||||||||
| 566 | bool QOpenGL2PaintEngineEx::isNativePaintingActive() const { | - | ||||||||||||||||||||||||||||||
| 567 | const QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 568 | return never executed: d->nativePaintingActive;return d->nativePaintingActive;never executed: return d->nativePaintingActive; | 0 | ||||||||||||||||||||||||||||||
| 569 | } | - | ||||||||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||||||||
| 571 | void QOpenGL2PaintEngineExPrivate::transferMode(EngineMode newMode) | - | ||||||||||||||||||||||||||||||
| 572 | { | - | ||||||||||||||||||||||||||||||
| 573 | if (newMode == mode
| 0 | ||||||||||||||||||||||||||||||
| 574 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||||||||
| 576 | if (newMode == TextDrawingMode
| 0 | ||||||||||||||||||||||||||||||
| 577 | shaderManager->setHasComplexGeometry(true); | - | ||||||||||||||||||||||||||||||
| 578 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 579 | shaderManager->setHasComplexGeometry(false); | - | ||||||||||||||||||||||||||||||
| 580 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 581 | - | |||||||||||||||||||||||||||||||
| 582 | if (newMode == ImageDrawingMode
| 0 | ||||||||||||||||||||||||||||||
| 583 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray); | - | ||||||||||||||||||||||||||||||
| 584 | setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, staticTextureCoordinateArray); | - | ||||||||||||||||||||||||||||||
| 585 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||||||||
| 587 | if (newMode == ImageArrayDrawingMode
| 0 | ||||||||||||||||||||||||||||||
| 588 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data()); | - | ||||||||||||||||||||||||||||||
| 589 | setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data()); | - | ||||||||||||||||||||||||||||||
| 590 | - | |||||||||||||||||||||||||||||||
| 591 | if (newMode == ImageOpacityArrayDrawingMode
| 0 | ||||||||||||||||||||||||||||||
| 592 | setVertexAttributePointer(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data()); never executed: setVertexAttributePointer(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data()); | 0 | ||||||||||||||||||||||||||||||
| 593 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 594 | - | |||||||||||||||||||||||||||||||
| 595 | - | |||||||||||||||||||||||||||||||
| 596 | if (newMode != TextDrawingMode
| 0 | ||||||||||||||||||||||||||||||
| 597 | shaderManager->setMaskType(QOpenGLEngineShaderManager::NoMask); never executed: shaderManager->setMaskType(QOpenGLEngineShaderManager::NoMask); | 0 | ||||||||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||||||||
| 599 | mode = newMode; | - | ||||||||||||||||||||||||||||||
| 600 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 601 | - | |||||||||||||||||||||||||||||||
| 602 | struct QOpenGL2PEVectorPathCache | - | ||||||||||||||||||||||||||||||
| 603 | { | - | ||||||||||||||||||||||||||||||
| 604 | - | |||||||||||||||||||||||||||||||
| 605 | - | |||||||||||||||||||||||||||||||
| 606 | - | |||||||||||||||||||||||||||||||
| 607 | - | |||||||||||||||||||||||||||||||
| 608 | float *vertices; | - | ||||||||||||||||||||||||||||||
| 609 | void *indices; | - | ||||||||||||||||||||||||||||||
| 610 | - | |||||||||||||||||||||||||||||||
| 611 | int vertexCount; | - | ||||||||||||||||||||||||||||||
| 612 | int indexCount; | - | ||||||||||||||||||||||||||||||
| 613 | GLenum primitiveType; | - | ||||||||||||||||||||||||||||||
| 614 | qreal iscale; | - | ||||||||||||||||||||||||||||||
| 615 | QVertexIndexVector::Type indexType; | - | ||||||||||||||||||||||||||||||
| 616 | }; | - | ||||||||||||||||||||||||||||||
| 617 | - | |||||||||||||||||||||||||||||||
| 618 | void QOpenGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, void *data) | - | ||||||||||||||||||||||||||||||
| 619 | { | - | ||||||||||||||||||||||||||||||
| 620 | QOpenGL2PEVectorPathCache *c = (QOpenGL2PEVectorPathCache *) data; | - | ||||||||||||||||||||||||||||||
| 621 | - | |||||||||||||||||||||||||||||||
| 622 | - | |||||||||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||||||||
| 624 | - | |||||||||||||||||||||||||||||||
| 625 | - | |||||||||||||||||||||||||||||||
| 626 | - | |||||||||||||||||||||||||||||||
| 627 | (void)engine;; | - | ||||||||||||||||||||||||||||||
| 628 | free(c->vertices); | - | ||||||||||||||||||||||||||||||
| 629 | free(c->indices); | - | ||||||||||||||||||||||||||||||
| 630 | - | |||||||||||||||||||||||||||||||
| 631 | delete c; | - | ||||||||||||||||||||||||||||||
| 632 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 633 | - | |||||||||||||||||||||||||||||||
| 634 | - | |||||||||||||||||||||||||||||||
| 635 | void QOpenGL2PaintEngineExPrivate::fill(const QVectorPath& path) | - | ||||||||||||||||||||||||||||||
| 636 | { | - | ||||||||||||||||||||||||||||||
| 637 | transferMode(BrushDrawingMode); | - | ||||||||||||||||||||||||||||||
| 638 | - | |||||||||||||||||||||||||||||||
| 639 | if (snapToPixelGrid
| 0 | ||||||||||||||||||||||||||||||
| 640 | snapToPixelGrid = false; | - | ||||||||||||||||||||||||||||||
| 641 | matrixDirty = true; | - | ||||||||||||||||||||||||||||||
| 642 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 643 | - | |||||||||||||||||||||||||||||||
| 644 | - | |||||||||||||||||||||||||||||||
| 645 | if (matrixDirty
| 0 | ||||||||||||||||||||||||||||||
| 646 | updateMatrix(); never executed: updateMatrix(); | 0 | ||||||||||||||||||||||||||||||
| 647 | - | |||||||||||||||||||||||||||||||
| 648 | const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); | - | ||||||||||||||||||||||||||||||
| 649 | - | |||||||||||||||||||||||||||||||
| 650 | - | |||||||||||||||||||||||||||||||
| 651 | if (path.shape() == QVectorPath::RectangleHint
| 0 | ||||||||||||||||||||||||||||||
| 652 | QOpenGLRect rect(points[0].x(), points[0].y(), points[2].x(), points[2].y()); | - | ||||||||||||||||||||||||||||||
| 653 | prepareForDraw(currentBrush.isOpaque()); | - | ||||||||||||||||||||||||||||||
| 654 | composite(rect); | - | ||||||||||||||||||||||||||||||
| 655 | } never executed: else if (path.isConvex()end of block
| 0 | ||||||||||||||||||||||||||||||
| 656 | - | |||||||||||||||||||||||||||||||
| 657 | if (path.isCacheable()
| 0 | ||||||||||||||||||||||||||||||
| 658 | QVectorPath::CacheEntry *data = path.lookupCacheData(q); | - | ||||||||||||||||||||||||||||||
| 659 | QOpenGL2PEVectorPathCache *cache; | - | ||||||||||||||||||||||||||||||
| 660 | - | |||||||||||||||||||||||||||||||
| 661 | bool updateCache = false; | - | ||||||||||||||||||||||||||||||
| 662 | - | |||||||||||||||||||||||||||||||
| 663 | if (data
| 0 | ||||||||||||||||||||||||||||||
| 664 | cache = (QOpenGL2PEVectorPathCache *) data->data; | - | ||||||||||||||||||||||||||||||
| 665 | - | |||||||||||||||||||||||||||||||
| 666 | if (path.isCurved()
| 0 | ||||||||||||||||||||||||||||||
| 667 | qreal scaleFactor = cache->iscale / inverseScale; | - | ||||||||||||||||||||||||||||||
| 668 | if (scaleFactor < 0.5
| 0 | ||||||||||||||||||||||||||||||
| 669 | - | |||||||||||||||||||||||||||||||
| 670 | - | |||||||||||||||||||||||||||||||
| 671 | - | |||||||||||||||||||||||||||||||
| 672 | - | |||||||||||||||||||||||||||||||
| 673 | - | |||||||||||||||||||||||||||||||
| 674 | free(cache->vertices); | - | ||||||||||||||||||||||||||||||
| 675 | ((!(cache->indices == 0)) ? qt_assert("cache->indices == 0",__FILE__,791) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||||||||
| 677 | updateCache = true; | - | ||||||||||||||||||||||||||||||
| 678 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 679 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 680 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 681 | cache = new QOpenGL2PEVectorPathCache; | - | ||||||||||||||||||||||||||||||
| 682 | data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath); | - | ||||||||||||||||||||||||||||||
| 683 | updateCache = true; | - | ||||||||||||||||||||||||||||||
| 684 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 685 | - | |||||||||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||||||||
| 687 | if (updateCache
| 0 | ||||||||||||||||||||||||||||||
| 688 | vertexCoordinateArray.clear(); | - | ||||||||||||||||||||||||||||||
| 689 | vertexCoordinateArray.addPath(path, inverseScale, false); | - | ||||||||||||||||||||||||||||||
| 690 | int vertexCount = vertexCoordinateArray.vertexCount(); | - | ||||||||||||||||||||||||||||||
| 691 | int floatSizeInBytes = vertexCount * 2 * sizeof(float); | - | ||||||||||||||||||||||||||||||
| 692 | cache->vertexCount = vertexCount; | - | ||||||||||||||||||||||||||||||
| 693 | cache->indexCount = 0; | - | ||||||||||||||||||||||||||||||
| 694 | cache->primitiveType = 0x0006; | - | ||||||||||||||||||||||||||||||
| 695 | cache->iscale = inverseScale; | - | ||||||||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||||||||
| 698 | - | |||||||||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||||||||
| 702 | cache->vertices = (float *) malloc(floatSizeInBytes); | - | ||||||||||||||||||||||||||||||
| 703 | memcpy(cache->vertices, vertexCoordinateArray.data(), floatSizeInBytes); | - | ||||||||||||||||||||||||||||||
| 704 | cache->indices = 0; | - | ||||||||||||||||||||||||||||||
| 705 | - | |||||||||||||||||||||||||||||||
| 706 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||||||||
| 708 | prepareForDraw(currentBrush.isOpaque()); | - | ||||||||||||||||||||||||||||||
| 709 | - | |||||||||||||||||||||||||||||||
| 710 | - | |||||||||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||||||||
| 712 | - | |||||||||||||||||||||||||||||||
| 713 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); | - | ||||||||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||||||||
| 715 | funcs.glDrawArrays(cache->primitiveType, 0, cache->vertexCount); | - | ||||||||||||||||||||||||||||||
| 716 | - | |||||||||||||||||||||||||||||||
| 717 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 718 | - | |||||||||||||||||||||||||||||||
| 719 | - | |||||||||||||||||||||||||||||||
| 720 | path.makeCacheable(); | - | ||||||||||||||||||||||||||||||
| 721 | vertexCoordinateArray.clear(); | - | ||||||||||||||||||||||||||||||
| 722 | vertexCoordinateArray.addPath(path, inverseScale, false); | - | ||||||||||||||||||||||||||||||
| 723 | prepareForDraw(currentBrush.isOpaque()); | - | ||||||||||||||||||||||||||||||
| 724 | drawVertexArrays(vertexCoordinateArray, 0x0006); | - | ||||||||||||||||||||||||||||||
| 725 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 726 | - | |||||||||||||||||||||||||||||||
| 727 | } else { | - | ||||||||||||||||||||||||||||||
| 728 | bool useCache = path.isCacheable(); | - | ||||||||||||||||||||||||||||||
| 729 | if (useCache
| 0 | ||||||||||||||||||||||||||||||
| 730 | QRectF bbox = path.controlPointRect(); | - | ||||||||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||||||||
| 732 | useCache &= (
| 0 | ||||||||||||||||||||||||||||||
| 733 | && (
| 0 | ||||||||||||||||||||||||||||||
| 734 | && (
| 0 | ||||||||||||||||||||||||||||||
| 735 | && (
| 0 | ||||||||||||||||||||||||||||||
| 736 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 737 | - | |||||||||||||||||||||||||||||||
| 738 | if (useCache
| 0 | ||||||||||||||||||||||||||||||
| 739 | QVectorPath::CacheEntry *data = path.lookupCacheData(q); | - | ||||||||||||||||||||||||||||||
| 740 | QOpenGL2PEVectorPathCache *cache; | - | ||||||||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||||||||
| 742 | bool updateCache = false; | - | ||||||||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||||||||
| 744 | if (data
| 0 | ||||||||||||||||||||||||||||||
| 745 | cache = (QOpenGL2PEVectorPathCache *) data->data; | - | ||||||||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||||||||
| 747 | if (path.isCurved()
| 0 | ||||||||||||||||||||||||||||||
| 748 | qreal scaleFactor = cache->iscale / inverseScale; | - | ||||||||||||||||||||||||||||||
| 749 | if (scaleFactor < 0.5
| 0 | ||||||||||||||||||||||||||||||
| 750 | - | |||||||||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||||||||
| 754 | free(cache->vertices); | - | ||||||||||||||||||||||||||||||
| 755 | free(cache->indices); | - | ||||||||||||||||||||||||||||||
| 756 | - | |||||||||||||||||||||||||||||||
| 757 | updateCache = true; | - | ||||||||||||||||||||||||||||||
| 758 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 759 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 760 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 761 | cache = new QOpenGL2PEVectorPathCache; | - | ||||||||||||||||||||||||||||||
| 762 | data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath); | - | ||||||||||||||||||||||||||||||
| 763 | updateCache = true; | - | ||||||||||||||||||||||||||||||
| 764 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||||||||
| 766 | - | |||||||||||||||||||||||||||||||
| 767 | if (updateCache
| 0 | ||||||||||||||||||||||||||||||
| 768 | QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); | - | ||||||||||||||||||||||||||||||
| 769 | cache->vertexCount = polys.vertices.size() / 2; | - | ||||||||||||||||||||||||||||||
| 770 | cache->indexCount = polys.indices.size(); | - | ||||||||||||||||||||||||||||||
| 771 | cache->primitiveType = 0x0004; | - | ||||||||||||||||||||||||||||||
| 772 | cache->iscale = inverseScale; | - | ||||||||||||||||||||||||||||||
| 773 | cache->indexType = polys.indices.type(); | - | ||||||||||||||||||||||||||||||
| 774 | cache->vertices = (float *) malloc(sizeof(float) * polys.vertices.size()); | - | ||||||||||||||||||||||||||||||
| 775 | if (polys.indices.type() == QVertexIndexVector::UnsignedInt
| 0 | ||||||||||||||||||||||||||||||
| 776 | cache->indices = (quint32 *) malloc(sizeof(quint32) * polys.indices.size()); | - | ||||||||||||||||||||||||||||||
| 777 | memcpy(cache->indices, polys.indices.data(), sizeof(quint32) * polys.indices.size()); | - | ||||||||||||||||||||||||||||||
| 778 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 779 | cache->indices = (quint16 *) malloc(sizeof(quint16) * polys.indices.size()); | - | ||||||||||||||||||||||||||||||
| 780 | memcpy(cache->indices, polys.indices.data(), sizeof(quint16) * polys.indices.size()); | - | ||||||||||||||||||||||||||||||
| 781 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 782 | for (int i = 0; i < polys.vertices.size()
| 0 | ||||||||||||||||||||||||||||||
| 783 | cache->vertices[i] = float(inverseScale * polys.vertices.at(i)); never executed: cache->vertices[i] = float(inverseScale * polys.vertices.at(i)); | 0 | ||||||||||||||||||||||||||||||
| 784 | - | |||||||||||||||||||||||||||||||
| 785 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 786 | - | |||||||||||||||||||||||||||||||
| 787 | prepareForDraw(currentBrush.isOpaque()); | - | ||||||||||||||||||||||||||||||
| 788 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); | - | ||||||||||||||||||||||||||||||
| 789 | if (cache->indexType == QVertexIndexVector::UnsignedInt
| 0 | ||||||||||||||||||||||||||||||
| 790 | funcs.glDrawElements(cache->primitiveType, cache->indexCount, 0x1405, (qint32 *)cache->indices); never executed: funcs.glDrawElements(cache->primitiveType, cache->indexCount, 0x1405, (qint32 *)cache->indices); | 0 | ||||||||||||||||||||||||||||||
| 791 | else | - | ||||||||||||||||||||||||||||||
| 792 | funcs.glDrawElements(cache->primitiveType, cache->indexCount, 0x1403, (qint16 *)cache->indices); never executed: funcs.glDrawElements(cache->primitiveType, cache->indexCount, 0x1403, (qint16 *)cache->indices); | 0 | ||||||||||||||||||||||||||||||
| 793 | - | |||||||||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||||||||
| 795 | } else { | - | ||||||||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||||||||
| 798 | path.makeCacheable(); | - | ||||||||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||||||||
| 800 | if (device->context()->format().stencilBufferSize() <= 0
| 0 | ||||||||||||||||||||||||||||||
| 801 | - | |||||||||||||||||||||||||||||||
| 802 | - | |||||||||||||||||||||||||||||||
| 803 | QRectF bbox = path.controlPointRect(); | - | ||||||||||||||||||||||||||||||
| 804 | - | |||||||||||||||||||||||||||||||
| 805 | bool withinLimits = (
| 0 | ||||||||||||||||||||||||||||||
| 806 | && (
| 0 | ||||||||||||||||||||||||||||||
| 807 | && (
| 0 | ||||||||||||||||||||||||||||||
| 808 | && (
| 0 | ||||||||||||||||||||||||||||||
| 809 | if (withinLimits
| 0 | ||||||||||||||||||||||||||||||
| 810 | QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); | - | ||||||||||||||||||||||||||||||
| 811 | - | |||||||||||||||||||||||||||||||
| 812 | QVarLengthArray<float> vertices(polys.vertices.size()); | - | ||||||||||||||||||||||||||||||
| 813 | for (int i = 0; i < polys.vertices.size()
| 0 | ||||||||||||||||||||||||||||||
| 814 | vertices[i] = float(inverseScale * polys.vertices.at(i)); never executed: vertices[i] = float(inverseScale * polys.vertices.at(i)); | 0 | ||||||||||||||||||||||||||||||
| 815 | - | |||||||||||||||||||||||||||||||
| 816 | prepareForDraw(currentBrush.isOpaque()); | - | ||||||||||||||||||||||||||||||
| 817 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, vertices.constData()); | - | ||||||||||||||||||||||||||||||
| 818 | if (funcs.hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint)
| 0 | ||||||||||||||||||||||||||||||
| 819 | funcs.glDrawElements(0x0004, polys.indices.size(), 0x1405, polys.indices.data()); never executed: funcs.glDrawElements(0x0004, polys.indices.size(), 0x1405, polys.indices.data()); | 0 | ||||||||||||||||||||||||||||||
| 820 | else | - | ||||||||||||||||||||||||||||||
| 821 | funcs.glDrawElements(0x0004, polys.indices.size(), 0x1403, polys.indices.data()); never executed: funcs.glDrawElements(0x0004, polys.indices.size(), 0x1403, polys.indices.data()); | 0 | ||||||||||||||||||||||||||||||
| 822 | } else { | - | ||||||||||||||||||||||||||||||
| 823 | - | |||||||||||||||||||||||||||||||
| 824 | QMessageLogger(__FILE__, 967, __PRETTY_FUNCTION__).warning("Painter path exceeds +/-32767 pixels."); | - | ||||||||||||||||||||||||||||||
| 825 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 826 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 827 | } | - | ||||||||||||||||||||||||||||||
| 828 | - | |||||||||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||||||||
| 830 | vertexCoordinateArray.clear(); | - | ||||||||||||||||||||||||||||||
| 831 | vertexCoordinateArray.addPath(path, inverseScale, false); | - | ||||||||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||||||||
| 833 | fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill()); | - | ||||||||||||||||||||||||||||||
| 834 | - | |||||||||||||||||||||||||||||||
| 835 | funcs.glStencilMask(0xff); | - | ||||||||||||||||||||||||||||||
| 836 | funcs.glStencilOp(0x1E00, 0x1E01, 0x1E01); | - | ||||||||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||||||||
| 838 | if (q->state()->clipTestEnabled
| 0 | ||||||||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||||||||
| 840 | funcs.glStencilFunc(0x0205, q->state()->currentClip, GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 841 | } never executed: else if (path.hasWindingFill()end of block
| 0 | ||||||||||||||||||||||||||||||
| 842 | - | |||||||||||||||||||||||||||||||
| 843 | funcs.glStencilFunc(0x0205, 0, 0xff); | - | ||||||||||||||||||||||||||||||
| 844 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 845 | - | |||||||||||||||||||||||||||||||
| 846 | funcs.glStencilFunc(0x0205, 0, GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 847 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 848 | prepareForDraw(currentBrush.isOpaque()); | - | ||||||||||||||||||||||||||||||
| 849 | - | |||||||||||||||||||||||||||||||
| 850 | - | |||||||||||||||||||||||||||||||
| 851 | composite(vertexCoordinateArray.boundingRect()); | - | ||||||||||||||||||||||||||||||
| 852 | funcs.glStencilMask(0); | - | ||||||||||||||||||||||||||||||
| 853 | updateClipScissorTest(); | - | ||||||||||||||||||||||||||||||
| 854 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 855 | } | - | ||||||||||||||||||||||||||||||
| 856 | } | - | ||||||||||||||||||||||||||||||
| 857 | - | |||||||||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||||||||
| 859 | void QOpenGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, | - | ||||||||||||||||||||||||||||||
| 860 | int count, | - | ||||||||||||||||||||||||||||||
| 861 | int *stops, | - | ||||||||||||||||||||||||||||||
| 862 | int stopCount, | - | ||||||||||||||||||||||||||||||
| 863 | const QOpenGLRect &bounds, | - | ||||||||||||||||||||||||||||||
| 864 | StencilFillMode mode) | - | ||||||||||||||||||||||||||||||
| 865 | { | - | ||||||||||||||||||||||||||||||
| 866 | ((!(count || stops)) ? qt_assert("count || stops",__FILE__,1009) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 867 | - | |||||||||||||||||||||||||||||||
| 868 | - | |||||||||||||||||||||||||||||||
| 869 | funcs.glStencilMask(0xff); | - | ||||||||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||||||||
| 871 | if (dirtyStencilRegion.intersects(currentScissorBounds)
| 0 | ||||||||||||||||||||||||||||||
| 872 | QVector<QRect> clearRegion = dirtyStencilRegion.intersected(currentScissorBounds).rects(); | - | ||||||||||||||||||||||||||||||
| 873 | funcs.glClearStencil(0); | - | ||||||||||||||||||||||||||||||
| 874 | for (int i = 0; i < clearRegion.size()
| 0 | ||||||||||||||||||||||||||||||
| 875 | - | |||||||||||||||||||||||||||||||
| 876 | setScissor(clearRegion.at(i)); | - | ||||||||||||||||||||||||||||||
| 877 | - | |||||||||||||||||||||||||||||||
| 878 | funcs.glClear(0x00000400); | - | ||||||||||||||||||||||||||||||
| 879 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 880 | - | |||||||||||||||||||||||||||||||
| 881 | dirtyStencilRegion -= currentScissorBounds; | - | ||||||||||||||||||||||||||||||
| 882 | - | |||||||||||||||||||||||||||||||
| 883 | - | |||||||||||||||||||||||||||||||
| 884 | updateClipScissorTest(); | - | ||||||||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||||||||
| 886 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||||||||
| 888 | funcs.glColorMask(0, 0, 0, 0); | - | ||||||||||||||||||||||||||||||
| 889 | useSimpleShader(); | - | ||||||||||||||||||||||||||||||
| 890 | funcs.glEnable(0x0B90); | - | ||||||||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||||||||
| 892 | if (mode == WindingFillMode
| 0 | ||||||||||||||||||||||||||||||
| 893 | ((!(stops && !count)) ? qt_assert("stops && !count",__FILE__,1036) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 894 | if (q->state()->clipTestEnabled
| 0 | ||||||||||||||||||||||||||||||
| 895 | - | |||||||||||||||||||||||||||||||
| 896 | funcs.glStencilFunc(0x0203, GLuint(0x80) | q->state()->currentClip, ~GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 897 | funcs.glStencilOp(0x1E00, 0x1E01, 0x1E01); | - | ||||||||||||||||||||||||||||||
| 898 | composite(bounds); | - | ||||||||||||||||||||||||||||||
| 899 | - | |||||||||||||||||||||||||||||||
| 900 | funcs.glStencilFunc(0x0202, GLuint(0x80), GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 901 | } never executed: else if (!stencilCleanend of block
| 0 | ||||||||||||||||||||||||||||||
| 902 | - | |||||||||||||||||||||||||||||||
| 903 | funcs.glStencilFunc(0x0207, 0, 0xff); | - | ||||||||||||||||||||||||||||||
| 904 | funcs.glStencilOp(0, 0, 0); | - | ||||||||||||||||||||||||||||||
| 905 | composite(bounds); | - | ||||||||||||||||||||||||||||||
| 906 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 907 | - | |||||||||||||||||||||||||||||||
| 908 | - | |||||||||||||||||||||||||||||||
| 909 | funcs.glStencilOpSeparate(0x0404, 0x1E00, 0x8507, 0x8507); | - | ||||||||||||||||||||||||||||||
| 910 | - | |||||||||||||||||||||||||||||||
| 911 | funcs.glStencilOpSeparate(0x0405, 0x1E00, 0x8508, 0x8508); | - | ||||||||||||||||||||||||||||||
| 912 | funcs.glStencilMask(~GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 913 | drawVertexArrays(data, stops, stopCount, 0x0006); | - | ||||||||||||||||||||||||||||||
| 914 | - | |||||||||||||||||||||||||||||||
| 915 | if (q->state()->clipTestEnabled
| 0 | ||||||||||||||||||||||||||||||
| 916 | - | |||||||||||||||||||||||||||||||
| 917 | funcs.glStencilFunc(0x0202, q->state()->currentClip, ~GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 918 | funcs.glStencilOp(0x1E00, 0x1E01, 0x1E01); | - | ||||||||||||||||||||||||||||||
| 919 | funcs.glStencilMask(GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 920 | composite(bounds); | - | ||||||||||||||||||||||||||||||
| 921 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 922 | } never executed: else if (mode == OddEvenFillModeend of block
| 0 | ||||||||||||||||||||||||||||||
| 923 | funcs.glStencilMask(GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 924 | funcs.glStencilOp(0x1E00, 0x1E00, 0x150A); | - | ||||||||||||||||||||||||||||||
| 925 | drawVertexArrays(data, stops, stopCount, 0x0006); | - | ||||||||||||||||||||||||||||||
| 926 | - | |||||||||||||||||||||||||||||||
| 927 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 928 | ((!(count && !stops)) ? qt_assert("count && !stops",__FILE__,1071) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 929 | funcs.glStencilMask(GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 930 | - | |||||||||||||||||||||||||||||||
| 931 | - | |||||||||||||||||||||||||||||||
| 932 | - | |||||||||||||||||||||||||||||||
| 933 | - | |||||||||||||||||||||||||||||||
| 934 | - | |||||||||||||||||||||||||||||||
| 935 | - | |||||||||||||||||||||||||||||||
| 936 | funcs.glStencilOp(0x1E00, 0x1E00, 0x1E01); | - | ||||||||||||||||||||||||||||||
| 937 | if (q->state()->clipTestEnabled
| 0 | ||||||||||||||||||||||||||||||
| 938 | funcs.glStencilFunc(0x0203, q->state()->currentClip | GLuint(0x80), | - | ||||||||||||||||||||||||||||||
| 939 | ~GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 940 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 941 | funcs.glStencilFunc(0x0207, GLuint(0x80), 0xff); | - | ||||||||||||||||||||||||||||||
| 942 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 943 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data); | - | ||||||||||||||||||||||||||||||
| 944 | funcs.glDrawArrays(0x0005, 0, count); | - | ||||||||||||||||||||||||||||||
| 945 | - | |||||||||||||||||||||||||||||||
| 946 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 947 | - | |||||||||||||||||||||||||||||||
| 948 | - | |||||||||||||||||||||||||||||||
| 949 | funcs.glColorMask(1, 1, 1, 1); | - | ||||||||||||||||||||||||||||||
| 950 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 951 | - | |||||||||||||||||||||||||||||||
| 952 | - | |||||||||||||||||||||||||||||||
| 953 | - | |||||||||||||||||||||||||||||||
| 954 | - | |||||||||||||||||||||||||||||||
| 955 | - | |||||||||||||||||||||||||||||||
| 956 | - | |||||||||||||||||||||||||||||||
| 957 | void QOpenGL2PaintEngineExPrivate::resetClipIfNeeded() | - | ||||||||||||||||||||||||||||||
| 958 | { | - | ||||||||||||||||||||||||||||||
| 959 | if (maxClip != (GLuint(0x80) - 1)
| 0 | ||||||||||||||||||||||||||||||
| 960 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 961 | - | |||||||||||||||||||||||||||||||
| 962 | QOpenGL2PaintEngineEx * const q = q_func(); | - | ||||||||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||||||||
| 964 | useSimpleShader(); | - | ||||||||||||||||||||||||||||||
| 965 | funcs.glEnable(0x0B90); | - | ||||||||||||||||||||||||||||||
| 966 | funcs.glColorMask(0, 0, 0, 0); | - | ||||||||||||||||||||||||||||||
| 967 | - | |||||||||||||||||||||||||||||||
| 968 | QRectF bounds = q->state()->matrix.inverted().mapRect(QRectF(0, 0, width, height)); | - | ||||||||||||||||||||||||||||||
| 969 | QOpenGLRect rect(bounds.left(), bounds.top(), bounds.right(), bounds.bottom()); | - | ||||||||||||||||||||||||||||||
| 970 | - | |||||||||||||||||||||||||||||||
| 971 | - | |||||||||||||||||||||||||||||||
| 972 | funcs.glStencilFunc(0x0203, q->state()->currentClip, 0xff); | - | ||||||||||||||||||||||||||||||
| 973 | funcs.glStencilOp(0x1E00, 0x150A, 0x150A); | - | ||||||||||||||||||||||||||||||
| 974 | funcs.glStencilMask(GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 975 | composite(rect); | - | ||||||||||||||||||||||||||||||
| 976 | - | |||||||||||||||||||||||||||||||
| 977 | - | |||||||||||||||||||||||||||||||
| 978 | funcs.glStencilFunc(0x0205, 0x01, GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 979 | funcs.glStencilOp(0, 0x1E01, 0x1E01); | - | ||||||||||||||||||||||||||||||
| 980 | funcs.glStencilMask(0xff); | - | ||||||||||||||||||||||||||||||
| 981 | composite(rect); | - | ||||||||||||||||||||||||||||||
| 982 | - | |||||||||||||||||||||||||||||||
| 983 | q->state()->currentClip = 1; | - | ||||||||||||||||||||||||||||||
| 984 | q->state()->canRestoreClip = false; | - | ||||||||||||||||||||||||||||||
| 985 | - | |||||||||||||||||||||||||||||||
| 986 | maxClip = 1; | - | ||||||||||||||||||||||||||||||
| 987 | - | |||||||||||||||||||||||||||||||
| 988 | funcs.glStencilMask(0x0); | - | ||||||||||||||||||||||||||||||
| 989 | funcs.glColorMask(1, 1, 1, 1); | - | ||||||||||||||||||||||||||||||
| 990 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 991 | - | |||||||||||||||||||||||||||||||
| 992 | bool QOpenGL2PaintEngineExPrivate::prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache) | - | ||||||||||||||||||||||||||||||
| 993 | { | - | ||||||||||||||||||||||||||||||
| 994 | QOpenGL2PaintEngineEx * const q = q_func(); | - | ||||||||||||||||||||||||||||||
| 995 | - | |||||||||||||||||||||||||||||||
| 996 | ((!(cache.transform().type() <= QTransform::TxScale)) ? qt_assert("cache.transform().type() <= QTransform::TxScale",__FILE__,1139) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 997 | - | |||||||||||||||||||||||||||||||
| 998 | QTransform &transform = q->state()->matrix; | - | ||||||||||||||||||||||||||||||
| 999 | transform.scale(1.0 / cache.transform().m11(), 1.0 / cache.transform().m22()); | - | ||||||||||||||||||||||||||||||
| 1000 | bool ret = prepareForDraw(false); | - | ||||||||||||||||||||||||||||||
| 1001 | transform.scale(cache.transform().m11(), cache.transform().m22()); | - | ||||||||||||||||||||||||||||||
| 1002 | - | |||||||||||||||||||||||||||||||
| 1003 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||||||||
| 1004 | } | - | ||||||||||||||||||||||||||||||
| 1005 | - | |||||||||||||||||||||||||||||||
| 1006 | bool QOpenGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) | - | ||||||||||||||||||||||||||||||
| 1007 | { | - | ||||||||||||||||||||||||||||||
| 1008 | if (brushTextureDirty
| 0 | ||||||||||||||||||||||||||||||
| 1009 | updateBrushTexture(); never executed: updateBrushTexture(); | 0 | ||||||||||||||||||||||||||||||
| 1010 | - | |||||||||||||||||||||||||||||||
| 1011 | if (compositionModeDirty
| 0 | ||||||||||||||||||||||||||||||
| 1012 | updateCompositionMode(); never executed: updateCompositionMode(); | 0 | ||||||||||||||||||||||||||||||
| 1013 | - | |||||||||||||||||||||||||||||||
| 1014 | if (matrixDirty
| 0 | ||||||||||||||||||||||||||||||
| 1015 | updateMatrix(); never executed: updateMatrix(); | 0 | ||||||||||||||||||||||||||||||
| 1016 | - | |||||||||||||||||||||||||||||||
| 1017 | const bool stateHasOpacity = q->state()->opacity < 0.99f; | - | ||||||||||||||||||||||||||||||
| 1018 | if (q->state()->composition_mode == QPainter::CompositionMode_Source
| 0 | ||||||||||||||||||||||||||||||
| 1019 | || (q->state()->composition_mode == QPainter::CompositionMode_SourceOver
| 0 | ||||||||||||||||||||||||||||||
| 1020 | && srcPixelsAreOpaque
| 0 | ||||||||||||||||||||||||||||||
| 1021 | { | - | ||||||||||||||||||||||||||||||
| 1022 | funcs.glDisable(0x0BE2); | - | ||||||||||||||||||||||||||||||
| 1023 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1024 | funcs.glEnable(0x0BE2); | - | ||||||||||||||||||||||||||||||
| 1025 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1026 | - | |||||||||||||||||||||||||||||||
| 1027 | QOpenGLEngineShaderManager::OpacityMode opacityMode; | - | ||||||||||||||||||||||||||||||
| 1028 | if (mode == ImageOpacityArrayDrawingMode
| 0 | ||||||||||||||||||||||||||||||
| 1029 | opacityMode = QOpenGLEngineShaderManager::AttributeOpacity; | - | ||||||||||||||||||||||||||||||
| 1030 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1031 | opacityMode = stateHasOpacity
| 0 | ||||||||||||||||||||||||||||||
| 1032 | : QOpenGLEngineShaderManager::NoOpacity; | - | ||||||||||||||||||||||||||||||
| 1033 | if (stateHasOpacity
| 0 | ||||||||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||||||||
| 1035 | bool brushIsPattern = (
| 0 | ||||||||||||||||||||||||||||||
| 1036 | (
| 0 | ||||||||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||||||||
| 1038 | if ((
| 0 | ||||||||||||||||||||||||||||||
| 1039 | opacityMode = QOpenGLEngineShaderManager::NoOpacity; never executed: opacityMode = QOpenGLEngineShaderManager::NoOpacity; | 0 | ||||||||||||||||||||||||||||||
| 1040 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1041 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1042 | shaderManager->setOpacityMode(opacityMode); | - | ||||||||||||||||||||||||||||||
| 1043 | - | |||||||||||||||||||||||||||||||
| 1044 | bool changed = shaderManager->useCorrectShaderProg(); | - | ||||||||||||||||||||||||||||||
| 1045 | - | |||||||||||||||||||||||||||||||
| 1046 | if (changed
| 0 | ||||||||||||||||||||||||||||||
| 1047 | - | |||||||||||||||||||||||||||||||
| 1048 | brushUniformsDirty = true; | - | ||||||||||||||||||||||||||||||
| 1049 | opacityUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 1050 | matrixUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 1051 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1052 | - | |||||||||||||||||||||||||||||||
| 1053 | if (brushUniformsDirty
| 0 | ||||||||||||||||||||||||||||||
| 1054 | updateBrushUniforms(); never executed: updateBrushUniforms(); | 0 | ||||||||||||||||||||||||||||||
| 1055 | - | |||||||||||||||||||||||||||||||
| 1056 | if (opacityMode == QOpenGLEngineShaderManager::UniformOpacity
| 0 | ||||||||||||||||||||||||||||||
| 1057 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::GlobalOpacity), (GLfloat)q->state()->opacity); | - | ||||||||||||||||||||||||||||||
| 1058 | opacityUniformDirty = false; | - | ||||||||||||||||||||||||||||||
| 1059 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||||||||
| 1061 | if (matrixUniformDirty
| 0 | ||||||||||||||||||||||||||||||
| 1062 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::Matrix), | - | ||||||||||||||||||||||||||||||
| 1063 | pmvMatrix); | - | ||||||||||||||||||||||||||||||
| 1064 | matrixUniformDirty = false; | - | ||||||||||||||||||||||||||||||
| 1065 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1066 | - | |||||||||||||||||||||||||||||||
| 1067 | return never executed: changed;return changed;never executed: return changed; | 0 | ||||||||||||||||||||||||||||||
| 1068 | } | - | ||||||||||||||||||||||||||||||
| 1069 | - | |||||||||||||||||||||||||||||||
| 1070 | void QOpenGL2PaintEngineExPrivate::composite(const QOpenGLRect& boundingRect) | - | ||||||||||||||||||||||||||||||
| 1071 | { | - | ||||||||||||||||||||||||||||||
| 1072 | setCoords(staticVertexCoordinateArray, boundingRect); | - | ||||||||||||||||||||||||||||||
| 1073 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray); | - | ||||||||||||||||||||||||||||||
| 1074 | funcs.glDrawArrays(0x0006, 0, 4); | - | ||||||||||||||||||||||||||||||
| 1075 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1076 | - | |||||||||||||||||||||||||||||||
| 1077 | - | |||||||||||||||||||||||||||||||
| 1078 | void QOpenGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, int stopCount, | - | ||||||||||||||||||||||||||||||
| 1079 | GLenum primitive) | - | ||||||||||||||||||||||||||||||
| 1080 | { | - | ||||||||||||||||||||||||||||||
| 1081 | - | |||||||||||||||||||||||||||||||
| 1082 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data); | - | ||||||||||||||||||||||||||||||
| 1083 | - | |||||||||||||||||||||||||||||||
| 1084 | int previousStop = 0; | - | ||||||||||||||||||||||||||||||
| 1085 | for (int i=0; i<stopCount
| 0 | ||||||||||||||||||||||||||||||
| 1086 | int stop = stops[i]; | - | ||||||||||||||||||||||||||||||
| 1087 | - | |||||||||||||||||||||||||||||||
| 1088 | - | |||||||||||||||||||||||||||||||
| 1089 | - | |||||||||||||||||||||||||||||||
| 1090 | - | |||||||||||||||||||||||||||||||
| 1091 | - | |||||||||||||||||||||||||||||||
| 1092 | funcs.glDrawArrays(primitive, previousStop, stop - previousStop); | - | ||||||||||||||||||||||||||||||
| 1093 | previousStop = stop; | - | ||||||||||||||||||||||||||||||
| 1094 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1095 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1096 | - | |||||||||||||||||||||||||||||||
| 1097 | - | |||||||||||||||||||||||||||||||
| 1098 | - | |||||||||||||||||||||||||||||||
| 1099 | QOpenGL2PaintEngineEx::QOpenGL2PaintEngineEx() | - | ||||||||||||||||||||||||||||||
| 1100 | : QPaintEngineEx(*(new QOpenGL2PaintEngineExPrivate(this))) | - | ||||||||||||||||||||||||||||||
| 1101 | { | - | ||||||||||||||||||||||||||||||
| 1102 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1103 | - | |||||||||||||||||||||||||||||||
| 1104 | QOpenGL2PaintEngineEx::~QOpenGL2PaintEngineEx() | - | ||||||||||||||||||||||||||||||
| 1105 | { | - | ||||||||||||||||||||||||||||||
| 1106 | } | - | ||||||||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||||||||
| 1108 | void QOpenGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) | - | ||||||||||||||||||||||||||||||
| 1109 | { | - | ||||||||||||||||||||||||||||||
| 1110 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1111 | - | |||||||||||||||||||||||||||||||
| 1112 | if (qbrush_style(brush) == Qt::NoBrush
| 0 | ||||||||||||||||||||||||||||||
| 1113 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1114 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 1115 | d->setBrush(brush); | - | ||||||||||||||||||||||||||||||
| 1116 | d->fill(path); | - | ||||||||||||||||||||||||||||||
| 1117 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1118 | - | |||||||||||||||||||||||||||||||
| 1119 | __attribute__((visibility("default"))) bool qt_scaleForTransform(const QTransform &transform, qreal *scale); | - | ||||||||||||||||||||||||||||||
| 1120 | - | |||||||||||||||||||||||||||||||
| 1121 | - | |||||||||||||||||||||||||||||||
| 1122 | void QOpenGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) | - | ||||||||||||||||||||||||||||||
| 1123 | { | - | ||||||||||||||||||||||||||||||
| 1124 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1125 | - | |||||||||||||||||||||||||||||||
| 1126 | const QBrush &penBrush = qpen_brush(pen); | - | ||||||||||||||||||||||||||||||
| 1127 | if (qpen_style(pen) == Qt::NoPen
| 0 | ||||||||||||||||||||||||||||||
| 1128 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||||||||
| 1130 | QOpenGL2PaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1131 | if (qt_pen_is_cosmetic(pen, state()->renderHints)
| 0 | ||||||||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||||||||
| 1133 | QPaintEngineEx::stroke(path, pen); | - | ||||||||||||||||||||||||||||||
| 1134 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1135 | } | - | ||||||||||||||||||||||||||||||
| 1136 | - | |||||||||||||||||||||||||||||||
| 1137 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 1138 | d->setBrush(penBrush); | - | ||||||||||||||||||||||||||||||
| 1139 | d->stroke(path, pen); | - | ||||||||||||||||||||||||||||||
| 1140 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1141 | - | |||||||||||||||||||||||||||||||
| 1142 | void QOpenGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen) | - | ||||||||||||||||||||||||||||||
| 1143 | { | - | ||||||||||||||||||||||||||||||
| 1144 | const QOpenGL2PaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 1145 | if (snapToPixelGrid
| 0 | ||||||||||||||||||||||||||||||
| 1146 | snapToPixelGrid = false; | - | ||||||||||||||||||||||||||||||
| 1147 | matrixDirty = true; | - | ||||||||||||||||||||||||||||||
| 1148 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1149 | - | |||||||||||||||||||||||||||||||
| 1150 | const Qt::PenStyle penStyle = qpen_style(pen); | - | ||||||||||||||||||||||||||||||
| 1151 | const QBrush &penBrush = qpen_brush(pen); | - | ||||||||||||||||||||||||||||||
| 1152 | const bool opaque = penBrush.isOpaque()
| 0 | ||||||||||||||||||||||||||||||
| 1153 | - | |||||||||||||||||||||||||||||||
| 1154 | transferMode(BrushDrawingMode); | - | ||||||||||||||||||||||||||||||
| 1155 | - | |||||||||||||||||||||||||||||||
| 1156 | - | |||||||||||||||||||||||||||||||
| 1157 | - | |||||||||||||||||||||||||||||||
| 1158 | - | |||||||||||||||||||||||||||||||
| 1159 | updateMatrix(); | - | ||||||||||||||||||||||||||||||
| 1160 | - | |||||||||||||||||||||||||||||||
| 1161 | QRectF clip = q->state()->matrix.inverted().mapRect(q->state()->clipEnabled | - | ||||||||||||||||||||||||||||||
| 1162 | ? q->state()->rectangleClip | - | ||||||||||||||||||||||||||||||
| 1163 | : QRectF(0, 0, width, height)); | - | ||||||||||||||||||||||||||||||
| 1164 | - | |||||||||||||||||||||||||||||||
| 1165 | if (penStyle == Qt::SolidLine
| 0 | ||||||||||||||||||||||||||||||
| 1166 | stroker.process(path, pen, clip, s->renderHints); | - | ||||||||||||||||||||||||||||||
| 1167 | - | |||||||||||||||||||||||||||||||
| 1168 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1169 | dasher.process(path, pen, clip, s->renderHints); | - | ||||||||||||||||||||||||||||||
| 1170 | - | |||||||||||||||||||||||||||||||
| 1171 | QVectorPath dashStroke(dasher.points(), | - | ||||||||||||||||||||||||||||||
| 1172 | dasher.elementCount(), | - | ||||||||||||||||||||||||||||||
| 1173 | dasher.elementTypes(), | - | ||||||||||||||||||||||||||||||
| 1174 | s->renderHints); | - | ||||||||||||||||||||||||||||||
| 1175 | stroker.process(dashStroke, pen, clip, s->renderHints); | - | ||||||||||||||||||||||||||||||
| 1176 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1177 | - | |||||||||||||||||||||||||||||||
| 1178 | if (!stroker.vertexCount()
| 0 | ||||||||||||||||||||||||||||||
| 1179 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1180 | - | |||||||||||||||||||||||||||||||
| 1181 | if (opaque
| 0 | ||||||||||||||||||||||||||||||
| 1182 | prepareForDraw(opaque); | - | ||||||||||||||||||||||||||||||
| 1183 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, stroker.vertices()); | - | ||||||||||||||||||||||||||||||
| 1184 | funcs.glDrawArrays(0x0005, 0, stroker.vertexCount() / 2); | - | ||||||||||||||||||||||||||||||
| 1185 | - | |||||||||||||||||||||||||||||||
| 1186 | - | |||||||||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||||||||
| 1188 | - | |||||||||||||||||||||||||||||||
| 1189 | - | |||||||||||||||||||||||||||||||
| 1190 | - | |||||||||||||||||||||||||||||||
| 1191 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1192 | qreal width = qpen_widthf(pen) / 2; | - | ||||||||||||||||||||||||||||||
| 1193 | if (width == 0
| 0 | ||||||||||||||||||||||||||||||
| 1194 | width = 0.5; never executed: width = 0.5; | 0 | ||||||||||||||||||||||||||||||
| 1195 | qreal extra = pen.joinStyle() == Qt::MiterJoin
| 0 | ||||||||||||||||||||||||||||||
| 1196 | ? qMax(pen.miterLimit() * width, width) | - | ||||||||||||||||||||||||||||||
| 1197 | : width; | - | ||||||||||||||||||||||||||||||
| 1198 | - | |||||||||||||||||||||||||||||||
| 1199 | if (qt_pen_is_cosmetic(pen, q->state()->renderHints)
| 0 | ||||||||||||||||||||||||||||||
| 1200 | extra = extra * inverseScale; never executed: extra = extra * inverseScale; | 0 | ||||||||||||||||||||||||||||||
| 1201 | - | |||||||||||||||||||||||||||||||
| 1202 | QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra); | - | ||||||||||||||||||||||||||||||
| 1203 | - | |||||||||||||||||||||||||||||||
| 1204 | fillStencilWithVertexArray(stroker.vertices(), stroker.vertexCount() / 2, | - | ||||||||||||||||||||||||||||||
| 1205 | 0, 0, bounds, QOpenGL2PaintEngineExPrivate::TriStripStrokeFillMode); | - | ||||||||||||||||||||||||||||||
| 1206 | - | |||||||||||||||||||||||||||||||
| 1207 | funcs.glStencilOp(0x1E00, 0x1E01, 0x1E01); | - | ||||||||||||||||||||||||||||||
| 1208 | - | |||||||||||||||||||||||||||||||
| 1209 | - | |||||||||||||||||||||||||||||||
| 1210 | funcs.glStencilFunc(0x0205, 0, GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 1211 | prepareForDraw(false); | - | ||||||||||||||||||||||||||||||
| 1212 | - | |||||||||||||||||||||||||||||||
| 1213 | - | |||||||||||||||||||||||||||||||
| 1214 | composite(bounds); | - | ||||||||||||||||||||||||||||||
| 1215 | - | |||||||||||||||||||||||||||||||
| 1216 | funcs.glStencilMask(0); | - | ||||||||||||||||||||||||||||||
| 1217 | - | |||||||||||||||||||||||||||||||
| 1218 | updateClipScissorTest(); | - | ||||||||||||||||||||||||||||||
| 1219 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1220 | } | - | ||||||||||||||||||||||||||||||
| 1221 | - | |||||||||||||||||||||||||||||||
| 1222 | void QOpenGL2PaintEngineEx::penChanged() { } | - | ||||||||||||||||||||||||||||||
| 1223 | void QOpenGL2PaintEngineEx::brushChanged() { } | - | ||||||||||||||||||||||||||||||
| 1224 | void QOpenGL2PaintEngineEx::brushOriginChanged() { } | - | ||||||||||||||||||||||||||||||
| 1225 | - | |||||||||||||||||||||||||||||||
| 1226 | void QOpenGL2PaintEngineEx::opacityChanged() | - | ||||||||||||||||||||||||||||||
| 1227 | { | - | ||||||||||||||||||||||||||||||
| 1228 | - | |||||||||||||||||||||||||||||||
| 1229 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1230 | state()->opacityChanged = true; | - | ||||||||||||||||||||||||||||||
| 1231 | - | |||||||||||||||||||||||||||||||
| 1232 | ((!(d->shaderManager)) ? qt_assert("d->shaderManager",__FILE__,1375) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 1233 | d->brushUniformsDirty = true; | - | ||||||||||||||||||||||||||||||
| 1234 | d->opacityUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 1235 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1236 | - | |||||||||||||||||||||||||||||||
| 1237 | void QOpenGL2PaintEngineEx::compositionModeChanged() | - | ||||||||||||||||||||||||||||||
| 1238 | { | - | ||||||||||||||||||||||||||||||
| 1239 | - | |||||||||||||||||||||||||||||||
| 1240 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1241 | state()->compositionModeChanged = true; | - | ||||||||||||||||||||||||||||||
| 1242 | d->compositionModeDirty = true; | - | ||||||||||||||||||||||||||||||
| 1243 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1244 | - | |||||||||||||||||||||||||||||||
| 1245 | void QOpenGL2PaintEngineEx::renderHintsChanged() | - | ||||||||||||||||||||||||||||||
| 1246 | { | - | ||||||||||||||||||||||||||||||
| 1247 | state()->renderHintsChanged = true; | - | ||||||||||||||||||||||||||||||
| 1248 | - | |||||||||||||||||||||||||||||||
| 1249 | - | |||||||||||||||||||||||||||||||
| 1250 | if (!QOpenGLContext::currentContext()->isOpenGLES()
| 0 | ||||||||||||||||||||||||||||||
| 1251 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1252 | if ((
| 0 | ||||||||||||||||||||||||||||||
| 1253 | || (
| 0 | ||||||||||||||||||||||||||||||
| 1254 | d->funcs.glEnable(0x809D); never executed: d->funcs.glEnable(0x809D); | 0 | ||||||||||||||||||||||||||||||
| 1255 | else | - | ||||||||||||||||||||||||||||||
| 1256 | d->funcs.glDisable(0x809D); never executed: d->funcs.glDisable(0x809D); | 0 | ||||||||||||||||||||||||||||||
| 1257 | } | - | ||||||||||||||||||||||||||||||
| 1258 | - | |||||||||||||||||||||||||||||||
| 1259 | - | |||||||||||||||||||||||||||||||
| 1260 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||||||||
| 1262 | - | |||||||||||||||||||||||||||||||
| 1263 | - | |||||||||||||||||||||||||||||||
| 1264 | - | |||||||||||||||||||||||||||||||
| 1265 | d->lastTextureUsed = GLuint(-1); | - | ||||||||||||||||||||||||||||||
| 1266 | - | |||||||||||||||||||||||||||||||
| 1267 | d->brushTextureDirty = true; | - | ||||||||||||||||||||||||||||||
| 1268 | - | |||||||||||||||||||||||||||||||
| 1269 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1270 | - | |||||||||||||||||||||||||||||||
| 1271 | void QOpenGL2PaintEngineEx::transformChanged() | - | ||||||||||||||||||||||||||||||
| 1272 | { | - | ||||||||||||||||||||||||||||||
| 1273 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1274 | d->matrixDirty = true; | - | ||||||||||||||||||||||||||||||
| 1275 | state()->matrixChanged = true; | - | ||||||||||||||||||||||||||||||
| 1276 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1277 | - | |||||||||||||||||||||||||||||||
| 1278 | - | |||||||||||||||||||||||||||||||
| 1279 | static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy) | - | ||||||||||||||||||||||||||||||
| 1280 | { | - | ||||||||||||||||||||||||||||||
| 1281 | return never executed: QRectF(r.x() * sx, r.y() * sy, r.width() * sx, r.height() * sy);return QRectF(r.x() * sx, r.y() * sy, r.width() * sx, r.height() * sy);never executed: return QRectF(r.x() * sx, r.y() * sy, r.width() * sx, r.height() * sy); | 0 | ||||||||||||||||||||||||||||||
| 1282 | } | - | ||||||||||||||||||||||||||||||
| 1283 | - | |||||||||||||||||||||||||||||||
| 1284 | void QOpenGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, const QRectF & src) | - | ||||||||||||||||||||||||||||||
| 1285 | { | - | ||||||||||||||||||||||||||||||
| 1286 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1287 | QOpenGLContext *ctx = d->ctx; | - | ||||||||||||||||||||||||||||||
| 1288 | - | |||||||||||||||||||||||||||||||
| 1289 | - | |||||||||||||||||||||||||||||||
| 1290 | - | |||||||||||||||||||||||||||||||
| 1291 | if (pixmap.paintEngine()->type() == QPaintEngine::Raster
| 0 | ||||||||||||||||||||||||||||||
| 1292 | return never executed: drawImage(dest, pixmap.toImage(), src);return drawImage(dest, pixmap.toImage(), src);never executed: return drawImage(dest, pixmap.toImage(), src); | 0 | ||||||||||||||||||||||||||||||
| 1293 | - | |||||||||||||||||||||||||||||||
| 1294 | int max_texture_size = ctx->d_func()->maxTextureSize(); | - | ||||||||||||||||||||||||||||||
| 1295 | if (pixmap.width() > max_texture_size
| 0 | ||||||||||||||||||||||||||||||
| 1296 | QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); | - | ||||||||||||||||||||||||||||||
| 1297 | - | |||||||||||||||||||||||||||||||
| 1298 | const qreal sx = scaled.width() / qreal(pixmap.width()); | - | ||||||||||||||||||||||||||||||
| 1299 | const qreal sy = scaled.height() / qreal(pixmap.height()); | - | ||||||||||||||||||||||||||||||
| 1300 | - | |||||||||||||||||||||||||||||||
| 1301 | drawPixmap(dest, scaled, scaleRect(src, sx, sy)); | - | ||||||||||||||||||||||||||||||
| 1302 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1303 | } | - | ||||||||||||||||||||||||||||||
| 1304 | - | |||||||||||||||||||||||||||||||
| 1305 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 1306 | d->transferMode(ImageDrawingMode); | - | ||||||||||||||||||||||||||||||
| 1307 | - | |||||||||||||||||||||||||||||||
| 1308 | GLenum filterMode = state()->renderHints & QPainter::SmoothPixmapTransform
| 0 | ||||||||||||||||||||||||||||||
| 1309 | d->updateTexture(GLuint(0), pixmap, 0x812F, filterMode); | - | ||||||||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||||||||
| 1311 | bool isBitmap = pixmap.isQBitmap(); | - | ||||||||||||||||||||||||||||||
| 1312 | bool isOpaque = !isBitmap
| 0 | ||||||||||||||||||||||||||||||
| 1313 | - | |||||||||||||||||||||||||||||||
| 1314 | d->shaderManager->setSrcPixelType(isBitmap ? QOpenGLEngineShaderManager::PatternSrc : QOpenGLEngineShaderManager::ImageSrc); | - | ||||||||||||||||||||||||||||||
| 1315 | - | |||||||||||||||||||||||||||||||
| 1316 | QOpenGLRect srcRect(src.left(), src.top(), src.right(), src.bottom()); | - | ||||||||||||||||||||||||||||||
| 1317 | d->drawTexture(dest, srcRect, pixmap.size(), isOpaque, isBitmap); | - | ||||||||||||||||||||||||||||||
| 1318 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1319 | - | |||||||||||||||||||||||||||||||
| 1320 | void QOpenGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const QRectF& src, | - | ||||||||||||||||||||||||||||||
| 1321 | Qt::ImageConversionFlags) | - | ||||||||||||||||||||||||||||||
| 1322 | { | - | ||||||||||||||||||||||||||||||
| 1323 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1324 | QOpenGLContext *ctx = d->ctx; | - | ||||||||||||||||||||||||||||||
| 1325 | - | |||||||||||||||||||||||||||||||
| 1326 | int max_texture_size = ctx->d_func()->maxTextureSize(); | - | ||||||||||||||||||||||||||||||
| 1327 | if (image.width() > max_texture_size
| 0 | ||||||||||||||||||||||||||||||
| 1328 | QImage scaled = image.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); | - | ||||||||||||||||||||||||||||||
| 1329 | - | |||||||||||||||||||||||||||||||
| 1330 | const qreal sx = scaled.width() / qreal(image.width()); | - | ||||||||||||||||||||||||||||||
| 1331 | const qreal sy = scaled.height() / qreal(image.height()); | - | ||||||||||||||||||||||||||||||
| 1332 | - | |||||||||||||||||||||||||||||||
| 1333 | drawImage(dest, scaled, scaleRect(src, sx, sy)); | - | ||||||||||||||||||||||||||||||
| 1334 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1335 | } | - | ||||||||||||||||||||||||||||||
| 1336 | - | |||||||||||||||||||||||||||||||
| 1337 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 1338 | d->transferMode(ImageDrawingMode); | - | ||||||||||||||||||||||||||||||
| 1339 | - | |||||||||||||||||||||||||||||||
| 1340 | QOpenGLTextureCache::BindOptions bindOption = QOpenGLTextureCache::PremultipliedAlphaBindOption; | - | ||||||||||||||||||||||||||||||
| 1341 | - | |||||||||||||||||||||||||||||||
| 1342 | switch (image.format()) { | - | ||||||||||||||||||||||||||||||
| 1343 | case never executed: QImage::Format_RGBA8888:case QImage::Format_RGBA8888:never executed: case QImage::Format_RGBA8888: | 0 | ||||||||||||||||||||||||||||||
| 1344 | case never executed: QImage::Format_ARGB32:case QImage::Format_ARGB32:never executed: case QImage::Format_ARGB32: | 0 | ||||||||||||||||||||||||||||||
| 1345 | d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::NonPremultipliedImageSrc); | - | ||||||||||||||||||||||||||||||
| 1346 | bindOption = 0; | - | ||||||||||||||||||||||||||||||
| 1347 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1348 | case never executed: QImage::Format_Alpha8:case QImage::Format_Alpha8:never executed: case QImage::Format_Alpha8: | 0 | ||||||||||||||||||||||||||||||
| 1349 | if (ctx->functions()->hasOpenGLFeature(QOpenGLFunctions::TextureRGFormats)
| 0 | ||||||||||||||||||||||||||||||
| 1350 | d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::AlphaImageSrc); | - | ||||||||||||||||||||||||||||||
| 1351 | bindOption = QOpenGLTextureCache::UseRedFor8BitBindOption; | - | ||||||||||||||||||||||||||||||
| 1352 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||||||||
| 1353 | d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc); never executed: d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc); | 0 | ||||||||||||||||||||||||||||||
| 1354 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1355 | case never executed: QImage::Format_Grayscale8:case QImage::Format_Grayscale8:never executed: case QImage::Format_Grayscale8: | 0 | ||||||||||||||||||||||||||||||
| 1356 | if (ctx->functions()->hasOpenGLFeature(QOpenGLFunctions::TextureRGFormats)
| 0 | ||||||||||||||||||||||||||||||
| 1357 | d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::GrayscaleImageSrc); | - | ||||||||||||||||||||||||||||||
| 1358 | bindOption = QOpenGLTextureCache::UseRedFor8BitBindOption; | - | ||||||||||||||||||||||||||||||
| 1359 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||||||||
| 1360 | d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc); never executed: d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc); | 0 | ||||||||||||||||||||||||||||||
| 1361 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1362 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 1363 | d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc); | - | ||||||||||||||||||||||||||||||
| 1364 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 1365 | } | - | ||||||||||||||||||||||||||||||
| 1366 | - | |||||||||||||||||||||||||||||||
| 1367 | ImageWithBindOptions imageWithOptions = { image, bindOption }; | - | ||||||||||||||||||||||||||||||
| 1368 | GLenum filterMode = state()->renderHints & QPainter::SmoothPixmapTransform
| 0 | ||||||||||||||||||||||||||||||
| 1369 | d->updateTexture(GLuint(0), imageWithOptions, 0x812F, filterMode); | - | ||||||||||||||||||||||||||||||
| 1370 | - | |||||||||||||||||||||||||||||||
| 1371 | d->drawTexture(dest, src, image.size(), !image.hasAlphaChannel()); | - | ||||||||||||||||||||||||||||||
| 1372 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||||||||
| 1374 | void QOpenGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) | - | ||||||||||||||||||||||||||||||
| 1375 | { | - | ||||||||||||||||||||||||||||||
| 1376 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||||||||
| 1378 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 1379 | - | |||||||||||||||||||||||||||||||
| 1380 | QPainterState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1381 | - | |||||||||||||||||||||||||||||||
| 1382 | QFontEngine *fontEngine = textItem->fontEngine(); | - | ||||||||||||||||||||||||||||||
| 1383 | if (shouldDrawCachedGlyphs(fontEngine, s->matrix)
| 0 | ||||||||||||||||||||||||||||||
| 1384 | QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None
| 0 | ||||||||||||||||||||||||||||||
| 1385 | ? fontEngine->glyphFormat : d->glyphCacheFormat; | - | ||||||||||||||||||||||||||||||
| 1386 | if (glyphFormat == QFontEngine::Format_A32
| 0 | ||||||||||||||||||||||||||||||
| 1387 | if (d->device->context()->format().alphaBufferSize() > 0
| 0 | ||||||||||||||||||||||||||||||
| 1388 | || (s->composition_mode != QPainter::CompositionMode_Source
| 0 | ||||||||||||||||||||||||||||||
| 1389 | && s->composition_mode != QPainter::CompositionMode_SourceOver
| 0 | ||||||||||||||||||||||||||||||
| 1390 | { | - | ||||||||||||||||||||||||||||||
| 1391 | glyphFormat = QFontEngine::Format_A8; | - | ||||||||||||||||||||||||||||||
| 1392 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1393 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1394 | - | |||||||||||||||||||||||||||||||
| 1395 | d->drawCachedGlyphs(glyphFormat, textItem); | - | ||||||||||||||||||||||||||||||
| 1396 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1397 | QPaintEngineEx::drawStaticTextItem(textItem); | - | ||||||||||||||||||||||||||||||
| 1398 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1399 | } | - | ||||||||||||||||||||||||||||||
| 1400 | - | |||||||||||||||||||||||||||||||
| 1401 | bool QOpenGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src) | - | ||||||||||||||||||||||||||||||
| 1402 | { | - | ||||||||||||||||||||||||||||||
| 1403 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1404 | if (!d->shaderManager
| 0 | ||||||||||||||||||||||||||||||
| 1405 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1406 | - | |||||||||||||||||||||||||||||||
| 1407 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 1408 | d->transferMode(ImageDrawingMode); | - | ||||||||||||||||||||||||||||||
| 1409 | - | |||||||||||||||||||||||||||||||
| 1410 | GLenum filterMode = state()->renderHints & QPainter::SmoothPixmapTransform
| 0 | ||||||||||||||||||||||||||||||
| 1411 | d->updateTexture(GLuint(0), textureId, 0x812F, filterMode); | - | ||||||||||||||||||||||||||||||
| 1412 | - | |||||||||||||||||||||||||||||||
| 1413 | d->shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc); | - | ||||||||||||||||||||||||||||||
| 1414 | - | |||||||||||||||||||||||||||||||
| 1415 | QOpenGLRect srcRect(src.left(), src.bottom(), src.right(), src.top()); | - | ||||||||||||||||||||||||||||||
| 1416 | d->drawTexture(dest, srcRect, size, false); | - | ||||||||||||||||||||||||||||||
| 1417 | - | |||||||||||||||||||||||||||||||
| 1418 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 1419 | } | - | ||||||||||||||||||||||||||||||
| 1420 | - | |||||||||||||||||||||||||||||||
| 1421 | void QOpenGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem) | - | ||||||||||||||||||||||||||||||
| 1422 | { | - | ||||||||||||||||||||||||||||||
| 1423 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1424 | - | |||||||||||||||||||||||||||||||
| 1425 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 1426 | QOpenGL2PaintEngineState *s = state(); | - | ||||||||||||||||||||||||||||||
| 1427 | - | |||||||||||||||||||||||||||||||
| 1428 | const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); | - | ||||||||||||||||||||||||||||||
| 1429 | - | |||||||||||||||||||||||||||||||
| 1430 | QTransform::TransformationType txtype = s->matrix.type(); | - | ||||||||||||||||||||||||||||||
| 1431 | - | |||||||||||||||||||||||||||||||
| 1432 | QFontEngine::GlyphFormat glyphFormat = ti.fontEngine->glyphFormat != QFontEngine::Format_None
| 0 | ||||||||||||||||||||||||||||||
| 1433 | ? ti.fontEngine->glyphFormat : d->glyphCacheFormat; | - | ||||||||||||||||||||||||||||||
| 1434 | - | |||||||||||||||||||||||||||||||
| 1435 | if (glyphFormat == QFontEngine::Format_A32
| 0 | ||||||||||||||||||||||||||||||
| 1436 | if (d->device->context()->format().alphaBufferSize() > 0
| 0 | ||||||||||||||||||||||||||||||
| 1437 | || (state()->composition_mode != QPainter::CompositionMode_Source
| 0 | ||||||||||||||||||||||||||||||
| 1438 | && state()->composition_mode != QPainter::CompositionMode_SourceOver
| 0 | ||||||||||||||||||||||||||||||
| 1439 | { | - | ||||||||||||||||||||||||||||||
| 1440 | glyphFormat = QFontEngine::Format_A8; | - | ||||||||||||||||||||||||||||||
| 1441 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1442 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1443 | - | |||||||||||||||||||||||||||||||
| 1444 | if (shouldDrawCachedGlyphs(ti.fontEngine, s->matrix)
| 0 | ||||||||||||||||||||||||||||||
| 1445 | QVarLengthArray<QFixedPoint> positions; | - | ||||||||||||||||||||||||||||||
| 1446 | QVarLengthArray<glyph_t> glyphs; | - | ||||||||||||||||||||||||||||||
| 1447 | QTransform matrix = QTransform::fromTranslate(p.x(), p.y()); | - | ||||||||||||||||||||||||||||||
| 1448 | ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); | - | ||||||||||||||||||||||||||||||
| 1449 | - | |||||||||||||||||||||||||||||||
| 1450 | { | - | ||||||||||||||||||||||||||||||
| 1451 | QStaticTextItem staticTextItem; | - | ||||||||||||||||||||||||||||||
| 1452 | staticTextItem.setFontEngine(ti.fontEngine); | - | ||||||||||||||||||||||||||||||
| 1453 | staticTextItem.glyphs = glyphs.data(); | - | ||||||||||||||||||||||||||||||
| 1454 | staticTextItem.numGlyphs = glyphs.size(); | - | ||||||||||||||||||||||||||||||
| 1455 | staticTextItem.glyphPositions = positions.data(); | - | ||||||||||||||||||||||||||||||
| 1456 | - | |||||||||||||||||||||||||||||||
| 1457 | d->drawCachedGlyphs(glyphFormat, &staticTextItem); | - | ||||||||||||||||||||||||||||||
| 1458 | } | - | ||||||||||||||||||||||||||||||
| 1459 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1460 | } | - | ||||||||||||||||||||||||||||||
| 1461 | - | |||||||||||||||||||||||||||||||
| 1462 | QPaintEngineEx::drawTextItem(p, ti); | - | ||||||||||||||||||||||||||||||
| 1463 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1464 | - | |||||||||||||||||||||||||||||||
| 1465 | namespace { | - | ||||||||||||||||||||||||||||||
| 1466 | - | |||||||||||||||||||||||||||||||
| 1467 | class QOpenGLStaticTextUserData: public QStaticTextUserData | - | ||||||||||||||||||||||||||||||
| 1468 | { | - | ||||||||||||||||||||||||||||||
| 1469 | public: | - | ||||||||||||||||||||||||||||||
| 1470 | QOpenGLStaticTextUserData() | - | ||||||||||||||||||||||||||||||
| 1471 | : QStaticTextUserData(OpenGLUserData), cacheSize(0, 0), cacheSerialNumber(0) | - | ||||||||||||||||||||||||||||||
| 1472 | { | - | ||||||||||||||||||||||||||||||
| 1473 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1474 | - | |||||||||||||||||||||||||||||||
| 1475 | ~QOpenGLStaticTextUserData() | - | ||||||||||||||||||||||||||||||
| 1476 | { | - | ||||||||||||||||||||||||||||||
| 1477 | } | - | ||||||||||||||||||||||||||||||
| 1478 | - | |||||||||||||||||||||||||||||||
| 1479 | QSize cacheSize; | - | ||||||||||||||||||||||||||||||
| 1480 | QOpenGL2PEXVertexArray vertexCoordinateArray; | - | ||||||||||||||||||||||||||||||
| 1481 | QOpenGL2PEXVertexArray textureCoordinateArray; | - | ||||||||||||||||||||||||||||||
| 1482 | QFontEngine::GlyphFormat glyphFormat; | - | ||||||||||||||||||||||||||||||
| 1483 | int cacheSerialNumber; | - | ||||||||||||||||||||||||||||||
| 1484 | }; | - | ||||||||||||||||||||||||||||||
| 1485 | - | |||||||||||||||||||||||||||||||
| 1486 | } | - | ||||||||||||||||||||||||||||||
| 1487 | - | |||||||||||||||||||||||||||||||
| 1488 | - | |||||||||||||||||||||||||||||||
| 1489 | - | |||||||||||||||||||||||||||||||
| 1490 | - | |||||||||||||||||||||||||||||||
| 1491 | bool QOpenGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &t) const | - | ||||||||||||||||||||||||||||||
| 1492 | { | - | ||||||||||||||||||||||||||||||
| 1493 | - | |||||||||||||||||||||||||||||||
| 1494 | if (t.type() == QTransform::TxProject
| 0 | ||||||||||||||||||||||||||||||
| 1495 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1496 | - | |||||||||||||||||||||||||||||||
| 1497 | - | |||||||||||||||||||||||||||||||
| 1498 | - | |||||||||||||||||||||||||||||||
| 1499 | - | |||||||||||||||||||||||||||||||
| 1500 | if (!fontEngine->supportsTransformation(t)
| 0 | ||||||||||||||||||||||||||||||
| 1501 | - | |||||||||||||||||||||||||||||||
| 1502 | - | |||||||||||||||||||||||||||||||
| 1503 | - | |||||||||||||||||||||||||||||||
| 1504 | - | |||||||||||||||||||||||||||||||
| 1505 | float det = t.determinant(); | - | ||||||||||||||||||||||||||||||
| 1506 | if (det >= 0.25f
| 0 | ||||||||||||||||||||||||||||||
| 1507 | - | |||||||||||||||||||||||||||||||
| 1508 | return never executed: QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);never executed: return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); | 0 | ||||||||||||||||||||||||||||||
| 1509 | } | - | ||||||||||||||||||||||||||||||
| 1510 | - | |||||||||||||||||||||||||||||||
| 1511 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1512 | } | - | ||||||||||||||||||||||||||||||
| 1513 | - | |||||||||||||||||||||||||||||||
| 1514 | return never executed: QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);never executed: return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); | 0 | ||||||||||||||||||||||||||||||
| 1515 | } | - | ||||||||||||||||||||||||||||||
| 1516 | - | |||||||||||||||||||||||||||||||
| 1517 | void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat glyphFormat, | - | ||||||||||||||||||||||||||||||
| 1518 | QStaticTextItem *staticTextItem) | - | ||||||||||||||||||||||||||||||
| 1519 | { | - | ||||||||||||||||||||||||||||||
| 1520 | QOpenGL2PaintEngineEx * const q = q_func(); | - | ||||||||||||||||||||||||||||||
| 1521 | - | |||||||||||||||||||||||||||||||
| 1522 | QOpenGL2PaintEngineState *s = q->state(); | - | ||||||||||||||||||||||||||||||
| 1523 | - | |||||||||||||||||||||||||||||||
| 1524 | void *cacheKey = ctx->shareGroup(); | - | ||||||||||||||||||||||||||||||
| 1525 | bool recreateVertexArrays = false; | - | ||||||||||||||||||||||||||||||
| 1526 | - | |||||||||||||||||||||||||||||||
| 1527 | QTransform glyphCacheTransform; | - | ||||||||||||||||||||||||||||||
| 1528 | QFontEngine *fe = staticTextItem->fontEngine(); | - | ||||||||||||||||||||||||||||||
| 1529 | if (fe->supportsTransformation(s->matrix)
| 0 | ||||||||||||||||||||||||||||||
| 1530 | - | |||||||||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||||||||
| 1532 | - | |||||||||||||||||||||||||||||||
| 1533 | glyphCacheTransform = s->matrix.type() < QTransform::TxRotate
| 0 | ||||||||||||||||||||||||||||||
| 1534 | QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) : | - | ||||||||||||||||||||||||||||||
| 1535 | QTransform::fromScale( | - | ||||||||||||||||||||||||||||||
| 1536 | QVector2D(s->matrix.m11(), s->matrix.m12()).length(), | - | ||||||||||||||||||||||||||||||
| 1537 | QVector2D(s->matrix.m21(), s->matrix.m22()).length()); | - | ||||||||||||||||||||||||||||||
| 1538 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1539 | - | |||||||||||||||||||||||||||||||
| 1540 | QOpenGLTextureGlyphCache *cache = | - | ||||||||||||||||||||||||||||||
| 1541 | (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphFormat, glyphCacheTransform); | - | ||||||||||||||||||||||||||||||
| 1542 | if (!cache
| 0 | ||||||||||||||||||||||||||||||
| 1543 | cache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform); | - | ||||||||||||||||||||||||||||||
| 1544 | fe->setGlyphCache(cacheKey, cache); | - | ||||||||||||||||||||||||||||||
| 1545 | recreateVertexArrays = true; | - | ||||||||||||||||||||||||||||||
| 1546 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1547 | - | |||||||||||||||||||||||||||||||
| 1548 | if (staticTextItem->userDataNeedsUpdate
| 0 | ||||||||||||||||||||||||||||||
| 1549 | recreateVertexArrays = true; | - | ||||||||||||||||||||||||||||||
| 1550 | } never executed: else if (staticTextItem->userData() == 0end of block
| 0 | ||||||||||||||||||||||||||||||
| 1551 | recreateVertexArrays = true; | - | ||||||||||||||||||||||||||||||
| 1552 | } never executed: else if (staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserDataend of block
| 0 | ||||||||||||||||||||||||||||||
| 1553 | recreateVertexArrays = true; | - | ||||||||||||||||||||||||||||||
| 1554 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1555 | QOpenGLStaticTextUserData *userData = static_cast<QOpenGLStaticTextUserData *>(staticTextItem->userData()); | - | ||||||||||||||||||||||||||||||
| 1556 | if (userData->glyphFormat != glyphFormat
| 0 | ||||||||||||||||||||||||||||||
| 1557 | recreateVertexArrays = true; | - | ||||||||||||||||||||||||||||||
| 1558 | } never executed: else if (userData->cacheSerialNumber != cache->serialNumber()end of block
| 0 | ||||||||||||||||||||||||||||||
| 1559 | recreateVertexArrays = true; | - | ||||||||||||||||||||||||||||||
| 1560 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1561 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1562 | - | |||||||||||||||||||||||||||||||
| 1563 | - | |||||||||||||||||||||||||||||||
| 1564 | - | |||||||||||||||||||||||||||||||
| 1565 | - | |||||||||||||||||||||||||||||||
| 1566 | if (recreateVertexArrays
| 0 | ||||||||||||||||||||||||||||||
| 1567 | cache->setPaintEnginePrivate(this); | - | ||||||||||||||||||||||||||||||
| 1568 | if (!cache->populate(fe, staticTextItem->numGlyphs,
| 0 | ||||||||||||||||||||||||||||||
| 1569 | staticTextItem->glyphs, staticTextItem->glyphPositions)
| 0 | ||||||||||||||||||||||||||||||
| 1570 | - | |||||||||||||||||||||||||||||||
| 1571 | cache->clear(); | - | ||||||||||||||||||||||||||||||
| 1572 | cache->populate(fe, staticTextItem->numGlyphs, | - | ||||||||||||||||||||||||||||||
| 1573 | staticTextItem->glyphs, staticTextItem->glyphPositions); | - | ||||||||||||||||||||||||||||||
| 1574 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1575 | - | |||||||||||||||||||||||||||||||
| 1576 | if (cache->hasPendingGlyphs()
| 0 | ||||||||||||||||||||||||||||||
| 1577 | - | |||||||||||||||||||||||||||||||
| 1578 | - | |||||||||||||||||||||||||||||||
| 1579 | - | |||||||||||||||||||||||||||||||
| 1580 | - | |||||||||||||||||||||||||||||||
| 1581 | - | |||||||||||||||||||||||||||||||
| 1582 | static const GLenum glypchCacheTextureUnit = GLuint(0); | - | ||||||||||||||||||||||||||||||
| 1583 | activateTextureUnit(glypchCacheTextureUnit); | - | ||||||||||||||||||||||||||||||
| 1584 | - | |||||||||||||||||||||||||||||||
| 1585 | cache->fillInPendingGlyphs(); | - | ||||||||||||||||||||||||||||||
| 1586 | - | |||||||||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||||||||
| 1588 | lastTextureUsed = cache->texture(); | - | ||||||||||||||||||||||||||||||
| 1589 | - | |||||||||||||||||||||||||||||||
| 1590 | - | |||||||||||||||||||||||||||||||
| 1591 | - | |||||||||||||||||||||||||||||||
| 1592 | brushTextureDirty = (GLuint(0) == glypchCacheTextureUnit); | - | ||||||||||||||||||||||||||||||
| 1593 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1594 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1595 | - | |||||||||||||||||||||||||||||||
| 1596 | if (cache->width() == 0
| 0 | ||||||||||||||||||||||||||||||
| 1597 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1598 | - | |||||||||||||||||||||||||||||||
| 1599 | if (glyphFormat == QFontEngine::Format_ARGB
| 0 | ||||||||||||||||||||||||||||||
| 1600 | transferMode(ImageArrayDrawingMode); never executed: transferMode(ImageArrayDrawingMode); | 0 | ||||||||||||||||||||||||||||||
| 1601 | else | - | ||||||||||||||||||||||||||||||
| 1602 | transferMode(TextDrawingMode); never executed: transferMode(TextDrawingMode); | 0 | ||||||||||||||||||||||||||||||
| 1603 | - | |||||||||||||||||||||||||||||||
| 1604 | int margin = fe->glyphMargin(glyphFormat); | - | ||||||||||||||||||||||||||||||
| 1605 | - | |||||||||||||||||||||||||||||||
| 1606 | GLfloat dx = 1.0 / cache->width(); | - | ||||||||||||||||||||||||||||||
| 1607 | GLfloat dy = 1.0 / cache->height(); | - | ||||||||||||||||||||||||||||||
| 1608 | - | |||||||||||||||||||||||||||||||
| 1609 | - | |||||||||||||||||||||||||||||||
| 1610 | QOpenGL2PEXVertexArray *vertexCoordinates = &vertexCoordinateArray; | - | ||||||||||||||||||||||||||||||
| 1611 | QOpenGL2PEXVertexArray *textureCoordinates = &textureCoordinateArray; | - | ||||||||||||||||||||||||||||||
| 1612 | - | |||||||||||||||||||||||||||||||
| 1613 | if (staticTextItem->useBackendOptimizations
| 0 | ||||||||||||||||||||||||||||||
| 1614 | QOpenGLStaticTextUserData *userData = 0; | - | ||||||||||||||||||||||||||||||
| 1615 | - | |||||||||||||||||||||||||||||||
| 1616 | if (staticTextItem->userData() == 0
| 0 | ||||||||||||||||||||||||||||||
| 1617 | || staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData
| 0 | ||||||||||||||||||||||||||||||
| 1618 | - | |||||||||||||||||||||||||||||||
| 1619 | userData = new QOpenGLStaticTextUserData(); | - | ||||||||||||||||||||||||||||||
| 1620 | staticTextItem->setUserData(userData); | - | ||||||||||||||||||||||||||||||
| 1621 | - | |||||||||||||||||||||||||||||||
| 1622 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1623 | userData = static_cast<QOpenGLStaticTextUserData*>(staticTextItem->userData()); | - | ||||||||||||||||||||||||||||||
| 1624 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1625 | - | |||||||||||||||||||||||||||||||
| 1626 | userData->glyphFormat = glyphFormat; | - | ||||||||||||||||||||||||||||||
| 1627 | userData->cacheSerialNumber = cache->serialNumber(); | - | ||||||||||||||||||||||||||||||
| 1628 | - | |||||||||||||||||||||||||||||||
| 1629 | - | |||||||||||||||||||||||||||||||
| 1630 | vertexCoordinates = &userData->vertexCoordinateArray; | - | ||||||||||||||||||||||||||||||
| 1631 | textureCoordinates = &userData->textureCoordinateArray; | - | ||||||||||||||||||||||||||||||
| 1632 | - | |||||||||||||||||||||||||||||||
| 1633 | QSize size(cache->width(), cache->height()); | - | ||||||||||||||||||||||||||||||
| 1634 | if (userData->cacheSize != size
| 0 | ||||||||||||||||||||||||||||||
| 1635 | recreateVertexArrays = true; | - | ||||||||||||||||||||||||||||||
| 1636 | userData->cacheSize = size; | - | ||||||||||||||||||||||||||||||
| 1637 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1638 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1639 | - | |||||||||||||||||||||||||||||||
| 1640 | if (recreateVertexArrays
| 0 | ||||||||||||||||||||||||||||||
| 1641 | vertexCoordinates->clear(); | - | ||||||||||||||||||||||||||||||
| 1642 | textureCoordinates->clear(); | - | ||||||||||||||||||||||||||||||
| 1643 | - | |||||||||||||||||||||||||||||||
| 1644 | bool supportsSubPixelPositions = fe->supportsSubPixelPositions(); | - | ||||||||||||||||||||||||||||||
| 1645 | for (int i=0; i<staticTextItem->numGlyphs
| 0 | ||||||||||||||||||||||||||||||
| 1646 | QFixed subPixelPosition; | - | ||||||||||||||||||||||||||||||
| 1647 | if (supportsSubPixelPositions
| 0 | ||||||||||||||||||||||||||||||
| 1648 | subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x); never executed: subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x); | 0 | ||||||||||||||||||||||||||||||
| 1649 | - | |||||||||||||||||||||||||||||||
| 1650 | QTextureGlyphCache::GlyphAndSubPixelPosition glyph(staticTextItem->glyphs[i], subPixelPosition); | - | ||||||||||||||||||||||||||||||
| 1651 | - | |||||||||||||||||||||||||||||||
| 1652 | const QTextureGlyphCache::Coord &c = cache->coords[glyph]; | - | ||||||||||||||||||||||||||||||
| 1653 | if (c.isNull()
| 0 | ||||||||||||||||||||||||||||||
| 1654 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||
| 1655 | - | |||||||||||||||||||||||||||||||
| 1656 | int x = qFloor(staticTextItem->glyphPositions[i].x.toReal() * cache->transform().m11()) + c.baseLineX - margin; | - | ||||||||||||||||||||||||||||||
| 1657 | int y = qRound(staticTextItem->glyphPositions[i].y.toReal() * cache->transform().m22()) - c.baseLineY - margin; | - | ||||||||||||||||||||||||||||||
| 1658 | - | |||||||||||||||||||||||||||||||
| 1659 | vertexCoordinates->addQuad(QRectF(x, y, c.w, c.h)); | - | ||||||||||||||||||||||||||||||
| 1660 | textureCoordinates->addQuad(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy)); | - | ||||||||||||||||||||||||||||||
| 1661 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1662 | - | |||||||||||||||||||||||||||||||
| 1663 | staticTextItem->userDataNeedsUpdate = false; | - | ||||||||||||||||||||||||||||||
| 1664 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1665 | - | |||||||||||||||||||||||||||||||
| 1666 | int numGlyphs = vertexCoordinates->vertexCount() / 4; | - | ||||||||||||||||||||||||||||||
| 1667 | if (numGlyphs == 0
| 0 | ||||||||||||||||||||||||||||||
| 1668 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1669 | - | |||||||||||||||||||||||||||||||
| 1670 | if (elementIndices.size() < numGlyphs*6
| 0 | ||||||||||||||||||||||||||||||
| 1671 | ((!(elementIndices.size() % 6 == 0)) ? qt_assert("elementIndices.size() % 6 == 0",__FILE__,1814) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 1672 | int j = elementIndices.size() / 6 * 4; | - | ||||||||||||||||||||||||||||||
| 1673 | while (j < numGlyphs*4
| 0 | ||||||||||||||||||||||||||||||
| 1674 | elementIndices.append(j + 0); | - | ||||||||||||||||||||||||||||||
| 1675 | elementIndices.append(j + 0); | - | ||||||||||||||||||||||||||||||
| 1676 | elementIndices.append(j + 1); | - | ||||||||||||||||||||||||||||||
| 1677 | elementIndices.append(j + 2); | - | ||||||||||||||||||||||||||||||
| 1678 | elementIndices.append(j + 3); | - | ||||||||||||||||||||||||||||||
| 1679 | elementIndices.append(j + 3); | - | ||||||||||||||||||||||||||||||
| 1680 | - | |||||||||||||||||||||||||||||||
| 1681 | j += 4; | - | ||||||||||||||||||||||||||||||
| 1682 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1683 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1684 | - | |||||||||||||||||||||||||||||||
| 1685 | - | |||||||||||||||||||||||||||||||
| 1686 | - | |||||||||||||||||||||||||||||||
| 1687 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1688 | - | |||||||||||||||||||||||||||||||
| 1689 | if (glyphFormat != QFontEngine::Format_ARGB
| 0 | ||||||||||||||||||||||||||||||
| 1690 | setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data()); | - | ||||||||||||||||||||||||||||||
| 1691 | setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinates->data()); | - | ||||||||||||||||||||||||||||||
| 1692 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1693 | - | |||||||||||||||||||||||||||||||
| 1694 | if (!snapToPixelGrid
| 0 | ||||||||||||||||||||||||||||||
| 1695 | snapToPixelGrid = true; | - | ||||||||||||||||||||||||||||||
| 1696 | matrixDirty = true; | - | ||||||||||||||||||||||||||||||
| 1697 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1698 | - | |||||||||||||||||||||||||||||||
| 1699 | QBrush pensBrush = q->state()->pen.brush(); | - | ||||||||||||||||||||||||||||||
| 1700 | setBrush(pensBrush); | - | ||||||||||||||||||||||||||||||
| 1701 | - | |||||||||||||||||||||||||||||||
| 1702 | if (glyphFormat == QFontEngine::Format_A32
| 0 | ||||||||||||||||||||||||||||||
| 1703 | - | |||||||||||||||||||||||||||||||
| 1704 | - | |||||||||||||||||||||||||||||||
| 1705 | - | |||||||||||||||||||||||||||||||
| 1706 | QPainter::CompositionMode compMode = q->state()->composition_mode; | - | ||||||||||||||||||||||||||||||
| 1707 | ((!(compMode == QPainter::CompositionMode_Source || compMode == QPainter::CompositionMode_SourceOver)) ? qt_assert("compMode == QPainter::CompositionMode_Source || compMode == QPainter::CompositionMode_SourceOver", | - | ||||||||||||||||||||||||||||||
| 1708 | __FILE__ | - | ||||||||||||||||||||||||||||||
| 1709 | , | - | ||||||||||||||||||||||||||||||
| 1710 | 1860 | - | ||||||||||||||||||||||||||||||
| 1711 | ) : qt_noop()) | - | ||||||||||||||||||||||||||||||
| 1712 | ; | - | ||||||||||||||||||||||||||||||
| 1713 | - | |||||||||||||||||||||||||||||||
| 1714 | shaderManager->setMaskType(QOpenGLEngineShaderManager::SubPixelMaskPass1); | - | ||||||||||||||||||||||||||||||
| 1715 | - | |||||||||||||||||||||||||||||||
| 1716 | if (pensBrush.style() == Qt::SolidPattern
| 0 | ||||||||||||||||||||||||||||||
| 1717 | - | |||||||||||||||||||||||||||||||
| 1718 | QColor c = pensBrush.color(); | - | ||||||||||||||||||||||||||||||
| 1719 | qreal oldOpacity = q->state()->opacity; | - | ||||||||||||||||||||||||||||||
| 1720 | if (compMode == QPainter::CompositionMode_Source
| 0 | ||||||||||||||||||||||||||||||
| 1721 | c = qt_premultiplyColor(c, q->state()->opacity); | - | ||||||||||||||||||||||||||||||
| 1722 | q->state()->opacity = 1; | - | ||||||||||||||||||||||||||||||
| 1723 | opacityUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 1724 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1725 | - | |||||||||||||||||||||||||||||||
| 1726 | compositionModeDirty = false; | - | ||||||||||||||||||||||||||||||
| 1727 | prepareForCachedGlyphDraw(*cache); | - | ||||||||||||||||||||||||||||||
| 1728 | - | |||||||||||||||||||||||||||||||
| 1729 | - | |||||||||||||||||||||||||||||||
| 1730 | if (compMode == QPainter::CompositionMode_Source
| 0 | ||||||||||||||||||||||||||||||
| 1731 | q->state()->opacity = oldOpacity; | - | ||||||||||||||||||||||||||||||
| 1732 | opacityUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 1733 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1734 | - | |||||||||||||||||||||||||||||||
| 1735 | funcs.glEnable(0x0BE2); | - | ||||||||||||||||||||||||||||||
| 1736 | funcs.glBlendFunc(0x8001, 0x0301); | - | ||||||||||||||||||||||||||||||
| 1737 | funcs.glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); | - | ||||||||||||||||||||||||||||||
| 1738 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1739 | - | |||||||||||||||||||||||||||||||
| 1740 | - | |||||||||||||||||||||||||||||||
| 1741 | qreal oldOpacity = q->state()->opacity; | - | ||||||||||||||||||||||||||||||
| 1742 | if (compMode == QPainter::CompositionMode_Source
| 0 | ||||||||||||||||||||||||||||||
| 1743 | q->state()->opacity = 1; | - | ||||||||||||||||||||||||||||||
| 1744 | opacityUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 1745 | pensBrush = Qt::white; | - | ||||||||||||||||||||||||||||||
| 1746 | setBrush(pensBrush); | - | ||||||||||||||||||||||||||||||
| 1747 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1748 | - | |||||||||||||||||||||||||||||||
| 1749 | compositionModeDirty = false; | - | ||||||||||||||||||||||||||||||
| 1750 | prepareForCachedGlyphDraw(*cache); | - | ||||||||||||||||||||||||||||||
| 1751 | funcs.glEnable(0x0BE2); | - | ||||||||||||||||||||||||||||||
| 1752 | funcs.glBlendFunc(0, 0x0301); | - | ||||||||||||||||||||||||||||||
| 1753 | - | |||||||||||||||||||||||||||||||
| 1754 | updateTexture(GLuint(1), cache->texture(), 0x2901, 0x2600, ForceUpdate); | - | ||||||||||||||||||||||||||||||
| 1755 | - | |||||||||||||||||||||||||||||||
| 1756 | - | |||||||||||||||||||||||||||||||
| 1757 | - | |||||||||||||||||||||||||||||||
| 1758 | - | |||||||||||||||||||||||||||||||
| 1759 | funcs.glDrawElements(0x0005, 6 * numGlyphs, 0x1403, elementIndices.data()); | - | ||||||||||||||||||||||||||||||
| 1760 | - | |||||||||||||||||||||||||||||||
| 1761 | - | |||||||||||||||||||||||||||||||
| 1762 | shaderManager->setMaskType(QOpenGLEngineShaderManager::SubPixelMaskPass2); | - | ||||||||||||||||||||||||||||||
| 1763 | - | |||||||||||||||||||||||||||||||
| 1764 | if (compMode == QPainter::CompositionMode_Source
| 0 | ||||||||||||||||||||||||||||||
| 1765 | q->state()->opacity = oldOpacity; | - | ||||||||||||||||||||||||||||||
| 1766 | opacityUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 1767 | pensBrush = q->state()->pen.brush(); | - | ||||||||||||||||||||||||||||||
| 1768 | setBrush(pensBrush); | - | ||||||||||||||||||||||||||||||
| 1769 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1770 | - | |||||||||||||||||||||||||||||||
| 1771 | compositionModeDirty = false; | - | ||||||||||||||||||||||||||||||
| 1772 | prepareForCachedGlyphDraw(*cache); | - | ||||||||||||||||||||||||||||||
| 1773 | funcs.glEnable(0x0BE2); | - | ||||||||||||||||||||||||||||||
| 1774 | funcs.glBlendFunc(1, 1); | - | ||||||||||||||||||||||||||||||
| 1775 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1776 | compositionModeDirty = true; | - | ||||||||||||||||||||||||||||||
| 1777 | } never executed: else if (glyphFormat == QFontEngine::Format_ARGBend of block
| 0 | ||||||||||||||||||||||||||||||
| 1778 | currentBrush = noBrush; | - | ||||||||||||||||||||||||||||||
| 1779 | shaderManager->setSrcPixelType(QOpenGLEngineShaderManager::ImageSrc); | - | ||||||||||||||||||||||||||||||
| 1780 | if (prepareForCachedGlyphDraw(*cache)
| 0 | ||||||||||||||||||||||||||||||
| 1781 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::ImageTexture), GLuint(0)); never executed: shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::ImageTexture), GLuint(0)); | 0 | ||||||||||||||||||||||||||||||
| 1782 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1783 | - | |||||||||||||||||||||||||||||||
| 1784 | - | |||||||||||||||||||||||||||||||
| 1785 | shaderManager->setMaskType(QOpenGLEngineShaderManager::PixelMask); | - | ||||||||||||||||||||||||||||||
| 1786 | prepareForCachedGlyphDraw(*cache); | - | ||||||||||||||||||||||||||||||
| 1787 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1788 | - | |||||||||||||||||||||||||||||||
| 1789 | GLenum textureUnit = GLuint(1); | - | ||||||||||||||||||||||||||||||
| 1790 | if (glyphFormat == QFontEngine::Format_ARGB
| 0 | ||||||||||||||||||||||||||||||
| 1791 | textureUnit = GLuint(0); never executed: textureUnit = GLuint(0); | 0 | ||||||||||||||||||||||||||||||
| 1792 | - | |||||||||||||||||||||||||||||||
| 1793 | QOpenGLTextureGlyphCache::FilterMode filterMode = (
| 0 | ||||||||||||||||||||||||||||||
| 1794 | QOpenGLTextureGlyphCache::Linear : QOpenGLTextureGlyphCache::Nearest; | - | ||||||||||||||||||||||||||||||
| 1795 | - | |||||||||||||||||||||||||||||||
| 1796 | GLenum glFilterMode = filterMode == QOpenGLTextureGlyphCache::Linear
| 0 | ||||||||||||||||||||||||||||||
| 1797 | - | |||||||||||||||||||||||||||||||
| 1798 | TextureUpdateMode updateMode = UpdateIfNeeded; | - | ||||||||||||||||||||||||||||||
| 1799 | if (cache->filterMode() != filterMode
| 0 | ||||||||||||||||||||||||||||||
| 1800 | updateMode = ForceUpdate; | - | ||||||||||||||||||||||||||||||
| 1801 | cache->setFilterMode(filterMode); | - | ||||||||||||||||||||||||||||||
| 1802 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1803 | - | |||||||||||||||||||||||||||||||
| 1804 | updateTexture(textureUnit, cache->texture(), 0x2901, glFilterMode, updateMode); | - | ||||||||||||||||||||||||||||||
| 1805 | - | |||||||||||||||||||||||||||||||
| 1806 | - | |||||||||||||||||||||||||||||||
| 1807 | - | |||||||||||||||||||||||||||||||
| 1808 | - | |||||||||||||||||||||||||||||||
| 1809 | - | |||||||||||||||||||||||||||||||
| 1810 | funcs.glDrawElements(0x0005, 6 * numGlyphs, 0x1403, elementIndices.data()); | - | ||||||||||||||||||||||||||||||
| 1811 | - | |||||||||||||||||||||||||||||||
| 1812 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1813 | - | |||||||||||||||||||||||||||||||
| 1814 | void QOpenGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, | - | ||||||||||||||||||||||||||||||
| 1815 | QPainter::PixmapFragmentHints hints) | - | ||||||||||||||||||||||||||||||
| 1816 | { | - | ||||||||||||||||||||||||||||||
| 1817 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1818 | - | |||||||||||||||||||||||||||||||
| 1819 | if (state()->composition_mode > QPainter::CompositionMode_Plus
| 0 | ||||||||||||||||||||||||||||||
| 1820 | QPaintEngineEx::drawPixmapFragments(fragments, fragmentCount, pixmap, hints); | - | ||||||||||||||||||||||||||||||
| 1821 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1822 | } | - | ||||||||||||||||||||||||||||||
| 1823 | - | |||||||||||||||||||||||||||||||
| 1824 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 1825 | int max_texture_size = d->ctx->d_func()->maxTextureSize(); | - | ||||||||||||||||||||||||||||||
| 1826 | if (pixmap.width() > max_texture_size
| 0 | ||||||||||||||||||||||||||||||
| 1827 | QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); | - | ||||||||||||||||||||||||||||||
| 1828 | d->drawPixmapFragments(fragments, fragmentCount, scaled, hints); | - | ||||||||||||||||||||||||||||||
| 1829 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 1830 | d->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); | - | ||||||||||||||||||||||||||||||
| 1831 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1832 | } | - | ||||||||||||||||||||||||||||||
| 1833 | - | |||||||||||||||||||||||||||||||
| 1834 | - | |||||||||||||||||||||||||||||||
| 1835 | void QOpenGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragment *fragments, | - | ||||||||||||||||||||||||||||||
| 1836 | int fragmentCount, const QPixmap &pixmap, | - | ||||||||||||||||||||||||||||||
| 1837 | QPainter::PixmapFragmentHints hints) | - | ||||||||||||||||||||||||||||||
| 1838 | { | - | ||||||||||||||||||||||||||||||
| 1839 | GLfloat dx = 1.0f / pixmap.size().width(); | - | ||||||||||||||||||||||||||||||
| 1840 | GLfloat dy = 1.0f / pixmap.size().height(); | - | ||||||||||||||||||||||||||||||
| 1841 | - | |||||||||||||||||||||||||||||||
| 1842 | vertexCoordinateArray.clear(); | - | ||||||||||||||||||||||||||||||
| 1843 | textureCoordinateArray.clear(); | - | ||||||||||||||||||||||||||||||
| 1844 | opacityArray.reset(); | - | ||||||||||||||||||||||||||||||
| 1845 | - | |||||||||||||||||||||||||||||||
| 1846 | if (snapToPixelGrid
| 0 | ||||||||||||||||||||||||||||||
| 1847 | snapToPixelGrid = false; | - | ||||||||||||||||||||||||||||||
| 1848 | matrixDirty = true; | - | ||||||||||||||||||||||||||||||
| 1849 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1850 | - | |||||||||||||||||||||||||||||||
| 1851 | bool allOpaque = true; | - | ||||||||||||||||||||||||||||||
| 1852 | - | |||||||||||||||||||||||||||||||
| 1853 | for (int i = 0; i < fragmentCount
| 0 | ||||||||||||||||||||||||||||||
| 1854 | qreal s = 0; | - | ||||||||||||||||||||||||||||||
| 1855 | qreal c = 1; | - | ||||||||||||||||||||||||||||||
| 1856 | if (fragments[i].rotation != 0
| 0 | ||||||||||||||||||||||||||||||
| 1857 | s = qFastSin(qDegreesToRadians(fragments[i].rotation)); | - | ||||||||||||||||||||||||||||||
| 1858 | c = qFastCos(qDegreesToRadians(fragments[i].rotation)); | - | ||||||||||||||||||||||||||||||
| 1859 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1860 | - | |||||||||||||||||||||||||||||||
| 1861 | qreal right = 0.5 * fragments[i].scaleX * fragments[i].width; | - | ||||||||||||||||||||||||||||||
| 1862 | qreal bottom = 0.5 * fragments[i].scaleY * fragments[i].height; | - | ||||||||||||||||||||||||||||||
| 1863 | QOpenGLPoint bottomRight(right * c - bottom * s, right * s + bottom * c); | - | ||||||||||||||||||||||||||||||
| 1864 | QOpenGLPoint bottomLeft(-right * c - bottom * s, -right * s + bottom * c); | - | ||||||||||||||||||||||||||||||
| 1865 | - | |||||||||||||||||||||||||||||||
| 1866 | vertexCoordinateArray.addVertex(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y); | - | ||||||||||||||||||||||||||||||
| 1867 | vertexCoordinateArray.addVertex(-bottomLeft.x + fragments[i].x, -bottomLeft.y + fragments[i].y); | - | ||||||||||||||||||||||||||||||
| 1868 | vertexCoordinateArray.addVertex(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y); | - | ||||||||||||||||||||||||||||||
| 1869 | vertexCoordinateArray.addVertex(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y); | - | ||||||||||||||||||||||||||||||
| 1870 | vertexCoordinateArray.addVertex(bottomLeft.x + fragments[i].x, bottomLeft.y + fragments[i].y); | - | ||||||||||||||||||||||||||||||
| 1871 | vertexCoordinateArray.addVertex(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y); | - | ||||||||||||||||||||||||||||||
| 1872 | - | |||||||||||||||||||||||||||||||
| 1873 | QOpenGLRect src(fragments[i].sourceLeft * dx, fragments[i].sourceTop * dy, | - | ||||||||||||||||||||||||||||||
| 1874 | (fragments[i].sourceLeft + fragments[i].width) * dx, | - | ||||||||||||||||||||||||||||||
| 1875 | (fragments[i].sourceTop + fragments[i].height) * dy); | - | ||||||||||||||||||||||||||||||
| 1876 | - | |||||||||||||||||||||||||||||||
| 1877 | textureCoordinateArray.addVertex(src.right, src.bottom); | - | ||||||||||||||||||||||||||||||
| 1878 | textureCoordinateArray.addVertex(src.right, src.top); | - | ||||||||||||||||||||||||||||||
| 1879 | textureCoordinateArray.addVertex(src.left, src.top); | - | ||||||||||||||||||||||||||||||
| 1880 | textureCoordinateArray.addVertex(src.left, src.top); | - | ||||||||||||||||||||||||||||||
| 1881 | textureCoordinateArray.addVertex(src.left, src.bottom); | - | ||||||||||||||||||||||||||||||
| 1882 | textureCoordinateArray.addVertex(src.right, src.bottom); | - | ||||||||||||||||||||||||||||||
| 1883 | - | |||||||||||||||||||||||||||||||
| 1884 | qreal opacity = fragments[i].opacity * q->state()->opacity; | - | ||||||||||||||||||||||||||||||
| 1885 | opacityArray << opacity << opacity << opacity << opacity << opacity << opacity; | - | ||||||||||||||||||||||||||||||
| 1886 | allOpaque &= (opacity >= 0.99f); | - | ||||||||||||||||||||||||||||||
| 1887 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1888 | - | |||||||||||||||||||||||||||||||
| 1889 | transferMode(ImageOpacityArrayDrawingMode); | - | ||||||||||||||||||||||||||||||
| 1890 | - | |||||||||||||||||||||||||||||||
| 1891 | GLenum filterMode = q->state()->renderHints & QPainter::SmoothPixmapTransform
| 0 | ||||||||||||||||||||||||||||||
| 1892 | updateTexture(GLuint(0), pixmap, 0x812F, filterMode); | - | ||||||||||||||||||||||||||||||
| 1893 | - | |||||||||||||||||||||||||||||||
| 1894 | bool isBitmap = pixmap.isQBitmap(); | - | ||||||||||||||||||||||||||||||
| 1895 | bool isOpaque = !isBitmap
| 0 | ||||||||||||||||||||||||||||||
| 1896 | - | |||||||||||||||||||||||||||||||
| 1897 | - | |||||||||||||||||||||||||||||||
| 1898 | currentBrush = noBrush; | - | ||||||||||||||||||||||||||||||
| 1899 | shaderManager->setSrcPixelType(isBitmap ? QOpenGLEngineShaderManager::PatternSrc | - | ||||||||||||||||||||||||||||||
| 1900 | : QOpenGLEngineShaderManager::ImageSrc); | - | ||||||||||||||||||||||||||||||
| 1901 | if (prepareForDraw(isOpaque)
| 0 | ||||||||||||||||||||||||||||||
| 1902 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::ImageTexture), GLuint(0)); never executed: shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::ImageTexture), GLuint(0)); | 0 | ||||||||||||||||||||||||||||||
| 1903 | - | |||||||||||||||||||||||||||||||
| 1904 | if (isBitmap
| 0 | ||||||||||||||||||||||||||||||
| 1905 | QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity); | - | ||||||||||||||||||||||||||||||
| 1906 | shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::PatternColor), col); | - | ||||||||||||||||||||||||||||||
| 1907 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1908 | - | |||||||||||||||||||||||||||||||
| 1909 | funcs.glDrawArrays(0x0004, 0, 6 * fragmentCount); | - | ||||||||||||||||||||||||||||||
| 1910 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1911 | - | |||||||||||||||||||||||||||||||
| 1912 | bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev) | - | ||||||||||||||||||||||||||||||
| 1913 | { | - | ||||||||||||||||||||||||||||||
| 1914 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1915 | - | |||||||||||||||||||||||||||||||
| 1916 | ((!(pdev->devType() == QInternal::OpenGL)) ? qt_assert("pdev->devType() == QInternal::OpenGL",__FILE__,2064) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 1917 | d->device = static_cast<QOpenGLPaintDevice*>(pdev); | - | ||||||||||||||||||||||||||||||
| 1918 | - | |||||||||||||||||||||||||||||||
| 1919 | if (!d->device
| 0 | ||||||||||||||||||||||||||||||
| 1920 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1921 | - | |||||||||||||||||||||||||||||||
| 1922 | d->device->ensureActiveTarget(); | - | ||||||||||||||||||||||||||||||
| 1923 | - | |||||||||||||||||||||||||||||||
| 1924 | if (d->device->context() != QOpenGLContext::currentContext()
| 0 | ||||||||||||||||||||||||||||||
| 1925 | QMessageLogger(__FILE__, 2073, __PRETTY_FUNCTION__).warning("QPainter::begin(): QOpenGLPaintDevice's context needs to be current"); | - | ||||||||||||||||||||||||||||||
| 1926 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1927 | } | - | ||||||||||||||||||||||||||||||
| 1928 | - | |||||||||||||||||||||||||||||||
| 1929 | d->ctx = QOpenGLContext::currentContext(); | - | ||||||||||||||||||||||||||||||
| 1930 | d->ctx->d_func()->active_engine = this; | - | ||||||||||||||||||||||||||||||
| 1931 | - | |||||||||||||||||||||||||||||||
| 1932 | QOpenGLPaintDevicePrivate::get(d->device)->beginPaint(); | - | ||||||||||||||||||||||||||||||
| 1933 | - | |||||||||||||||||||||||||||||||
| 1934 | d->funcs.initializeOpenGLFunctions(); | - | ||||||||||||||||||||||||||||||
| 1935 | - | |||||||||||||||||||||||||||||||
| 1936 | for (int i = 0; i < 3
| 0 | ||||||||||||||||||||||||||||||
| 1937 | d->vertexAttributeArraysEnabledState[i] = false; never executed: d->vertexAttributeArraysEnabledState[i] = false; | 0 | ||||||||||||||||||||||||||||||
| 1938 | - | |||||||||||||||||||||||||||||||
| 1939 | const QSize sz = d->device->size(); | - | ||||||||||||||||||||||||||||||
| 1940 | d->width = sz.width(); | - | ||||||||||||||||||||||||||||||
| 1941 | d->height = sz.height(); | - | ||||||||||||||||||||||||||||||
| 1942 | d->mode = BrushDrawingMode; | - | ||||||||||||||||||||||||||||||
| 1943 | d->brushTextureDirty = true; | - | ||||||||||||||||||||||||||||||
| 1944 | d->brushUniformsDirty = true; | - | ||||||||||||||||||||||||||||||
| 1945 | d->matrixUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 1946 | d->matrixDirty = true; | - | ||||||||||||||||||||||||||||||
| 1947 | d->compositionModeDirty = true; | - | ||||||||||||||||||||||||||||||
| 1948 | d->opacityUniformDirty = true; | - | ||||||||||||||||||||||||||||||
| 1949 | d->needsSync = true; | - | ||||||||||||||||||||||||||||||
| 1950 | d->useSystemClip = !systemClip().isEmpty(); | - | ||||||||||||||||||||||||||||||
| 1951 | d->currentBrush = QBrush(); | - | ||||||||||||||||||||||||||||||
| 1952 | - | |||||||||||||||||||||||||||||||
| 1953 | d->dirtyStencilRegion = QRect(0, 0, d->width, d->height); | - | ||||||||||||||||||||||||||||||
| 1954 | d->stencilClean = true; | - | ||||||||||||||||||||||||||||||
| 1955 | - | |||||||||||||||||||||||||||||||
| 1956 | d->shaderManager = new QOpenGLEngineShaderManager(d->ctx); | - | ||||||||||||||||||||||||||||||
| 1957 | - | |||||||||||||||||||||||||||||||
| 1958 | d->funcs.glDisable(0x0B90); | - | ||||||||||||||||||||||||||||||
| 1959 | d->funcs.glDisable(0x0B71); | - | ||||||||||||||||||||||||||||||
| 1960 | d->funcs.glDisable(0x0C11); | - | ||||||||||||||||||||||||||||||
| 1961 | - | |||||||||||||||||||||||||||||||
| 1962 | d->glyphCacheFormat = QFontEngine::Format_A8; | - | ||||||||||||||||||||||||||||||
| 1963 | - | |||||||||||||||||||||||||||||||
| 1964 | - | |||||||||||||||||||||||||||||||
| 1965 | if (!QOpenGLContext::currentContext()->isOpenGLES()
| 0 | ||||||||||||||||||||||||||||||
| 1966 | d->funcs.glDisable(0x809D); | - | ||||||||||||||||||||||||||||||
| 1967 | d->glyphCacheFormat = QFontEngine::Format_A32; | - | ||||||||||||||||||||||||||||||
| 1968 | d->multisamplingAlwaysEnabled = false; | - | ||||||||||||||||||||||||||||||
| 1969 | } never executed: elseend of block | 0 | ||||||||||||||||||||||||||||||
| 1970 | - | |||||||||||||||||||||||||||||||
| 1971 | { | - | ||||||||||||||||||||||||||||||
| 1972 | - | |||||||||||||||||||||||||||||||
| 1973 | - | |||||||||||||||||||||||||||||||
| 1974 | d->multisamplingAlwaysEnabled = d->device->context()->format().samples() > 1; | - | ||||||||||||||||||||||||||||||
| 1975 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1976 | - | |||||||||||||||||||||||||||||||
| 1977 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||||||||
| 1978 | } | - | ||||||||||||||||||||||||||||||
| 1979 | - | |||||||||||||||||||||||||||||||
| 1980 | bool QOpenGL2PaintEngineEx::end() | - | ||||||||||||||||||||||||||||||
| 1981 | { | - | ||||||||||||||||||||||||||||||
| 1982 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 1983 | - | |||||||||||||||||||||||||||||||
| 1984 | QOpenGLPaintDevicePrivate::get(d->device)->endPaint(); | - | ||||||||||||||||||||||||||||||
| 1985 | - | |||||||||||||||||||||||||||||||
| 1986 | QOpenGLContext *ctx = d->ctx; | - | ||||||||||||||||||||||||||||||
| 1987 | d->funcs.glUseProgram(0); | - | ||||||||||||||||||||||||||||||
| 1988 | d->transferMode(BrushDrawingMode); | - | ||||||||||||||||||||||||||||||
| 1989 | - | |||||||||||||||||||||||||||||||
| 1990 | ctx->d_func()->active_engine = 0; | - | ||||||||||||||||||||||||||||||
| 1991 | - | |||||||||||||||||||||||||||||||
| 1992 | d->resetGLState(); | - | ||||||||||||||||||||||||||||||
| 1993 | - | |||||||||||||||||||||||||||||||
| 1994 | delete d->shaderManager; | - | ||||||||||||||||||||||||||||||
| 1995 | d->shaderManager = 0; | - | ||||||||||||||||||||||||||||||
| 1996 | d->currentBrush = QBrush(); | - | ||||||||||||||||||||||||||||||
| 1997 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||||||||
| 1998 | } | - | ||||||||||||||||||||||||||||||
| 1999 | - | |||||||||||||||||||||||||||||||
| 2000 | void QOpenGL2PaintEngineEx::ensureActive() | - | ||||||||||||||||||||||||||||||
| 2001 | { | - | ||||||||||||||||||||||||||||||
| 2002 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 2003 | QOpenGLContext *ctx = d->ctx; | - | ||||||||||||||||||||||||||||||
| 2004 | - | |||||||||||||||||||||||||||||||
| 2005 | if (isActive()
| 0 | ||||||||||||||||||||||||||||||
| 2006 | ctx->d_func()->active_engine = this; | - | ||||||||||||||||||||||||||||||
| 2007 | d->needsSync = true; | - | ||||||||||||||||||||||||||||||
| 2008 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2009 | - | |||||||||||||||||||||||||||||||
| 2010 | if (d->needsSync
| 0 | ||||||||||||||||||||||||||||||
| 2011 | d->device->ensureActiveTarget(); | - | ||||||||||||||||||||||||||||||
| 2012 | - | |||||||||||||||||||||||||||||||
| 2013 | d->transferMode(BrushDrawingMode); | - | ||||||||||||||||||||||||||||||
| 2014 | d->funcs.glViewport(0, 0, d->width, d->height); | - | ||||||||||||||||||||||||||||||
| 2015 | d->needsSync = false; | - | ||||||||||||||||||||||||||||||
| 2016 | d->shaderManager->setDirty(); | - | ||||||||||||||||||||||||||||||
| 2017 | d->syncGlState(); | - | ||||||||||||||||||||||||||||||
| 2018 | for (int i = 0; i < 3
| 0 | ||||||||||||||||||||||||||||||
| 2019 | d->vertexAttribPointers[i] = (GLfloat*)-1; never executed: d->vertexAttribPointers[i] = (GLfloat*)-1; | 0 | ||||||||||||||||||||||||||||||
| 2020 | setState(state()); | - | ||||||||||||||||||||||||||||||
| 2021 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2022 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||||||||
| 2024 | void QOpenGL2PaintEngineExPrivate::updateClipScissorTest() | - | ||||||||||||||||||||||||||||||
| 2025 | { | - | ||||||||||||||||||||||||||||||
| 2026 | QOpenGL2PaintEngineEx * const q = q_func(); | - | ||||||||||||||||||||||||||||||
| 2027 | if (q->state()->clipTestEnabled
| 0 | ||||||||||||||||||||||||||||||
| 2028 | funcs.glEnable(0x0B90); | - | ||||||||||||||||||||||||||||||
| 2029 | funcs.glStencilFunc(0x0203, q->state()->currentClip, ~GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 2030 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 2031 | funcs.glDisable(0x0B90); | - | ||||||||||||||||||||||||||||||
| 2032 | funcs.glStencilFunc(0x0207, 0, 0xff); | - | ||||||||||||||||||||||||||||||
| 2033 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2034 | - | |||||||||||||||||||||||||||||||
| 2035 | - | |||||||||||||||||||||||||||||||
| 2036 | - | |||||||||||||||||||||||||||||||
| 2037 | - | |||||||||||||||||||||||||||||||
| 2038 | QRect bounds = q->state()->rectangleClip; | - | ||||||||||||||||||||||||||||||
| 2039 | if (!q->state()->clipEnabled
| 0 | ||||||||||||||||||||||||||||||
| 2040 | if (useSystemClip
| 0 | ||||||||||||||||||||||||||||||
| 2041 | bounds = systemClip.boundingRect(); never executed: bounds = systemClip.boundingRect(); | 0 | ||||||||||||||||||||||||||||||
| 2042 | else | - | ||||||||||||||||||||||||||||||
| 2043 | bounds = QRect(0, 0, width, height); never executed: bounds = QRect(0, 0, width, height); | 0 | ||||||||||||||||||||||||||||||
| 2044 | } else { | - | ||||||||||||||||||||||||||||||
| 2045 | if (useSystemClip
| 0 | ||||||||||||||||||||||||||||||
| 2046 | bounds = bounds.intersected(systemClip.boundingRect()); never executed: bounds = bounds.intersected(systemClip.boundingRect()); | 0 | ||||||||||||||||||||||||||||||
| 2047 | else | - | ||||||||||||||||||||||||||||||
| 2048 | bounds = bounds.intersected(QRect(0, 0, width, height)); never executed: bounds = bounds.intersected(QRect(0, 0, width, height)); | 0 | ||||||||||||||||||||||||||||||
| 2049 | } | - | ||||||||||||||||||||||||||||||
| 2050 | - | |||||||||||||||||||||||||||||||
| 2051 | currentScissorBounds = bounds; | - | ||||||||||||||||||||||||||||||
| 2052 | - | |||||||||||||||||||||||||||||||
| 2053 | if (bounds == QRect(0, 0, width, height)
| 0 | ||||||||||||||||||||||||||||||
| 2054 | funcs.glDisable(0x0C11); | - | ||||||||||||||||||||||||||||||
| 2055 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 2056 | funcs.glEnable(0x0C11); | - | ||||||||||||||||||||||||||||||
| 2057 | setScissor(bounds); | - | ||||||||||||||||||||||||||||||
| 2058 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2059 | - | |||||||||||||||||||||||||||||||
| 2060 | } | - | ||||||||||||||||||||||||||||||
| 2061 | - | |||||||||||||||||||||||||||||||
| 2062 | void QOpenGL2PaintEngineExPrivate::setScissor(const QRect &rect) | - | ||||||||||||||||||||||||||||||
| 2063 | { | - | ||||||||||||||||||||||||||||||
| 2064 | const int left = rect.left(); | - | ||||||||||||||||||||||||||||||
| 2065 | const int width = rect.width(); | - | ||||||||||||||||||||||||||||||
| 2066 | int bottom = height - (rect.top() + rect.height()); | - | ||||||||||||||||||||||||||||||
| 2067 | if (device->paintFlipped()
| 0 | ||||||||||||||||||||||||||||||
| 2068 | bottom = rect.top(); | - | ||||||||||||||||||||||||||||||
| 2069 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2070 | const int height = rect.height(); | - | ||||||||||||||||||||||||||||||
| 2071 | - | |||||||||||||||||||||||||||||||
| 2072 | funcs.glScissor(left, bottom, width, height); | - | ||||||||||||||||||||||||||||||
| 2073 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2074 | - | |||||||||||||||||||||||||||||||
| 2075 | void QOpenGL2PaintEngineEx::clipEnabledChanged() | - | ||||||||||||||||||||||||||||||
| 2076 | { | - | ||||||||||||||||||||||||||||||
| 2077 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 2078 | - | |||||||||||||||||||||||||||||||
| 2079 | state()->clipChanged = true; | - | ||||||||||||||||||||||||||||||
| 2080 | - | |||||||||||||||||||||||||||||||
| 2081 | if (painter()->hasClipping()
| 0 | ||||||||||||||||||||||||||||||
| 2082 | d->regenerateClip(); never executed: d->regenerateClip(); | 0 | ||||||||||||||||||||||||||||||
| 2083 | else | - | ||||||||||||||||||||||||||||||
| 2084 | d->systemStateChanged(); never executed: d->systemStateChanged(); | 0 | ||||||||||||||||||||||||||||||
| 2085 | } | - | ||||||||||||||||||||||||||||||
| 2086 | - | |||||||||||||||||||||||||||||||
| 2087 | void QOpenGL2PaintEngineExPrivate::clearClip(uint value) | - | ||||||||||||||||||||||||||||||
| 2088 | { | - | ||||||||||||||||||||||||||||||
| 2089 | dirtyStencilRegion -= currentScissorBounds; | - | ||||||||||||||||||||||||||||||
| 2090 | - | |||||||||||||||||||||||||||||||
| 2091 | funcs.glStencilMask(0xff); | - | ||||||||||||||||||||||||||||||
| 2092 | funcs.glClearStencil(value); | - | ||||||||||||||||||||||||||||||
| 2093 | funcs.glClear(0x00000400); | - | ||||||||||||||||||||||||||||||
| 2094 | funcs.glStencilMask(0x0); | - | ||||||||||||||||||||||||||||||
| 2095 | - | |||||||||||||||||||||||||||||||
| 2096 | q->state()->needsClipBufferClear = false; | - | ||||||||||||||||||||||||||||||
| 2097 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2098 | - | |||||||||||||||||||||||||||||||
| 2099 | void QOpenGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value) | - | ||||||||||||||||||||||||||||||
| 2100 | { | - | ||||||||||||||||||||||||||||||
| 2101 | transferMode(BrushDrawingMode); | - | ||||||||||||||||||||||||||||||
| 2102 | - | |||||||||||||||||||||||||||||||
| 2103 | if (snapToPixelGrid
| 0 | ||||||||||||||||||||||||||||||
| 2104 | snapToPixelGrid = false; | - | ||||||||||||||||||||||||||||||
| 2105 | matrixDirty = true; | - | ||||||||||||||||||||||||||||||
| 2106 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2107 | - | |||||||||||||||||||||||||||||||
| 2108 | if (matrixDirty
| 0 | ||||||||||||||||||||||||||||||
| 2109 | updateMatrix(); never executed: updateMatrix(); | 0 | ||||||||||||||||||||||||||||||
| 2110 | - | |||||||||||||||||||||||||||||||
| 2111 | stencilClean = false; | - | ||||||||||||||||||||||||||||||
| 2112 | - | |||||||||||||||||||||||||||||||
| 2113 | const bool singlePass = !path.hasWindingFill()
| 0 | ||||||||||||||||||||||||||||||
| 2114 | && (((
| 0 | ||||||||||||||||||||||||||||||
| 2115 | || q->state()->needsClipBufferClear
| 0 | ||||||||||||||||||||||||||||||
| 2116 | const uint referenceClipValue = q->state()->needsClipBufferClear
| 0 | ||||||||||||||||||||||||||||||
| 2117 | - | |||||||||||||||||||||||||||||||
| 2118 | if (q->state()->needsClipBufferClear
| 0 | ||||||||||||||||||||||||||||||
| 2119 | clearClip(1); never executed: clearClip(1); | 0 | ||||||||||||||||||||||||||||||
| 2120 | - | |||||||||||||||||||||||||||||||
| 2121 | if (path.isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 2122 | funcs.glEnable(0x0B90); | - | ||||||||||||||||||||||||||||||
| 2123 | funcs.glStencilFunc(0x0203, value, ~GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 2124 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2125 | } | - | ||||||||||||||||||||||||||||||
| 2126 | - | |||||||||||||||||||||||||||||||
| 2127 | if (q->state()->clipTestEnabled
| 0 | ||||||||||||||||||||||||||||||
| 2128 | funcs.glStencilFunc(0x0203, q->state()->currentClip, ~GLuint(0x80)); never executed: funcs.glStencilFunc(0x0203, q->state()->currentClip, ~GLuint(0x80)); | 0 | ||||||||||||||||||||||||||||||
| 2129 | else | - | ||||||||||||||||||||||||||||||
| 2130 | funcs.glStencilFunc(0x0207, 0, 0xff); never executed: funcs.glStencilFunc(0x0207, 0, 0xff); | 0 | ||||||||||||||||||||||||||||||
| 2131 | - | |||||||||||||||||||||||||||||||
| 2132 | vertexCoordinateArray.clear(); | - | ||||||||||||||||||||||||||||||
| 2133 | vertexCoordinateArray.addPath(path, inverseScale, false); | - | ||||||||||||||||||||||||||||||
| 2134 | - | |||||||||||||||||||||||||||||||
| 2135 | if (!singlePass
| 0 | ||||||||||||||||||||||||||||||
| 2136 | fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill()); never executed: fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill()); | 0 | ||||||||||||||||||||||||||||||
| 2137 | - | |||||||||||||||||||||||||||||||
| 2138 | funcs.glColorMask(false, false, false, false); | - | ||||||||||||||||||||||||||||||
| 2139 | funcs.glEnable(0x0B90); | - | ||||||||||||||||||||||||||||||
| 2140 | useSimpleShader(); | - | ||||||||||||||||||||||||||||||
| 2141 | - | |||||||||||||||||||||||||||||||
| 2142 | if (singlePass
| 0 | ||||||||||||||||||||||||||||||
| 2143 | - | |||||||||||||||||||||||||||||||
| 2144 | - | |||||||||||||||||||||||||||||||
| 2145 | - | |||||||||||||||||||||||||||||||
| 2146 | funcs.glStencilFunc(0x0203, referenceClipValue, ~GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 2147 | funcs.glStencilOp(0x1E00, 0x150A, 0x150A); | - | ||||||||||||||||||||||||||||||
| 2148 | funcs.glStencilMask(value ^ referenceClipValue); | - | ||||||||||||||||||||||||||||||
| 2149 | - | |||||||||||||||||||||||||||||||
| 2150 | drawVertexArrays(vertexCoordinateArray, 0x0006); | - | ||||||||||||||||||||||||||||||
| 2151 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 2152 | funcs.glStencilOp(0x1E00, 0x1E01, 0x1E01); | - | ||||||||||||||||||||||||||||||
| 2153 | funcs.glStencilMask(0xff); | - | ||||||||||||||||||||||||||||||
| 2154 | - | |||||||||||||||||||||||||||||||
| 2155 | if (!q->state()->clipTestEnabled
| 0 | ||||||||||||||||||||||||||||||
| 2156 | - | |||||||||||||||||||||||||||||||
| 2157 | funcs.glStencilFunc(0x0205, GLuint(0x80), ~GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 2158 | composite(vertexCoordinateArray.boundingRect()); | - | ||||||||||||||||||||||||||||||
| 2159 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2160 | - | |||||||||||||||||||||||||||||||
| 2161 | - | |||||||||||||||||||||||||||||||
| 2162 | funcs.glStencilFunc(0x0205, value, GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 2163 | - | |||||||||||||||||||||||||||||||
| 2164 | composite(vertexCoordinateArray.boundingRect()); | - | ||||||||||||||||||||||||||||||
| 2165 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2166 | - | |||||||||||||||||||||||||||||||
| 2167 | funcs.glStencilFunc(0x0203, value, ~GLuint(0x80)); | - | ||||||||||||||||||||||||||||||
| 2168 | funcs.glStencilMask(0); | - | ||||||||||||||||||||||||||||||
| 2169 | - | |||||||||||||||||||||||||||||||
| 2170 | funcs.glColorMask(true, true, true, true); | - | ||||||||||||||||||||||||||||||
| 2171 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2172 | - | |||||||||||||||||||||||||||||||
| 2173 | void QOpenGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) | - | ||||||||||||||||||||||||||||||
| 2174 | { | - | ||||||||||||||||||||||||||||||
| 2175 | - | |||||||||||||||||||||||||||||||
| 2176 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 2177 | - | |||||||||||||||||||||||||||||||
| 2178 | state()->clipChanged = true; | - | ||||||||||||||||||||||||||||||
| 2179 | - | |||||||||||||||||||||||||||||||
| 2180 | ensureActive(); | - | ||||||||||||||||||||||||||||||
| 2181 | - | |||||||||||||||||||||||||||||||
| 2182 | if (op == Qt::ReplaceClip
| 0 | ||||||||||||||||||||||||||||||
| 2183 | op = Qt::IntersectClip; | - | ||||||||||||||||||||||||||||||
| 2184 | if (d->hasClipOperations()
| 0 | ||||||||||||||||||||||||||||||
| 2185 | d->systemStateChanged(); | - | ||||||||||||||||||||||||||||||
| 2186 | state()->canRestoreClip = false; | - | ||||||||||||||||||||||||||||||
| 2187 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2188 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2189 | - | |||||||||||||||||||||||||||||||
| 2190 | - | |||||||||||||||||||||||||||||||
| 2191 | if (!path.isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 2192 | const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); | - | ||||||||||||||||||||||||||||||
| 2193 | QRectF rect(points[0], points[2]); | - | ||||||||||||||||||||||||||||||
| 2194 | - | |||||||||||||||||||||||||||||||
| 2195 | if (state()->matrix.type() <= QTransform::TxScale
| 0 | ||||||||||||||||||||||||||||||
| 2196 | || (state()->matrix.type() == QTransform::TxRotate
| 0 | ||||||||||||||||||||||||||||||
| 2197 | && qFuzzyIsNull(state()->matrix.m11())
| 0 | ||||||||||||||||||||||||||||||
| 2198 | && qFuzzyIsNull(state()->matrix.m22())
| 0 | ||||||||||||||||||||||||||||||
| 2199 | { | - | ||||||||||||||||||||||||||||||
| 2200 | state()->rectangleClip = state()->rectangleClip.intersected(state()->matrix.mapRect(rect).toRect()); | - | ||||||||||||||||||||||||||||||
| 2201 | d->updateClipScissorTest(); | - | ||||||||||||||||||||||||||||||
| 2202 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2203 | } | - | ||||||||||||||||||||||||||||||
| 2204 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2205 | - | |||||||||||||||||||||||||||||||
| 2206 | - | |||||||||||||||||||||||||||||||
| 2207 | const QRect pathRect = state()->matrix.mapRect(path.controlPointRect()).toAlignedRect(); | - | ||||||||||||||||||||||||||||||
| 2208 | - | |||||||||||||||||||||||||||||||
| 2209 | switch (op) { | - | ||||||||||||||||||||||||||||||
| 2210 | case never executed: Qt::NoClip:case Qt::NoClip:never executed: case Qt::NoClip: | 0 | ||||||||||||||||||||||||||||||
| 2211 | if (d->useSystemClip
| 0 | ||||||||||||||||||||||||||||||
| 2212 | state()->clipTestEnabled = true; | - | ||||||||||||||||||||||||||||||
| 2213 | state()->currentClip = 1; | - | ||||||||||||||||||||||||||||||
| 2214 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 2215 | state()->clipTestEnabled = false; | - | ||||||||||||||||||||||||||||||
| 2216 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2217 | state()->rectangleClip = QRect(0, 0, d->width, d->height); | - | ||||||||||||||||||||||||||||||
| 2218 | state()->canRestoreClip = false; | - | ||||||||||||||||||||||||||||||
| 2219 | d->updateClipScissorTest(); | - | ||||||||||||||||||||||||||||||
| 2220 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2221 | case never executed: Qt::IntersectClip:case Qt::IntersectClip:never executed: case Qt::IntersectClip: | 0 | ||||||||||||||||||||||||||||||
| 2222 | state()->rectangleClip = state()->rectangleClip.intersected(pathRect); | - | ||||||||||||||||||||||||||||||
| 2223 | d->updateClipScissorTest(); | - | ||||||||||||||||||||||||||||||
| 2224 | d->resetClipIfNeeded(); | - | ||||||||||||||||||||||||||||||
| 2225 | ++d->maxClip; | - | ||||||||||||||||||||||||||||||
| 2226 | d->writeClip(path, d->maxClip); | - | ||||||||||||||||||||||||||||||
| 2227 | state()->currentClip = d->maxClip; | - | ||||||||||||||||||||||||||||||
| 2228 | state()->clipTestEnabled = true; | - | ||||||||||||||||||||||||||||||
| 2229 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2230 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 2231 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 2232 | } | - | ||||||||||||||||||||||||||||||
| 2233 | } | - | ||||||||||||||||||||||||||||||
| 2234 | - | |||||||||||||||||||||||||||||||
| 2235 | void QOpenGL2PaintEngineExPrivate::regenerateClip() | - | ||||||||||||||||||||||||||||||
| 2236 | { | - | ||||||||||||||||||||||||||||||
| 2237 | systemStateChanged(); | - | ||||||||||||||||||||||||||||||
| 2238 | replayClipOperations(); | - | ||||||||||||||||||||||||||||||
| 2239 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2240 | - | |||||||||||||||||||||||||||||||
| 2241 | void QOpenGL2PaintEngineExPrivate::systemStateChanged() | - | ||||||||||||||||||||||||||||||
| 2242 | { | - | ||||||||||||||||||||||||||||||
| 2243 | QOpenGL2PaintEngineEx * const q = q_func(); | - | ||||||||||||||||||||||||||||||
| 2244 | - | |||||||||||||||||||||||||||||||
| 2245 | q->state()->clipChanged = true; | - | ||||||||||||||||||||||||||||||
| 2246 | - | |||||||||||||||||||||||||||||||
| 2247 | if (systemClip.isEmpty()
| 0 | ||||||||||||||||||||||||||||||
| 2248 | useSystemClip = false; | - | ||||||||||||||||||||||||||||||
| 2249 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 2250 | if (q->paintDevice()->devType() == QInternal::Widget
| 0 | ||||||||||||||||||||||||||||||
| 2251 | - | |||||||||||||||||||||||||||||||
| 2252 | - | |||||||||||||||||||||||||||||||
| 2253 | useSystemClip = true; | - | ||||||||||||||||||||||||||||||
| 2254 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 2255 | useSystemClip = true; | - | ||||||||||||||||||||||||||||||
| 2256 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2257 | } | - | ||||||||||||||||||||||||||||||
| 2258 | - | |||||||||||||||||||||||||||||||
| 2259 | q->state()->clipTestEnabled = false; | - | ||||||||||||||||||||||||||||||
| 2260 | q->state()->needsClipBufferClear = true; | - | ||||||||||||||||||||||||||||||
| 2261 | - | |||||||||||||||||||||||||||||||
| 2262 | q->state()->currentClip = 1; | - | ||||||||||||||||||||||||||||||
| 2263 | maxClip = 1; | - | ||||||||||||||||||||||||||||||
| 2264 | - | |||||||||||||||||||||||||||||||
| 2265 | q->state()->rectangleClip = useSystemClip
| 0 | ||||||||||||||||||||||||||||||
| 2266 | updateClipScissorTest(); | - | ||||||||||||||||||||||||||||||
| 2267 | - | |||||||||||||||||||||||||||||||
| 2268 | if (systemClip.rectCount() == 1
| 0 | ||||||||||||||||||||||||||||||
| 2269 | if (systemClip.boundingRect() == QRect(0, 0, width, height)
| 0 | ||||||||||||||||||||||||||||||
| 2270 | useSystemClip = false; never executed: useSystemClip = false; | 0 | ||||||||||||||||||||||||||||||
| 2271 | - | |||||||||||||||||||||||||||||||
| 2272 | - | |||||||||||||||||||||||||||||||
| 2273 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2274 | - | |||||||||||||||||||||||||||||||
| 2275 | } | - | ||||||||||||||||||||||||||||||
| 2276 | - | |||||||||||||||||||||||||||||||
| 2277 | if (useSystemClip
| 0 | ||||||||||||||||||||||||||||||
| 2278 | clearClip(0); | - | ||||||||||||||||||||||||||||||
| 2279 | - | |||||||||||||||||||||||||||||||
| 2280 | QPainterPath path; | - | ||||||||||||||||||||||||||||||
| 2281 | path.addRegion(systemClip); | - | ||||||||||||||||||||||||||||||
| 2282 | - | |||||||||||||||||||||||||||||||
| 2283 | q->state()->currentClip = 0; | - | ||||||||||||||||||||||||||||||
| 2284 | writeClip(qtVectorPathForPath(q->state()->matrix.inverted().map(path)), 1); | - | ||||||||||||||||||||||||||||||
| 2285 | q->state()->currentClip = 1; | - | ||||||||||||||||||||||||||||||
| 2286 | q->state()->clipTestEnabled = true; | - | ||||||||||||||||||||||||||||||
| 2287 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2288 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2289 | - | |||||||||||||||||||||||||||||||
| 2290 | void QOpenGL2PaintEngineEx::setState(QPainterState *new_state) | - | ||||||||||||||||||||||||||||||
| 2291 | { | - | ||||||||||||||||||||||||||||||
| 2292 | - | |||||||||||||||||||||||||||||||
| 2293 | - | |||||||||||||||||||||||||||||||
| 2294 | QOpenGL2PaintEngineExPrivate * const d = d_func(); | - | ||||||||||||||||||||||||||||||
| 2295 | - | |||||||||||||||||||||||||||||||
| 2296 | QOpenGL2PaintEngineState *s = static_cast<QOpenGL2PaintEngineState *>(new_state); | - | ||||||||||||||||||||||||||||||
| 2297 | QOpenGL2PaintEngineState *old_state = state(); | - | ||||||||||||||||||||||||||||||
| 2298 | - | |||||||||||||||||||||||||||||||
| 2299 | QPaintEngineEx::setState(s); | - | ||||||||||||||||||||||||||||||
| 2300 | - | |||||||||||||||||||||||||||||||
| 2301 | if (s->isNew
| 0 | ||||||||||||||||||||||||||||||
| 2302 | - | |||||||||||||||||||||||||||||||
| 2303 | - | |||||||||||||||||||||||||||||||
| 2304 | - | |||||||||||||||||||||||||||||||
| 2305 | s->isNew = false; | - | ||||||||||||||||||||||||||||||
| 2306 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 2307 | } | - | ||||||||||||||||||||||||||||||
| 2308 | - | |||||||||||||||||||||||||||||||
| 2309 | - | |||||||||||||||||||||||||||||||
| 2310 | - | |||||||||||||||||||||||||||||||
| 2311 | if (old_state == s
| 0 | ||||||||||||||||||||||||||||||
| 2312 | renderHintsChanged(); never executed: renderHintsChanged(); | 0 | ||||||||||||||||||||||||||||||
| 2313 | - | |||||||||||||||||||||||||||||||
| 2314 | if (old_state == s
| 0 | ||||||||||||||||||||||||||||||
| 2315 | d->matrixDirty = true; never executed: d->matrixDirty = true; | 0 | ||||||||||||||||||||||||||||||
| 2316 | - | |||||||||||||||||||||||||||||||
| 2317 | if (old_state == s
| 0 | ||||||||||||||||||||||||||||||
| 2318 | d->compositionModeDirty = true; never executed: d->compositionModeDirty = true; | 0 | ||||||||||||||||||||||||||||||
| 2319 | - | |||||||||||||||||||||||||||||||
| 2320 | if (old_state == s
| 0 | ||||||||||||||||||||||||||||||
| 2321 | d->opacityUniformDirty = true; never executed: d->opacityUniformDirty = true; | 0 | ||||||||||||||||||||||||||||||
| 2322 | - | |||||||||||||||||||||||||||||||
| 2323 | if (old_state == s
| 0 | ||||||||||||||||||||||||||||||
| 2324 | if (old_state
| 0 | ||||||||||||||||||||||||||||||
| 2325 | d->updateClipScissorTest(); | - | ||||||||||||||||||||||||||||||
| 2326 | d->funcs.glDepthFunc(0x0203); | - | ||||||||||||||||||||||||||||||
| 2327 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||||||||
| 2328 | d->regenerateClip(); | - | ||||||||||||||||||||||||||||||
| 2329 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2330 | } | - | ||||||||||||||||||||||||||||||
| 2331 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2332 | - | |||||||||||||||||||||||||||||||
| 2333 | QPainterState *QOpenGL2PaintEngineEx::createState(QPainterState *orig) const | - | ||||||||||||||||||||||||||||||
| 2334 | { | - | ||||||||||||||||||||||||||||||
| 2335 | if (orig
| 0 | ||||||||||||||||||||||||||||||
| 2336 | const_cast< never executed: QOpenGL2PaintEngineEx *>(this)->ensureActive();const_cast<QOpenGL2PaintEngineEx *>(this)->ensureActive();never executed: const_cast<QOpenGL2PaintEngineEx *>(this)->ensureActive(); | 0 | ||||||||||||||||||||||||||||||
| 2337 | - | |||||||||||||||||||||||||||||||
| 2338 | QOpenGL2PaintEngineState *s; | - | ||||||||||||||||||||||||||||||
| 2339 | if (!orig
| 0 | ||||||||||||||||||||||||||||||
| 2340 | s = new QOpenGL2PaintEngineState(); never executed: s = new QOpenGL2PaintEngineState(); | 0 | ||||||||||||||||||||||||||||||
| 2341 | else | - | ||||||||||||||||||||||||||||||
| 2342 | s = new QOpenGL2PaintEngineState(*static_cast<QOpenGL2PaintEngineState *>(orig)); never executed: s = new QOpenGL2PaintEngineState(*static_cast<QOpenGL2PaintEngineState *>(orig)); | 0 | ||||||||||||||||||||||||||||||
| 2343 | - | |||||||||||||||||||||||||||||||
| 2344 | s->matrixChanged = false; | - | ||||||||||||||||||||||||||||||
| 2345 | s->compositionModeChanged = false; | - | ||||||||||||||||||||||||||||||
| 2346 | s->opacityChanged = false; | - | ||||||||||||||||||||||||||||||
| 2347 | s->renderHintsChanged = false; | - | ||||||||||||||||||||||||||||||
| 2348 | s->clipChanged = false; | - | ||||||||||||||||||||||||||||||
| 2349 | - | |||||||||||||||||||||||||||||||
| 2350 | return never executed: s;return s;never executed: return s; | 0 | ||||||||||||||||||||||||||||||
| 2351 | } | - | ||||||||||||||||||||||||||||||
| 2352 | - | |||||||||||||||||||||||||||||||
| 2353 | QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &other) | - | ||||||||||||||||||||||||||||||
| 2354 | : QPainterState(other) | - | ||||||||||||||||||||||||||||||
| 2355 | { | - | ||||||||||||||||||||||||||||||
| 2356 | isNew = true; | - | ||||||||||||||||||||||||||||||
| 2357 | needsClipBufferClear = other.needsClipBufferClear; | - | ||||||||||||||||||||||||||||||
| 2358 | clipTestEnabled = other.clipTestEnabled; | - | ||||||||||||||||||||||||||||||
| 2359 | currentClip = other.currentClip; | - | ||||||||||||||||||||||||||||||
| 2360 | canRestoreClip = other.canRestoreClip; | - | ||||||||||||||||||||||||||||||
| 2361 | rectangleClip = other.rectangleClip; | - | ||||||||||||||||||||||||||||||
| 2362 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2363 | - | |||||||||||||||||||||||||||||||
| 2364 | QOpenGL2PaintEngineState::QOpenGL2PaintEngineState() | - | ||||||||||||||||||||||||||||||
| 2365 | { | - | ||||||||||||||||||||||||||||||
| 2366 | isNew = true; | - | ||||||||||||||||||||||||||||||
| 2367 | needsClipBufferClear = true; | - | ||||||||||||||||||||||||||||||
| 2368 | clipTestEnabled = false; | - | ||||||||||||||||||||||||||||||
| 2369 | canRestoreClip = true; | - | ||||||||||||||||||||||||||||||
| 2370 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2371 | - | |||||||||||||||||||||||||||||||
| 2372 | QOpenGL2PaintEngineState::~QOpenGL2PaintEngineState() | - | ||||||||||||||||||||||||||||||
| 2373 | { | - | ||||||||||||||||||||||||||||||
| 2374 | } | - | ||||||||||||||||||||||||||||||
| 2375 | - | |||||||||||||||||||||||||||||||
| 2376 | void QOpenGL2PaintEngineExPrivate::setVertexAttribArrayEnabled(int arrayIndex, bool enabled) | - | ||||||||||||||||||||||||||||||
| 2377 | { | - | ||||||||||||||||||||||||||||||
| 2378 | ((!(arrayIndex < 3)) ? qt_assert("arrayIndex < QT_GL_VERTEX_ARRAY_TRACKED_COUNT",__FILE__,2538) : qt_noop()); | - | ||||||||||||||||||||||||||||||
| 2379 | - | |||||||||||||||||||||||||||||||
| 2380 | if (vertexAttributeArraysEnabledState[arrayIndex]
| 0 | ||||||||||||||||||||||||||||||
| 2381 | funcs.glDisableVertexAttribArray(arrayIndex); never executed: funcs.glDisableVertexAttribArray(arrayIndex); | 0 | ||||||||||||||||||||||||||||||
| 2382 | - | |||||||||||||||||||||||||||||||
| 2383 | if (!vertexAttributeArraysEnabledState[arrayIndex]
| 0 | ||||||||||||||||||||||||||||||
| 2384 | funcs.glEnableVertexAttribArray(arrayIndex); never executed: funcs.glEnableVertexAttribArray(arrayIndex); | 0 | ||||||||||||||||||||||||||||||
| 2385 | - | |||||||||||||||||||||||||||||||
| 2386 | vertexAttributeArraysEnabledState[arrayIndex] = enabled; | - | ||||||||||||||||||||||||||||||
| 2387 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2388 | - | |||||||||||||||||||||||||||||||
| 2389 | void QOpenGL2PaintEngineExPrivate::syncGlState() | - | ||||||||||||||||||||||||||||||
| 2390 | { | - | ||||||||||||||||||||||||||||||
| 2391 | for (int i = 0; i < 3
| 0 | ||||||||||||||||||||||||||||||
| 2392 | if (vertexAttributeArraysEnabledState[i]
| 0 | ||||||||||||||||||||||||||||||
| 2393 | funcs.glEnableVertexAttribArray(i); never executed: funcs.glEnableVertexAttribArray(i); | 0 | ||||||||||||||||||||||||||||||
| 2394 | else | - | ||||||||||||||||||||||||||||||
| 2395 | funcs.glDisableVertexAttribArray(i); never executed: funcs.glDisableVertexAttribArray(i); | 0 | ||||||||||||||||||||||||||||||
| 2396 | } | - | ||||||||||||||||||||||||||||||
| 2397 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 2398 | - | |||||||||||||||||||||||||||||||
| 2399 | - | |||||||||||||||||||||||||||||||
| 2400 | - | |||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |