gl2paintengineex/qpaintengineex_opengl2.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12 -
13 -
14 -
15 -
16 -
17__attribute__((visibility("default"))) QImage qt_imageForBrush(int brushStyle, bool invert); -
18 -
19 -
20 -
21QGL2PaintEngineExPrivate::~QGL2PaintEngineExPrivate() -
22{ -
23 delete shaderManager; -
24 -
25 while (pathCaches.size()) {
never evaluated: pathCaches.size()
0
26 QVectorPath::CacheEntry *e = *(pathCaches.constBegin()); -
27 e->cleanup(e->engine, e->data); -
28 e->data = 0; -
29 e->engine = 0; -
30 }
never executed: }
0
31 -
32 if (elementIndicesVBOId != 0) {
never evaluated: elementIndicesVBOId != 0
0
33 QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteBuffers(1, &elementIndicesVBOId); -
34 elementIndicesVBOId = 0; -
35 }
never executed: }
0
36}
never executed: }
0
37 -
38void QGL2PaintEngineExPrivate::updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id) -
39{ -
40 -
41 if (id != GLuint(-1) && id == lastTextureUsed)
never evaluated: id != GLuint(-1)
never evaluated: id == lastTextureUsed
0
42 return;
never executed: return;
0
43 -
44 lastTextureUsed = id; -
45 -
46 if (smoothPixmapTransform) {
never evaluated: smoothPixmapTransform
0
47 glTexParameteri(target, 0x2800, 0x2601); -
48 glTexParameteri(target, 0x2801, 0x2601); -
49 } else {
never executed: }
0
50 glTexParameteri(target, 0x2800, 0x2600); -
51 glTexParameteri(target, 0x2801, 0x2600); -
52 }
never executed: }
0
53 glTexParameteri(target, 0x2802, wrapMode); -
54 glTexParameteri(target, 0x2803, wrapMode); -
55}
never executed: }
0
56 -
57 -
58inline QColor qt_premultiplyColor(QColor c, GLfloat opacity) -
59{ -
60 qreal alpha = c.alphaF() * opacity; -
61 c.setAlphaF(alpha); -
62 c.setRedF(c.redF() * alpha); -
63 c.setGreenF(c.greenF() * alpha); -
64 c.setBlueF(c.blueF() * alpha); -
65 return c;
never executed: return c;
0
66} -
67 -
68 -
69void QGL2PaintEngineExPrivate::setBrush(const QBrush& brush) -
70{ -
71 if (qbrush_fast_equals(currentBrush, brush))
never evaluated: qbrush_fast_equals(currentBrush, brush)
0
72 return;
never executed: return;
0
73 -
74 const Qt::BrushStyle newStyle = qbrush_style(brush); -
75 qt_noop(); -
76 -
77 currentBrush = brush; -
78 if (!currentBrushPixmap.isNull())
never evaluated: !currentBrushPixmap.isNull()
0
79 currentBrushPixmap = QPixmap();
never executed: currentBrushPixmap = QPixmap();
0
80 brushUniformsDirty = true; -
81 -
82 if (newStyle > Qt::SolidPattern)
never evaluated: newStyle > Qt::SolidPattern
0
83 brushTextureDirty = true;
never executed: brushTextureDirty = true;
0
84 -
85 if (currentBrush.style() == Qt::TexturePattern
never evaluated: currentBrush.style() == Qt::TexturePattern
0
86 && qHasPixmapTexture(brush) && brush.texture().isQBitmap())
never evaluated: qHasPixmapTexture(brush)
never evaluated: brush.texture().isQBitmap()
0
87 { -
88 shaderManager->setSrcPixelType(QGLEngineShaderManager::TextureSrcWithPattern); -
89 } else {
never executed: }
0
90 shaderManager->setSrcPixelType(newStyle); -
91 }
never executed: }
0
92 shaderManager->optimiseForBrushTransform(currentBrush.transform().type()); -
93}
never executed: }
0
94 -
95 -
96void QGL2PaintEngineExPrivate::useSimpleShader() -
97{ -
98 shaderManager->useSimpleProgram(); -
99 -
100 if (matrixDirty)
never evaluated: matrixDirty
0
101 updateMatrix();
never executed: updateMatrix();
0
102}
never executed: }
0
103 -
104 -
105 -
106 -
107 -
108 -
109 -
110void QGL2PaintEngineExPrivate::updateBrushTexture() -
111{ -
112 QGL2PaintEngineEx * const q = q_func(); -
113 -
114 Qt::BrushStyle style = currentBrush.style(); -
115 -
116 if ( (style >= Qt::Dense1Pattern) && (style <= Qt::DiagCrossPattern) ) {
never evaluated: (style >= Qt::Dense1Pattern)
never evaluated: (style <= Qt::DiagCrossPattern)
0
117 -
118 QImage texImage = qt_imageForBrush(style, false); -
119 -
120 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(0)); -
121 ctx->d_func()->bindTexture(texImage, 0x0DE1, 0x1908, QGLContext::InternalBindOption); -
122 updateTextureFilter(0x0DE1, 0x2901, q->state()->renderHints & QPainter::SmoothPixmapTransform); -
123 }
never executed: }
0
124 else if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
never evaluated: style >= Qt::LinearGradientPattern
never evaluated: style <= Qt::ConicalGradientPattern
0
125 -
126 -
127 const QGradient* g = currentBrush.gradient(); -
128 -
129 -
130 -
131 GLuint texId = QGL2GradientCache::cacheForContext(ctx)->getBuffer(*g, 1.0); -
132 -
133 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(0)); -
134 glBindTexture(0x0DE1, texId); -
135 -
136 if (g->spread() == QGradient::RepeatSpread || g->type() == QGradient::ConicalGradient)
never evaluated: g->spread() == QGradient::RepeatSpread
never evaluated: g->type() == QGradient::ConicalGradient
0
137 updateTextureFilter(0x0DE1, 0x2901, q->state()->renderHints & QPainter::SmoothPixmapTransform);
never executed: updateTextureFilter(0x0DE1, 0x2901, q->state()->renderHints & QPainter::SmoothPixmapTransform);
0
138 else if (g->spread() == QGradient::ReflectSpread)
never evaluated: g->spread() == QGradient::ReflectSpread
0
139 updateTextureFilter(0x0DE1, 0x8370, q->state()->renderHints & QPainter::SmoothPixmapTransform);
never executed: updateTextureFilter(0x0DE1, 0x8370, q->state()->renderHints & QPainter::SmoothPixmapTransform);
0
140 else -
141 updateTextureFilter(0x0DE1, 0x812F, q->state()->renderHints & QPainter::SmoothPixmapTransform);
never executed: updateTextureFilter(0x0DE1, 0x812F, q->state()->renderHints & QPainter::SmoothPixmapTransform);
0
142 } -
143 else if (style == Qt::TexturePattern) {
never evaluated: style == Qt::TexturePattern
0
144 currentBrushPixmap = currentBrush.texture(); -
145 -
146 int max_texture_size = ctx->d_func()->maxTextureSize(); -
147 if (currentBrushPixmap.width() > max_texture_size || currentBrushPixmap.height() > max_texture_size)
never evaluated: currentBrushPixmap.width() > max_texture_size
never evaluated: currentBrushPixmap.height() > max_texture_size
0
148 currentBrushPixmap = currentBrushPixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);
never executed: currentBrushPixmap = currentBrushPixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);
0
149 -
150 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(0)); -
151 QGLTexture *tex = ctx->d_func()->bindTexture(currentBrushPixmap, 0x0DE1, 0x1908, -
152 QGLContext::InternalBindOption | -
153 QGLContext::CanFlipNativePixmapBindOption); -
154 updateTextureFilter(0x0DE1, 0x2901, q->state()->renderHints & QPainter::SmoothPixmapTransform); -
155 textureInvertedY = tex->options & QGLContext::InvertedYBindOption ? -1 : 1;
never evaluated: tex->options & QGLContext::InvertedYBindOption
0
156 }
never executed: }
0
157 brushTextureDirty = false; -
158}
never executed: }
0
159 -
160 -
161void QGL2PaintEngineExPrivate::updateBrushUniforms() -
162{ -
163 -
164 Qt::BrushStyle style = currentBrush.style(); -
165 -
166 if (style == Qt::NoBrush)
never evaluated: style == Qt::NoBrush
0
167 return;
never executed: return;
0
168 -
169 QTransform brushQTransform = currentBrush.transform(); -
170 -
171 if (style == Qt::SolidPattern) {
never evaluated: style == Qt::SolidPattern
0
172 QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity); -
173 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::FragmentColor), col); -
174 }
never executed: }
0
175 else { -
176 -
177 QPointF translationPoint; -
178 -
179 if (style <= Qt::DiagCrossPattern) {
never evaluated: style <= Qt::DiagCrossPattern
0
180 QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity); -
181 -
182 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); -
183 -
184 QVector2D halfViewportSize(width*0.5, height*0.5); -
185 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); -
186 }
never executed: }
0
187 else if (style == Qt::LinearGradientPattern) {
never evaluated: style == Qt::LinearGradientPattern
0
188 const QLinearGradient *g = static_cast<const QLinearGradient *>(currentBrush.gradient()); -
189 -
190 QPointF realStart = g->start(); -
191 QPointF realFinal = g->finalStop(); -
192 translationPoint = realStart; -
193 -
194 QPointF l = realFinal - realStart; -
195 -
196 QVector3D linearData( -
197 l.x(), -
198 l.y(), -
199 1.0f / (l.x() * l.x() + l.y() * l.y()) -
200 ); -
201 -
202 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::LinearData), linearData); -
203 -
204 QVector2D halfViewportSize(width*0.5, height*0.5); -
205 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); -
206 }
never executed: }
0
207 else if (style == Qt::ConicalGradientPattern) {
never evaluated: style == Qt::ConicalGradientPattern
0
208 const QConicalGradient *g = static_cast<const QConicalGradient *>(currentBrush.gradient()); -
209 translationPoint = g->center(); -
210 -
211 GLfloat angle = -(g->angle() * 2 * Q_PI) / 360.0; -
212 -
213 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Angle), angle); -
214 -
215 QVector2D halfViewportSize(width*0.5, height*0.5); -
216 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); -
217 }
never executed: }
0
218 else if (style == Qt::RadialGradientPattern) {
never evaluated: style == Qt::RadialGradientPattern
0
219 const QRadialGradient *g = static_cast<const QRadialGradient *>(currentBrush.gradient()); -
220 QPointF realCenter = g->center(); -
221 QPointF realFocal = g->focalPoint(); -
222 qreal realRadius = g->centerRadius() - g->focalRadius(); -
223 translationPoint = realFocal; -
224 -
225 QPointF fmp = realCenter - realFocal; -
226 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Fmp), fmp); -
227 -
228 GLfloat fmp2_m_radius2 = -fmp.x() * fmp.x() - fmp.y() * fmp.y() + realRadius*realRadius; -
229 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Fmp2MRadius2), fmp2_m_radius2); -
230 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Inverse2Fmp2MRadius2), -
231 GLfloat(1.0 / (2.0*fmp2_m_radius2))); -
232 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::SqrFr), -
233 GLfloat(g->focalRadius() * g->focalRadius())); -
234 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BRadius), -
235 GLfloat(2 * (g->centerRadius() - g->focalRadius()) * g->focalRadius()), -
236 g->focalRadius(), -
237 g->centerRadius() - g->focalRadius()); -
238 -
239 QVector2D halfViewportSize(width*0.5, height*0.5); -
240 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); -
241 }
never executed: }
0
242 else if (style == Qt::TexturePattern) {
never evaluated: style == Qt::TexturePattern
0
243 const QPixmap& texPixmap = currentBrush.texture(); -
244 -
245 if (qHasPixmapTexture(currentBrush) && currentBrush.texture().isQBitmap()) {
never evaluated: qHasPixmapTexture(currentBrush)
never evaluated: currentBrush.texture().isQBitmap()
0
246 QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity); -
247 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); -
248 }
never executed: }
0
249 -
250 QSizeF invertedTextureSize(1.0 / texPixmap.width(), 1.0 / texPixmap.height()); -
251 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::InvertedTextureSize), invertedTextureSize); -
252 -
253 QVector2D halfViewportSize(width*0.5, height*0.5); -
254 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize); -
255 }
never executed: }
0
256 else -
257 QMessageLogger("gl2paintengineex/qpaintengineex_opengl2.cpp", 339, __PRETTY_FUNCTION__).warning("QGL2PaintEngineEx: Unimplemented fill style");
never executed: QMessageLogger("gl2paintengineex/qpaintengineex_opengl2.cpp", 339, __PRETTY_FUNCTION__).warning("QGL2PaintEngineEx: Unimplemented fill style");
0
258 -
259 const QPointF &brushOrigin = q->state()->brushOrigin; -
260 QTransform matrix = q->state()->matrix; -
261 matrix.translate(brushOrigin.x(), brushOrigin.y()); -
262 -
263 QTransform translate(1, 0, 0, 1, -translationPoint.x(), -translationPoint.y()); -
264 qreal m22 = -1; -
265 qreal dy = height; -
266 if (device->isFlipped()) {
never evaluated: device->isFlipped()
0
267 m22 = 1; -
268 dy = 0; -
269 }
never executed: }
0
270 QTransform gl_to_qt(1, 0, 0, m22, 0, dy); -
271 QTransform inv_matrix; -
272 if (style == Qt::TexturePattern && textureInvertedY == -1)
never evaluated: style == Qt::TexturePattern
never evaluated: textureInvertedY == -1
0
273 inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush.texture().height()) * brushQTransform * matrix).inverted() * translate;
never executed: inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush.texture().height()) * brushQTransform * matrix).inverted() * translate;
0
274 else -
275 inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate;
never executed: inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate;
0
276 -
277 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BrushTransform), inv_matrix); -
278 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BrushTexture), GLuint(0)); -
279 }
never executed: }
0
280 brushUniformsDirty = false; -
281}
never executed: }
0
282 -
283 -
284 -
285void QGL2PaintEngineExPrivate::updateMatrix() -
286{ -
287 -
288 -
289 const QTransform& transform = q->state()->matrix; -
290 const GLfloat wfactor = 2.0f / width; -
291 GLfloat hfactor = -2.0f / height; -
292 -
293 GLfloat dx = transform.dx(); -
294 GLfloat dy = transform.dy(); -
295 -
296 if (device->isFlipped()) {
never evaluated: device->isFlipped()
0
297 hfactor *= -1; -
298 dy -= height; -
299 }
never executed: }
0
300 -
301 -
302 -
303 if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) {
never evaluated: snapToPixelGrid
never evaluated: transform.type() == QTransform::TxTranslate
0
304 -
305 dx = ceilf(dx - 0.5f); -
306 dy = ceilf(dy - 0.5f); -
307 }
never executed: }
0
308 pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13(); -
309 pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23(); -
310 pmvMatrix[2][0] = (wfactor * dx) - transform.m33(); -
311 pmvMatrix[0][1] = (hfactor * transform.m12()) + transform.m13(); -
312 pmvMatrix[1][1] = (hfactor * transform.m22()) + transform.m23(); -
313 pmvMatrix[2][1] = (hfactor * dy) + transform.m33(); -
314 pmvMatrix[0][2] = transform.m13(); -
315 pmvMatrix[1][2] = transform.m23(); -
316 pmvMatrix[2][2] = transform.m33(); -
317 -
318 -
319 -
320 inverseScale = qMax(1 / qMax( qMax(qAbs(transform.m11()), qAbs(transform.m22())), -
321 qMax(qAbs(transform.m12()), qAbs(transform.m21())) ), -
322 qreal(0.0001)); -
323 -
324 matrixDirty = false; -
325 matrixUniformDirty = true; -
326 -
327 -
328 -
329 QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]); -
330 QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]); -
331 QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]); -
332 -
333 dasher.setInvScale(inverseScale); -
334 stroker.setInvScale(inverseScale); -
335}
never executed: }
0
336 -
337 -
338void QGL2PaintEngineExPrivate::updateCompositionMode() -
339{ -
340 -
341 -
342 -
343 switch(q->state()->composition_mode) { -
344 case QPainter::CompositionMode_SourceOver: -
345 glBlendFunc(0x1, 0x0303); -
346 break;
never executed: break;
0
347 case QPainter::CompositionMode_DestinationOver: -
348 glBlendFunc(0x0305, 0x1); -
349 break;
never executed: break;
0
350 case QPainter::CompositionMode_Clear: -
351 glBlendFunc(0x0, 0x0); -
352 break;
never executed: break;
0
353 case QPainter::CompositionMode_Source: -
354 glBlendFunc(0x1, 0x0); -
355 break;
never executed: break;
0
356 case QPainter::CompositionMode_Destination: -
357 glBlendFunc(0x0, 0x1); -
358 break;
never executed: break;
0
359 case QPainter::CompositionMode_SourceIn: -
360 glBlendFunc(0x0304, 0x0); -
361 break;
never executed: break;
0
362 case QPainter::CompositionMode_DestinationIn: -
363 glBlendFunc(0x0, 0x0302); -
364 break;
never executed: break;
0
365 case QPainter::CompositionMode_SourceOut: -
366 glBlendFunc(0x0305, 0x0); -
367 break;
never executed: break;
0
368 case QPainter::CompositionMode_DestinationOut: -
369 glBlendFunc(0x0, 0x0303); -
370 break;
never executed: break;
0
371 case QPainter::CompositionMode_SourceAtop: -
372 glBlendFunc(0x0304, 0x0303); -
373 break;
never executed: break;
0
374 case QPainter::CompositionMode_DestinationAtop: -
375 glBlendFunc(0x0305, 0x0302); -
376 break;
never executed: break;
0
377 case QPainter::CompositionMode_Xor: -
378 glBlendFunc(0x0305, 0x0303); -
379 break;
never executed: break;
0
380 case QPainter::CompositionMode_Plus: -
381 glBlendFunc(0x1, 0x1); -
382 break;
never executed: break;
0
383 default: -
384 QMessageLogger("gl2paintengineex/qpaintengineex_opengl2.cpp", 484, __PRETTY_FUNCTION__).warning("Unsupported composition mode"); -
385 break;
never executed: break;
0
386 } -
387 -
388 compositionModeDirty = false; -
389}
never executed: }
0
390 -
391static inline void setCoords(GLfloat *coords, const QGLRect &rect) -
392{ -
393 coords[0] = rect.left; -
394 coords[1] = rect.top; -
395 coords[2] = rect.right; -
396 coords[3] = rect.top; -
397 coords[4] = rect.right; -
398 coords[5] = rect.bottom; -
399 coords[6] = rect.left; -
400 coords[7] = rect.bottom; -
401}
never executed: }
0
402 -
403void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern) -
404{ -
405 -
406 currentBrush = noBrush; -
407 shaderManager->setSrcPixelType(pattern ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc); -
408 -
409 if (snapToPixelGrid) {
never evaluated: snapToPixelGrid
0
410 snapToPixelGrid = false; -
411 matrixDirty = true; -
412 }
never executed: }
0
413 -
414 if (prepareForDraw(opaque))
never evaluated: prepareForDraw(opaque)
0
415 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), GLuint(0));
never executed: shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), GLuint(0));
0
416 -
417 if (pattern) {
never evaluated: pattern
0
418 QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity); -
419 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); -
420 }
never executed: }
0
421 -
422 GLfloat dx = 1.0 / textureSize.width(); -
423 GLfloat dy = 1.0 / textureSize.height(); -
424 -
425 QGLRect srcTextureRect(src.left*dx, src.top*dy, src.right*dx, src.bottom*dy); -
426 -
427 setCoords(staticVertexCoordinateArray, dest); -
428 setCoords(staticTextureCoordinateArray, srcTextureRect); -
429 -
430 glDrawArrays(0x0006, 0, 4); -
431}
never executed: }
0
432 -
433void QGL2PaintEngineEx::beginNativePainting() -
434{ -
435 QGL2PaintEngineExPrivate * const d = d_func(); -
436 ensureActive(); -
437 d->transferMode(BrushDrawingMode); -
438 -
439 d->nativePaintingActive = true; -
440 -
441 QGLContext *ctx = d->ctx; -
442 QGLContextPrivate::extensionFuncs(ctx).qt_glUseProgram(0); -
443 -
444 -
445 for (int i = 0; i < 3; ++i)
never evaluated: i < 3
0
446 QGLContextPrivate::extensionFuncs(ctx).qt_glDisableVertexAttribArray(i);
never executed: QGLContextPrivate::extensionFuncs(ctx).qt_glDisableVertexAttribArray(i);
0
447 -
448 -
449 const QGLFormat &fmt = d->device->format(); -
450 if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 1)
never evaluated: fmt.majorVersion() < 3
never evaluated: fmt.majorVersion() == 3
never evaluated: fmt.minorVersion() < 1
0
451 || fmt.profile() == QGLFormat::CompatibilityProfile)
never evaluated: fmt.profile() == QGLFormat::CompatibilityProfile
0
452 { -
453 -
454 -
455 -
456 const QTransform& mtx = state()->matrix; -
457 -
458 float mv_matrix[4][4] = -
459 { -
460 { float(mtx.m11()), float(mtx.m12()), 0, float(mtx.m13()) }, -
461 { float(mtx.m21()), float(mtx.m22()), 0, float(mtx.m23()) }, -
462 { 0, 0, 1, 0 }, -
463 { float(mtx.dx()), float(mtx.dy()), 0, float(mtx.m33()) } -
464 }; -
465 -
466 const QSize sz = d->device->size(); -
467 -
468 glMatrixMode(0x1701); -
469 glLoadIdentity(); -
470 glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999); -
471 -
472 glMatrixMode(0x1700); -
473 glLoadMatrixf(&mv_matrix[0][0]); -
474 }
never executed: }
0
475 -
476 -
477 -
478 -
479 d->lastTextureUsed = GLuint(-1); -
480 d->dirtyStencilRegion = QRect(0, 0, d->width, d->height); -
481 d->resetGLState(); -
482 -
483 d->shaderManager->setDirty(); -
484 -
485 d->needsSync = true; -
486}
never executed: }
0
487 -
488void QGL2PaintEngineExPrivate::resetGLState() -
489{ -
490 glDisable(0x0BE2); -
491 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0); -
492 glDisable(0x0B90); -
493 glDisable(0x0B71); -
494 glDisable(0x0C11); -
495 glDepthMask(true); -
496 glDepthFunc(0x0201); -
497 glClearDepth(1); -
498 glStencilMask(0xff); -
499 glStencilOp(0x1E00, 0x1E00, 0x1E00); -
500 glStencilFunc(0x0207, 0, 0xff); -
501 ctx->d_func()->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false); -
502 ctx->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, false); -
503 ctx->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false); -
504 -
505 -
506 float color[] = { 1.0f, 1.0f, 1.0f, 1.0f }; -
507 QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib4fv(3, color); -
508 -
509}
never executed: }
0
510 -
511void QGL2PaintEngineEx::endNativePainting() -
512{ -
513 QGL2PaintEngineExPrivate * const d = d_func(); -
514 d->needsSync = true; -
515 d->nativePaintingActive = false; -
516}
never executed: }
0
517 -
518void QGL2PaintEngineEx::invalidateState() -
519{ -
520 QGL2PaintEngineExPrivate * const d = d_func(); -
521 d->needsSync = true; -
522}
never executed: }
0
523 -
524bool QGL2PaintEngineEx::isNativePaintingActive() const { -
525 const QGL2PaintEngineExPrivate * const d = d_func(); -
526 return d->nativePaintingActive;
never executed: return d->nativePaintingActive;
0
527} -
528 -
529void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) -
530{ -
531 if (newMode == mode)
never evaluated: newMode == mode
0
532 return;
never executed: return;
0
533 -
534 if (mode == TextDrawingMode || mode == ImageDrawingMode || mode == ImageArrayDrawingMode) {
never evaluated: mode == TextDrawingMode
never evaluated: mode == ImageDrawingMode
never evaluated: mode == ImageArrayDrawingMode
0
535 lastTextureUsed = GLuint(-1); -
536 }
never executed: }
0
537 -
538 if (newMode == TextDrawingMode) {
never evaluated: newMode == TextDrawingMode
0
539 shaderManager->setHasComplexGeometry(true); -
540 } else {
never executed: }
0
541 shaderManager->setHasComplexGeometry(false); -
542 }
never executed: }
0
543 -
544 if (newMode == ImageDrawingMode) {
never evaluated: newMode == ImageDrawingMode
0
545 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray); -
546 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, staticTextureCoordinateArray); -
547 }
never executed: }
0
548 -
549 if (newMode == ImageArrayDrawingMode) {
never evaluated: newMode == ImageArrayDrawingMode
0
550 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data()); -
551 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data()); -
552 setVertexAttributePointer(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data()); -
553 }
never executed: }
0
554 -
555 -
556 if (newMode != TextDrawingMode)
never evaluated: newMode != TextDrawingMode
0
557 shaderManager->setMaskType(QGLEngineShaderManager::NoMask);
never executed: shaderManager->setMaskType(QGLEngineShaderManager::NoMask);
0
558 -
559 mode = newMode; -
560}
never executed: }
0
561 -
562struct QGL2PEVectorPathCache -
563{ -
564 -
565 -
566 -
567 -
568 float *vertices; -
569 void *indices; -
570 -
571 int vertexCount; -
572 int indexCount; -
573 GLenum primitiveType; -
574 qreal iscale; -
575 QVertexIndexVector::Type indexType; -
576}; -
577 -
578void QGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, void *data) -
579{ -
580 QGL2PEVectorPathCache *c = (QGL2PEVectorPathCache *) data; -
581 -
582 -
583 -
584 -
585 -
586 -
587 (void)engine;; -
588 free(c->vertices); -
589 free(c->indices); -
590 -
591 delete c; -
592}
never executed: }
0
593 -
594 -
595void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) -
596{ -
597 transferMode(BrushDrawingMode); -
598 -
599 if (snapToPixelGrid) {
never evaluated: snapToPixelGrid
0
600 snapToPixelGrid = false; -
601 matrixDirty = true; -
602 }
never executed: }
0
603 -
604 -
605 if (matrixDirty)
never evaluated: matrixDirty
0
606 updateMatrix();
never executed: updateMatrix();
0
607 -
608 const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); -
609 -
610 -
611 if (path.shape() == QVectorPath::RectangleHint) {
never evaluated: path.shape() == QVectorPath::RectangleHint
0
612 QGLRect rect(points[0].x(), points[0].y(), points[2].x(), points[2].y()); -
613 prepareForDraw(currentBrush.isOpaque()); -
614 composite(rect); -
615 } else if (path.isConvex()) {
never evaluated: path.isConvex()
never executed: }
0
616 -
617 if (path.isCacheable()) {
never evaluated: path.isCacheable()
0
618 QVectorPath::CacheEntry *data = path.lookupCacheData(q); -
619 QGL2PEVectorPathCache *cache; -
620 -
621 bool updateCache = false; -
622 -
623 if (data) {
never evaluated: data
0
624 cache = (QGL2PEVectorPathCache *) data->data; -
625 -
626 if (path.isCurved()) {
never evaluated: path.isCurved()
0
627 qreal scaleFactor = cache->iscale / inverseScale; -
628 if (scaleFactor < 0.5 || scaleFactor > 2.0) {
never evaluated: scaleFactor < 0.5
never evaluated: scaleFactor > 2.0
0
629 -
630 -
631 -
632 -
633 -
634 free(cache->vertices); -
635 qt_noop(); -
636 -
637 updateCache = true; -
638 }
never executed: }
0
639 }
never executed: }
0
640 } else {
never executed: }
0
641 cache = new QGL2PEVectorPathCache; -
642 data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath); -
643 updateCache = true; -
644 }
never executed: }
0
645 -
646 -
647 if (updateCache) {
never evaluated: updateCache
0
648 vertexCoordinateArray.clear(); -
649 vertexCoordinateArray.addPath(path, inverseScale, false); -
650 int vertexCount = vertexCoordinateArray.vertexCount(); -
651 int floatSizeInBytes = vertexCount * 2 * sizeof(float); -
652 cache->vertexCount = vertexCount; -
653 cache->indexCount = 0; -
654 cache->primitiveType = 0x0006; -
655 cache->iscale = inverseScale; -
656 -
657 -
658 -
659 -
660 -
661 -
662 cache->vertices = (float *) malloc(floatSizeInBytes); -
663 memcpy(cache->vertices, vertexCoordinateArray.data(), floatSizeInBytes); -
664 cache->indices = 0; -
665 -
666 }
never executed: }
0
667 -
668 prepareForDraw(currentBrush.isOpaque()); -
669 -
670 -
671 -
672 -
673 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); -
674 -
675 glDrawArrays(cache->primitiveType, 0, cache->vertexCount); -
676 -
677 } else {
never executed: }
0
678 -
679 -
680 path.makeCacheable(); -
681 vertexCoordinateArray.clear(); -
682 vertexCoordinateArray.addPath(path, inverseScale, false); -
683 prepareForDraw(currentBrush.isOpaque()); -
684 drawVertexArrays(vertexCoordinateArray, 0x0006); -
685 }
never executed: }
0
686 -
687 } else { -
688 bool useCache = path.isCacheable(); -
689 if (useCache) {
never evaluated: useCache
0
690 QRectF bbox = path.controlPointRect(); -
691 -
692 useCache &= (bbox.left() > -0x8000 * inverseScale)
never evaluated: (bbox.left() > -0x8000 * inverseScale)
0
693 && (bbox.right() < 0x8000 * inverseScale)
never evaluated: (bbox.right() < 0x8000 * inverseScale)
0
694 && (bbox.top() > -0x8000 * inverseScale)
never evaluated: (bbox.top() > -0x8000 * inverseScale)
0
695 && (bbox.bottom() < 0x8000 * inverseScale);
never evaluated: (bbox.bottom() < 0x8000 * inverseScale)
0
696 }
never executed: }
0
697 -
698 if (useCache) {
never evaluated: useCache
0
699 QVectorPath::CacheEntry *data = path.lookupCacheData(q); -
700 QGL2PEVectorPathCache *cache; -
701 -
702 bool updateCache = false; -
703 -
704 if (data) {
never evaluated: data
0
705 cache = (QGL2PEVectorPathCache *) data->data; -
706 -
707 if (path.isCurved()) {
never evaluated: path.isCurved()
0
708 qreal scaleFactor = cache->iscale / inverseScale; -
709 if (scaleFactor < 0.5 || scaleFactor > 2.0) {
never evaluated: scaleFactor < 0.5
never evaluated: scaleFactor > 2.0
0
710 -
711 -
712 -
713 -
714 free(cache->vertices); -
715 free(cache->indices); -
716 -
717 updateCache = true; -
718 }
never executed: }
0
719 }
never executed: }
0
720 } else {
never executed: }
0
721 cache = new QGL2PEVectorPathCache; -
722 data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath); -
723 updateCache = true; -
724 }
never executed: }
0
725 -
726 -
727 if (updateCache) {
never evaluated: updateCache
0
728 QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); -
729 cache->vertexCount = polys.vertices.size() / 2; -
730 cache->indexCount = polys.indices.size(); -
731 cache->primitiveType = 0x0004; -
732 cache->iscale = inverseScale; -
733 cache->indexType = polys.indices.type(); -
734 cache->vertices = (float *) malloc(sizeof(float) * polys.vertices.size()); -
735 if (polys.indices.type() == QVertexIndexVector::UnsignedInt) {
never evaluated: polys.indices.type() == QVertexIndexVector::UnsignedInt
0
736 cache->indices = (quint32 *) malloc(sizeof(quint32) * polys.indices.size()); -
737 memcpy(cache->indices, polys.indices.data(), sizeof(quint32) * polys.indices.size()); -
738 } else {
never executed: }
0
739 cache->indices = (quint16 *) malloc(sizeof(quint16) * polys.indices.size()); -
740 memcpy(cache->indices, polys.indices.data(), sizeof(quint16) * polys.indices.size()); -
741 }
never executed: }
0
742 for (int i = 0; i < polys.vertices.size(); ++i)
never evaluated: i < polys.vertices.size()
0
743 cache->vertices[i] = float(inverseScale * polys.vertices.at(i));
never executed: cache->vertices[i] = float(inverseScale * polys.vertices.at(i));
0
744 -
745 }
never executed: }
0
746 -
747 prepareForDraw(currentBrush.isOpaque()); -
748 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices); -
749 if (cache->indexType == QVertexIndexVector::UnsignedInt)
never evaluated: cache->indexType == QVertexIndexVector::UnsignedInt
0
750 glDrawElements(cache->primitiveType, cache->indexCount, 0x1405, (qint32 *)cache->indices);
never executed: glDrawElements(cache->primitiveType, cache->indexCount, 0x1405, (qint32 *)cache->indices);
0
751 else -
752 glDrawElements(cache->primitiveType, cache->indexCount, 0x1403, (qint16 *)cache->indices);
never executed: glDrawElements(cache->primitiveType, cache->indexCount, 0x1403, (qint16 *)cache->indices);
0
753 -
754 -
755 } else { -
756 -
757 -
758 path.makeCacheable(); -
759 -
760 if (!device->format().stencil()) {
never evaluated: !device->format().stencil()
0
761 -
762 -
763 QRectF bbox = path.controlPointRect(); -
764 -
765 bool withinLimits = (bbox.left() > -0x8000 * inverseScale)
never evaluated: (bbox.left() > -0x8000 * inverseScale)
0
766 && (bbox.right() < 0x8000 * inverseScale)
never evaluated: (bbox.right() < 0x8000 * inverseScale)
0
767 && (bbox.top() > -0x8000 * inverseScale)
never evaluated: (bbox.top() > -0x8000 * inverseScale)
0
768 && (bbox.bottom() < 0x8000 * inverseScale);
never evaluated: (bbox.bottom() < 0x8000 * inverseScale)
0
769 if (withinLimits) {
never evaluated: withinLimits
0
770 QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale)); -
771 -
772 QVarLengthArray<float> vertices(polys.vertices.size()); -
773 for (int i = 0; i < polys.vertices.size(); ++i)
never evaluated: i < polys.vertices.size()
0
774 vertices[i] = float(inverseScale * polys.vertices.at(i));
never executed: vertices[i] = float(inverseScale * polys.vertices.at(i));
0
775 -
776 prepareForDraw(currentBrush.isOpaque()); -
777 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, vertices.constData()); -
778 if (polys.indices.type() == QVertexIndexVector::UnsignedInt)
never evaluated: polys.indices.type() == QVertexIndexVector::UnsignedInt
0
779 glDrawElements(0x0004, polys.indices.size(), 0x1405, polys.indices.data());
never executed: glDrawElements(0x0004, polys.indices.size(), 0x1405, polys.indices.data());
0
780 else -
781 glDrawElements(0x0004, polys.indices.size(), 0x1403, polys.indices.data());
never executed: glDrawElements(0x0004, polys.indices.size(), 0x1403, polys.indices.data());
0
782 } else { -
783 -
784 QMessageLogger("gl2paintengineex/qpaintengineex_opengl2.cpp", 911, __PRETTY_FUNCTION__).warning("Painter path exceeds +/-32767 pixels."); -
785 }
never executed: }
0
786 return;
never executed: return;
0
787 } -
788 -
789 -
790 vertexCoordinateArray.clear(); -
791 vertexCoordinateArray.addPath(path, inverseScale, false); -
792 -
793 fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill()); -
794 -
795 glStencilMask(0xff); -
796 glStencilOp(0x1E00, 0x1E01, 0x1E01); -
797 -
798 if (q->state()->clipTestEnabled) {
never evaluated: q->state()->clipTestEnabled
0
799 -
800 glStencilFunc(0x0205, q->state()->currentClip, GLuint(0x80)); -
801 } else if (path.hasWindingFill()) {
never executed: }
never evaluated: path.hasWindingFill()
0
802 -
803 glStencilFunc(0x0205, 0, 0xff); -
804 } else {
never executed: }
0
805 -
806 glStencilFunc(0x0205, 0, GLuint(0x80)); -
807 }
never executed: }
0
808 prepareForDraw(currentBrush.isOpaque()); -
809 -
810 -
811 composite(vertexCoordinateArray.boundingRect()); -
812 glStencilMask(0); -
813 updateClipScissorTest(); -
814 }
never executed: }
0
815 } -
816} -
817 -
818 -
819void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, -
820 int count, -
821 int *stops, -
822 int stopCount, -
823 const QGLRect &bounds, -
824 StencilFillMode mode) -
825{ -
826 qt_noop(); -
827 -
828 -
829 glStencilMask(0xff); -
830 -
831 if (dirtyStencilRegion.intersects(currentScissorBounds)) {
never evaluated: dirtyStencilRegion.intersects(currentScissorBounds)
0
832 QVector<QRect> clearRegion = dirtyStencilRegion.intersected(currentScissorBounds).rects(); -
833 glClearStencil(0); -
834 for (int i = 0; i < clearRegion.size(); ++i) {
never evaluated: i < clearRegion.size()
0
835 -
836 setScissor(clearRegion.at(i)); -
837 -
838 glClear(0x00000400); -
839 }
never executed: }
0
840 -
841 dirtyStencilRegion -= currentScissorBounds; -
842 -
843 -
844 updateClipScissorTest(); -
845 -
846 }
never executed: }
0
847 -
848 glColorMask(0x0, 0x0, 0x0, 0x0); -
849 useSimpleShader(); -
850 glEnable(0x0B90); -
851 -
852 if (mode == WindingFillMode) {
never evaluated: mode == WindingFillMode
0
853 qt_noop(); -
854 if (q->state()->clipTestEnabled) {
never evaluated: q->state()->clipTestEnabled
0
855 -
856 glStencilFunc(0x0203, GLuint(0x80) | q->state()->currentClip, ~GLuint(0x80)); -
857 glStencilOp(0x1E00, 0x1E01, 0x1E01); -
858 composite(bounds); -
859 -
860 glStencilFunc(0x0202, GLuint(0x80), GLuint(0x80)); -
861 } else if (!stencilClean) {
never executed: }
never evaluated: !stencilClean
0
862 -
863 glStencilFunc(0x0207, 0, 0xff); -
864 glStencilOp(0x0, 0x0, 0x0); -
865 composite(bounds); -
866 }
never executed: }
0
867 -
868 -
869 QGLContextPrivate::extensionFuncs(ctx).qt_glStencilOpSeparate(0x0404, 0x1E00, 0x8507, 0x8507); -
870 -
871 QGLContextPrivate::extensionFuncs(ctx).qt_glStencilOpSeparate(0x0405, 0x1E00, 0x8508, 0x8508); -
872 glStencilMask(~GLuint(0x80)); -
873 drawVertexArrays(data, stops, stopCount, 0x0006); -
874 -
875 if (q->state()->clipTestEnabled) {
never evaluated: q->state()->clipTestEnabled
0
876 -
877 glStencilFunc(0x0202, q->state()->currentClip, ~GLuint(0x80)); -
878 glStencilOp(0x1E00, 0x1E01, 0x1E01); -
879 glStencilMask(GLuint(0x80)); -
880 composite(bounds); -
881 }
never executed: }
0
882 } else if (mode == OddEvenFillMode) {
never executed: }
never evaluated: mode == OddEvenFillMode
0
883 glStencilMask(GLuint(0x80)); -
884 glStencilOp(0x1E00, 0x1E00, 0x150A); -
885 drawVertexArrays(data, stops, stopCount, 0x0006); -
886 -
887 } else {
never executed: }
0
888 qt_noop(); -
889 glStencilMask(GLuint(0x80)); -
890 -
891 -
892 -
893 -
894 -
895 -
896 glStencilOp(0x1E00, 0x1E00, 0x1E01); -
897 if (q->state()->clipTestEnabled) {
never evaluated: q->state()->clipTestEnabled
0
898 glStencilFunc(0x0203, q->state()->currentClip | GLuint(0x80), -
899 ~GLuint(0x80)); -
900 } else {
never executed: }
0
901 glStencilFunc(0x0207, GLuint(0x80), 0xff); -
902 }
never executed: }
0
903 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data); -
904 glDrawArrays(0x0005, 0, count); -
905 -
906 }
never executed: }
0
907 -
908 -
909 glColorMask(0x1, 0x1, 0x1, 0x1); -
910}
never executed: }
0
911 -
912 -
913 -
914 -
915 -
916 -
917void QGL2PaintEngineExPrivate::resetClipIfNeeded() -
918{ -
919 if (maxClip != (GLuint(0x80) - 1))
never evaluated: maxClip != (GLuint(0x80) - 1)
0
920 return;
never executed: return;
0
921 -
922 QGL2PaintEngineEx * const q = q_func(); -
923 -
924 useSimpleShader(); -
925 glEnable(0x0B90); -
926 glColorMask(0x0, 0x0, 0x0, 0x0); -
927 -
928 QRectF bounds = q->state()->matrix.inverted().mapRect(QRectF(0, 0, width, height)); -
929 QGLRect rect(bounds.left(), bounds.top(), bounds.right(), bounds.bottom()); -
930 -
931 -
932 glStencilFunc(0x0203, q->state()->currentClip, 0xff); -
933 glStencilOp(0x1E00, 0x150A, 0x150A); -
934 glStencilMask(GLuint(0x80)); -
935 composite(rect); -
936 -
937 -
938 glStencilFunc(0x0205, 0x01, GLuint(0x80)); -
939 glStencilOp(0x0, 0x1E01, 0x1E01); -
940 glStencilMask(0xff); -
941 composite(rect); -
942 -
943 q->state()->currentClip = 1; -
944 q->state()->canRestoreClip = false; -
945 -
946 maxClip = 1; -
947 -
948 glStencilMask(0x0); -
949 glColorMask(0x1, 0x1, 0x1, 0x1); -
950}
never executed: }
0
951 -
952bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) -
953{ -
954 if (brushTextureDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode)
never evaluated: brushTextureDirty
never evaluated: mode != ImageDrawingMode
never evaluated: mode != ImageArrayDrawingMode
0
955 updateBrushTexture();
never executed: updateBrushTexture();
0
956 -
957 if (compositionModeDirty)
never evaluated: compositionModeDirty
0
958 updateCompositionMode();
never executed: updateCompositionMode();
0
959 -
960 if (matrixDirty)
never evaluated: matrixDirty
0
961 updateMatrix();
never executed: updateMatrix();
0
962 -
963 const bool stateHasOpacity = q->state()->opacity < 0.99f; -
964 if (q->state()->composition_mode == QPainter::CompositionMode_Source
never evaluated: q->state()->composition_mode == QPainter::CompositionMode_Source
0
965 || (q->state()->composition_mode == QPainter::CompositionMode_SourceOver
never evaluated: q->state()->composition_mode == QPainter::CompositionMode_SourceOver
0
966 && srcPixelsAreOpaque && !stateHasOpacity))
never evaluated: srcPixelsAreOpaque
never evaluated: !stateHasOpacity
0
967 { -
968 glDisable(0x0BE2); -
969 } else {
never executed: }
0
970 glEnable(0x0BE2); -
971 }
never executed: }
0
972 -
973 QGLEngineShaderManager::OpacityMode opacityMode; -
974 if (mode == ImageArrayDrawingMode) {
never evaluated: mode == ImageArrayDrawingMode
0
975 opacityMode = QGLEngineShaderManager::AttributeOpacity; -
976 } else {
never executed: }
0
977 opacityMode = stateHasOpacity ? QGLEngineShaderManager::UniformOpacity
never evaluated: stateHasOpacity
0
978 : QGLEngineShaderManager::NoOpacity; -
979 if (stateHasOpacity && (mode != ImageDrawingMode)) {
never evaluated: stateHasOpacity
never evaluated: (mode != ImageDrawingMode)
0
980 -
981 bool brushIsPattern = (currentBrush.style() >= Qt::Dense1Pattern) &&
never evaluated: (currentBrush.style() >= Qt::Dense1Pattern)
0
982 (currentBrush.style() <= Qt::DiagCrossPattern);
never evaluated: (currentBrush.style() <= Qt::DiagCrossPattern)
0
983 -
984 if ((currentBrush.style() == Qt::SolidPattern) || brushIsPattern)
never evaluated: (currentBrush.style() == Qt::SolidPattern)
never evaluated: brushIsPattern
0
985 opacityMode = QGLEngineShaderManager::NoOpacity;
never executed: opacityMode = QGLEngineShaderManager::NoOpacity;
0
986 }
never executed: }
0
987 }
never executed: }
0
988 shaderManager->setOpacityMode(opacityMode); -
989 -
990 bool changed = shaderManager->useCorrectShaderProg(); -
991 -
992 if (changed) {
never evaluated: changed
0
993 -
994 brushUniformsDirty = true; -
995 opacityUniformDirty = true; -
996 matrixUniformDirty = true; -
997 }
never executed: }
0
998 -
999 if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode)
never evaluated: brushUniformsDirty
never evaluated: mode != ImageDrawingMode
never evaluated: mode != ImageArrayDrawingMode
0
1000 updateBrushUniforms();
never executed: updateBrushUniforms();
0
1001 -
1002 if (opacityMode == QGLEngineShaderManager::UniformOpacity && opacityUniformDirty) {
never evaluated: opacityMode == QGLEngineShaderManager::UniformOpacity
never evaluated: opacityUniformDirty
0
1003 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::GlobalOpacity), (GLfloat)q->state()->opacity); -
1004 opacityUniformDirty = false; -
1005 }
never executed: }
0
1006 -
1007 if (matrixUniformDirty && shaderManager->hasComplexGeometry()) {
never evaluated: matrixUniformDirty
never evaluated: shaderManager->hasComplexGeometry()
0
1008 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Matrix), -
1009 pmvMatrix); -
1010 matrixUniformDirty = false; -
1011 }
never executed: }
0
1012 -
1013 return changed;
never executed: return changed;
0
1014} -
1015 -
1016void QGL2PaintEngineExPrivate::composite(const QGLRect& boundingRect) -
1017{ -
1018 setCoords(staticVertexCoordinateArray, boundingRect); -
1019 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray); -
1020 glDrawArrays(0x0006, 0, 4); -
1021}
never executed: }
0
1022 -
1023 -
1024void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, int stopCount, -
1025 GLenum primitive) -
1026{ -
1027 -
1028 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)data); -
1029 -
1030 int previousStop = 0; -
1031 for (int i=0; i<stopCount; ++i) {
never evaluated: i<stopCount
0
1032 int stop = stops[i]; -
1033 -
1034 -
1035 -
1036 -
1037 -
1038 glDrawArrays(primitive, previousStop, stop - previousStop); -
1039 previousStop = stop; -
1040 }
never executed: }
0
1041}
never executed: }
0
1042 -
1043 -
1044 -
1045QGL2PaintEngineEx::QGL2PaintEngineEx() -
1046 : QPaintEngineEx(*(new QGL2PaintEngineExPrivate(this))) -
1047{ -
1048}
never executed: }
0
1049 -
1050QGL2PaintEngineEx::~QGL2PaintEngineEx() -
1051{ -
1052} -
1053 -
1054void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) -
1055{ -
1056 QGL2PaintEngineExPrivate * const d = d_func(); -
1057 -
1058 if (qbrush_style(brush) == Qt::NoBrush)
never evaluated: qbrush_style(brush) == Qt::NoBrush
0
1059 return;
never executed: return;
0
1060 ensureActive(); -
1061 d->setBrush(brush); -
1062 d->fill(path); -
1063}
never executed: }
0
1064 -
1065__attribute__((visibility("default"))) bool qt_scaleForTransform(const QTransform &transform, qreal *scale); -
1066 -
1067 -
1068void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) -
1069{ -
1070 QGL2PaintEngineExPrivate * const d = d_func(); -
1071 -
1072 const QBrush &penBrush = qpen_brush(pen); -
1073 if (qpen_style(pen) == Qt::NoPen || qbrush_style(penBrush) == Qt::NoBrush)
never evaluated: qpen_style(pen) == Qt::NoPen
never evaluated: qbrush_style(penBrush) == Qt::NoBrush
0
1074 return;
never executed: return;
0
1075 -
1076 QOpenGL2PaintEngineState *s = state(); -
1077 if (qt_pen_is_cosmetic(pen, s->renderHints) && !qt_scaleForTransform(s->transform(), 0)) {
never evaluated: qt_pen_is_cosmetic(pen, s->renderHints)
never evaluated: !qt_scaleForTransform(s->transform(), 0)
0
1078 -
1079 QPaintEngineEx::stroke(path, pen); -
1080 return;
never executed: return;
0
1081 } -
1082 -
1083 ensureActive(); -
1084 d->setBrush(penBrush); -
1085 d->stroke(path, pen); -
1086}
never executed: }
0
1087 -
1088void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen) -
1089{ -
1090 const QOpenGL2PaintEngineState *s = q->state(); -
1091 if (snapToPixelGrid) {
never evaluated: snapToPixelGrid
0
1092 snapToPixelGrid = false; -
1093 matrixDirty = true; -
1094 }
never executed: }
0
1095 -
1096 const Qt::PenStyle penStyle = qpen_style(pen); -
1097 const QBrush &penBrush = qpen_brush(pen); -
1098 const bool opaque = penBrush.isOpaque() && s->opacity > 0.99;
never evaluated: penBrush.isOpaque()
never evaluated: s->opacity > 0.99
0
1099 -
1100 transferMode(BrushDrawingMode); -
1101 -
1102 -
1103 -
1104 -
1105 updateMatrix(); -
1106 -
1107 QRectF clip = q->state()->matrix.inverted().mapRect(q->state()->clipEnabled -
1108 ? q->state()->rectangleClip -
1109 : QRectF(0, 0, width, height)); -
1110 -
1111 if (penStyle == Qt::SolidLine) {
never evaluated: penStyle == Qt::SolidLine
0
1112 stroker.process(path, pen, clip, s->renderHints); -
1113 -
1114 } else {
never executed: }
0
1115 dasher.process(path, pen, clip, s->renderHints); -
1116 -
1117 QVectorPath dashStroke(dasher.points(), -
1118 dasher.elementCount(), -
1119 dasher.elementTypes()); -
1120 stroker.process(dashStroke, pen, clip, s->renderHints); -
1121 }
never executed: }
0
1122 -
1123 if (!stroker.vertexCount())
never evaluated: !stroker.vertexCount()
0
1124 return;
never executed: return;
0
1125 -
1126 if (opaque) {
never evaluated: opaque
0
1127 prepareForDraw(opaque); -
1128 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, stroker.vertices()); -
1129 glDrawArrays(0x0005, 0, stroker.vertexCount() / 2); -
1130 -
1131 -
1132 -
1133 -
1134 -
1135 -
1136 } else {
never executed: }
0
1137 qreal width = qpen_widthf(pen) / 2; -
1138 if (width == 0)
never evaluated: width == 0
0
1139 width = 0.5;
never executed: width = 0.5;
0
1140 qreal extra = pen.joinStyle() == Qt::MiterJoin
never evaluated: pen.joinStyle() == Qt::MiterJoin
0
1141 ? qMax(pen.miterLimit() * width, width) -
1142 : width; -
1143 -
1144 if (qt_pen_is_cosmetic(pen, s->renderHints))
never evaluated: qt_pen_is_cosmetic(pen, s->renderHints)
0
1145 extra = extra * inverseScale;
never executed: extra = extra * inverseScale;
0
1146 -
1147 QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra); -
1148 -
1149 fillStencilWithVertexArray(stroker.vertices(), stroker.vertexCount() / 2, -
1150 0, 0, bounds, QGL2PaintEngineExPrivate::TriStripStrokeFillMode); -
1151 -
1152 glStencilOp(0x1E00, 0x1E01, 0x1E01); -
1153 -
1154 -
1155 glStencilFunc(0x0205, 0, GLuint(0x80)); -
1156 prepareForDraw(false); -
1157 -
1158 -
1159 composite(bounds); -
1160 -
1161 glStencilMask(0); -
1162 -
1163 updateClipScissorTest(); -
1164 }
never executed: }
0
1165} -
1166 -
1167void QGL2PaintEngineEx::penChanged() { } -
1168void QGL2PaintEngineEx::brushChanged() { } -
1169void QGL2PaintEngineEx::brushOriginChanged() { } -
1170 -
1171void QGL2PaintEngineEx::opacityChanged() -
1172{ -
1173 -
1174 QGL2PaintEngineExPrivate * const d = d_func(); -
1175 state()->opacityChanged = true; -
1176 -
1177 qt_noop(); -
1178 d->brushUniformsDirty = true; -
1179 d->opacityUniformDirty = true; -
1180}
never executed: }
0
1181 -
1182void QGL2PaintEngineEx::compositionModeChanged() -
1183{ -
1184 -
1185 QGL2PaintEngineExPrivate * const d = d_func(); -
1186 state()->compositionModeChanged = true; -
1187 d->compositionModeDirty = true; -
1188}
never executed: }
0
1189 -
1190void QGL2PaintEngineEx::renderHintsChanged() -
1191{ -
1192 state()->renderHintsChanged = true; -
1193 -
1194 -
1195 if ((state()->renderHints & QPainter::Antialiasing)
never evaluated: (state()->renderHints & QPainter::Antialiasing)
0
1196 || (state()->renderHints & QPainter::HighQualityAntialiasing))
never evaluated: (state()->renderHints & QPainter::HighQualityAntialiasing)
0
1197 glEnable(0x809D);
never executed: glEnable(0x809D);
0
1198 else -
1199 glDisable(0x809D);
never executed: glDisable(0x809D);
0
1200 -
1201 -
1202 QGL2PaintEngineExPrivate * const d = d_func(); -
1203 d->lastTextureUsed = GLuint(-1); -
1204 d->brushTextureDirty = true; -
1205 -
1206}
never executed: }
0
1207 -
1208void QGL2PaintEngineEx::transformChanged() -
1209{ -
1210 QGL2PaintEngineExPrivate * const d = d_func(); -
1211 d->matrixDirty = true; -
1212 state()->matrixChanged = true; -
1213}
never executed: }
0
1214 -
1215 -
1216static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy) -
1217{ -
1218 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
1219} -
1220 -
1221void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, const QRectF & src) -
1222{ -
1223 QGL2PaintEngineExPrivate * const d = d_func(); -
1224 QGLContext *ctx = d->ctx; -
1225 -
1226 int max_texture_size = ctx->d_func()->maxTextureSize(); -
1227 if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) {
never evaluated: pixmap.width() > max_texture_size
never evaluated: pixmap.height() > max_texture_size
0
1228 QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); -
1229 -
1230 const qreal sx = scaled.width() / qreal(pixmap.width()); -
1231 const qreal sy = scaled.height() / qreal(pixmap.height()); -
1232 -
1233 drawPixmap(dest, scaled, scaleRect(src, sx, sy)); -
1234 return;
never executed: return;
0
1235 } -
1236 -
1237 ensureActive(); -
1238 d->transferMode(ImageDrawingMode); -
1239 -
1240 QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption|QGLContext::CanFlipNativePixmapBindOption; -
1241 -
1242 -
1243 -
1244 -
1245 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(0)); -
1246 QGLTexture *texture = -
1247 ctx->d_func()->bindTexture(pixmap, 0x0DE1, 0x1908, bindOptions); -
1248 -
1249 GLfloat top = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.top()) : src.top();
never evaluated: texture->options & QGLContext::InvertedYBindOption
0
1250 GLfloat bottom = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.bottom()) : src.bottom();
never evaluated: texture->options & QGLContext::InvertedYBindOption
0
1251 QGLRect srcRect(src.left(), top, src.right(), bottom); -
1252 -
1253 bool isBitmap = pixmap.isQBitmap(); -
1254 bool isOpaque = !isBitmap && !pixmap.hasAlpha();
never evaluated: !isBitmap
never evaluated: !pixmap.hasAlpha()
0
1255 -
1256 d->updateTextureFilter(0x0DE1, 0x812F, -
1257 state()->renderHints & QPainter::SmoothPixmapTransform, texture->id); -
1258 d->drawTexture(dest, srcRect, pixmap.size(), isOpaque, isBitmap); -
1259 -
1260 if (texture->options&QGLContext::TemporarilyCachedBindOption) {
never evaluated: texture->options&QGLContext::TemporarilyCachedBindOption
0
1261 -
1262 -
1263 QGLTextureCache::instance()->remove(ctx, texture->id); -
1264 }
never executed: }
0
1265}
never executed: }
0
1266 -
1267void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const QRectF& src, -
1268 Qt::ImageConversionFlags) -
1269{ -
1270 QGL2PaintEngineExPrivate * const d = d_func(); -
1271 QGLContext *ctx = d->ctx; -
1272 -
1273 int max_texture_size = ctx->d_func()->maxTextureSize(); -
1274 if (image.width() > max_texture_size || image.height() > max_texture_size) {
never evaluated: image.width() > max_texture_size
never evaluated: image.height() > max_texture_size
0
1275 QImage scaled = image.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); -
1276 -
1277 const qreal sx = scaled.width() / qreal(image.width()); -
1278 const qreal sy = scaled.height() / qreal(image.height()); -
1279 -
1280 drawImage(dest, scaled, scaleRect(src, sx, sy)); -
1281 return;
never executed: return;
0
1282 } -
1283 -
1284 ensureActive(); -
1285 d->transferMode(ImageDrawingMode); -
1286 -
1287 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(0)); -
1288 -
1289 QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption; -
1290 -
1291 -
1292 -
1293 -
1294 QGLTexture *texture = ctx->d_func()->bindTexture(image, 0x0DE1, 0x1908, bindOptions); -
1295 GLuint id = texture->id; -
1296 -
1297 d->updateTextureFilter(0x0DE1, 0x812F, -
1298 state()->renderHints & QPainter::SmoothPixmapTransform, id); -
1299 d->drawTexture(dest, src, image.size(), !image.hasAlphaChannel()); -
1300 -
1301 if (texture->options&QGLContext::TemporarilyCachedBindOption) {
never evaluated: texture->options&QGLContext::TemporarilyCachedBindOption
0
1302 -
1303 -
1304 QGLTextureCache::instance()->remove(ctx, texture->id); -
1305 }
never executed: }
0
1306}
never executed: }
0
1307 -
1308void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem) -
1309{ -
1310 QGL2PaintEngineExPrivate * const d = d_func(); -
1311 -
1312 ensureActive(); -
1313 -
1314 QPainterState *s = state(); -
1315 float det = s->matrix.determinant(); -
1316 -
1317 -
1318 QFontEngine *fontEngine = textItem->fontEngine(); -
1319 if (shouldDrawCachedGlyphs(fontEngine, s->matrix) && det >= 0.25f && det <= 4.f) {
never evaluated: shouldDrawCachedGlyphs(fontEngine, s->matrix)
never evaluated: det >= 0.25f
never evaluated: det <= 4.f
0
1320 QFontEngineGlyphCache::Type glyphType = fontEngine->glyphFormat >= 0
never evaluated: fontEngine->glyphFormat >= 0
0
1321 ? QFontEngineGlyphCache::Type(textItem->fontEngine()->glyphFormat) -
1322 : d->glyphCacheType; -
1323 if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
never evaluated: glyphType == QFontEngineGlyphCache::Raster_RGBMask
0
1324 if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
never evaluated: !QGLFramebufferObject::hasOpenGLFramebufferObjects()
0
1325 || d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate
never evaluated: d->device->alphaRequested()
never evaluated: s->matrix.type() > QTransform::TxTranslate
0
1326 || (s->composition_mode != QPainter::CompositionMode_Source
never evaluated: s->composition_mode != QPainter::CompositionMode_Source
0
1327 && s->composition_mode != QPainter::CompositionMode_SourceOver))
never evaluated: s->composition_mode != QPainter::CompositionMode_SourceOver
0
1328 { -
1329 glyphType = QFontEngineGlyphCache::Raster_A8; -
1330 }
never executed: }
0
1331 }
never executed: }
0
1332 -
1333 d->drawCachedGlyphs(glyphType, textItem); -
1334 } else {
never executed: }
0
1335 QPaintEngineEx::drawStaticTextItem(textItem); -
1336 }
never executed: }
0
1337} -
1338 -
1339bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src) -
1340{ -
1341 QGL2PaintEngineExPrivate * const d = d_func(); -
1342 if (!d->shaderManager)
never evaluated: !d->shaderManager
0
1343 return false;
never executed: return false;
0
1344 -
1345 ensureActive(); -
1346 d->transferMode(ImageDrawingMode); -
1347 -
1348 -
1349 QGLContext *ctx = d->ctx; -
1350 -
1351 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(0)); -
1352 glBindTexture(0x0DE1, textureId); -
1353 -
1354 QGLRect srcRect(src.left(), src.bottom(), src.right(), src.top()); -
1355 -
1356 d->updateTextureFilter(0x0DE1, 0x812F, -
1357 state()->renderHints & QPainter::SmoothPixmapTransform, textureId); -
1358 d->drawTexture(dest, srcRect, size, false); -
1359 return true;
never executed: return true;
0
1360} -
1361 -
1362void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem) -
1363{ -
1364 QGL2PaintEngineExPrivate * const d = d_func(); -
1365 -
1366 ensureActive(); -
1367 QOpenGL2PaintEngineState *s = state(); -
1368 -
1369 const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); -
1370 -
1371 QTransform::TransformationType txtype = s->matrix.type(); -
1372 -
1373 float det = s->matrix.determinant(); -
1374 bool drawCached = txtype < QTransform::TxProject; -
1375 -
1376 -
1377 if (!shouldDrawCachedGlyphs(ti.fontEngine, s->matrix) || det < 0.25f || det > 4.f)
never evaluated: !shouldDrawCachedGlyphs(ti.fontEngine, s->matrix)
never evaluated: det < 0.25f
never evaluated: det > 4.f
0
1378 drawCached = false;
never executed: drawCached = false;
0
1379 -
1380 QFontEngineGlyphCache::Type glyphType = ti.fontEngine->glyphFormat >= 0
never evaluated: ti.fontEngine->glyphFormat >= 0
0
1381 ? QFontEngineGlyphCache::Type(ti.fontEngine->glyphFormat) -
1382 : d->glyphCacheType; -
1383 -
1384 -
1385 if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
never evaluated: glyphType == QFontEngineGlyphCache::Raster_RGBMask
0
1386 if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
never evaluated: !QGLFramebufferObject::hasOpenGLFramebufferObjects()
0
1387 || d->device->alphaRequested() || txtype > QTransform::TxTranslate
never evaluated: d->device->alphaRequested()
never evaluated: txtype > QTransform::TxTranslate
0
1388 || (state()->composition_mode != QPainter::CompositionMode_Source
never evaluated: state()->composition_mode != QPainter::CompositionMode_Source
0
1389 && state()->composition_mode != QPainter::CompositionMode_SourceOver))
never evaluated: state()->composition_mode != QPainter::CompositionMode_SourceOver
0
1390 { -
1391 glyphType = QFontEngineGlyphCache::Raster_A8; -
1392 }
never executed: }
0
1393 }
never executed: }
0
1394 -
1395 if (drawCached) {
never evaluated: drawCached
0
1396 QVarLengthArray<QFixedPoint> positions; -
1397 QVarLengthArray<glyph_t> glyphs; -
1398 QTransform matrix = QTransform::fromTranslate(p.x(), p.y()); -
1399 ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); -
1400 -
1401 { -
1402 QStaticTextItem staticTextItem; -
1403 staticTextItem.chars = const_cast<QChar *>(ti.chars); -
1404 staticTextItem.setFontEngine(ti.fontEngine); -
1405 staticTextItem.glyphs = glyphs.data(); -
1406 staticTextItem.numChars = ti.num_chars; -
1407 staticTextItem.numGlyphs = glyphs.size(); -
1408 staticTextItem.glyphPositions = positions.data(); -
1409 -
1410 d->drawCachedGlyphs(glyphType, &staticTextItem); -
1411 } -
1412 return;
never executed: return;
0
1413 } -
1414 -
1415 QPaintEngineEx::drawTextItem(p, ti); -
1416}
never executed: }
0
1417 -
1418namespace { -
1419 -
1420 class QOpenGLStaticTextUserData: public QStaticTextUserData -
1421 { -
1422 public: -
1423 QOpenGLStaticTextUserData() -
1424 : QStaticTextUserData(OpenGLUserData), cacheSize(0, 0), cacheSerialNumber(0) -
1425 { -
1426 }
never executed: }
0
1427 -
1428 ~QOpenGLStaticTextUserData() -
1429 { -
1430 } -
1431 -
1432 QSize cacheSize; -
1433 QGL2PEXVertexArray vertexCoordinateArray; -
1434 QGL2PEXVertexArray textureCoordinateArray; -
1435 QFontEngineGlyphCache::Type glyphType; -
1436 int cacheSerialNumber; -
1437 }; -
1438 -
1439} -
1440 -
1441 -
1442 -
1443 -
1444void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType, -
1445 QStaticTextItem *staticTextItem) -
1446{ -
1447 QGL2PaintEngineEx * const q = q_func(); -
1448 -
1449 QOpenGL2PaintEngineState *s = q->state(); -
1450 -
1451 void *cacheKey = const_cast<QGLContext *>(QGLContextPrivate::contextGroup(ctx)->context()); -
1452 bool recreateVertexArrays = false; -
1453 -
1454 QFontEngine *fe = staticTextItem->fontEngine(); -
1455 QGLTextureGlyphCache *cache = -
1456 (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, QTransform()); -
1457 if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) {
never evaluated: !cache
never evaluated: cache->cacheType() != glyphType
never evaluated: cache->contextGroup() == 0
0
1458 cache = new QGLTextureGlyphCache(glyphType, QTransform()); -
1459 fe->setGlyphCache(cacheKey, cache); -
1460 recreateVertexArrays = true; -
1461 }
never executed: }
0
1462 -
1463 if (staticTextItem->userDataNeedsUpdate) {
never evaluated: staticTextItem->userDataNeedsUpdate
0
1464 recreateVertexArrays = true; -
1465 } else if (staticTextItem->userData() == 0) {
never executed: }
never evaluated: staticTextItem->userData() == 0
0
1466 recreateVertexArrays = true; -
1467 } else if (staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) {
never executed: }
never evaluated: staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData
0
1468 recreateVertexArrays = true; -
1469 } else {
never executed: }
0
1470 QOpenGLStaticTextUserData *userData = static_cast<QOpenGLStaticTextUserData *>(staticTextItem->userData()); -
1471 if (userData->glyphType != glyphType) {
never evaluated: userData->glyphType != glyphType
0
1472 recreateVertexArrays = true; -
1473 } else if (userData->cacheSerialNumber != cache->serialNumber()) {
never executed: }
never evaluated: userData->cacheSerialNumber != cache->serialNumber()
0
1474 recreateVertexArrays = true; -
1475 }
never executed: }
0
1476 } -
1477 -
1478 -
1479 -
1480 -
1481 if (recreateVertexArrays) {
never evaluated: recreateVertexArrays
0
1482 cache->setPaintEnginePrivate(this); -
1483 if (!cache->populate(fe, staticTextItem->numGlyphs, 0
1484 staticTextItem->glyphs, staticTextItem->glyphPositions)) {
never evaluated: !cache->populate(fe, staticTextItem->numGlyphs, staticTextItem->glyphs, staticTextItem->glyphPositions)
0
1485 -
1486 cache->clear(); -
1487 cache->populate(fe, staticTextItem->numGlyphs, -
1488 staticTextItem->glyphs, staticTextItem->glyphPositions); -
1489 }
never executed: }
0
1490 cache->fillInPendingGlyphs(); -
1491 }
never executed: }
0
1492 -
1493 if (cache->width() == 0 || cache->height() == 0)
never evaluated: cache->width() == 0
never evaluated: cache->height() == 0
0
1494 return;
never executed: return;
0
1495 -
1496 transferMode(TextDrawingMode); -
1497 -
1498 int margin = fe->glyphMargin(glyphType); -
1499 -
1500 GLfloat dx = 1.0 / cache->width(); -
1501 GLfloat dy = 1.0 / cache->height(); -
1502 -
1503 -
1504 QGL2PEXVertexArray *vertexCoordinates = &vertexCoordinateArray; -
1505 QGL2PEXVertexArray *textureCoordinates = &textureCoordinateArray; -
1506 -
1507 if (staticTextItem->useBackendOptimizations) {
never evaluated: staticTextItem->useBackendOptimizations
0
1508 QOpenGLStaticTextUserData *userData = 0; -
1509 -
1510 if (staticTextItem->userData() == 0
never evaluated: staticTextItem->userData() == 0
0
1511 || staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) {
never evaluated: staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData
0
1512 -
1513 userData = new QOpenGLStaticTextUserData(); -
1514 staticTextItem->setUserData(userData); -
1515 -
1516 } else {
never executed: }
0
1517 userData = static_cast<QOpenGLStaticTextUserData*>(staticTextItem->userData()); -
1518 }
never executed: }
0
1519 -
1520 userData->glyphType = glyphType; -
1521 userData->cacheSerialNumber = cache->serialNumber(); -
1522 -
1523 -
1524 vertexCoordinates = &userData->vertexCoordinateArray; -
1525 textureCoordinates = &userData->textureCoordinateArray; -
1526 -
1527 QSize size(cache->width(), cache->height()); -
1528 if (userData->cacheSize != size) {
never evaluated: userData->cacheSize != size
0
1529 recreateVertexArrays = true; -
1530 userData->cacheSize = size; -
1531 }
never executed: }
0
1532 }
never executed: }
0
1533 -
1534 if (recreateVertexArrays) {
never evaluated: recreateVertexArrays
0
1535 vertexCoordinates->clear(); -
1536 textureCoordinates->clear(); -
1537 -
1538 bool supportsSubPixelPositions = fe->supportsSubPixelPositions(); -
1539 for (int i=0; i<staticTextItem->numGlyphs; ++i) {
never evaluated: i<staticTextItem->numGlyphs
0
1540 QFixed subPixelPosition; -
1541 if (supportsSubPixelPositions)
never evaluated: supportsSubPixelPositions
0
1542 subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x);
never executed: subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x);
0
1543 -
1544 QTextureGlyphCache::GlyphAndSubPixelPosition glyph(staticTextItem->glyphs[i], subPixelPosition); -
1545 -
1546 const QTextureGlyphCache::Coord &c = cache->coords[glyph]; -
1547 if (c.isNull())
never evaluated: c.isNull()
0
1548 continue;
never executed: continue;
0
1549 -
1550 int x = qFloor(staticTextItem->glyphPositions[i].x) + c.baseLineX - margin; -
1551 int y = qRound(staticTextItem->glyphPositions[i].y) - c.baseLineY - margin; -
1552 -
1553 vertexCoordinates->addQuad(QRectF(x, y, c.w, c.h)); -
1554 textureCoordinates->addQuad(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy)); -
1555 }
never executed: }
0
1556 -
1557 staticTextItem->userDataNeedsUpdate = false; -
1558 }
never executed: }
0
1559 -
1560 int numGlyphs = vertexCoordinates->vertexCount() / 4; -
1561 if (numGlyphs == 0)
never evaluated: numGlyphs == 0
0
1562 return;
never executed: return;
0
1563 -
1564 if (elementIndices.size() < numGlyphs*6) {
never evaluated: elementIndices.size() < numGlyphs*6
0
1565 qt_noop(); -
1566 int j = elementIndices.size() / 6 * 4; -
1567 while (j < numGlyphs*4) {
never evaluated: j < numGlyphs*4
0
1568 elementIndices.append(j + 0); -
1569 elementIndices.append(j + 0); -
1570 elementIndices.append(j + 1); -
1571 elementIndices.append(j + 2); -
1572 elementIndices.append(j + 3); -
1573 elementIndices.append(j + 3); -
1574 -
1575 j += 4; -
1576 }
never executed: }
0
1577 } else {
never executed: }
0
1578 -
1579 -
1580 -
1581 }
never executed: }
0
1582 -
1583 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data()); -
1584 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinates->data()); -
1585 -
1586 if (!snapToPixelGrid) {
never evaluated: !snapToPixelGrid
0
1587 snapToPixelGrid = true; -
1588 matrixDirty = true; -
1589 }
never executed: }
0
1590 -
1591 QBrush pensBrush = q->state()->pen.brush(); -
1592 setBrush(pensBrush); -
1593 -
1594 if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
never evaluated: glyphType == QFontEngineGlyphCache::Raster_RGBMask
0
1595 -
1596 -
1597 -
1598 QPainter::CompositionMode compMode = q->state()->composition_mode; -
1599 qt_noop(); -
1600 -
1601 -
1602 shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass1); -
1603 -
1604 if (pensBrush.style() == Qt::SolidPattern) {
never evaluated: pensBrush.style() == Qt::SolidPattern
0
1605 -
1606 QColor c = pensBrush.color(); -
1607 qreal oldOpacity = q->state()->opacity; -
1608 if (compMode == QPainter::CompositionMode_Source) {
never evaluated: compMode == QPainter::CompositionMode_Source
0
1609 c = qt_premultiplyColor(c, q->state()->opacity); -
1610 q->state()->opacity = 1; -
1611 opacityUniformDirty = true; -
1612 }
never executed: }
0
1613 -
1614 compositionModeDirty = false; -
1615 prepareForDraw(false); -
1616 -
1617 -
1618 if (compMode == QPainter::CompositionMode_Source) {
never evaluated: compMode == QPainter::CompositionMode_Source
0
1619 q->state()->opacity = oldOpacity; -
1620 opacityUniformDirty = true; -
1621 }
never executed: }
0
1622 -
1623 glEnable(0x0BE2); -
1624 glBlendFunc(0x8001, 0x0301); -
1625 QGLContextPrivate::extensionFuncs(ctx).qt_glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF()); -
1626 } else {
never executed: }
0
1627 -
1628 -
1629 qreal oldOpacity = q->state()->opacity; -
1630 if (compMode == QPainter::CompositionMode_Source) {
never evaluated: compMode == QPainter::CompositionMode_Source
0
1631 q->state()->opacity = 1; -
1632 opacityUniformDirty = true; -
1633 pensBrush = Qt::white; -
1634 setBrush(pensBrush); -
1635 }
never executed: }
0
1636 -
1637 compositionModeDirty = false; -
1638 prepareForDraw(false); -
1639 glEnable(0x0BE2); -
1640 glBlendFunc(0x0, 0x0301); -
1641 -
1642 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(1)); -
1643 glBindTexture(0x0DE1, cache->texture()); -
1644 updateTextureFilter(0x0DE1, 0x2901, false); -
1645 -
1646 -
1647 -
1648 -
1649 glDrawElements(0x0005, 6 * numGlyphs, 0x1403, elementIndices.data()); -
1650 -
1651 -
1652 shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass2); -
1653 -
1654 if (compMode == QPainter::CompositionMode_Source) {
never evaluated: compMode == QPainter::CompositionMode_Source
0
1655 q->state()->opacity = oldOpacity; -
1656 opacityUniformDirty = true; -
1657 pensBrush = q->state()->pen.brush(); -
1658 setBrush(pensBrush); -
1659 }
never executed: }
0
1660 -
1661 compositionModeDirty = false; -
1662 prepareForDraw(false); -
1663 glEnable(0x0BE2); -
1664 glBlendFunc(0x1, 0x1); -
1665 }
never executed: }
0
1666 compositionModeDirty = true; -
1667 } else {
never executed: }
0
1668 -
1669 -
1670 shaderManager->setMaskType(QGLEngineShaderManager::PixelMask); -
1671 prepareForDraw(false); -
1672 }
never executed: }
0
1673 -
1674 QGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QGLTextureGlyphCache::Linear:QGLTextureGlyphCache::Nearest;
never evaluated: (s->matrix.type() > QTransform::TxTranslate)
0
1675 if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) {
never evaluated: lastMaskTextureUsed != cache->texture()
never evaluated: cache->filterMode() != filterMode
0
1676 -
1677 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(1)); -
1678 if (lastMaskTextureUsed != cache->texture()) {
never evaluated: lastMaskTextureUsed != cache->texture()
0
1679 glBindTexture(0x0DE1, cache->texture()); -
1680 lastMaskTextureUsed = cache->texture(); -
1681 }
never executed: }
0
1682 -
1683 if (cache->filterMode() != filterMode) {
never evaluated: cache->filterMode() != filterMode
0
1684 if (filterMode == QGLTextureGlyphCache::Linear) {
never evaluated: filterMode == QGLTextureGlyphCache::Linear
0
1685 glTexParameteri(0x0DE1, 0x2800, 0x2601); -
1686 glTexParameteri(0x0DE1, 0x2801, 0x2601); -
1687 } else {
never executed: }
0
1688 glTexParameteri(0x0DE1, 0x2800, 0x2600); -
1689 glTexParameteri(0x0DE1, 0x2801, 0x2600); -
1690 }
never executed: }
0
1691 cache->setFilterMode(filterMode); -
1692 }
never executed: }
0
1693 }
never executed: }
0
1694 -
1695 bool srgbFrameBufferEnabled = false; -
1696 -
1697 -
1698 -
1699 -
1700 -
1701 glDrawElements(0x0005, 6 * numGlyphs, 0x1403, elementIndices.data()); -
1702 -
1703 -
1704 if (srgbFrameBufferEnabled)
never evaluated: srgbFrameBufferEnabled
0
1705 glDisable(0x8DB9);
never executed: glDisable(0x8DB9);
0
1706 -
1707}
never executed: }
0
1708 -
1709void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, -
1710 QPainter::PixmapFragmentHints hints) -
1711{ -
1712 QGL2PaintEngineExPrivate * const d = d_func(); -
1713 -
1714 if (state()->composition_mode > QPainter::CompositionMode_Plus) {
never evaluated: state()->composition_mode > QPainter::CompositionMode_Plus
0
1715 QPaintEngineEx::drawPixmapFragments(fragments, fragmentCount, pixmap, hints); -
1716 return;
never executed: return;
0
1717 } -
1718 -
1719 ensureActive(); -
1720 int max_texture_size = d->ctx->d_func()->maxTextureSize(); -
1721 if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) {
never evaluated: pixmap.width() > max_texture_size
never evaluated: pixmap.height() > max_texture_size
0
1722 QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio); -
1723 d->drawPixmapFragments(fragments, fragmentCount, scaled, hints); -
1724 } else {
never executed: }
0
1725 d->drawPixmapFragments(fragments, fragmentCount, pixmap, hints); -
1726 }
never executed: }
0
1727} -
1728 -
1729 -
1730void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragment *fragments, -
1731 int fragmentCount, const QPixmap &pixmap, -
1732 QPainter::PixmapFragmentHints hints) -
1733{ -
1734 GLfloat dx = 1.0f / pixmap.size().width(); -
1735 GLfloat dy = 1.0f / pixmap.size().height(); -
1736 -
1737 vertexCoordinateArray.clear(); -
1738 textureCoordinateArray.clear(); -
1739 opacityArray.reset(); -
1740 -
1741 if (snapToPixelGrid) {
never evaluated: snapToPixelGrid
0
1742 snapToPixelGrid = false; -
1743 matrixDirty = true; -
1744 }
never executed: }
0
1745 -
1746 bool allOpaque = true; -
1747 -
1748 for (int i = 0; i < fragmentCount; ++i) {
never evaluated: i < fragmentCount
0
1749 qreal s = 0; -
1750 qreal c = 1; -
1751 if (fragments[i].rotation != 0) {
never evaluated: fragments[i].rotation != 0
0
1752 s = qFastSin(fragments[i].rotation * Q_PI / 180); -
1753 c = qFastCos(fragments[i].rotation * Q_PI / 180); -
1754 }
never executed: }
0
1755 -
1756 qreal right = 0.5 * fragments[i].scaleX * fragments[i].width; -
1757 qreal bottom = 0.5 * fragments[i].scaleY * fragments[i].height; -
1758 QGLPoint bottomRight(right * c - bottom * s, right * s + bottom * c); -
1759 QGLPoint bottomLeft(-right * c - bottom * s, -right * s + bottom * c); -
1760 -
1761 vertexCoordinateArray.addVertex(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y); -
1762 vertexCoordinateArray.addVertex(-bottomLeft.x + fragments[i].x, -bottomLeft.y + fragments[i].y); -
1763 vertexCoordinateArray.addVertex(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y); -
1764 vertexCoordinateArray.addVertex(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y); -
1765 vertexCoordinateArray.addVertex(bottomLeft.x + fragments[i].x, bottomLeft.y + fragments[i].y); -
1766 vertexCoordinateArray.addVertex(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y); -
1767 -
1768 QGLRect src(fragments[i].sourceLeft * dx, fragments[i].sourceTop * dy, -
1769 (fragments[i].sourceLeft + fragments[i].width) * dx, -
1770 (fragments[i].sourceTop + fragments[i].height) * dy); -
1771 -
1772 textureCoordinateArray.addVertex(src.right, src.bottom); -
1773 textureCoordinateArray.addVertex(src.right, src.top); -
1774 textureCoordinateArray.addVertex(src.left, src.top); -
1775 textureCoordinateArray.addVertex(src.left, src.top); -
1776 textureCoordinateArray.addVertex(src.left, src.bottom); -
1777 textureCoordinateArray.addVertex(src.right, src.bottom); -
1778 -
1779 qreal opacity = fragments[i].opacity * q->state()->opacity; -
1780 opacityArray << opacity << opacity << opacity << opacity << opacity << opacity; -
1781 allOpaque &= (opacity >= 0.99f); -
1782 }
never executed: }
0
1783 -
1784 QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture(0x84C0 + GLuint(0)); -
1785 QGLTexture *texture = ctx->d_func()->bindTexture(pixmap, 0x0DE1, 0x1908, -
1786 QGLContext::InternalBindOption -
1787 | QGLContext::CanFlipNativePixmapBindOption); -
1788 -
1789 if (texture->options & QGLContext::InvertedYBindOption) {
never evaluated: texture->options & QGLContext::InvertedYBindOption
0
1790 -
1791 QGLPoint *data = textureCoordinateArray.data(); -
1792 for (int i = 0; i < 6 * fragmentCount; ++i)
never evaluated: i < 6 * fragmentCount
0
1793 data[i].y = 1 - data[i].y;
never executed: data[i].y = 1 - data[i].y;
0
1794 }
never executed: }
0
1795 -
1796 transferMode(ImageArrayDrawingMode); -
1797 -
1798 bool isBitmap = pixmap.isQBitmap(); -
1799 bool isOpaque = !isBitmap && (!pixmap.hasAlpha() || (hints & QPainter::OpaqueHint)) && allOpaque;
never evaluated: !isBitmap
never evaluated: !pixmap.hasAlpha()
never evaluated: (hints & QPainter::OpaqueHint)
never evaluated: allOpaque
0
1800 -
1801 updateTextureFilter(0x0DE1, 0x812F, -
1802 q->state()->renderHints & QPainter::SmoothPixmapTransform, texture->id); -
1803 -
1804 -
1805 currentBrush = noBrush; -
1806 shaderManager->setSrcPixelType(isBitmap ? QGLEngineShaderManager::PatternSrc -
1807 : QGLEngineShaderManager::ImageSrc); -
1808 if (prepareForDraw(isOpaque))
never evaluated: prepareForDraw(isOpaque)
0
1809 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), GLuint(0));
never executed: shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), GLuint(0));
0
1810 -
1811 if (isBitmap) {
never evaluated: isBitmap
0
1812 QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity); -
1813 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col); -
1814 }
never executed: }
0
1815 -
1816 glDrawArrays(0x0004, 0, 6 * fragmentCount); -
1817}
never executed: }
0
1818 -
1819bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) -
1820{ -
1821 QGL2PaintEngineExPrivate * const d = d_func(); -
1822 -
1823 -
1824 if (pdev->devType() == QInternal::OpenGL)
never evaluated: pdev->devType() == QInternal::OpenGL
0
1825 d->device = static_cast<QGLPaintDevice*>(pdev);
never executed: d->device = static_cast<QGLPaintDevice*>(pdev);
0
1826 else -
1827 d->device = QGLPaintDevice::getDevice(pdev);
never executed: d->device = QGLPaintDevice::getDevice(pdev);
0
1828 -
1829 if (!d->device)
never evaluated: !d->device
0
1830 return false;
never executed: return false;
0
1831 -
1832 d->ctx = d->device->context(); -
1833 d->ctx->d_ptr->active_engine = this; -
1834 -
1835 const QSize sz = d->device->size(); -
1836 d->width = sz.width(); -
1837 d->height = sz.height(); -
1838 d->mode = BrushDrawingMode; -
1839 d->brushTextureDirty = true; -
1840 d->brushUniformsDirty = true; -
1841 d->matrixUniformDirty = true; -
1842 d->matrixDirty = true; -
1843 d->compositionModeDirty = true; -
1844 d->opacityUniformDirty = true; -
1845 d->needsSync = true; -
1846 d->useSystemClip = !systemClip().isEmpty(); -
1847 d->currentBrush = QBrush(); -
1848 -
1849 d->dirtyStencilRegion = QRect(0, 0, d->width, d->height); -
1850 d->stencilClean = true; -
1851 -
1852 -
1853 -
1854 -
1855 d->device->beginPaint(); -
1856 -
1857 -
1858 bool success = qt_resolve_version_2_0_functions(d->ctx)
never evaluated: qt_resolve_version_2_0_functions(d->ctx)
0
1859 && qt_resolve_buffer_extensions(d->ctx)
never evaluated: qt_resolve_buffer_extensions(d->ctx)
0
1860 && (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
never evaluated: !QGLFramebufferObject::hasOpenGLFramebufferObjects()
0
1861 || qt_resolve_framebufferobject_extensions(d->ctx));
never evaluated: qt_resolve_framebufferobject_extensions(d->ctx)
0
1862 qt_noop(); -
1863 (void)success;; -
1864 -
1865 -
1866 d->shaderManager = new QGLEngineShaderManager(d->ctx); -
1867 -
1868 glDisable(0x0B90); -
1869 glDisable(0x0B71); -
1870 glDisable(0x0C11); -
1871 -
1872 -
1873 glDisable(0x809D); -
1874 -
1875 -
1876 d->glyphCacheType = QFontEngineGlyphCache::Raster_A8; -
1877 -
1878 -
1879 d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; -
1880 -
1881 -
1882 -
1883 -
1884 -
1885 -
1886 -
1887 d->multisamplingAlwaysEnabled = false; -
1888 -
1889 -
1890 return true;
never executed: return true;
0
1891} -
1892 -
1893bool QGL2PaintEngineEx::end() -
1894{ -
1895 QGL2PaintEngineExPrivate * const d = d_func(); -
1896 -
1897 QGLContext *ctx = d->ctx; -
1898 QGLContextPrivate::extensionFuncs(ctx).qt_glUseProgram(0); -
1899 d->transferMode(BrushDrawingMode); -
1900 d->device->endPaint(); -
1901 -
1902 ctx->d_ptr->active_engine = 0; -
1903 -
1904 d->resetGLState(); -
1905 -
1906 delete d->shaderManager; -
1907 d->shaderManager = 0; -
1908 d->currentBrush = QBrush(); -
1909 return false;
never executed: return false;
0
1910} -
1911 -
1912void QGL2PaintEngineEx::ensureActive() -
1913{ -
1914 QGL2PaintEngineExPrivate * const d = d_func(); -
1915 QGLContext *ctx = d->ctx; -
1916 -
1917 if (isActive() && ctx->d_ptr->active_engine != this) {
never evaluated: isActive()
never evaluated: ctx->d_ptr->active_engine != this
0
1918 ctx->d_ptr->active_engine = this; -
1919 d->needsSync = true; -
1920 }
never executed: }
0
1921 -
1922 d->device->ensureActiveTarget(); -
1923 -
1924 if (d->needsSync) {
never evaluated: d->needsSync
0
1925 d->transferMode(BrushDrawingMode); -
1926 glViewport(0, 0, d->width, d->height); -
1927 d->needsSync = false; -
1928 d->lastMaskTextureUsed = 0; -
1929 d->shaderManager->setDirty(); -
1930 d->ctx->d_func()->syncGlState(); -
1931 for (int i = 0; i < 3; ++i)
never evaluated: i < 3
0
1932 d->vertexAttribPointers[i] = (GLfloat*)-1;
never executed: d->vertexAttribPointers[i] = (GLfloat*)-1;
0
1933 setState(state()); -
1934 }
never executed: }
0
1935}
never executed: }
0
1936 -
1937void QGL2PaintEngineExPrivate::updateClipScissorTest() -
1938{ -
1939 QGL2PaintEngineEx * const q = q_func(); -
1940 if (q->state()->clipTestEnabled) {
never evaluated: q->state()->clipTestEnabled
0
1941 glEnable(0x0B90); -
1942 glStencilFunc(0x0203, q->state()->currentClip, ~GLuint(0x80)); -
1943 } else {
never executed: }
0
1944 glDisable(0x0B90); -
1945 glStencilFunc(0x0207, 0, 0xff); -
1946 }
never executed: }
0
1947 -
1948 -
1949 -
1950 -
1951 QRect bounds = q->state()->rectangleClip; -
1952 if (!q->state()->clipEnabled) {
never evaluated: !q->state()->clipEnabled
0
1953 if (useSystemClip)
never evaluated: useSystemClip
0
1954 bounds = systemClip.boundingRect();
never executed: bounds = systemClip.boundingRect();
0
1955 else -
1956 bounds = QRect(0, 0, width, height);
never executed: bounds = QRect(0, 0, width, height);
0
1957 } else { -
1958 if (useSystemClip)
never evaluated: useSystemClip
0
1959 bounds = bounds.intersected(systemClip.boundingRect());
never executed: bounds = bounds.intersected(systemClip.boundingRect());
0
1960 else -
1961 bounds = bounds.intersected(QRect(0, 0, width, height));
never executed: bounds = bounds.intersected(QRect(0, 0, width, height));
0
1962 } -
1963 -
1964 currentScissorBounds = bounds; -
1965 -
1966 if (bounds == QRect(0, 0, width, height)) {
never evaluated: bounds == QRect(0, 0, width, height)
0
1967 glDisable(0x0C11); -
1968 } else {
never executed: }
0
1969 glEnable(0x0C11); -
1970 setScissor(bounds); -
1971 }
never executed: }
0
1972 -
1973} -
1974 -
1975void QGL2PaintEngineExPrivate::setScissor(const QRect &rect) -
1976{ -
1977 const int left = rect.left(); -
1978 const int width = rect.width(); -
1979 int bottom = height - (rect.top() + rect.height()); -
1980 if (device->isFlipped()) {
never evaluated: device->isFlipped()
0
1981 bottom = rect.top(); -
1982 }
never executed: }
0
1983 const int height = rect.height(); -
1984 -
1985 glScissor(left, bottom, width, height); -
1986}
never executed: }
0
1987 -
1988void QGL2PaintEngineEx::clipEnabledChanged() -
1989{ -
1990 QGL2PaintEngineExPrivate * const d = d_func(); -
1991 -
1992 state()->clipChanged = true; -
1993 -
1994 if (painter()->hasClipping())
never evaluated: painter()->hasClipping()
0
1995 d->regenerateClip();
never executed: d->regenerateClip();
0
1996 else -
1997 d->systemStateChanged();
never executed: d->systemStateChanged();
0
1998} -
1999 -
2000void QGL2PaintEngineExPrivate::clearClip(uint value) -
2001{ -
2002 dirtyStencilRegion -= currentScissorBounds; -
2003 -
2004 glStencilMask(0xff); -
2005 glClearStencil(value); -
2006 glClear(0x00000400); -
2007 glStencilMask(0x0); -
2008 -
2009 q->state()->needsClipBufferClear = false; -
2010}
never executed: }
0
2011 -
2012void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value) -
2013{ -
2014 transferMode(BrushDrawingMode); -
2015 -
2016 if (snapToPixelGrid) {
never evaluated: snapToPixelGrid
0
2017 snapToPixelGrid = false; -
2018 matrixDirty = true; -
2019 }
never executed: }
0
2020 -
2021 if (matrixDirty)
never evaluated: matrixDirty
0
2022 updateMatrix();
never executed: updateMatrix();
0
2023 -
2024 stencilClean = false; -
2025 -
2026 const bool singlePass = !path.hasWindingFill()
never evaluated: !path.hasWindingFill()
0
2027 && (((q->state()->currentClip == maxClip - 1) && q->state()->clipTestEnabled)
never evaluated: (q->state()->currentClip == maxClip - 1)
never evaluated: q->state()->clipTestEnabled
0
2028 || q->state()->needsClipBufferClear);
never evaluated: q->state()->needsClipBufferClear
0
2029 const uint referenceClipValue = q->state()->needsClipBufferClear ? 1 : q->state()->currentClip;
never evaluated: q->state()->needsClipBufferClear
0
2030 -
2031 if (q->state()->needsClipBufferClear)
never evaluated: q->state()->needsClipBufferClear
0
2032 clearClip(1);
never executed: clearClip(1);
0
2033 -
2034 if (path.isEmpty()) {
never evaluated: path.isEmpty()
0
2035 glEnable(0x0B90); -
2036 glStencilFunc(0x0203, value, ~GLuint(0x80)); -
2037 return;
never executed: return;
0
2038 } -
2039 -
2040 if (q->state()->clipTestEnabled)
never evaluated: q->state()->clipTestEnabled
0
2041 glStencilFunc(0x0203, q->state()->currentClip, ~GLuint(0x80));
never executed: glStencilFunc(0x0203, q->state()->currentClip, ~GLuint(0x80));
0
2042 else -
2043 glStencilFunc(0x0207, 0, 0xff);
never executed: glStencilFunc(0x0207, 0, 0xff);
0
2044 -
2045 vertexCoordinateArray.clear(); -
2046 vertexCoordinateArray.addPath(path, inverseScale, false); -
2047 -
2048 if (!singlePass)
never evaluated: !singlePass
0
2049 fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill());
never executed: fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill());
0
2050 -
2051 glColorMask(false, false, false, false); -
2052 glEnable(0x0B90); -
2053 useSimpleShader(); -
2054 -
2055 if (singlePass) {
never evaluated: singlePass
0
2056 -
2057 -
2058 -
2059 glStencilFunc(0x0203, referenceClipValue, ~GLuint(0x80)); -
2060 glStencilOp(0x1E00, 0x150A, 0x150A); -
2061 glStencilMask(value ^ referenceClipValue); -
2062 -
2063 drawVertexArrays(vertexCoordinateArray, 0x0006); -
2064 } else {
never executed: }
0
2065 glStencilOp(0x1E00, 0x1E01, 0x1E01); -
2066 glStencilMask(0xff); -
2067 -
2068 if (!q->state()->clipTestEnabled && path.hasWindingFill()) {
never evaluated: !q->state()->clipTestEnabled
never evaluated: path.hasWindingFill()
0
2069 -
2070 glStencilFunc(0x0205, GLuint(0x80), ~GLuint(0x80)); -
2071 composite(vertexCoordinateArray.boundingRect()); -
2072 }
never executed: }
0
2073 -
2074 -
2075 glStencilFunc(0x0205, value, GLuint(0x80)); -
2076 -
2077 composite(vertexCoordinateArray.boundingRect()); -
2078 }
never executed: }
0
2079 -
2080 glStencilFunc(0x0203, value, ~GLuint(0x80)); -
2081 glStencilMask(0); -
2082 -
2083 glColorMask(true, true, true, true); -
2084}
never executed: }
0
2085 -
2086void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) -
2087{ -
2088 -
2089 QGL2PaintEngineExPrivate * const d = d_func(); -
2090 -
2091 state()->clipChanged = true; -
2092 -
2093 ensureActive(); -
2094 -
2095 if (op == Qt::ReplaceClip) {
never evaluated: op == Qt::ReplaceClip
0
2096 op = Qt::IntersectClip; -
2097 if (d->hasClipOperations()) {
never evaluated: d->hasClipOperations()
0
2098 d->systemStateChanged(); -
2099 state()->canRestoreClip = false; -
2100 }
never executed: }
0
2101 }
never executed: }
0
2102 -
2103 -
2104 if (!path.isEmpty() && op == Qt::IntersectClip && (path.shape() == QVectorPath::RectangleHint)) {
never evaluated: !path.isEmpty()
never evaluated: op == Qt::IntersectClip
never evaluated: (path.shape() == QVectorPath::RectangleHint)
0
2105 const QPointF* const points = reinterpret_cast<const QPointF*>(path.points()); -
2106 QRectF rect(points[0], points[2]); -
2107 -
2108 if (state()->matrix.type() <= QTransform::TxScale
never evaluated: state()->matrix.type() <= QTransform::TxScale
0
2109 || (state()->matrix.type() == QTransform::TxRotate
never evaluated: state()->matrix.type() == QTransform::TxRotate
0
2110 && qFuzzyIsNull(state()->matrix.m11())
never evaluated: qFuzzyIsNull(state()->matrix.m11())
0
2111 && qFuzzyIsNull(state()->matrix.m22())))
never evaluated: qFuzzyIsNull(state()->matrix.m22())
0
2112 { -
2113 state()->rectangleClip = state()->rectangleClip.intersected(state()->matrix.mapRect(rect).toRect()); -
2114 d->updateClipScissorTest(); -
2115 return;
never executed: return;
0
2116 } -
2117 }
never executed: }
0
2118 -
2119 -
2120 const QRect pathRect = state()->matrix.mapRect(path.controlPointRect()).toAlignedRect(); -
2121 -
2122 switch (op) { -
2123 case Qt::NoClip: -
2124 if (d->useSystemClip) {
never evaluated: d->useSystemClip
0
2125 state()->clipTestEnabled = true; -
2126 state()->currentClip = 1; -
2127 } else {
never executed: }
0
2128 state()->clipTestEnabled = false; -
2129 }
never executed: }
0
2130 state()->rectangleClip = QRect(0, 0, d->width, d->height); -
2131 state()->canRestoreClip = false; -
2132 d->updateClipScissorTest(); -
2133 break;
never executed: break;
0
2134 case Qt::IntersectClip: -
2135 state()->rectangleClip = state()->rectangleClip.intersected(pathRect); -
2136 d->updateClipScissorTest(); -
2137 d->resetClipIfNeeded(); -
2138 ++d->maxClip; -
2139 d->writeClip(path, d->maxClip); -
2140 state()->currentClip = d->maxClip; -
2141 state()->clipTestEnabled = true; -
2142 break;
never executed: break;
0
2143 default: -
2144 break;
never executed: break;
0
2145 } -
2146}
never executed: }
0
2147 -
2148void QGL2PaintEngineExPrivate::regenerateClip() -
2149{ -
2150 systemStateChanged(); -
2151 replayClipOperations(); -
2152}
never executed: }
0
2153 -
2154void QGL2PaintEngineExPrivate::systemStateChanged() -
2155{ -
2156 QGL2PaintEngineEx * const q = q_func(); -
2157 -
2158 q->state()->clipChanged = true; -
2159 -
2160 if (systemClip.isEmpty()) {
never evaluated: systemClip.isEmpty()
0
2161 useSystemClip = false; -
2162 } else {
never executed: }
0
2163 if (q->paintDevice()->devType() == QInternal::Widget && currentClipDevice) {
never evaluated: q->paintDevice()->devType() == QInternal::Widget
never evaluated: currentClipDevice
0
2164 QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast<QWidget *>(currentClipDevice)->window()); -
2165 useSystemClip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter;
never evaluated: widgetPrivate->extra
never evaluated: widgetPrivate->extra->inRenderWithPainter
0
2166 } else {
never executed: }
0
2167 useSystemClip = true; -
2168 }
never executed: }
0
2169 } -
2170 -
2171 q->state()->clipTestEnabled = false; -
2172 q->state()->needsClipBufferClear = true; -
2173 -
2174 q->state()->currentClip = 1; -
2175 maxClip = 1; -
2176 -
2177 q->state()->rectangleClip = useSystemClip ? systemClip.boundingRect() : QRect(0, 0, width, height);
never evaluated: useSystemClip
0
2178 updateClipScissorTest(); -
2179 -
2180 if (systemClip.rectCount() == 1) {
never evaluated: systemClip.rectCount() == 1
0
2181 if (systemClip.boundingRect() == QRect(0, 0, width, height))
never evaluated: systemClip.boundingRect() == QRect(0, 0, width, height)
0
2182 useSystemClip = false;
never executed: useSystemClip = false;
0
2183 -
2184 -
2185 return;
never executed: return;
0
2186 -
2187 } -
2188 -
2189 if (useSystemClip) {
never evaluated: useSystemClip
0
2190 clearClip(0); -
2191 -
2192 QPainterPath path; -
2193 path.addRegion(systemClip); -
2194 -
2195 q->state()->currentClip = 0; -
2196 writeClip(qtVectorPathForPath(q->state()->matrix.inverted().map(path)), 1); -
2197 q->state()->currentClip = 1; -
2198 q->state()->clipTestEnabled = true; -
2199 }
never executed: }
0
2200}
never executed: }
0
2201 -
2202void QGL2PaintEngineEx::setState(QPainterState *new_state) -
2203{ -
2204 -
2205 -
2206 QGL2PaintEngineExPrivate * const d = d_func(); -
2207 -
2208 QOpenGL2PaintEngineState *s = static_cast<QOpenGL2PaintEngineState *>(new_state); -
2209 QOpenGL2PaintEngineState *old_state = state(); -
2210 -
2211 QPaintEngineEx::setState(s); -
2212 -
2213 if (s->isNew) {
never evaluated: s->isNew
0
2214 -
2215 -
2216 -
2217 s->isNew = false; -
2218 return;
never executed: return;
0
2219 } -
2220 -
2221 -
2222 -
2223 if (old_state == s || old_state->renderHintsChanged)
never evaluated: old_state == s
never evaluated: old_state->renderHintsChanged
0
2224 renderHintsChanged();
never executed: renderHintsChanged();
0
2225 -
2226 if (old_state == s || old_state->matrixChanged)
never evaluated: old_state == s
never evaluated: old_state->matrixChanged
0
2227 d->matrixDirty = true;
never executed: d->matrixDirty = true;
0
2228 -
2229 if (old_state == s || old_state->compositionModeChanged)
never evaluated: old_state == s
never evaluated: old_state->compositionModeChanged
0
2230 d->compositionModeDirty = true;
never executed: d->compositionModeDirty = true;
0
2231 -
2232 if (old_state == s || old_state->opacityChanged)
never evaluated: old_state == s
never evaluated: old_state->opacityChanged
0
2233 d->opacityUniformDirty = true;
never executed: d->opacityUniformDirty = true;
0
2234 -
2235 if (old_state == s || old_state->clipChanged) {
never evaluated: old_state == s
never evaluated: old_state->clipChanged
0
2236 if (old_state && old_state != s && old_state->canRestoreClip) {
never evaluated: old_state
never evaluated: old_state != s
never evaluated: old_state->canRestoreClip
0
2237 d->updateClipScissorTest(); -
2238 glDepthFunc(0x0203); -
2239 } else {
never executed: }
0
2240 d->regenerateClip(); -
2241 }
never executed: }
0
2242 } -
2243}
never executed: }
0
2244 -
2245QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const -
2246{ -
2247 if (orig)
never evaluated: orig
0
2248 const_cast<QGL2PaintEngineEx *>(this)->ensureActive();
never executed: const_cast<QGL2PaintEngineEx *>(this)->ensureActive();
0
2249 -
2250 QOpenGL2PaintEngineState *s; -
2251 if (!orig)
never evaluated: !orig
0
2252 s = new QOpenGL2PaintEngineState();
never executed: s = new QOpenGL2PaintEngineState();
0
2253 else -
2254 s = new QOpenGL2PaintEngineState(*static_cast<QOpenGL2PaintEngineState *>(orig));
never executed: s = new QOpenGL2PaintEngineState(*static_cast<QOpenGL2PaintEngineState *>(orig));
0
2255 -
2256 s->matrixChanged = false; -
2257 s->compositionModeChanged = false; -
2258 s->opacityChanged = false; -
2259 s->renderHintsChanged = false; -
2260 s->clipChanged = false; -
2261 -
2262 return s;
never executed: return s;
0
2263} -
2264 -
2265QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &other) -
2266 : QPainterState(other) -
2267{ -
2268 isNew = true; -
2269 needsClipBufferClear = other.needsClipBufferClear; -
2270 clipTestEnabled = other.clipTestEnabled; -
2271 currentClip = other.currentClip; -
2272 canRestoreClip = other.canRestoreClip; -
2273 rectangleClip = other.rectangleClip; -
2274}
never executed: }
0
2275 -
2276QOpenGL2PaintEngineState::QOpenGL2PaintEngineState() -
2277{ -
2278 isNew = true; -
2279 needsClipBufferClear = true; -
2280 clipTestEnabled = false; -
2281 canRestoreClip = true; -
2282}
never executed: }
0
2283 -
2284QOpenGL2PaintEngineState::~QOpenGL2PaintEngineState() -
2285{ -
2286} -
2287 -
2288 -
2289 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial