qpaintengineex_opengl2.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtOpenGL module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40/*-
41 When the active program changes, we need to update it's uniforms.-
42 We could track state for each program and only update stale uniforms-
43 - Could lead to lots of overhead if there's a lot of programs-
44 We could update all the uniforms when the program changes-
45 - Could end up updating lots of uniforms which don't need updating-
46-
47 Updating uniforms should be cheap, so the overhead of updating up-to-date-
48 uniforms should be minimal. It's also less complex.-
49-
50 Things which _may_ cause a different program to be used:-
51 - Change in brush/pen style-
52 - Change in painter opacity-
53 - Change in composition mode-
54-
55 Whenever we set a mode on the shader manager - it needs to tell us if it had-
56 to switch to a different program.-
57-
58 The shader manager should only switch when we tell it to. E.g. if we set a new-
59 brush style and then switch to transparent painter, we only want it to compile-
60 and use the correct program when we really need it.-
61*/-
62-
63// #define QT_OPENGL_CACHE_AS_VBOS-
64-
65#include "qglgradientcache_p.h"-
66#include "qpaintengineex_opengl2_p.h"-
67-
68#include <string.h> //for memcpy-
69#include <qmath.h>-
70-
71#include <private/qgl_p.h>-
72#include <private/qpaintengineex_p.h>-
73#include <QPaintEngine>-
74#include <private/qpainter_p.h>-
75#include <private/qfontengine_p.h>-
76#include <private/qdatabuffer_p.h>-
77#include <private/qstatictext_p.h>-
78#include <QtGui/private/qtriangulator_p.h>-
79-
80#include "qglengineshadermanager_p.h"-
81#include "qgl2pexvertexarray_p.h"-
82#include "qtextureglyphcache_gl_p.h"-
83-
84#include <QDebug>-
85-
86#ifndef QT_OPENGL_ES_2-
87# include <qopenglfunctions_1_1.h>-
88#endif-
89-
90QT_BEGIN_NAMESPACE-
91-
92-
93-
94Q_GUI_EXPORT QImage qt_imageForBrush(int brushStyle, bool invert);-
95-
96////////////////////////////////// Private Methods //////////////////////////////////////////-
97-
98QGL2PaintEngineExPrivate::~QGL2PaintEngineExPrivate()-
99{-
100 delete shaderManager;-
101-
102 while (pathCaches.size()) {
pathCaches.size()Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-1
103 QVectorPath::CacheEntry *e = *(pathCaches.constBegin());-
104 e->cleanup(e->engine, e->data);-
105 e->data = 0;-
106 e->engine = 0;-
107 }
never executed: end of block
0
108-
109 if (elementIndicesVBOId != 0) {
elementIndicesVBOId != 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-1
110 glDeleteBuffers(1, &elementIndicesVBOId);-
111 elementIndicesVBOId = 0;-
112 }
never executed: end of block
0
113}
executed 1 time by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
1
114-
115void QGL2PaintEngineExPrivate::updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id)-
116{-
117// glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT); //### Is it always this texture unit?-
118 if (id != GLuint(-1) && id == lastTextureUsed)
id != GLuint(-1)Description
TRUEnever evaluated
FALSEnever evaluated
id == lastTextureUsedDescription
TRUEnever evaluated
FALSEnever evaluated
0
119 return;
never executed: return;
0
120-
121 lastTextureUsed = id;-
122-
123 if (smoothPixmapTransform) {
smoothPixmapTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
124 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);-
125 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);-
126 } else {
never executed: end of block
0
127 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);-
128 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);-
129 }
never executed: end of block
0
130 glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapMode);-
131 glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapMode);-
132}
never executed: end of block
0
133-
134-
135inline QColor qt_premultiplyColor(QColor c, GLfloat opacity)-
136{-
137 qreal alpha = c.alphaF() * opacity;-
138 c.setAlphaF(alpha);-
139 c.setRedF(c.redF() * alpha);-
140 c.setGreenF(c.greenF() * alpha);-
141 c.setBlueF(c.blueF() * alpha);-
142 return c;
executed 3 times by 1 test: return c;
Executed by:
  • tst_qmdiarea - unknown status
3
143}-
144-
145-
146void QGL2PaintEngineExPrivate::setBrush(const QBrush& brush)-
147{-
148 if (qbrush_fast_equals(currentBrush, brush))
qbrush_fast_eq...tBrush, brush)Description
TRUEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
3-39
149 return;
executed 39 times by 1 test: return;
Executed by:
  • tst_qmdiarea - unknown status
39
150-
151 const Qt::BrushStyle newStyle = qbrush_style(brush);-
152 Q_ASSERT(newStyle != Qt::NoBrush);-
153-
154 currentBrush = brush;-
155 if (!currentBrushPixmap.isNull())
!currentBrushPixmap.isNull()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
156 currentBrushPixmap = QPixmap();
never executed: currentBrushPixmap = QPixmap();
0
157 brushUniformsDirty = true; // All brushes have at least one uniform-
158-
159 if (newStyle > Qt::SolidPattern)
newStyle > Qt::SolidPatternDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
160 brushTextureDirty = true;
never executed: brushTextureDirty = true;
0
161-
162 if (currentBrush.style() == Qt::TexturePattern
currentBrush.s...TexturePatternDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
163 && qHasPixmapTexture(brush) && brush.texture().isQBitmap())
qHasPixmapTexture(brush)Description
TRUEnever evaluated
FALSEnever evaluated
brush.texture().isQBitmap()Description
TRUEnever evaluated
FALSEnever evaluated
0
164 {-
165 shaderManager->setSrcPixelType(QGLEngineShaderManager::TextureSrcWithPattern);-
166 } else {
never executed: end of block
0
167 shaderManager->setSrcPixelType(newStyle);-
168 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
169 shaderManager->optimiseForBrushTransform(currentBrush.transform().type());-
170}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
171-
172-
173void QGL2PaintEngineExPrivate::useSimpleShader()-
174{-
175 shaderManager->useSimpleProgram();-
176-
177 if (matrixDirty)
matrixDirtyDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-6
178 updateMatrix();
never executed: updateMatrix();
0
179}
executed 6 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
6
180-
181// ####TODO Properly #ifdef this class to use #define symbols actually defined-
182// by OpenGL/ES includes-
183#ifndef GL_MIRRORED_REPEAT_IBM-
184#define GL_MIRRORED_REPEAT_IBM 0x8370-
185#endif-
186-
187void QGL2PaintEngineExPrivate::updateBrushTexture()-
188{-
189 Q_Q(QGL2PaintEngineEx);-
190// qDebug("QGL2PaintEngineExPrivate::updateBrushTexture()");-
191 Qt::BrushStyle style = currentBrush.style();-
192-
193 if ( (style >= Qt::Dense1Pattern) && (style <= Qt::DiagCrossPattern) ) {
(style >= Qt::Dense1Pattern)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
(style <= Qt::...gCrossPattern)Description
TRUEnever evaluated
FALSEnever evaluated
0-3
194 // Get the image data for the pattern-
195 QImage texImage = qt_imageForBrush(style, false);-
196-
197 glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT);-
198 ctx->d_func()->bindTexture(texImage, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);-
199 updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform);-
200 }
never executed: end of block
0
201 else if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
style >= Qt::L...radientPatternDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
style <= Qt::C...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0-3
202 // Gradiant brush: All the gradiants use the same texture-
203-
204 const QGradient* g = currentBrush.gradient();-
205-
206 // We apply global opacity in the fragment shaders, so we always pass 1.0-
207 // for opacity to the cache.-
208 GLuint texId = QGL2GradientCache::cacheForContext(ctx)->getBuffer(*g, 1.0);-
209-
210 glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT);-
211 glBindTexture(GL_TEXTURE_2D, texId);-
212-
213 if (g->spread() == QGradient::RepeatSpread || g->type() == QGradient::ConicalGradient)
g->spread() ==...::RepeatSpreadDescription
TRUEnever evaluated
FALSEnever evaluated
g->type() == Q...onicalGradientDescription
TRUEnever evaluated
FALSEnever evaluated
0
214 updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform);
never executed: updateTextureFilter(0x0DE1, 0x2901, q->state()->renderHints & QPainter::SmoothPixmapTransform);
0
215 else if (g->spread() == QGradient::ReflectSpread)
g->spread() ==...:ReflectSpreadDescription
TRUEnever evaluated
FALSEnever evaluated
0
216 updateTextureFilter(GL_TEXTURE_2D, GL_MIRRORED_REPEAT_IBM, q->state()->renderHints & QPainter::SmoothPixmapTransform);
never executed: updateTextureFilter(0x0DE1, 0x8370, q->state()->renderHints & QPainter::SmoothPixmapTransform);
0
217 else-
218 updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE, q->state()->renderHints & QPainter::SmoothPixmapTransform);
never executed: updateTextureFilter(0x0DE1, 0x812F, q->state()->renderHints & QPainter::SmoothPixmapTransform);
0
219 }-
220 else if (style == Qt::TexturePattern) {
style == Qt::TexturePatternDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
221 currentBrushPixmap = currentBrush.texture();-
222-
223 int max_texture_size = ctx->d_func()->maxTextureSize();-
224 if (currentBrushPixmap.width() > max_texture_size || currentBrushPixmap.height() > max_texture_size)
currentBrushPi...x_texture_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
currentBrushPi...x_texture_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
225 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
226-
227 GLuint wrapMode = GL_REPEAT;-
228 if (ctx->contextHandle()->isOpenGLES()) {
ctx->contextHa...->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
229 // OpenGL ES does not support GL_REPEAT wrap modes for NPOT textures. So instead,-
230 // we emulate GL_REPEAT by only taking the fractional part of the texture coords-
231 // in the qopenglslTextureBrushSrcFragmentShader program.-
232 wrapMode = GL_CLAMP_TO_EDGE;-
233 }
never executed: end of block
0
234-
235 glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT);-
236 QGLTexture *tex = ctx->d_func()->bindTexture(currentBrushPixmap, GL_TEXTURE_2D, GL_RGBA,-
237 QGLContext::InternalBindOption |-
238 QGLContext::CanFlipNativePixmapBindOption);-
239 updateTextureFilter(GL_TEXTURE_2D, wrapMode, q->state()->renderHints & QPainter::SmoothPixmapTransform);-
240 textureInvertedY = tex->options & QGLContext::InvertedYBindOption ? -1 : 1;
tex->options &...tedYBindOptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
241 }
never executed: end of block
0
242 brushTextureDirty = false;-
243}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
244-
245-
246void QGL2PaintEngineExPrivate::updateBrushUniforms()-
247{-
248// qDebug("QGL2PaintEngineExPrivate::updateBrushUniforms()");-
249 Qt::BrushStyle style = currentBrush.style();-
250-
251 if (style == Qt::NoBrush)
style == Qt::NoBrushDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
252 return;
never executed: return;
0
253-
254 QTransform brushQTransform = currentBrush.transform();-
255-
256 if (style == Qt::SolidPattern) {
style == Qt::SolidPatternDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
257 QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity);-
258 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::FragmentColor), col);-
259 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
260 else {-
261 // All other brushes have a transform and thus need the translation point:-
262 QPointF translationPoint;-
263-
264 if (style <= Qt::DiagCrossPattern) {
style <= Qt::DiagCrossPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
265 QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity);-
266-
267 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col);-
268-
269 QVector2D halfViewportSize(width*0.5, height*0.5);-
270 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);-
271 }
never executed: end of block
0
272 else if (style == Qt::LinearGradientPattern) {
style == Qt::L...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
273 const QLinearGradient *g = static_cast<const QLinearGradient *>(currentBrush.gradient());-
274-
275 QPointF realStart = g->start();-
276 QPointF realFinal = g->finalStop();-
277 translationPoint = realStart;-
278-
279 QPointF l = realFinal - realStart;-
280-
281 QVector3D linearData(-
282 l.x(),-
283 l.y(),-
284 1.0f / (l.x() * l.x() + l.y() * l.y())-
285 );-
286-
287 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::LinearData), linearData);-
288-
289 QVector2D halfViewportSize(width*0.5, height*0.5);-
290 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);-
291 }
never executed: end of block
0
292 else if (style == Qt::ConicalGradientPattern) {
style == Qt::C...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
293 const QConicalGradient *g = static_cast<const QConicalGradient *>(currentBrush.gradient());-
294 translationPoint = g->center();-
295-
296 GLfloat angle = -qDegreesToRadians(g->angle());-
297-
298 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Angle), angle);-
299-
300 QVector2D halfViewportSize(width*0.5, height*0.5);-
301 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);-
302 }
never executed: end of block
0
303 else if (style == Qt::RadialGradientPattern) {
style == Qt::R...radientPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
304 const QRadialGradient *g = static_cast<const QRadialGradient *>(currentBrush.gradient());-
305 QPointF realCenter = g->center();-
306 QPointF realFocal = g->focalPoint();-
307 qreal realRadius = g->centerRadius() - g->focalRadius();-
308 translationPoint = realFocal;-
309-
310 QPointF fmp = realCenter - realFocal;-
311 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Fmp), fmp);-
312-
313 GLfloat fmp2_m_radius2 = -fmp.x() * fmp.x() - fmp.y() * fmp.y() + realRadius*realRadius;-
314 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Fmp2MRadius2), fmp2_m_radius2);-
315 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Inverse2Fmp2MRadius2),-
316 GLfloat(1.0 / (2.0*fmp2_m_radius2)));-
317 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::SqrFr),-
318 GLfloat(g->focalRadius() * g->focalRadius()));-
319 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BRadius),-
320 GLfloat(2 * (g->centerRadius() - g->focalRadius()) * g->focalRadius()),-
321 g->focalRadius(),-
322 g->centerRadius() - g->focalRadius());-
323-
324 QVector2D halfViewportSize(width*0.5, height*0.5);-
325 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);-
326 }
never executed: end of block
0
327 else if (style == Qt::TexturePattern) {
style == Qt::TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
328 const QPixmap& texPixmap = currentBrush.texture();-
329-
330 if (qHasPixmapTexture(currentBrush) && currentBrush.texture().isQBitmap()) {
qHasPixmapText...(currentBrush)Description
TRUEnever evaluated
FALSEnever evaluated
currentBrush.t...().isQBitmap()Description
TRUEnever evaluated
FALSEnever evaluated
0
331 QColor col = qt_premultiplyColor(currentBrush.color(), (GLfloat)q->state()->opacity);-
332 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col);-
333 }
never executed: end of block
0
334-
335 QSizeF invertedTextureSize(1.0 / texPixmap.width(), 1.0 / texPixmap.height());-
336 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::InvertedTextureSize), invertedTextureSize);-
337-
338 QVector2D halfViewportSize(width*0.5, height*0.5);-
339 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::HalfViewportSize), halfViewportSize);-
340 }
never executed: end of block
0
341 else-
342 qWarning("QGL2PaintEngineEx: Unimplemented fill style");
never executed: QMessageLogger(__FILE__, 342, __PRETTY_FUNCTION__).warning("QGL2PaintEngineEx: Unimplemented fill style");
0
343-
344 const QPointF &brushOrigin = q->state()->brushOrigin;-
345 QTransform matrix = q->state()->matrix;-
346 matrix.translate(brushOrigin.x(), brushOrigin.y());-
347-
348 QTransform translate(1, 0, 0, 1, -translationPoint.x(), -translationPoint.y());-
349 qreal m22 = -1;-
350 qreal dy = height;-
351 if (device->isFlipped()) {
device->isFlipped()Description
TRUEnever evaluated
FALSEnever evaluated
0
352 m22 = 1;-
353 dy = 0;-
354 }
never executed: end of block
0
355 QTransform gl_to_qt(1, 0, 0, m22, 0, dy);-
356 QTransform inv_matrix;-
357 if (style == Qt::TexturePattern && textureInvertedY == -1)
style == Qt::TexturePatternDescription
TRUEnever evaluated
FALSEnever evaluated
textureInvertedY == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
358 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
359 else-
360 inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate;
never executed: inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate;
0
361-
362 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BrushTransform), inv_matrix);-
363 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::BrushTexture), QT_BRUSH_TEXTURE_UNIT);-
364 }
never executed: end of block
0
365 brushUniformsDirty = false;-
366}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
367-
368-
369// This assumes the shader manager has already setup the correct shader program-
370void QGL2PaintEngineExPrivate::updateMatrix()-
371{-
372// qDebug("QGL2PaintEngineExPrivate::updateMatrix()");-
373-
374 const QTransform& transform = q->state()->matrix;-
375-
376 // The projection matrix converts from Qt's coordinate system to GL's coordinate system-
377 // * GL's viewport is 2x2, Qt's is width x height-
378 // * GL has +y -> -y going from bottom -> top, Qt is the other way round-
379 // * GL has [0,0] in the center, Qt has it in the top-left-
380 //-
381 // This results in the Projection matrix below, which is multiplied by the painter's-
382 // transformation matrix, as shown below:-
383 //-
384 // Projection Matrix Painter Transform-
385 // ------------------------------------------------ -------------------------
386 // | 2.0 / width | 0.0 | -1.0 | | m11 | m21 | dx |-
387 // | 0.0 | -2.0 / height | 1.0 | * | m12 | m22 | dy |-
388 // | 0.0 | 0.0 | 1.0 | | m13 | m23 | m33 |-
389 // ------------------------------------------------ -------------------------
390 //-
391 // NOTE: The resultant matrix is also transposed, as GL expects column-major matracies-
392-
393 const GLfloat wfactor = 2.0f / width;-
394 GLfloat hfactor = -2.0f / height;-
395-
396 GLfloat dx = transform.dx();-
397 GLfloat dy = transform.dy();-
398-
399 if (device->isFlipped()) {
device->isFlipped()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
400 hfactor *= -1;-
401 dy -= height;-
402 }
never executed: end of block
0
403-
404 // Non-integer translates can have strange effects for some rendering operations such as-
405 // anti-aliased text rendering. In such cases, we snap the translate to the pixel grid.-
406 if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) {
snapToPixelGridDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
transform.type...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0-3
407 // 0.50 needs to rounded down to 0.0 for consistency with raster engine:-
408 dx = std::ceil(dx - 0.5f);-
409 dy = std::ceil(dy - 0.5f);-
410 }
never executed: end of block
0
411 pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13();-
412 pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23();-
413 pmvMatrix[2][0] = (wfactor * dx) - transform.m33();-
414 pmvMatrix[0][1] = (hfactor * transform.m12()) + transform.m13();-
415 pmvMatrix[1][1] = (hfactor * transform.m22()) + transform.m23();-
416 pmvMatrix[2][1] = (hfactor * dy) + transform.m33();-
417 pmvMatrix[0][2] = transform.m13();-
418 pmvMatrix[1][2] = transform.m23();-
419 pmvMatrix[2][2] = transform.m33();-
420-
421 // 1/10000 == 0.0001, so we have good enough res to cover curves-
422 // that span the entire widget...-
423 inverseScale = qMax(1 / qMax( qMax(qAbs(transform.m11()), qAbs(transform.m22())),-
424 qMax(qAbs(transform.m12()), qAbs(transform.m21())) ),-
425 qreal(0.0001));-
426-
427 matrixDirty = false;-
428 matrixUniformDirty = true;-
429-
430 // Set the PMV matrix attribute. As we use an attributes rather than uniforms, we only-
431 // need to do this once for every matrix change and persists across all shader programs.-
432 glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]);-
433 glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]);-
434 glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]);-
435-
436 dasher.setInvScale(inverseScale);-
437 stroker.setInvScale(inverseScale);-
438}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
439-
440-
441void QGL2PaintEngineExPrivate::updateCompositionMode()-
442{-
443 // NOTE: The entire paint engine works on pre-multiplied data - which is why some of these-
444 // composition modes look odd.-
445// qDebug() << "QGL2PaintEngineExPrivate::updateCompositionMode() - Setting GL composition mode for " << q->state()->composition_mode;-
446 switch(q->state()->composition_mode) {-
447 case QPainter::CompositionMode_SourceOver:
executed 3 times by 1 test: case QPainter::CompositionMode_SourceOver:
Executed by:
  • tst_qmdiarea - unknown status
3
448 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);-
449 break;
executed 3 times by 1 test: break;
Executed by:
  • tst_qmdiarea - unknown status
3
450 case QPainter::CompositionMode_DestinationOver:
never executed: case QPainter::CompositionMode_DestinationOver:
0
451 glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);-
452 break;
never executed: break;
0
453 case QPainter::CompositionMode_Clear:
never executed: case QPainter::CompositionMode_Clear:
0
454 glBlendFunc(GL_ZERO, GL_ZERO);-
455 break;
never executed: break;
0
456 case QPainter::CompositionMode_Source:
never executed: case QPainter::CompositionMode_Source:
0
457 glBlendFunc(GL_ONE, GL_ZERO);-
458 break;
never executed: break;
0
459 case QPainter::CompositionMode_Destination:
never executed: case QPainter::CompositionMode_Destination:
0
460 glBlendFunc(GL_ZERO, GL_ONE);-
461 break;
never executed: break;
0
462 case QPainter::CompositionMode_SourceIn:
never executed: case QPainter::CompositionMode_SourceIn:
0
463 glBlendFunc(GL_DST_ALPHA, GL_ZERO);-
464 break;
never executed: break;
0
465 case QPainter::CompositionMode_DestinationIn:
never executed: case QPainter::CompositionMode_DestinationIn:
0
466 glBlendFunc(GL_ZERO, GL_SRC_ALPHA);-
467 break;
never executed: break;
0
468 case QPainter::CompositionMode_SourceOut:
never executed: case QPainter::CompositionMode_SourceOut:
0
469 glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ZERO);-
470 break;
never executed: break;
0
471 case QPainter::CompositionMode_DestinationOut:
never executed: case QPainter::CompositionMode_DestinationOut:
0
472 glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);-
473 break;
never executed: break;
0
474 case QPainter::CompositionMode_SourceAtop:
never executed: case QPainter::CompositionMode_SourceAtop:
0
475 glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA);-
476 break;
never executed: break;
0
477 case QPainter::CompositionMode_DestinationAtop:
never executed: case QPainter::CompositionMode_DestinationAtop:
0
478 glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA);-
479 break;
never executed: break;
0
480 case QPainter::CompositionMode_Xor:
never executed: case QPainter::CompositionMode_Xor:
0
481 glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA);-
482 break;
never executed: break;
0
483 case QPainter::CompositionMode_Plus:
never executed: case QPainter::CompositionMode_Plus:
0
484 glBlendFunc(GL_ONE, GL_ONE);-
485 break;
never executed: break;
0
486 default:
never executed: default:
0
487 qWarning("Unsupported composition mode");-
488 break;
never executed: break;
0
489 }-
490-
491 compositionModeDirty = false;-
492}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
493-
494static inline void setCoords(GLfloat *coords, const QGLRect &rect)-
495{-
496 coords[0] = rect.left;-
497 coords[1] = rect.top;-
498 coords[2] = rect.right;-
499 coords[3] = rect.top;-
500 coords[4] = rect.right;-
501 coords[5] = rect.bottom;-
502 coords[6] = rect.left;-
503 coords[7] = rect.bottom;-
504}
executed 45 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
45
505-
506void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern)-
507{-
508 // Setup for texture drawing-
509 currentBrush = noBrush;-
510 shaderManager->setSrcPixelType(pattern ? QGLEngineShaderManager::PatternSrc : QGLEngineShaderManager::ImageSrc);-
511-
512 if (snapToPixelGrid) {
snapToPixelGridDescription
TRUEnever evaluated
FALSEnever evaluated
0
513 snapToPixelGrid = false;-
514 matrixDirty = true;-
515 }
never executed: end of block
0
516-
517 if (prepareForDraw(opaque))
prepareForDraw(opaque)Description
TRUEnever evaluated
FALSEnever evaluated
0
518 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT);
never executed: shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), GLuint(0));
0
519-
520 if (pattern) {
patternDescription
TRUEnever evaluated
FALSEnever evaluated
0
521 QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity);-
522 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col);-
523 }
never executed: end of block
0
524-
525 GLfloat dx = 1.0 / textureSize.width();-
526 GLfloat dy = 1.0 / textureSize.height();-
527-
528 QGLRect srcTextureRect(src.left*dx, src.top*dy, src.right*dx, src.bottom*dy);-
529-
530 setCoords(staticVertexCoordinateArray, dest);-
531 setCoords(staticTextureCoordinateArray, srcTextureRect);-
532-
533 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);-
534}
never executed: end of block
0
535-
536void QGL2PaintEngineEx::beginNativePainting()-
537{-
538 Q_D(QGL2PaintEngineEx);-
539 ensureActive();-
540 d->transferMode(BrushDrawingMode);-
541-
542 d->nativePaintingActive = true;-
543-
544 d->glUseProgram(0);-
545-
546 // Disable all the vertex attribute arrays:-
547 for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
i < 3Description
TRUEnever evaluated
FALSEnever evaluated
0
548 d->glDisableVertexAttribArray(i);
never executed: d->glDisableVertexAttribArray(i);
0
549-
550#ifndef QT_OPENGL_ES_2-
551 if (!d->ctx->contextHandle()->isOpenGLES()) {
!d->ctx->conte...->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
552 const QGLContext *ctx = d->ctx;-
553 const QGLFormat &fmt = d->device->format();-
554 if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 1)
fmt.majorVersion() < 3Description
TRUEnever evaluated
FALSEnever evaluated
fmt.majorVersion() == 3Description
TRUEnever evaluated
FALSEnever evaluated
fmt.minorVersion() < 1Description
TRUEnever evaluated
FALSEnever evaluated
0
555 || (fmt.majorVersion() == 3 && fmt.minorVersion() == 1 && ctx->contextHandle()->hasExtension(QByteArrayLiteral("GL_ARB_compatibility")))
never executed: return ba;
fmt.majorVersion() == 3Description
TRUEnever evaluated
FALSEnever evaluated
fmt.minorVersion() == 1Description
TRUEnever evaluated
FALSEnever evaluated
ctx->contextHa...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
556 || fmt.profile() == QGLFormat::CompatibilityProfile)
fmt.profile() ...ibilityProfileDescription
TRUEnever evaluated
FALSEnever evaluated
0
557 {-
558 // be nice to people who mix OpenGL 1.x code with QPainter commands-
559 // by setting modelview and projection matrices to mirror the GL 1-
560 // paint engine-
561 const QTransform& mtx = state()->matrix;-
562-
563 float mv_matrix[4][4] =-
564 {-
565 { float(mtx.m11()), float(mtx.m12()), 0, float(mtx.m13()) },-
566 { float(mtx.m21()), float(mtx.m22()), 0, float(mtx.m23()) },-
567 { 0, 0, 1, 0 },-
568 { float(mtx.dx()), float(mtx.dy()), 0, float(mtx.m33()) }-
569 };-
570-
571 const QSize sz = d->device->size();-
572-
573 QOpenGLFunctions_1_1 *gl1funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_1>();-
574 gl1funcs->initializeOpenGLFunctions();-
575-
576 gl1funcs->glMatrixMode(GL_PROJECTION);-
577 gl1funcs->glLoadIdentity();-
578 gl1funcs->glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999);-
579-
580 gl1funcs->glMatrixMode(GL_MODELVIEW);-
581 gl1funcs->glLoadMatrixf(&mv_matrix[0][0]);-
582 }
never executed: end of block
0
583 }
never executed: end of block
0
584#endif-
585-
586 d->lastTextureUsed = GLuint(-1);-
587 d->dirtyStencilRegion = QRect(0, 0, d->width, d->height);-
588 d->resetGLState();-
589-
590 d->shaderManager->setDirty();-
591-
592 d->needsSync = true;-
593}
never executed: end of block
0
594-
595void QGL2PaintEngineExPrivate::resetGLState()-
596{-
597 glDisable(GL_BLEND);-
598 glActiveTexture(GL_TEXTURE0);-
599 glDisable(GL_STENCIL_TEST);-
600 glDisable(GL_DEPTH_TEST);-
601 glDisable(GL_SCISSOR_TEST);-
602 glDepthMask(true);-
603 glDepthFunc(GL_LESS);-
604 glClearDepthf(1);-
605 glStencilMask(0xff);-
606 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);-
607 glStencilFunc(GL_ALWAYS, 0, 0xff);-
608 ctx->d_func()->setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false);-
609 ctx->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, false);-
610 ctx->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false);-
611#ifndef QT_OPENGL_ES_2-
612 if (!ctx->contextHandle()->isOpenGLES()) {
!ctx->contextH...->isOpenGLES()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
613 // gl_Color, corresponding to vertex attribute 3, may have been changed-
614 float color[] = { 1.0f, 1.0f, 1.0f, 1.0f };-
615 glVertexAttrib4fv(3, color);-
616 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
617#endif-
618}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
619-
620bool QGL2PaintEngineExPrivate::resetOpenGLContextActiveEngine()-
621{-
622 QOpenGLContext *guiGlContext = ctx->contextHandle();-
623 QOpenGLContextPrivate *guiGlContextPrivate =-
624 guiGlContext ? QOpenGLContextPrivate::get(guiGlContext) : 0;
guiGlContextDescription
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-48
625-
626 if (guiGlContextPrivate && guiGlContextPrivate->active_engine) {
guiGlContextPrivateDescription
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
guiGlContextPr...>active_engineDescription
TRUEnever evaluated
FALSEevaluated 48 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-48
627 ctx->d_func()->refreshCurrentFbo();-
628 guiGlContextPrivate->active_engine = 0;-
629 return true;
never executed: return true;
0
630 }-
631-
632 return false;
executed 48 times by 1 test: return false;
Executed by:
  • tst_qmdiarea - unknown status
48
633}-
634-
635void QGL2PaintEngineEx::endNativePainting()-
636{-
637 Q_D(QGL2PaintEngineEx);-
638 d->needsSync = true;-
639 d->nativePaintingActive = false;-
640}
never executed: end of block
0
641-
642void QGL2PaintEngineEx::invalidateState()-
643{-
644 Q_D(QGL2PaintEngineEx);-
645 d->needsSync = true;-
646}
never executed: end of block
0
647-
648bool QGL2PaintEngineEx::isNativePaintingActive() const {-
649 Q_D(const QGL2PaintEngineEx);-
650 return d->nativePaintingActive;
never executed: return d->nativePaintingActive;
0
651}-
652-
653bool QGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &t) const-
654{-
655 // The paint engine does not support projected cached glyph drawing-
656 if (t.type() == QTransform::TxProject)
t.type() == QT...orm::TxProjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
657 return false;
never executed: return false;
0
658-
659 // The font engine might not support filling the glyph cache-
660 // with the given transform applied, in which case we need to-
661 // fall back to the QPainterPath code-path.-
662 if (!fontEngine->supportsTransformation(t)) {
!fontEngine->s...nsformation(t)Description
TRUEnever evaluated
FALSEnever evaluated
0
663 // Except that drawing paths is slow, so for scales between-
664 // 0.5 and 2.0 we leave the glyph cache untransformed and deal-
665 // with the transform ourselves when painting, resulting in-
666 // drawing 1x cached glyphs with a smooth-scale.-
667 float det = t.determinant();-
668 if (det >= 0.25f && det <= 4.f) {
det >= 0.25fDescription
TRUEnever evaluated
FALSEnever evaluated
det <= 4.fDescription
TRUEnever evaluated
FALSEnever evaluated
0
669 // Assuming the baseclass still agrees-
670 return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);
never executed: return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);
0
671 }-
672-
673 return false; // Fall back to path-drawing
never executed: return false;
0
674 }-
675-
676 return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);
never executed: return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t);
0
677}-
678-
679void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode)-
680{-
681 if (newMode == mode)
newMode == modeDescription
TRUEevaluated 51 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-51
682 return;
executed 51 times by 1 test: return;
Executed by:
  • tst_qmdiarea - unknown status
51
683-
684 if (mode == TextDrawingMode || mode == ImageDrawingMode || mode == ImageArrayDrawingMode) {
mode == TextDrawingModeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == ImageDrawingModeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == ImageArrayDrawingModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
685 lastTextureUsed = GLuint(-1);-
686 }
never executed: end of block
0
687-
688 if (newMode == TextDrawingMode) {
newMode == TextDrawingModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
689 shaderManager->setHasComplexGeometry(true);-
690 } else {
never executed: end of block
0
691 shaderManager->setHasComplexGeometry(false);-
692 }
never executed: end of block
0
693-
694 if (newMode == ImageDrawingMode) {
newMode == ImageDrawingModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
695 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray);-
696 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, staticTextureCoordinateArray);-
697 }
never executed: end of block
0
698-
699 if (newMode == ImageArrayDrawingMode) {
newMode == Ima...rayDrawingModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
700 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data());-
701 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data());-
702 setVertexAttributePointer(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data());-
703 }
never executed: end of block
0
704-
705 // This needs to change when we implement high-quality anti-aliasing...-
706 if (newMode != TextDrawingMode)
newMode != TextDrawingModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
707 shaderManager->setMaskType(QGLEngineShaderManager::NoMask);
never executed: shaderManager->setMaskType(QGLEngineShaderManager::NoMask);
0
708-
709 mode = newMode;-
710}
never executed: end of block
0
711-
712struct QGL2PEVectorPathCache-
713{-
714#ifdef QT_OPENGL_CACHE_AS_VBOS-
715 GLuint vbo;-
716 GLuint ibo;-
717#else-
718 float *vertices;-
719 void *indices;-
720#endif-
721 int vertexCount;-
722 int indexCount;-
723 GLenum primitiveType;-
724 qreal iscale;-
725 QVertexIndexVector::Type indexType;-
726};-
727-
728void QGL2PaintEngineExPrivate::cleanupVectorPath(QPaintEngineEx *engine, void *data)-
729{-
730 QGL2PEVectorPathCache *c = (QGL2PEVectorPathCache *) data;-
731#ifdef QT_OPENGL_CACHE_AS_VBOS-
732 Q_ASSERT(engine->type() == QPaintEngine::OpenGL2);-
733 static_cast<QGL2PaintEngineEx *>(engine)->d_func()->unusedVBOSToClean << c->vbo;-
734 if (c->ibo)-
735 d->unusedIBOSToClean << c->ibo;-
736#else-
737 Q_UNUSED(engine);-
738 free(c->vertices);-
739 free(c->indices);-
740#endif-
741 delete c;-
742}
never executed: end of block
0
743-
744// Assumes everything is configured for the brush you want to use-
745void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)-
746{-
747 transferMode(BrushDrawingMode);-
748-
749 if (snapToPixelGrid) {
snapToPixelGridDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
750 snapToPixelGrid = false;-
751 matrixDirty = true;-
752 }
never executed: end of block
0
753-
754 // Might need to call updateMatrix to re-calculate inverseScale-
755 if (matrixDirty)
matrixDirtyDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
756 updateMatrix();
never executed: updateMatrix();
0
757-
758 const QPointF* const points = reinterpret_cast<const QPointF*>(path.points());-
759-
760 // Check to see if there's any hints-
761 if (path.shape() == QVectorPath::RectangleHint) {
path.shape() =...:RectangleHintDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-42
762 QGLRect rect(points[0].x(), points[0].y(), points[2].x(), points[2].y());-
763 prepareForDraw(currentBrush.isOpaque());-
764 composite(rect);-
765 } else if (path.isConvex()) {
executed 42 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
path.isConvex()Description
TRUEnever evaluated
FALSEnever evaluated
0-42
766-
767 if (path.isCacheable()) {
path.isCacheable()Description
TRUEnever evaluated
FALSEnever evaluated
0
768 QVectorPath::CacheEntry *data = path.lookupCacheData(q);-
769 QGL2PEVectorPathCache *cache;-
770-
771 bool updateCache = false;-
772-
773 if (data) {
dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
774 cache = (QGL2PEVectorPathCache *) data->data;-
775 // Check if scale factor is exceeded for curved paths and generate curves if so...-
776 if (path.isCurved()) {
path.isCurved()Description
TRUEnever evaluated
FALSEnever evaluated
0
777 qreal scaleFactor = cache->iscale / inverseScale;-
778 if (scaleFactor < 0.5 || scaleFactor > 2.0) {
scaleFactor < 0.5Description
TRUEnever evaluated
FALSEnever evaluated
scaleFactor > 2.0Description
TRUEnever evaluated
FALSEnever evaluated
0
779#ifdef QT_OPENGL_CACHE_AS_VBOS-
780 glDeleteBuffers(1, &cache->vbo);-
781 cache->vbo = 0;-
782 Q_ASSERT(cache->ibo == 0);-
783#else-
784 free(cache->vertices);-
785 Q_ASSERT(cache->indices == 0);-
786#endif-
787 updateCache = true;-
788 }
never executed: end of block
0
789 }
never executed: end of block
0
790 } else {
never executed: end of block
0
791 cache = new QGL2PEVectorPathCache;-
792 data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath);-
793 updateCache = true;-
794 }
never executed: end of block
0
795-
796 // Flatten the path at the current scale factor and fill it into the cache struct.-
797 if (updateCache) {
updateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
798 vertexCoordinateArray.clear();-
799 vertexCoordinateArray.addPath(path, inverseScale, false);-
800 int vertexCount = vertexCoordinateArray.vertexCount();-
801 int floatSizeInBytes = vertexCount * 2 * sizeof(float);-
802 cache->vertexCount = vertexCount;-
803 cache->indexCount = 0;-
804 cache->primitiveType = GL_TRIANGLE_FAN;-
805 cache->iscale = inverseScale;-
806#ifdef QT_OPENGL_CACHE_AS_VBOS-
807 glGenBuffers(1, &cache->vbo);-
808 glBindBuffer(GL_ARRAY_BUFFER, cache->vbo);-
809 glBufferData(GL_ARRAY_BUFFER, floatSizeInBytes, vertexCoordinateArray.data(), GL_STATIC_DRAW);-
810 cache->ibo = 0;-
811#else-
812 cache->vertices = (float *) malloc(floatSizeInBytes);-
813 memcpy(cache->vertices, vertexCoordinateArray.data(), floatSizeInBytes);-
814 cache->indices = 0;-
815#endif-
816 }
never executed: end of block
0
817-
818 prepareForDraw(currentBrush.isOpaque());-
819#ifdef QT_OPENGL_CACHE_AS_VBOS-
820 glBindBuffer(GL_ARRAY_BUFFER, cache->vbo);-
821 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, 0);-
822#else-
823 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices);-
824#endif-
825 glDrawArrays(cache->primitiveType, 0, cache->vertexCount);-
826-
827 } else {
never executed: end of block
0
828 // printf(" - Marking path as cachable...\n");-
829 // Tag it for later so that if the same path is drawn twice, it is assumed to be static and thus cachable-
830 path.makeCacheable();-
831 vertexCoordinateArray.clear();-
832 vertexCoordinateArray.addPath(path, inverseScale, false);-
833 prepareForDraw(currentBrush.isOpaque());-
834 drawVertexArrays(vertexCoordinateArray, GL_TRIANGLE_FAN);-
835 }
never executed: end of block
0
836-
837 } else {-
838 bool useCache = path.isCacheable();-
839 if (useCache) {
useCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
840 QRectF bbox = path.controlPointRect();-
841 // If the path doesn't fit within these limits, it is possible that the triangulation will fail.-
842 useCache &= (bbox.left() > -0x8000 * inverseScale)
(bbox.left() >... inverseScale)Description
TRUEnever evaluated
FALSEnever evaluated
0
843 && (bbox.right() < 0x8000 * inverseScale)
(bbox.right() ... inverseScale)Description
TRUEnever evaluated
FALSEnever evaluated
0
844 && (bbox.top() > -0x8000 * inverseScale)
(bbox.top() > ... inverseScale)Description
TRUEnever evaluated
FALSEnever evaluated
0
845 && (bbox.bottom() < 0x8000 * inverseScale);
(bbox.bottom()... inverseScale)Description
TRUEnever evaluated
FALSEnever evaluated
0
846 }
never executed: end of block
0
847-
848 if (useCache) {
useCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
849 QVectorPath::CacheEntry *data = path.lookupCacheData(q);-
850 QGL2PEVectorPathCache *cache;-
851-
852 bool updateCache = false;-
853-
854 if (data) {
dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
855 cache = (QGL2PEVectorPathCache *) data->data;-
856 // Check if scale factor is exceeded for curved paths and generate curves if so...-
857 if (path.isCurved()) {
path.isCurved()Description
TRUEnever evaluated
FALSEnever evaluated
0
858 qreal scaleFactor = cache->iscale / inverseScale;-
859 if (scaleFactor < 0.5 || scaleFactor > 2.0) {
scaleFactor < 0.5Description
TRUEnever evaluated
FALSEnever evaluated
scaleFactor > 2.0Description
TRUEnever evaluated
FALSEnever evaluated
0
860#ifdef QT_OPENGL_CACHE_AS_VBOS-
861 glDeleteBuffers(1, &cache->vbo);-
862 glDeleteBuffers(1, &cache->ibo);-
863#else-
864 free(cache->vertices);-
865 free(cache->indices);-
866#endif-
867 updateCache = true;-
868 }
never executed: end of block
0
869 }
never executed: end of block
0
870 } else {
never executed: end of block
0
871 cache = new QGL2PEVectorPathCache;-
872 data = const_cast<QVectorPath &>(path).addCacheData(q, cache, cleanupVectorPath);-
873 updateCache = true;-
874 }
never executed: end of block
0
875-
876 // Flatten the path at the current scale factor and fill it into the cache struct.-
877 if (updateCache) {
updateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
878 QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale));-
879 cache->vertexCount = polys.vertices.size() / 2;-
880 cache->indexCount = polys.indices.size();-
881 cache->primitiveType = GL_TRIANGLES;-
882 cache->iscale = inverseScale;-
883 cache->indexType = polys.indices.type();-
884#ifdef QT_OPENGL_CACHE_AS_VBOS-
885 glGenBuffers(1, &cache->vbo);-
886 glGenBuffers(1, &cache->ibo);-
887 glBindBuffer(GL_ARRAY_BUFFER, cache->vbo);-
888 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo);-
889-
890 if (polys.indices.type() == QVertexIndexVector::UnsignedInt)-
891 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(quint32) * polys.indices.size(), polys.indices.data(), GL_STATIC_DRAW);-
892 else-
893 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(quint16) * polys.indices.size(), polys.indices.data(), GL_STATIC_DRAW);-
894-
895 QVarLengthArray<float> vertices(polys.vertices.size());-
896 for (int i = 0; i < polys.vertices.size(); ++i)-
897 vertices[i] = float(inverseScale * polys.vertices.at(i));-
898 glBufferData(GL_ARRAY_BUFFER, sizeof(float) * vertices.size(), vertices.data(), GL_STATIC_DRAW);-
899#else-
900 cache->vertices = (float *) malloc(sizeof(float) * polys.vertices.size());-
901 if (polys.indices.type() == QVertexIndexVector::UnsignedInt) {
polys.indices....r::UnsignedIntDescription
TRUEnever evaluated
FALSEnever evaluated
0
902 cache->indices = (quint32 *) malloc(sizeof(quint32) * polys.indices.size());-
903 memcpy(cache->indices, polys.indices.data(), sizeof(quint32) * polys.indices.size());-
904 } else {
never executed: end of block
0
905 cache->indices = (quint16 *) malloc(sizeof(quint16) * polys.indices.size());-
906 memcpy(cache->indices, polys.indices.data(), sizeof(quint16) * polys.indices.size());-
907 }
never executed: end of block
0
908 for (int i = 0; i < polys.vertices.size(); ++i)
i < polys.vertices.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
909 cache->vertices[i] = float(inverseScale * polys.vertices.at(i));
never executed: cache->vertices[i] = float(inverseScale * polys.vertices.at(i));
0
910#endif-
911 }
never executed: end of block
0
912-
913 prepareForDraw(currentBrush.isOpaque());-
914#ifdef QT_OPENGL_CACHE_AS_VBOS-
915 glBindBuffer(GL_ARRAY_BUFFER, cache->vbo);-
916 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cache->ibo);-
917 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, 0);-
918 if (cache->indexType == QVertexIndexVector::UnsignedInt)-
919 glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, 0);-
920 else-
921 glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_SHORT, 0);-
922 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);-
923 glBindBuffer(GL_ARRAY_BUFFER, 0);-
924#else-
925 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, cache->vertices);-
926 if (cache->indexType == QVertexIndexVector::UnsignedInt)
cache->indexTy...r::UnsignedIntDescription
TRUEnever evaluated
FALSEnever evaluated
0
927 glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_INT, (qint32 *)cache->indices);
never executed: glDrawElements(cache->primitiveType, cache->indexCount, 0x1405, (qint32 *)cache->indices);
0
928 else-
929 glDrawElements(cache->primitiveType, cache->indexCount, GL_UNSIGNED_SHORT, (qint16 *)cache->indices);
never executed: glDrawElements(cache->primitiveType, cache->indexCount, 0x1403, (qint16 *)cache->indices);
0
930#endif-
931-
932 } else {-
933 // printf(" - Marking path as cachable...\n");-
934 // Tag it for later so that if the same path is drawn twice, it is assumed to be static and thus cachable-
935 path.makeCacheable();-
936-
937 if (!device->format().stencil()) {
!device->format().stencil()Description
TRUEnever evaluated
FALSEnever evaluated
0
938 // If there is no stencil buffer, triangulate the path instead.-
939-
940 QRectF bbox = path.controlPointRect();-
941 // If the path doesn't fit within these limits, it is possible that the triangulation will fail.-
942 bool withinLimits = (bbox.left() > -0x8000 * inverseScale)
(bbox.left() >... inverseScale)Description
TRUEnever evaluated
FALSEnever evaluated
0
943 && (bbox.right() < 0x8000 * inverseScale)
(bbox.right() ... inverseScale)Description
TRUEnever evaluated
FALSEnever evaluated
0
944 && (bbox.top() > -0x8000 * inverseScale)
(bbox.top() > ... inverseScale)Description
TRUEnever evaluated
FALSEnever evaluated
0
945 && (bbox.bottom() < 0x8000 * inverseScale);
(bbox.bottom()... inverseScale)Description
TRUEnever evaluated
FALSEnever evaluated
0
946 if (withinLimits) {
withinLimitsDescription
TRUEnever evaluated
FALSEnever evaluated
0
947 QTriangleSet polys = qTriangulate(path, QTransform().scale(1 / inverseScale, 1 / inverseScale));-
948-
949 QVarLengthArray<float> vertices(polys.vertices.size());-
950 for (int i = 0; i < polys.vertices.size(); ++i)
i < polys.vertices.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
951 vertices[i] = float(inverseScale * polys.vertices.at(i));
never executed: vertices[i] = float(inverseScale * polys.vertices.at(i));
0
952-
953 prepareForDraw(currentBrush.isOpaque());-
954 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, vertices.constData());-
955 if (polys.indices.type() == QVertexIndexVector::UnsignedInt)
polys.indices....r::UnsignedIntDescription
TRUEnever evaluated
FALSEnever evaluated
0
956 glDrawElements(GL_TRIANGLES, polys.indices.size(), GL_UNSIGNED_INT, polys.indices.data());
never executed: glDrawElements(0x0004, polys.indices.size(), 0x1405, polys.indices.data());
0
957 else-
958 glDrawElements(GL_TRIANGLES, polys.indices.size(), GL_UNSIGNED_SHORT, polys.indices.data());
never executed: glDrawElements(0x0004, polys.indices.size(), 0x1403, polys.indices.data());
0
959 } else {-
960 // We can't handle big, concave painter paths with OpenGL without stencil buffer.-
961 qWarning("Painter path exceeds +/-32767 pixels.");-
962 }
never executed: end of block
0
963 return;
never executed: return;
0
964 }-
965-
966 // The path is too complicated & needs the stencil technique-
967 vertexCoordinateArray.clear();-
968 vertexCoordinateArray.addPath(path, inverseScale, false);-
969-
970 fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill());-
971-
972 glStencilMask(0xff);-
973 glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);-
974-
975 if (q->state()->clipTestEnabled) {
q->state()->clipTestEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
976 // Pass when high bit is set, replace stencil value with current clip-
977 glStencilFunc(GL_NOTEQUAL, q->state()->currentClip, GL_STENCIL_HIGH_BIT);-
978 } else if (path.hasWindingFill()) {
never executed: end of block
path.hasWindingFill()Description
TRUEnever evaluated
FALSEnever evaluated
0
979 // Pass when any bit is set, replace stencil value with 0-
980 glStencilFunc(GL_NOTEQUAL, 0, 0xff);-
981 } else {
never executed: end of block
0
982 // Pass when high bit is set, replace stencil value with 0-
983 glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT);-
984 }
never executed: end of block
0
985 prepareForDraw(currentBrush.isOpaque());-
986-
987 // Stencil the brush onto the dest buffer-
988 composite(vertexCoordinateArray.boundingRect());-
989 glStencilMask(0);-
990 updateClipScissorTest();-
991 }
never executed: end of block
0
992 }-
993}-
994-
995-
996void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data,-
997 int count,-
998 int *stops,-
999 int stopCount,-
1000 const QGLRect &bounds,-
1001 StencilFillMode mode)-
1002{-
1003 Q_ASSERT(count || stops);-
1004-
1005// qDebug("QGL2PaintEngineExPrivate::fillStencilWithVertexArray()");-
1006 glStencilMask(0xff); // Enable stencil writes-
1007-
1008 if (dirtyStencilRegion.intersects(currentScissorBounds)) {
dirtyStencilRe...ScissorBounds)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
1009 QVector<QRect> clearRegion = dirtyStencilRegion.intersected(currentScissorBounds).rects();-
1010 glClearStencil(0); // Clear to zero-
1011 for (int i = 0; i < clearRegion.size(); ++i) {
i < clearRegion.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1012#ifndef QT_GL_NO_SCISSOR_TEST-
1013 setScissor(clearRegion.at(i));-
1014#endif-
1015 glClear(GL_STENCIL_BUFFER_BIT);-
1016 }
never executed: end of block
0
1017-
1018 dirtyStencilRegion -= currentScissorBounds;-
1019-
1020#ifndef QT_GL_NO_SCISSOR_TEST-
1021 updateClipScissorTest();-
1022#endif-
1023 }
never executed: end of block
0
1024-
1025 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // Disable color writes-
1026 useSimpleShader();-
1027 glEnable(GL_STENCIL_TEST); // For some reason, this has to happen _after_ the simple shader is use()'d-
1028-
1029 if (mode == WindingFillMode) {
mode == WindingFillModeDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
1030 Q_ASSERT(stops && !count);-
1031 if (q->state()->clipTestEnabled) {
q->state()->clipTestEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1032 // Flatten clip values higher than current clip, and set high bit to match current clip-
1033 glStencilFunc(GL_LEQUAL, GL_STENCIL_HIGH_BIT | q->state()->currentClip, ~GL_STENCIL_HIGH_BIT);-
1034 glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);-
1035 composite(bounds);-
1036-
1037 glStencilFunc(GL_EQUAL, GL_STENCIL_HIGH_BIT, GL_STENCIL_HIGH_BIT);-
1038 } else if (!stencilClean) {
never executed: end of block
!stencilCleanDescription
TRUEnever evaluated
FALSEnever evaluated
0
1039 // Clear stencil buffer within bounding rect-
1040 glStencilFunc(GL_ALWAYS, 0, 0xff);-
1041 glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);-
1042 composite(bounds);-
1043 }
never executed: end of block
0
1044-
1045 // Inc. for front-facing triangle-
1046 glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_INCR_WRAP);-
1047 // Dec. for back-facing "holes"-
1048 glStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_DECR_WRAP);-
1049 glStencilMask(~GL_STENCIL_HIGH_BIT);-
1050 drawVertexArrays(data, stops, stopCount, GL_TRIANGLE_FAN);-
1051-
1052 if (q->state()->clipTestEnabled) {
q->state()->clipTestEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1053 // Clear high bit of stencil outside of path-
1054 glStencilFunc(GL_EQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT);-
1055 glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);-
1056 glStencilMask(GL_STENCIL_HIGH_BIT);-
1057 composite(bounds);-
1058 }
never executed: end of block
0
1059 } else if (mode == OddEvenFillMode) {
never executed: end of block
mode == OddEvenFillModeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
1060 glStencilMask(GL_STENCIL_HIGH_BIT);-
1061 glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); // Simply invert the stencil bit-
1062 drawVertexArrays(data, stops, stopCount, GL_TRIANGLE_FAN);-
1063-
1064 } else { // TriStripStrokeFillMode
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
1065 Q_ASSERT(count && !stops); // tristrips generated directly, so no vertexArray or stops-
1066 glStencilMask(GL_STENCIL_HIGH_BIT);-
1067#if 0-
1068 glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); // Simply invert the stencil bit-
1069 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data);-
1070 glDrawArrays(GL_TRIANGLE_STRIP, 0, count);-
1071#else-
1072-
1073 glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);-
1074 if (q->state()->clipTestEnabled) {
q->state()->clipTestEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1075 glStencilFunc(GL_LEQUAL, q->state()->currentClip | GL_STENCIL_HIGH_BIT,-
1076 ~GL_STENCIL_HIGH_BIT);-
1077 } else {
never executed: end of block
0
1078 glStencilFunc(GL_ALWAYS, GL_STENCIL_HIGH_BIT, 0xff);-
1079 }
never executed: end of block
0
1080 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data);-
1081 glDrawArrays(GL_TRIANGLE_STRIP, 0, count);-
1082#endif-
1083 }
never executed: end of block
0
1084-
1085 // Enable color writes & disable stencil writes-
1086 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);-
1087}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
1088-
1089/*-
1090 If the maximum value in the stencil buffer is GL_STENCIL_HIGH_BIT - 1,-
1091 restore the stencil buffer to a pristine state. The current clip region-
1092 is set to 1, and the rest to 0.-
1093*/-
1094void QGL2PaintEngineExPrivate::resetClipIfNeeded()-
1095{-
1096 if (maxClip != (GL_STENCIL_HIGH_BIT - 1))
maxClip != (GLuint(0x80) - 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1097 return;
never executed: return;
0
1098-
1099 Q_Q(QGL2PaintEngineEx);-
1100-
1101 useSimpleShader();-
1102 glEnable(GL_STENCIL_TEST);-
1103 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);-
1104-
1105 QRectF bounds = q->state()->matrix.inverted().mapRect(QRectF(0, 0, width, height));-
1106 QGLRect rect(bounds.left(), bounds.top(), bounds.right(), bounds.bottom());-
1107-
1108 // Set high bit on clip region-
1109 glStencilFunc(GL_LEQUAL, q->state()->currentClip, 0xff);-
1110 glStencilOp(GL_KEEP, GL_INVERT, GL_INVERT);-
1111 glStencilMask(GL_STENCIL_HIGH_BIT);-
1112 composite(rect);-
1113-
1114 // Reset clipping to 1 and everything else to zero-
1115 glStencilFunc(GL_NOTEQUAL, 0x01, GL_STENCIL_HIGH_BIT);-
1116 glStencilOp(GL_ZERO, GL_REPLACE, GL_REPLACE);-
1117 glStencilMask(0xff);-
1118 composite(rect);-
1119-
1120 q->state()->currentClip = 1;-
1121 q->state()->canRestoreClip = false;-
1122-
1123 maxClip = 1;-
1124-
1125 glStencilMask(0x0);-
1126 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);-
1127}
never executed: end of block
0
1128-
1129bool QGL2PaintEngineExPrivate::prepareForCachedGlyphDraw(const QFontEngineGlyphCache &cache)-
1130{-
1131 Q_Q(QGL2PaintEngineEx);-
1132-
1133 Q_ASSERT(cache.transform().type() <= QTransform::TxScale);-
1134-
1135 QTransform &transform = q->state()->matrix;-
1136 transform.scale(1.0 / cache.transform().m11(), 1.0 / cache.transform().m22());-
1137 bool ret = prepareForDraw(false);-
1138 transform.scale(cache.transform().m11(), cache.transform().m22());-
1139-
1140 return ret;
never executed: return ret;
0
1141}-
1142-
1143bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque)-
1144{-
1145 if (brushTextureDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode)
brushTextureDirtyDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
mode != ImageDrawingModeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
mode != ImageArrayDrawingModeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-39
1146 updateBrushTexture();
executed 3 times by 1 test: updateBrushTexture();
Executed by:
  • tst_qmdiarea - unknown status
3
1147-
1148 if (compositionModeDirty)
compositionModeDirtyDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
3-39
1149 updateCompositionMode();
executed 3 times by 1 test: updateCompositionMode();
Executed by:
  • tst_qmdiarea - unknown status
3
1150-
1151 if (matrixDirty)
matrixDirtyDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
1152 updateMatrix();
never executed: updateMatrix();
0
1153-
1154 const bool stateHasOpacity = q->state()->opacity < 0.99f;-
1155 if (q->state()->composition_mode == QPainter::CompositionMode_Source
q->state()->co...ionMode_SourceDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
1156 || (q->state()->composition_mode == QPainter::CompositionMode_SourceOver
q->state()->co...ode_SourceOverDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-42
1157 && srcPixelsAreOpaque && !stateHasOpacity))
srcPixelsAreOpaqueDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
!stateHasOpacityDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-42
1158 {-
1159 glDisable(GL_BLEND);-
1160 } else {
executed 42 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
42
1161 glEnable(GL_BLEND);-
1162 }
never executed: end of block
0
1163-
1164 QGLEngineShaderManager::OpacityMode opacityMode;-
1165 if (mode == ImageArrayDrawingMode) {
mode == ImageArrayDrawingModeDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
1166 opacityMode = QGLEngineShaderManager::AttributeOpacity;-
1167 } else {
never executed: end of block
0
1168 opacityMode = stateHasOpacity ? QGLEngineShaderManager::UniformOpacity
stateHasOpacityDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
1169 : QGLEngineShaderManager::NoOpacity;-
1170 if (stateHasOpacity && (mode != ImageDrawingMode)) {
stateHasOpacityDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
(mode != ImageDrawingMode)Description
TRUEnever evaluated
FALSEnever evaluated
0-42
1171 // Using a brush-
1172 bool brushIsPattern = (currentBrush.style() >= Qt::Dense1Pattern) &&
(currentBrush....Dense1Pattern)Description
TRUEnever evaluated
FALSEnever evaluated
0
1173 (currentBrush.style() <= Qt::DiagCrossPattern);
(currentBrush....gCrossPattern)Description
TRUEnever evaluated
FALSEnever evaluated
0
1174-
1175 if ((currentBrush.style() == Qt::SolidPattern) || brushIsPattern)
(currentBrush....:SolidPattern)Description
TRUEnever evaluated
FALSEnever evaluated
brushIsPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1176 opacityMode = QGLEngineShaderManager::NoOpacity; // Global opacity handled by srcPixel shader
never executed: opacityMode = QGLEngineShaderManager::NoOpacity;
0
1177 }
never executed: end of block
0
1178 }
executed 42 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
42
1179 shaderManager->setOpacityMode(opacityMode);-
1180-
1181 bool changed = shaderManager->useCorrectShaderProg();-
1182 // If the shader program needs changing, we change it and mark all uniforms as dirty-
1183 if (changed) {
changedDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
3-39
1184 // The shader program has changed so mark all uniforms as dirty:-
1185 brushUniformsDirty = true;-
1186 opacityUniformDirty = true;-
1187 matrixUniformDirty = true;-
1188 translateZUniformDirty = true;-
1189 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
1190-
1191 if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode)
brushUniformsDirtyDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
mode != ImageDrawingModeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
mode != ImageArrayDrawingModeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-39
1192 updateBrushUniforms();
executed 3 times by 1 test: updateBrushUniforms();
Executed by:
  • tst_qmdiarea - unknown status
3
1193-
1194 if (opacityMode == QGLEngineShaderManager::UniformOpacity && opacityUniformDirty) {
opacityMode ==...UniformOpacityDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
opacityUniformDirtyDescription
TRUEnever evaluated
FALSEnever evaluated
0-42
1195 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::GlobalOpacity), (GLfloat)q->state()->opacity);-
1196 opacityUniformDirty = false;-
1197 }
never executed: end of block
0
1198-
1199 if (matrixUniformDirty && shaderManager->hasComplexGeometry()) {
matrixUniformDirtyDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
shaderManager-...plexGeometry()Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
1200 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Matrix),-
1201 pmvMatrix);-
1202 matrixUniformDirty = false;-
1203 }
never executed: end of block
0
1204-
1205 if (translateZUniformDirty && shaderManager->hasComplexGeometry()) {
translateZUniformDirtyDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
shaderManager-...plexGeometry()Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
1206 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::TranslateZ),-
1207 translateZ);-
1208 translateZUniformDirty = false;-
1209 }
never executed: end of block
0
1210-
1211 return changed;
executed 42 times by 1 test: return changed;
Executed by:
  • tst_qmdiarea - unknown status
42
1212}-
1213-
1214void QGL2PaintEngineExPrivate::composite(const QGLRect& boundingRect)-
1215{-
1216 setCoords(staticVertexCoordinateArray, boundingRect);-
1217 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, staticVertexCoordinateArray);-
1218 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);-
1219}
executed 45 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
45
1220-
1221// Draws the vertex array as a set of <vertexArrayStops.size()> triangle fans.-
1222void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stops, int stopCount,-
1223 GLenum primitive)-
1224{-
1225 // Now setup the pointer to the vertex array:-
1226 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, data);-
1227-
1228 int previousStop = 0;-
1229 for (int i=0; i<stopCount; ++i) {
i<stopCountDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
3-42
1230 int stop = stops[i];-
1231/*-
1232 qDebug("Drawing triangle fan for vertecies %d -> %d:", previousStop, stop-1);-
1233 for (int i=previousStop; i<stop; ++i)-
1234 qDebug(" %02d: [%.2f, %.2f]", i, vertexArray.data()[i].x, vertexArray.data()[i].y);-
1235*/-
1236 glDrawArrays(primitive, previousStop, stop - previousStop);-
1237 previousStop = stop;-
1238 }
executed 42 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
42
1239}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
1240-
1241/////////////////////////////////// Public Methods //////////////////////////////////////////-
1242-
1243QGL2PaintEngineEx::QGL2PaintEngineEx()-
1244 : QPaintEngineEx(*(new QGL2PaintEngineExPrivate(this)))-
1245{-
1246}
executed 1 time by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
1
1247-
1248QGL2PaintEngineEx::~QGL2PaintEngineEx()-
1249{-
1250}-
1251-
1252void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush)-
1253{-
1254 Q_D(QGL2PaintEngineEx);-
1255-
1256 if (qbrush_style(brush) == Qt::NoBrush)
qbrush_style(b...== Qt::NoBrushDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
1257 return;
never executed: return;
0
1258 ensureActive();-
1259 d->setBrush(brush);-
1260 d->fill(path);-
1261}
executed 42 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
42
1262-
1263Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp-
1264-
1265-
1266void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)-
1267{-
1268 Q_D(QGL2PaintEngineEx);-
1269-
1270 const QBrush &penBrush = qpen_brush(pen);-
1271 if (qpen_style(pen) == Qt::NoPen || qbrush_style(penBrush) == Qt::NoBrush)
qpen_style(pen) == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
qbrush_style(p...== Qt::NoBrushDescription
TRUEnever evaluated
FALSEnever evaluated
0
1272 return;
never executed: return;
0
1273-
1274 QGL2PaintEngineState *s = state();-
1275 if (qt_pen_is_cosmetic(pen, s->renderHints) && !qt_scaleForTransform(s->transform(), 0)) {
qt_pen_is_cosm...->renderHints)Description
TRUEnever evaluated
FALSEnever evaluated
!qt_scaleForTr...ransform(), 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1276 // QTriangulatingStroker class is not meant to support cosmetically sheared strokes.-
1277 QPaintEngineEx::stroke(path, pen);-
1278 return;
never executed: return;
0
1279 }-
1280-
1281 ensureActive();-
1282 d->setBrush(penBrush);-
1283 d->stroke(path, pen);-
1284}
never executed: end of block
0
1285-
1286void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen)-
1287{-
1288 const QGL2PaintEngineState *s = q->state();-
1289 if (snapToPixelGrid) {
snapToPixelGridDescription
TRUEnever evaluated
FALSEnever evaluated
0
1290 snapToPixelGrid = false;-
1291 matrixDirty = true;-
1292 }
never executed: end of block
0
1293-
1294 const Qt::PenStyle penStyle = qpen_style(pen);-
1295 const QBrush &penBrush = qpen_brush(pen);-
1296 const bool opaque = penBrush.isOpaque() && s->opacity > 0.99;
penBrush.isOpaque()Description
TRUEnever evaluated
FALSEnever evaluated
s->opacity > 0.99Description
TRUEnever evaluated
FALSEnever evaluated
0
1297-
1298 transferMode(BrushDrawingMode);-
1299-
1300 // updateMatrix() is responsible for setting the inverse scale on-
1301 // the strokers, so we need to call it here and not wait for-
1302 // prepareForDraw() down below.-
1303 updateMatrix();-
1304-
1305 QRectF clip = q->state()->matrix.inverted().mapRect(q->state()->clipEnabled-
1306 ? q->state()->rectangleClip-
1307 : QRectF(0, 0, width, height));-
1308-
1309 if (penStyle == Qt::SolidLine) {
penStyle == Qt::SolidLineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1310 stroker.process(path, pen, clip, s->renderHints);-
1311-
1312 } else { // Some sort of dash
never executed: end of block
0
1313 dasher.process(path, pen, clip, s->renderHints);-
1314-
1315 QVectorPath dashStroke(dasher.points(),-
1316 dasher.elementCount(),-
1317 dasher.elementTypes());-
1318 stroker.process(dashStroke, pen, clip, s->renderHints);-
1319 }
never executed: end of block
0
1320-
1321 if (!stroker.vertexCount())
!stroker.vertexCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
1322 return;
never executed: return;
0
1323-
1324 if (opaque) {
opaqueDescription
TRUEnever evaluated
FALSEnever evaluated
0
1325 prepareForDraw(opaque);-
1326 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, stroker.vertices());-
1327 glDrawArrays(GL_TRIANGLE_STRIP, 0, stroker.vertexCount() / 2);-
1328-
1329// QBrush b(Qt::green);-
1330// d->setBrush(&b);-
1331// d->prepareForDraw(true);-
1332// glDrawArrays(GL_LINE_STRIP, 0, d->stroker.vertexCount() / 2);-
1333-
1334 } else {
never executed: end of block
0
1335 qreal width = qpen_widthf(pen) / 2;-
1336 if (width == 0)
width == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1337 width = 0.5;
never executed: width = 0.5;
0
1338 qreal extra = pen.joinStyle() == Qt::MiterJoin
pen.joinStyle(... Qt::MiterJoinDescription
TRUEnever evaluated
FALSEnever evaluated
0
1339 ? qMax(pen.miterLimit() * width, width)-
1340 : width;-
1341-
1342 if (qt_pen_is_cosmetic(pen, s->renderHints))
qt_pen_is_cosm...->renderHints)Description
TRUEnever evaluated
FALSEnever evaluated
0
1343 extra = extra * inverseScale;
never executed: extra = extra * inverseScale;
0
1344-
1345 QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra);-
1346-
1347 fillStencilWithVertexArray(stroker.vertices(), stroker.vertexCount() / 2,-
1348 0, 0, bounds, QGL2PaintEngineExPrivate::TriStripStrokeFillMode);-
1349-
1350 glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);-
1351-
1352 // Pass when any bit is set, replace stencil value with 0-
1353 glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT);-
1354 prepareForDraw(false);-
1355-
1356 // Stencil the brush onto the dest buffer-
1357 composite(bounds);-
1358-
1359 glStencilMask(0);-
1360-
1361 updateClipScissorTest();-
1362 }
never executed: end of block
0
1363}-
1364-
1365void QGL2PaintEngineEx::penChanged() { }-
1366void QGL2PaintEngineEx::brushChanged() { }-
1367void QGL2PaintEngineEx::brushOriginChanged() { }-
1368-
1369void QGL2PaintEngineEx::opacityChanged()-
1370{-
1371// qDebug("QGL2PaintEngineEx::opacityChanged()");-
1372 Q_D(QGL2PaintEngineEx);-
1373 state()->opacityChanged = true;-
1374-
1375 Q_ASSERT(d->shaderManager);-
1376 d->brushUniformsDirty = true;-
1377 d->opacityUniformDirty = true;-
1378}
never executed: end of block
0
1379-
1380void QGL2PaintEngineEx::compositionModeChanged()-
1381{-
1382// qDebug("QGL2PaintEngineEx::compositionModeChanged()");-
1383 Q_D(QGL2PaintEngineEx);-
1384 state()->compositionModeChanged = true;-
1385 d->compositionModeDirty = true;-
1386}
never executed: end of block
0
1387-
1388void QGL2PaintEngineEx::renderHintsChanged()-
1389{-
1390 Q_D(QGL2PaintEngineEx);-
1391 state()->renderHintsChanged = true;-
1392-
1393#if !defined(QT_OPENGL_ES_2)-
1394 if (!d->ctx->contextHandle()->isOpenGLES()) {
!d->ctx->conte...->isOpenGLES()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
1395 if ((state()->renderHints & QPainter::Antialiasing)-
1396 || (state()->renderHints & QPainter::HighQualityAntialiasing))-
1397 d->glEnable(GL_MULTISAMPLE);
never executed: d->glEnable(0x809D);
0
1398 else-
1399 d->glDisable(GL_MULTISAMPLE);
executed 3 times by 1 test: d->glDisable(0x809D);
Executed by:
  • tst_qmdiarea - unknown status
3
1400 }-
1401#endif-
1402-
1403 d->lastTextureUsed = GLuint(-1);-
1404 d->brushTextureDirty = true;-
1405// qDebug("QGL2PaintEngineEx::renderHintsChanged() not implemented!");-
1406}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
1407-
1408void QGL2PaintEngineEx::transformChanged()-
1409{-
1410 Q_D(QGL2PaintEngineEx);-
1411 d->matrixDirty = true;-
1412 state()->matrixChanged = true;-
1413}
never executed: end of block
0
1414-
1415-
1416static const QRectF scaleRect(const QRectF &r, qreal sx, qreal sy)-
1417{-
1418 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
1419}-
1420-
1421void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, const QRectF & src)-
1422{-
1423 Q_D(QGL2PaintEngineEx);-
1424 QGLContext *ctx = d->ctx;-
1425-
1426 int max_texture_size = ctx->d_func()->maxTextureSize();-
1427 if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) {
pixmap.width()...x_texture_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
pixmap.height(...x_texture_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1428 QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);-
1429-
1430 const qreal sx = scaled.width() / qreal(pixmap.width());-
1431 const qreal sy = scaled.height() / qreal(pixmap.height());-
1432-
1433 drawPixmap(dest, scaled, scaleRect(src, sx, sy));-
1434 return;
never executed: return;
0
1435 }-
1436-
1437 ensureActive();-
1438 d->transferMode(ImageDrawingMode);-
1439-
1440 QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption|QGLContext::CanFlipNativePixmapBindOption;-
1441#ifdef QGL_USE_TEXTURE_POOL-
1442 bindOptions |= QGLContext::TemporarilyCachedBindOption;-
1443#endif-
1444-
1445 d->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);-
1446 QGLTexture *texture =-
1447 ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, bindOptions);-
1448-
1449 GLfloat top = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.top()) : src.top();
texture->optio...tedYBindOptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1450 GLfloat bottom = texture->options & QGLContext::InvertedYBindOption ? (pixmap.height() - src.bottom()) : src.bottom();
texture->optio...tedYBindOptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1451 QGLRect srcRect(src.left(), top, src.right(), bottom);-
1452-
1453 bool isBitmap = pixmap.isQBitmap();-
1454 bool isOpaque = !isBitmap && !pixmap.hasAlpha();
!isBitmapDescription
TRUEnever evaluated
FALSEnever evaluated
!pixmap.hasAlpha()Description
TRUEnever evaluated
FALSEnever evaluated
0
1455-
1456 d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,-
1457 state()->renderHints & QPainter::SmoothPixmapTransform, texture->id);-
1458 d->drawTexture(dest, srcRect, pixmap.size(), isOpaque, isBitmap);-
1459-
1460 if (texture->options&QGLContext::TemporarilyCachedBindOption) {
texture->optio...chedBindOptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1461 // pixmap was temporarily cached as a QImage texture by pooling system-
1462 // and should be destroyed immediately-
1463 QGLTextureCache::instance()->remove(ctx, texture->id);-
1464 }
never executed: end of block
0
1465}
never executed: end of block
0
1466-
1467void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const QRectF& src,-
1468 Qt::ImageConversionFlags)-
1469{-
1470 Q_D(QGL2PaintEngineEx);-
1471 QGLContext *ctx = d->ctx;-
1472-
1473 int max_texture_size = ctx->d_func()->maxTextureSize();-
1474 if (image.width() > max_texture_size || image.height() > max_texture_size) {
image.width() ...x_texture_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
image.height()...x_texture_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1475 QImage scaled = image.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);-
1476-
1477 const qreal sx = scaled.width() / qreal(image.width());-
1478 const qreal sy = scaled.height() / qreal(image.height());-
1479-
1480 drawImage(dest, scaled, scaleRect(src, sx, sy));-
1481 return;
never executed: return;
0
1482 }-
1483-
1484 ensureActive();-
1485 d->transferMode(ImageDrawingMode);-
1486-
1487 d->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);-
1488-
1489 QGLContext::BindOptions bindOptions = QGLContext::InternalBindOption;-
1490#ifdef QGL_USE_TEXTURE_POOL-
1491 bindOptions |= QGLContext::TemporarilyCachedBindOption;-
1492#endif-
1493-
1494 QGLTexture *texture = ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, bindOptions);-
1495 GLuint id = texture->id;-
1496-
1497 d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,-
1498 state()->renderHints & QPainter::SmoothPixmapTransform, id);-
1499 d->drawTexture(dest, src, image.size(), !image.hasAlphaChannel());-
1500-
1501 if (texture->options&QGLContext::TemporarilyCachedBindOption) {
texture->optio...chedBindOptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1502 // image was temporarily cached by texture pooling system-
1503 // and should be destroyed immediately-
1504 QGLTextureCache::instance()->remove(ctx, texture->id);-
1505 }
never executed: end of block
0
1506}
never executed: end of block
0
1507-
1508void QGL2PaintEngineEx::drawStaticTextItem(QStaticTextItem *textItem)-
1509{-
1510 Q_D(QGL2PaintEngineEx);-
1511-
1512 ensureActive();-
1513-
1514 QPainterState *s = state();-
1515-
1516 // don't try to cache huge fonts or vastly transformed fonts-
1517 QFontEngine *fontEngine = textItem->fontEngine();-
1518 if (shouldDrawCachedGlyphs(fontEngine, s->matrix)) {
shouldDrawCach...ne, s->matrix)Description
TRUEnever evaluated
FALSEnever evaluated
0
1519-
1520 QFontEngine::GlyphFormat glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None
fontEngine->gl...e::Format_NoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1521 ? fontEngine->glyphFormat : d->glyphCacheFormat;-
1522-
1523 if (glyphFormat == QFontEngine::Format_A32) {
glyphFormat ==...ne::Format_A32Description
TRUEnever evaluated
FALSEnever evaluated
0
1524 if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
!QGLFramebuffe...ufferObjects()Description
TRUEnever evaluated
FALSEnever evaluated
0
1525 || d->device->alphaRequested() || s->matrix.type() > QTransform::TxTranslate
d->device->alphaRequested()Description
TRUEnever evaluated
FALSEnever evaluated
s->matrix.type...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1526 || (s->composition_mode != QPainter::CompositionMode_Source
s->composition...ionMode_SourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1527 && s->composition_mode != QPainter::CompositionMode_SourceOver))
s->composition...ode_SourceOverDescription
TRUEnever evaluated
FALSEnever evaluated
0
1528 {-
1529 glyphFormat = QFontEngine::Format_A8;-
1530 }
never executed: end of block
0
1531 }
never executed: end of block
0
1532-
1533 d->drawCachedGlyphs(glyphFormat, textItem);-
1534 } else {
never executed: end of block
0
1535 QPaintEngineEx::drawStaticTextItem(textItem);-
1536 }
never executed: end of block
0
1537}-
1538-
1539bool QGL2PaintEngineEx::drawTexture(const QRectF &dest, GLuint textureId, const QSize &size, const QRectF &src)-
1540{-
1541 Q_D(QGL2PaintEngineEx);-
1542 if (!d->shaderManager)
!d->shaderManagerDescription
TRUEnever evaluated
FALSEnever evaluated
0
1543 return false;
never executed: return false;
0
1544-
1545 ensureActive();-
1546 d->transferMode(ImageDrawingMode);-
1547-
1548 d->glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);-
1549 d->glBindTexture(GL_TEXTURE_2D, textureId);-
1550-
1551 QGLRect srcRect(src.left(), src.bottom(), src.right(), src.top());-
1552-
1553 d->updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,-
1554 state()->renderHints & QPainter::SmoothPixmapTransform, textureId);-
1555 d->drawTexture(dest, srcRect, size, false);-
1556 return true;
never executed: return true;
0
1557}-
1558-
1559void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem)-
1560{-
1561 Q_D(QGL2PaintEngineEx);-
1562-
1563 ensureActive();-
1564 QGL2PaintEngineState *s = state();-
1565-
1566 const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);-
1567-
1568 QTransform::TransformationType txtype = s->matrix.type();-
1569-
1570 QFontEngine::GlyphFormat glyphFormat = ti.fontEngine->glyphFormat != QFontEngine::Format_None
ti.fontEngine-...e::Format_NoneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1571 ? ti.fontEngine->glyphFormat : d->glyphCacheFormat;-
1572-
1573 if (glyphFormat == QFontEngine::Format_A32) {
glyphFormat ==...ne::Format_A32Description
TRUEnever evaluated
FALSEnever evaluated
0
1574 if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()
!QGLFramebuffe...ufferObjects()Description
TRUEnever evaluated
FALSEnever evaluated
0
1575 || d->device->alphaRequested() || txtype > QTransform::TxTranslate
d->device->alphaRequested()Description
TRUEnever evaluated
FALSEnever evaluated
txtype > QTran...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1576 || (state()->composition_mode != QPainter::CompositionMode_Source
state()->compo...ionMode_SourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1577 && state()->composition_mode != QPainter::CompositionMode_SourceOver))
state()->compo...ode_SourceOverDescription
TRUEnever evaluated
FALSEnever evaluated
0
1578 {-
1579 glyphFormat = QFontEngine::Format_A8;-
1580 }
never executed: end of block
0
1581 }
never executed: end of block
0
1582-
1583 if (shouldDrawCachedGlyphs(ti.fontEngine, s->matrix)) {
shouldDrawCach...ne, s->matrix)Description
TRUEnever evaluated
FALSEnever evaluated
0
1584 QVarLengthArray<QFixedPoint> positions;-
1585 QVarLengthArray<glyph_t> glyphs;-
1586 QTransform matrix = QTransform::fromTranslate(p.x(), p.y());-
1587 ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);-
1588-
1589 {-
1590 QStaticTextItem staticTextItem;-
1591 staticTextItem.setFontEngine(ti.fontEngine);-
1592 staticTextItem.glyphs = glyphs.data();-
1593 staticTextItem.numGlyphs = glyphs.size();-
1594 staticTextItem.glyphPositions = positions.data();-
1595-
1596 d->drawCachedGlyphs(glyphFormat, &staticTextItem);-
1597 }-
1598 return;
never executed: return;
0
1599 }-
1600-
1601 QPaintEngineEx::drawTextItem(p, ti);-
1602}
never executed: end of block
0
1603-
1604namespace {-
1605-
1606 class QOpenGLStaticTextUserData: public QStaticTextUserData-
1607 {-
1608 public:-
1609 QOpenGLStaticTextUserData()-
1610 : QStaticTextUserData(OpenGLUserData), cacheSize(0, 0), cacheSerialNumber(0)-
1611 {-
1612 }
never executed: end of block
0
1613-
1614 ~QOpenGLStaticTextUserData()-
1615 {-
1616 }-
1617-
1618 QSize cacheSize;-
1619 QGL2PEXVertexArray vertexCoordinateArray;-
1620 QGL2PEXVertexArray textureCoordinateArray;-
1621 QFontEngine::GlyphFormat glyphFormat;-
1622 int cacheSerialNumber;-
1623 };-
1624-
1625}-
1626-
1627-
1628// #define QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO-
1629-
1630void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngine::GlyphFormat glyphFormat,-
1631 QStaticTextItem *staticTextItem)-
1632{-
1633 Q_Q(QGL2PaintEngineEx);-
1634-
1635 QGL2PaintEngineState *s = q->state();-
1636-
1637 void *cacheKey = const_cast<QGLContext *>(QGLContextPrivate::contextGroup(ctx)->context());-
1638 bool recreateVertexArrays = false;-
1639-
1640 QTransform glyphCacheTransform;-
1641 QFontEngine *fe = staticTextItem->fontEngine();-
1642 if (fe->supportsTransformation(s->matrix)) {
fe->supportsTr...ion(s->matrix)Description
TRUEnever evaluated
FALSEnever evaluated
0
1643 // The font-engine supports rendering glyphs with the current transform, so we-
1644 // build a glyph-cache with the scale pre-applied, so that the cache contains-
1645 // glyphs with the appropriate resolution in the case of retina displays.-
1646 glyphCacheTransform = s->matrix.type() < QTransform::TxRotate ?
s->matrix.type...form::TxRotateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1647 QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) :-
1648 QTransform::fromScale(-
1649 QVector2D(s->matrix.m11(), s->matrix.m12()).length(),-
1650 QVector2D(s->matrix.m21(), s->matrix.m22()).length());-
1651 }
never executed: end of block
0
1652-
1653 QGLTextureGlyphCache *cache =-
1654 (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphFormat, glyphCacheTransform);-
1655 if (!cache || cache->glyphFormat() != glyphFormat || cache->contextGroup() == 0) {
!cacheDescription
TRUEnever evaluated
FALSEnever evaluated
cache->glyphFo...!= glyphFormatDescription
TRUEnever evaluated
FALSEnever evaluated
cache->contextGroup() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1656 cache = new QGLTextureGlyphCache(glyphFormat, glyphCacheTransform);-
1657 fe->setGlyphCache(cacheKey, cache);-
1658 recreateVertexArrays = true;-
1659 }
never executed: end of block
0
1660-
1661 if (staticTextItem->userDataNeedsUpdate) {
staticTextItem...ataNeedsUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1662 recreateVertexArrays = true;-
1663 } else if (staticTextItem->userData() == 0) {
never executed: end of block
staticTextItem...serData() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1664 recreateVertexArrays = true;-
1665 } else if (staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) {
never executed: end of block
staticTextItem...OpenGLUserDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1666 recreateVertexArrays = true;-
1667 } else {
never executed: end of block
0
1668 QOpenGLStaticTextUserData *userData = static_cast<QOpenGLStaticTextUserData *>(staticTextItem->userData());-
1669 if (userData->glyphFormat != glyphFormat) {
userData->glyp...!= glyphFormatDescription
TRUEnever evaluated
FALSEnever evaluated
0
1670 recreateVertexArrays = true;-
1671 } else if (userData->cacheSerialNumber != cache->serialNumber()) {
never executed: end of block
userData->cach...serialNumber()Description
TRUEnever evaluated
FALSEnever evaluated
0
1672 recreateVertexArrays = true;-
1673 }
never executed: end of block
0
1674 }
never executed: end of block
0
1675-
1676 // We only need to update the cache with new glyphs if we are actually going to recreate the vertex arrays.-
1677 // If the cache size has changed, we do need to regenerate the vertices, but we don't need to repopulate the-
1678 // cache so this text is performed before we test if the cache size has changed.-
1679 if (recreateVertexArrays) {
recreateVertexArraysDescription
TRUEnever evaluated
FALSEnever evaluated
0
1680 cache->setPaintEnginePrivate(this);-
1681 if (!cache->populate(fe, staticTextItem->numGlyphs,
!cache->popula...lyphPositions)Description
TRUEnever evaluated
FALSEnever evaluated
0
1682 staticTextItem->glyphs, staticTextItem->glyphPositions)) {
!cache->popula...lyphPositions)Description
TRUEnever evaluated
FALSEnever evaluated
0
1683 // No space for glyphs in cache. We need to reset it and try again.-
1684 cache->clear();-
1685 cache->populate(fe, staticTextItem->numGlyphs,-
1686 staticTextItem->glyphs, staticTextItem->glyphPositions);-
1687 }
never executed: end of block
0
1688 cache->fillInPendingGlyphs();-
1689 }
never executed: end of block
0
1690-
1691 if (cache->width() == 0 || cache->height() == 0)
cache->width() == 0Description
TRUEnever evaluated
FALSEnever evaluated
cache->height() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1692 return;
never executed: return;
0
1693-
1694 transferMode(TextDrawingMode);-
1695-
1696 int margin = fe->glyphMargin(glyphFormat);-
1697-
1698 GLfloat dx = 1.0 / cache->width();-
1699 GLfloat dy = 1.0 / cache->height();-
1700-
1701 // Use global arrays by default-
1702 QGL2PEXVertexArray *vertexCoordinates = &vertexCoordinateArray;-
1703 QGL2PEXVertexArray *textureCoordinates = &textureCoordinateArray;-
1704-
1705 if (staticTextItem->useBackendOptimizations) {
staticTextItem...dOptimizationsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1706 QOpenGLStaticTextUserData *userData = 0;-
1707-
1708 if (staticTextItem->userData() == 0
staticTextItem...serData() == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1709 || staticTextItem->userData()->type != QStaticTextUserData::OpenGLUserData) {
staticTextItem...OpenGLUserDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1710-
1711 userData = new QOpenGLStaticTextUserData();-
1712 staticTextItem->setUserData(userData);-
1713-
1714 } else {
never executed: end of block
0
1715 userData = static_cast<QOpenGLStaticTextUserData*>(staticTextItem->userData());-
1716 }
never executed: end of block
0
1717-
1718 userData->glyphFormat = glyphFormat;-
1719 userData->cacheSerialNumber = cache->serialNumber();-
1720-
1721 // Use cache if backend optimizations is turned on-
1722 vertexCoordinates = &userData->vertexCoordinateArray;-
1723 textureCoordinates = &userData->textureCoordinateArray;-
1724-
1725 QSize size(cache->width(), cache->height());-
1726 if (userData->cacheSize != size) {
userData->cacheSize != sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1727 recreateVertexArrays = true;-
1728 userData->cacheSize = size;-
1729 }
never executed: end of block
0
1730 }
never executed: end of block
0
1731-
1732 if (recreateVertexArrays) {
recreateVertexArraysDescription
TRUEnever evaluated
FALSEnever evaluated
0
1733 vertexCoordinates->clear();-
1734 textureCoordinates->clear();-
1735-
1736 bool supportsSubPixelPositions = fe->supportsSubPixelPositions();-
1737 for (int i=0; i<staticTextItem->numGlyphs; ++i) {
i<staticTextItem->numGlyphsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1738 QFixed subPixelPosition;-
1739 if (supportsSubPixelPositions)
supportsSubPixelPositionsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1740 subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x);
never executed: subPixelPosition = fe->subPixelPositionForX(staticTextItem->glyphPositions[i].x);
0
1741-
1742 QTextureGlyphCache::GlyphAndSubPixelPosition glyph(staticTextItem->glyphs[i], subPixelPosition);-
1743-
1744 const QTextureGlyphCache::Coord &c = cache->coords[glyph];-
1745 if (c.isNull())
c.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1746 continue;
never executed: continue;
0
1747-
1748 int x = qFloor(staticTextItem->glyphPositions[i].x.toReal() * cache->transform().m11()) + c.baseLineX - margin;-
1749 int y = qRound(staticTextItem->glyphPositions[i].y.toReal() * cache->transform().m22()) - c.baseLineY - margin;-
1750-
1751 vertexCoordinates->addQuad(QRectF(x, y, c.w, c.h));-
1752 textureCoordinates->addQuad(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy));-
1753 }
never executed: end of block
0
1754-
1755 staticTextItem->userDataNeedsUpdate = false;-
1756 }
never executed: end of block
0
1757-
1758 int numGlyphs = vertexCoordinates->vertexCount() / 4;-
1759 if (numGlyphs == 0)
numGlyphs == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1760 return;
never executed: return;
0
1761-
1762 if (elementIndices.size() < numGlyphs*6) {
elementIndices... < numGlyphs*6Description
TRUEnever evaluated
FALSEnever evaluated
0
1763 Q_ASSERT(elementIndices.size() % 6 == 0);-
1764 int j = elementIndices.size() / 6 * 4;-
1765 while (j < numGlyphs*4) {
j < numGlyphs*4Description
TRUEnever evaluated
FALSEnever evaluated
0
1766 elementIndices.append(j + 0);-
1767 elementIndices.append(j + 0);-
1768 elementIndices.append(j + 1);-
1769 elementIndices.append(j + 2);-
1770 elementIndices.append(j + 3);-
1771 elementIndices.append(j + 3);-
1772-
1773 j += 4;-
1774 }
never executed: end of block
0
1775-
1776#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)-
1777 if (elementIndicesVBOId == 0)-
1778 glGenBuffers(1, &elementIndicesVBOId);-
1779-
1780 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementIndicesVBOId);-
1781 glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementIndices.size() * sizeof(GLushort),-
1782 elementIndices.constData(), GL_STATIC_DRAW);-
1783#endif-
1784 } else {
never executed: end of block
0
1785#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)-
1786 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementIndicesVBOId);-
1787#endif-
1788 }
never executed: end of block
0
1789-
1790 setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data());-
1791 setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinates->data());-
1792-
1793 if (!snapToPixelGrid) {
!snapToPixelGridDescription
TRUEnever evaluated
FALSEnever evaluated
0
1794 snapToPixelGrid = true;-
1795 matrixDirty = true;-
1796 }
never executed: end of block
0
1797-
1798 QBrush pensBrush = q->state()->pen.brush();-
1799 setBrush(pensBrush);-
1800-
1801 if (glyphFormat == QFontEngine::Format_A32) {
glyphFormat ==...ne::Format_A32Description
TRUEnever evaluated
FALSEnever evaluated
0
1802-
1803 // Subpixel antialiasing without gamma correction-
1804-
1805 QPainter::CompositionMode compMode = q->state()->composition_mode;-
1806 Q_ASSERT(compMode == QPainter::CompositionMode_Source-
1807 || compMode == QPainter::CompositionMode_SourceOver);-
1808-
1809 shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass1);-
1810-
1811 if (pensBrush.style() == Qt::SolidPattern) {
pensBrush.styl...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
1812 // Solid patterns can get away with only one pass.-
1813 QColor c = pensBrush.color();-
1814 qreal oldOpacity = q->state()->opacity;-
1815 if (compMode == QPainter::CompositionMode_Source) {
compMode == QP...ionMode_SourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1816 c = qt_premultiplyColor(c, q->state()->opacity);-
1817 q->state()->opacity = 1;-
1818 opacityUniformDirty = true;-
1819 }
never executed: end of block
0
1820-
1821 compositionModeDirty = false; // I can handle this myself, thank you very much-
1822 prepareForCachedGlyphDraw(*cache);-
1823-
1824 // prepareForCachedGlyphDraw() have set the opacity on the current shader, so the opacity state can now be reset.-
1825 if (compMode == QPainter::CompositionMode_Source) {
compMode == QP...ionMode_SourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1826 q->state()->opacity = oldOpacity;-
1827 opacityUniformDirty = true;-
1828 }
never executed: end of block
0
1829-
1830 glEnable(GL_BLEND);-
1831 glBlendFunc(GL_CONSTANT_COLOR, GL_ONE_MINUS_SRC_COLOR);-
1832 glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());-
1833 } else {
never executed: end of block
0
1834 // Other brush styles need two passes.-
1835-
1836 qreal oldOpacity = q->state()->opacity;-
1837 if (compMode == QPainter::CompositionMode_Source) {
compMode == QP...ionMode_SourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1838 q->state()->opacity = 1;-
1839 opacityUniformDirty = true;-
1840 pensBrush = Qt::white;-
1841 setBrush(pensBrush);-
1842 }
never executed: end of block
0
1843-
1844 compositionModeDirty = false; // I can handle this myself, thank you very much-
1845 prepareForCachedGlyphDraw(*cache);-
1846 glEnable(GL_BLEND);-
1847 glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);-
1848-
1849 glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT);-
1850 glBindTexture(GL_TEXTURE_2D, cache->texture());-
1851 updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false);-
1852-
1853#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)-
1854 glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);-
1855#else-
1856 glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());-
1857#endif-
1858-
1859 shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass2);-
1860-
1861 if (compMode == QPainter::CompositionMode_Source) {
compMode == QP...ionMode_SourceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1862 q->state()->opacity = oldOpacity;-
1863 opacityUniformDirty = true;-
1864 pensBrush = q->state()->pen.brush();-
1865 setBrush(pensBrush);-
1866 }
never executed: end of block
0
1867-
1868 compositionModeDirty = false;-
1869 prepareForCachedGlyphDraw(*cache);-
1870 glEnable(GL_BLEND);-
1871 glBlendFunc(GL_ONE, GL_ONE);-
1872 }
never executed: end of block
0
1873 compositionModeDirty = true;-
1874 } else {
never executed: end of block
0
1875 // Grayscale/mono glyphs-
1876-
1877 shaderManager->setMaskType(QGLEngineShaderManager::PixelMask);-
1878 prepareForCachedGlyphDraw(*cache);-
1879 }
never executed: end of block
0
1880-
1881 QGLTextureGlyphCache::FilterMode filterMode = (s->matrix.type() > QTransform::TxTranslate)?QGLTextureGlyphCache::Linear:QGLTextureGlyphCache::Nearest;
(s->matrix.typ...::TxTranslate)Description
TRUEnever evaluated
FALSEnever evaluated
0
1882 if (lastMaskTextureUsed != cache->texture() || cache->filterMode() != filterMode) {
lastMaskTextur...che->texture()Description
TRUEnever evaluated
FALSEnever evaluated
cache->filterM... != filterModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1883-
1884 glActiveTexture(GL_TEXTURE0 + QT_MASK_TEXTURE_UNIT);-
1885 if (lastMaskTextureUsed != cache->texture()) {
lastMaskTextur...che->texture()Description
TRUEnever evaluated
FALSEnever evaluated
0
1886 glBindTexture(GL_TEXTURE_2D, cache->texture());-
1887 lastMaskTextureUsed = cache->texture();-
1888 }
never executed: end of block
0
1889-
1890 if (cache->filterMode() != filterMode) {
cache->filterM... != filterModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1891 if (filterMode == QGLTextureGlyphCache::Linear) {
filterMode == ...hCache::LinearDescription
TRUEnever evaluated
FALSEnever evaluated
0
1892 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);-
1893 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);-
1894 } else {
never executed: end of block
0
1895 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);-
1896 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);-
1897 }
never executed: end of block
0
1898 cache->setFilterMode(filterMode);-
1899 }
never executed: end of block
0
1900 }
never executed: end of block
0
1901-
1902#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO)-
1903 glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, 0);-
1904 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);-
1905#else-
1906 glDrawElements(GL_TRIANGLE_STRIP, 6 * numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data());-
1907#endif-
1908}
never executed: end of block
0
1909-
1910void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,-
1911 QPainter::PixmapFragmentHints hints)-
1912{-
1913 Q_D(QGL2PaintEngineEx);-
1914 // Use fallback for extended composition modes.-
1915 if (state()->composition_mode > QPainter::CompositionMode_Plus) {
state()->compo...itionMode_PlusDescription
TRUEnever evaluated
FALSEnever evaluated
0
1916 QPaintEngineEx::drawPixmapFragments(fragments, fragmentCount, pixmap, hints);-
1917 return;
never executed: return;
0
1918 }-
1919-
1920 ensureActive();-
1921 int max_texture_size = d->ctx->d_func()->maxTextureSize();-
1922 if (pixmap.width() > max_texture_size || pixmap.height() > max_texture_size) {
pixmap.width()...x_texture_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
pixmap.height(...x_texture_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1923 QPixmap scaled = pixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);-
1924 d->drawPixmapFragments(fragments, fragmentCount, scaled, hints);-
1925 } else {
never executed: end of block
0
1926 d->drawPixmapFragments(fragments, fragmentCount, pixmap, hints);-
1927 }
never executed: end of block
0
1928}-
1929-
1930-
1931void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragment *fragments,-
1932 int fragmentCount, const QPixmap &pixmap,-
1933 QPainter::PixmapFragmentHints hints)-
1934{-
1935 GLfloat dx = 1.0f / pixmap.size().width();-
1936 GLfloat dy = 1.0f / pixmap.size().height();-
1937-
1938 vertexCoordinateArray.clear();-
1939 textureCoordinateArray.clear();-
1940 opacityArray.reset();-
1941-
1942 if (snapToPixelGrid) {
snapToPixelGridDescription
TRUEnever evaluated
FALSEnever evaluated
0
1943 snapToPixelGrid = false;-
1944 matrixDirty = true;-
1945 }
never executed: end of block
0
1946-
1947 bool allOpaque = true;-
1948-
1949 for (int i = 0; i < fragmentCount; ++i) {
i < fragmentCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1950 qreal s = 0;-
1951 qreal c = 1;-
1952 if (fragments[i].rotation != 0) {
fragments[i].rotation != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1953 s = qFastSin(qDegreesToRadians(fragments[i].rotation));-
1954 c = qFastCos(qDegreesToRadians(fragments[i].rotation));-
1955 }
never executed: end of block
0
1956-
1957 qreal right = 0.5 * fragments[i].scaleX * fragments[i].width;-
1958 qreal bottom = 0.5 * fragments[i].scaleY * fragments[i].height;-
1959 QGLPoint bottomRight(right * c - bottom * s, right * s + bottom * c);-
1960 QGLPoint bottomLeft(-right * c - bottom * s, -right * s + bottom * c);-
1961-
1962 vertexCoordinateArray.addVertex(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y);-
1963 vertexCoordinateArray.addVertex(-bottomLeft.x + fragments[i].x, -bottomLeft.y + fragments[i].y);-
1964 vertexCoordinateArray.addVertex(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y);-
1965 vertexCoordinateArray.addVertex(-bottomRight.x + fragments[i].x, -bottomRight.y + fragments[i].y);-
1966 vertexCoordinateArray.addVertex(bottomLeft.x + fragments[i].x, bottomLeft.y + fragments[i].y);-
1967 vertexCoordinateArray.addVertex(bottomRight.x + fragments[i].x, bottomRight.y + fragments[i].y);-
1968-
1969 QGLRect src(fragments[i].sourceLeft * dx, fragments[i].sourceTop * dy,-
1970 (fragments[i].sourceLeft + fragments[i].width) * dx,-
1971 (fragments[i].sourceTop + fragments[i].height) * dy);-
1972-
1973 textureCoordinateArray.addVertex(src.right, src.bottom);-
1974 textureCoordinateArray.addVertex(src.right, src.top);-
1975 textureCoordinateArray.addVertex(src.left, src.top);-
1976 textureCoordinateArray.addVertex(src.left, src.top);-
1977 textureCoordinateArray.addVertex(src.left, src.bottom);-
1978 textureCoordinateArray.addVertex(src.right, src.bottom);-
1979-
1980 qreal opacity = fragments[i].opacity * q->state()->opacity;-
1981 opacityArray << opacity << opacity << opacity << opacity << opacity << opacity;-
1982 allOpaque &= (opacity >= 0.99f);-
1983 }
never executed: end of block
0
1984-
1985 glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);-
1986 QGLTexture *texture = ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA,-
1987 QGLContext::InternalBindOption-
1988 | QGLContext::CanFlipNativePixmapBindOption);-
1989-
1990 if (texture->options & QGLContext::InvertedYBindOption) {
texture->optio...tedYBindOptionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1991 // Flip texture y-coordinate.-
1992 QGLPoint *data = textureCoordinateArray.data();-
1993 for (int i = 0; i < 6 * fragmentCount; ++i)
i < 6 * fragmentCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
1994 data[i].y = 1 - data[i].y;
never executed: data[i].y = 1 - data[i].y;
0
1995 }
never executed: end of block
0
1996-
1997 transferMode(ImageArrayDrawingMode);-
1998-
1999 bool isBitmap = pixmap.isQBitmap();-
2000 bool isOpaque = !isBitmap && (!pixmap.hasAlpha() || (hints & QPainter::OpaqueHint)) && allOpaque;
!isBitmapDescription
TRUEnever evaluated
FALSEnever evaluated
!pixmap.hasAlpha()Description
TRUEnever evaluated
FALSEnever evaluated
(hints & QPainter::OpaqueHint)Description
TRUEnever evaluated
FALSEnever evaluated
allOpaqueDescription
TRUEnever evaluated
FALSEnever evaluated
0
2001-
2002 updateTextureFilter(GL_TEXTURE_2D, GL_CLAMP_TO_EDGE,-
2003 q->state()->renderHints & QPainter::SmoothPixmapTransform, texture->id);-
2004-
2005 // Setup for texture drawing-
2006 currentBrush = noBrush;-
2007 shaderManager->setSrcPixelType(isBitmap ? QGLEngineShaderManager::PatternSrc-
2008 : QGLEngineShaderManager::ImageSrc);-
2009 if (prepareForDraw(isOpaque))
prepareForDraw(isOpaque)Description
TRUEnever evaluated
FALSEnever evaluated
0
2010 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT);
never executed: shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), GLuint(0));
0
2011-
2012 if (isBitmap) {
isBitmapDescription
TRUEnever evaluated
FALSEnever evaluated
0
2013 QColor col = qt_premultiplyColor(q->state()->pen.color(), (GLfloat)q->state()->opacity);-
2014 shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::PatternColor), col);-
2015 }
never executed: end of block
0
2016-
2017 glDrawArrays(GL_TRIANGLES, 0, 6 * fragmentCount);-
2018}
never executed: end of block
0
2019-
2020bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)-
2021{-
2022 Q_D(QGL2PaintEngineEx);-
2023-
2024// qDebug("QGL2PaintEngineEx::begin()");-
2025 if (pdev->devType() == QInternal::OpenGL)
pdev->devType(...ternal::OpenGLDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2026 d->device = static_cast<QGLPaintDevice*>(pdev);
never executed: d->device = static_cast<QGLPaintDevice*>(pdev);
0
2027 else-
2028 d->device = QGLPaintDevice::getDevice(pdev);
executed 3 times by 1 test: d->device = QGLPaintDevice::getDevice(pdev);
Executed by:
  • tst_qmdiarea - unknown status
3
2029-
2030 if (!d->device)
!d->deviceDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2031 return false;
never executed: return false;
0
2032-
2033 d->ctx = d->device->context();-
2034 d->ctx->d_ptr->active_engine = this;-
2035-
2036 d->resetOpenGLContextActiveEngine();-
2037-
2038 const QSize sz = d->device->size();-
2039 d->width = sz.width();-
2040 d->height = sz.height();-
2041 d->mode = BrushDrawingMode;-
2042 d->brushTextureDirty = true;-
2043 d->brushUniformsDirty = true;-
2044 d->matrixUniformDirty = true;-
2045 d->matrixDirty = true;-
2046 d->compositionModeDirty = true;-
2047 d->opacityUniformDirty = true;-
2048 d->translateZUniformDirty = true;-
2049 d->needsSync = true;-
2050 d->useSystemClip = !systemClip().isEmpty();-
2051 d->currentBrush = QBrush();-
2052-
2053 d->dirtyStencilRegion = QRect(0, 0, d->width, d->height);-
2054 d->stencilClean = true;-
2055-
2056 // Calling begin paint should make the correct context current. So, any-
2057 // code which calls into GL or otherwise needs a current context *must*-
2058 // go after beginPaint:-
2059 d->device->beginPaint();-
2060-
2061 d->initializeOpenGLFunctions();-
2062-
2063 d->shaderManager = new QGLEngineShaderManager(d->ctx);-
2064-
2065 d->glDisable(GL_STENCIL_TEST);-
2066 d->glDisable(GL_DEPTH_TEST);-
2067 d->glDisable(GL_SCISSOR_TEST);-
2068-
2069#if !defined(QT_OPENGL_ES_2)-
2070 if (!d->ctx->contextHandle()->isOpenGLES())
!d->ctx->conte...->isOpenGLES()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
2071 d->glDisable(GL_MULTISAMPLE);
executed 3 times by 1 test: d->glDisable(0x809D);
Executed by:
  • tst_qmdiarea - unknown status
3
2072#endif-
2073-
2074 d->glyphCacheFormat = QFontEngine::Format_A8;-
2075-
2076#if !defined(QT_OPENGL_ES_2)-
2077 if (!d->ctx->contextHandle()->isOpenGLES()) {
!d->ctx->conte...->isOpenGLES()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
2078 d->glyphCacheFormat = QFontEngine::Format_A32;-
2079 d->multisamplingAlwaysEnabled = false;-
2080 } else {
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2081 d->multisamplingAlwaysEnabled = d->device->format().sampleBuffers();-
2082 }
never executed: end of block
0
2083#else-
2084 // OpenGL ES can't switch MSAA off, so if the gl paint device is-
2085 // multisampled, it's always multisampled.-
2086 d->multisamplingAlwaysEnabled = d->device->format().sampleBuffers();-
2087#endif-
2088-
2089 return true;
executed 3 times by 1 test: return true;
Executed by:
  • tst_qmdiarea - unknown status
3
2090}-
2091-
2092bool QGL2PaintEngineEx::end()-
2093{-
2094 Q_D(QGL2PaintEngineEx);-
2095-
2096 QGLContext *ctx = d->ctx;-
2097 d->glUseProgram(0);-
2098 d->transferMode(BrushDrawingMode);-
2099 d->device->endPaint();-
2100-
2101 ctx->d_ptr->active_engine = 0;-
2102-
2103 d->resetOpenGLContextActiveEngine();-
2104-
2105 d->resetGLState();-
2106-
2107 delete d->shaderManager;-
2108 d->shaderManager = 0;-
2109 d->currentBrush = QBrush();-
2110-
2111#ifdef QT_OPENGL_CACHE_AS_VBOS-
2112 if (!d->unusedVBOSToClean.isEmpty()) {-
2113 d->glDeleteBuffers(d->unusedVBOSToClean.size(), d->unusedVBOSToClean.constData());-
2114 d->unusedVBOSToClean.clear();-
2115 }-
2116 if (!d->unusedIBOSToClean.isEmpty()) {-
2117 d->glDeleteBuffers(d->unusedIBOSToClean.size(), d->unusedIBOSToClean.constData());-
2118 d->unusedIBOSToClean.clear();-
2119 }-
2120#endif-
2121-
2122 return false;
executed 3 times by 1 test: return false;
Executed by:
  • tst_qmdiarea - unknown status
3
2123}-
2124-
2125void QGL2PaintEngineEx::ensureActive()-
2126{-
2127 Q_D(QGL2PaintEngineEx);-
2128 QGLContext *ctx = d->ctx;-
2129-
2130 if (isActive() && (ctx->d_ptr->active_engine != this || d->resetOpenGLContextActiveEngine())) {
isActive()Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
ctx->d_ptr->ac...engine != thisDescription
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
d->resetOpenGL...ActiveEngine()Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-42
2131 ctx->d_ptr->active_engine = this;-
2132 d->needsSync = true;-
2133 }
never executed: end of block
0
2134-
2135 d->device->ensureActiveTarget();-
2136-
2137 if (d->needsSync) {
d->needsSyncDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
3-39
2138 d->transferMode(BrushDrawingMode);-
2139 d->glViewport(0, 0, d->width, d->height);-
2140 d->needsSync = false;-
2141 d->lastMaskTextureUsed = 0;-
2142 d->shaderManager->setDirty();-
2143 d->ctx->d_func()->syncGlState();-
2144 for (int i = 0; i < 3; ++i)
i < 3Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
3-9
2145 d->vertexAttribPointers[i] = (GLfloat*)-1; // Assume the pointers are clobbered
executed 9 times by 1 test: d->vertexAttribPointers[i] = (GLfloat*)-1;
Executed by:
  • tst_qmdiarea - unknown status
9
2146 setState(state());-
2147 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2148}
executed 42 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
42
2149-
2150void QGL2PaintEngineExPrivate::updateClipScissorTest()-
2151{-
2152 Q_Q(QGL2PaintEngineEx);-
2153 if (q->state()->clipTestEnabled) {
q->state()->clipTestEnabledDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2154 glEnable(GL_STENCIL_TEST);-
2155 glStencilFunc(GL_LEQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT);-
2156 } else {
never executed: end of block
0
2157 glDisable(GL_STENCIL_TEST);-
2158 glStencilFunc(GL_ALWAYS, 0, 0xff);-
2159 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2160-
2161#ifdef QT_GL_NO_SCISSOR_TEST-
2162 currentScissorBounds = QRect(0, 0, width, height);-
2163#else-
2164 QRect bounds = q->state()->rectangleClip;-
2165 if (!q->state()->clipEnabled) {
!q->state()->clipEnabledDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2166 if (useSystemClip)
useSystemClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2167 bounds = systemClip.boundingRect();
never executed: bounds = systemClip.boundingRect();
0
2168 else-
2169 bounds = QRect(0, 0, width, height);
never executed: bounds = QRect(0, 0, width, height);
0
2170 } else {-
2171 if (useSystemClip)
useSystemClipDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
2172 bounds = bounds.intersected(systemClip.boundingRect());
executed 3 times by 1 test: bounds = bounds.intersected(systemClip.boundingRect());
Executed by:
  • tst_qmdiarea - unknown status
3
2173 else-
2174 bounds = bounds.intersected(QRect(0, 0, width, height));
never executed: bounds = bounds.intersected(QRect(0, 0, width, height));
0
2175 }-
2176-
2177 currentScissorBounds = bounds;-
2178-
2179 if (bounds == QRect(0, 0, width, height)) {
bounds == QRec...width, height)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
1-2
2180 glDisable(GL_SCISSOR_TEST);-
2181 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
1
2182 glEnable(GL_SCISSOR_TEST);-
2183 setScissor(bounds);-
2184 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
2
2185#endif-
2186}-
2187-
2188void QGL2PaintEngineExPrivate::setScissor(const QRect &rect)-
2189{-
2190 const int left = rect.left();-
2191 const int width = rect.width();-
2192 int bottom = height - (rect.top() + rect.height());-
2193 if (device->isFlipped()) {
device->isFlipped()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-2
2194 bottom = rect.top();-
2195 }
never executed: end of block
0
2196 const int height = rect.height();-
2197-
2198 glScissor(left, bottom, width, height);-
2199}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
2
2200-
2201void QGL2PaintEngineEx::clipEnabledChanged()-
2202{-
2203 Q_D(QGL2PaintEngineEx);-
2204-
2205 state()->clipChanged = true;-
2206-
2207 if (painter()->hasClipping())
painter()->hasClipping()Description
TRUEnever evaluated
FALSEnever evaluated
0
2208 d->regenerateClip();
never executed: d->regenerateClip();
0
2209 else-
2210 d->systemStateChanged();
never executed: d->systemStateChanged();
0
2211}-
2212-
2213void QGL2PaintEngineExPrivate::clearClip(uint value)-
2214{-
2215 dirtyStencilRegion -= currentScissorBounds;-
2216-
2217 glStencilMask(0xff);-
2218 glClearStencil(value);-
2219 glClear(GL_STENCIL_BUFFER_BIT);-
2220 glStencilMask(0x0);-
2221-
2222 q->state()->needsClipBufferClear = false;-
2223}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2224-
2225void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value)-
2226{-
2227 transferMode(BrushDrawingMode);-
2228-
2229 if (snapToPixelGrid) {
snapToPixelGridDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2230 snapToPixelGrid = false;-
2231 matrixDirty = true;-
2232 }
never executed: end of block
0
2233-
2234 if (matrixDirty)
matrixDirtyDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
2235 updateMatrix();
executed 3 times by 1 test: updateMatrix();
Executed by:
  • tst_qmdiarea - unknown status
3
2236-
2237 stencilClean = false;-
2238-
2239 const bool singlePass = !path.hasWindingFill()
!path.hasWindingFill()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
2240 && (((q->state()->currentClip == maxClip - 1) && q->state()->clipTestEnabled)
(q->state()->c...= maxClip - 1)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
q->state()->clipTestEnabledDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2241 || q->state()->needsClipBufferClear);
q->state()->ne...lipBufferClearDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2242 const uint referenceClipValue = q->state()->needsClipBufferClear ? 1 : q->state()->currentClip;
q->state()->ne...lipBufferClearDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2243-
2244 if (q->state()->needsClipBufferClear)
q->state()->ne...lipBufferClearDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2245 clearClip(1);
never executed: clearClip(1);
0
2246-
2247 if (path.isEmpty()) {
path.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2248 glEnable(GL_STENCIL_TEST);-
2249 glStencilFunc(GL_LEQUAL, value, ~GL_STENCIL_HIGH_BIT);-
2250 return;
never executed: return;
0
2251 }-
2252-
2253 if (q->state()->clipTestEnabled)
q->state()->clipTestEnabledDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2254 glStencilFunc(GL_LEQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT);
never executed: glStencilFunc(0x0203, q->state()->currentClip, ~GLuint(0x80));
0
2255 else-
2256 glStencilFunc(GL_ALWAYS, 0, 0xff);
executed 3 times by 1 test: glStencilFunc(0x0207, 0, 0xff);
Executed by:
  • tst_qmdiarea - unknown status
3
2257-
2258 vertexCoordinateArray.clear();-
2259 vertexCoordinateArray.addPath(path, inverseScale, false);-
2260-
2261 if (!singlePass)
!singlePassDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
2262 fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill());
executed 3 times by 1 test: fillStencilWithVertexArray(vertexCoordinateArray, path.hasWindingFill());
Executed by:
  • tst_qmdiarea - unknown status
3
2263-
2264 glColorMask(false, false, false, false);-
2265 glEnable(GL_STENCIL_TEST);-
2266 useSimpleShader();-
2267-
2268 if (singlePass) {
singlePassDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2269 // Under these conditions we can set the new stencil value in a single-
2270 // pass, by using the current value and the "new value" as the toggles-
2271-
2272 glStencilFunc(GL_LEQUAL, referenceClipValue, ~GL_STENCIL_HIGH_BIT);-
2273 glStencilOp(GL_KEEP, GL_INVERT, GL_INVERT);-
2274 glStencilMask(value ^ referenceClipValue);-
2275-
2276 drawVertexArrays(vertexCoordinateArray, GL_TRIANGLE_FAN);-
2277 } else {
never executed: end of block
0
2278 glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE);-
2279 glStencilMask(0xff);-
2280-
2281 if (!q->state()->clipTestEnabled && path.hasWindingFill()) {
!q->state()->clipTestEnabledDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
path.hasWindingFill()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2282 // Pass when any clip bit is set, set high bit-
2283 glStencilFunc(GL_NOTEQUAL, GL_STENCIL_HIGH_BIT, ~GL_STENCIL_HIGH_BIT);-
2284 composite(vertexCoordinateArray.boundingRect());-
2285 }
never executed: end of block
0
2286-
2287 // Pass when high bit is set, replace stencil value with new clip value-
2288 glStencilFunc(GL_NOTEQUAL, value, GL_STENCIL_HIGH_BIT);-
2289-
2290 composite(vertexCoordinateArray.boundingRect());-
2291 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2292-
2293 glStencilFunc(GL_LEQUAL, value, ~GL_STENCIL_HIGH_BIT);-
2294 glStencilMask(0);-
2295-
2296 glColorMask(true, true, true, true);-
2297}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2298-
2299void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op)-
2300{-
2301// qDebug("QGL2PaintEngineEx::clip()");-
2302 Q_D(QGL2PaintEngineEx);-
2303-
2304 state()->clipChanged = true;-
2305-
2306 ensureActive();-
2307-
2308 if (op == Qt::ReplaceClip) {
op == Qt::ReplaceClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2309 op = Qt::IntersectClip;-
2310 if (d->hasClipOperations()) {
d->hasClipOperations()Description
TRUEnever evaluated
FALSEnever evaluated
0
2311 d->systemStateChanged();-
2312 state()->canRestoreClip = false;-
2313 }
never executed: end of block
0
2314 }
never executed: end of block
0
2315-
2316#ifndef QT_GL_NO_SCISSOR_TEST-
2317 if (!path.isEmpty() && op == Qt::IntersectClip && (path.shape() == QVectorPath::RectangleHint)) {
!path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
op == Qt::IntersectClipDescription
TRUEnever evaluated
FALSEnever evaluated
(path.shape() ...RectangleHint)Description
TRUEnever evaluated
FALSEnever evaluated
0
2318 const QPointF* const points = reinterpret_cast<const QPointF*>(path.points());-
2319 QRectF rect(points[0], points[2]);-
2320-
2321 if (state()->matrix.type() <= QTransform::TxScale
state()->matri...sform::TxScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2322 || (state()->matrix.type() == QTransform::TxRotate
state()->matri...form::TxRotateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2323 && qFuzzyIsNull(state()->matrix.m11())
qFuzzyIsNull(s...>matrix.m11())Description
TRUEnever evaluated
FALSEnever evaluated
0
2324 && qFuzzyIsNull(state()->matrix.m22())))
qFuzzyIsNull(s...>matrix.m22())Description
TRUEnever evaluated
FALSEnever evaluated
0
2325 {-
2326 state()->rectangleClip = state()->rectangleClip.intersected(state()->matrix.mapRect(rect).toRect());-
2327 d->updateClipScissorTest();-
2328 return;
never executed: return;
0
2329 }-
2330 }
never executed: end of block
0
2331#endif-
2332-
2333 const QRect pathRect = state()->matrix.mapRect(path.controlPointRect()).toAlignedRect();-
2334-
2335 switch (op) {-
2336 case Qt::NoClip:
never executed: case Qt::NoClip:
0
2337 if (d->useSystemClip) {
d->useSystemClipDescription
TRUEnever evaluated
FALSEnever evaluated
0
2338 state()->clipTestEnabled = true;-
2339 state()->currentClip = 1;-
2340 } else {
never executed: end of block
0
2341 state()->clipTestEnabled = false;-
2342 }
never executed: end of block
0
2343 state()->rectangleClip = QRect(0, 0, d->width, d->height);-
2344 state()->canRestoreClip = false;-
2345 d->updateClipScissorTest();-
2346 break;
never executed: break;
0
2347 case Qt::IntersectClip:
never executed: case Qt::IntersectClip:
0
2348 state()->rectangleClip = state()->rectangleClip.intersected(pathRect);-
2349 d->updateClipScissorTest();-
2350 d->resetClipIfNeeded();-
2351 ++d->maxClip;-
2352 d->writeClip(path, d->maxClip);-
2353 state()->currentClip = d->maxClip;-
2354 state()->clipTestEnabled = true;-
2355 break;
never executed: break;
0
2356 default:
never executed: default:
0
2357 break;
never executed: break;
0
2358 }-
2359}-
2360-
2361void QGL2PaintEngineExPrivate::regenerateClip()-
2362{-
2363 systemStateChanged();-
2364 replayClipOperations();-
2365}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2366-
2367void QGL2PaintEngineExPrivate::systemStateChanged()-
2368{-
2369 Q_Q(QGL2PaintEngineEx);-
2370-
2371 q->state()->clipChanged = true;-
2372-
2373 if (systemClip.isEmpty()) {
systemClip.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2374 useSystemClip = false;-
2375 } else {
never executed: end of block
0
2376 if (q->paintDevice()->devType() == QInternal::Widget && currentClipDevice) {
q->paintDevice...ternal::WidgetDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
currentClipDeviceDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2377 QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast<QWidget *>(currentClipDevice)->window());-
2378 useSystemClip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter;
widgetPrivate->extraDescription
TRUEnever evaluated
FALSEnever evaluated
widgetPrivate-...derWithPainterDescription
TRUEnever evaluated
FALSEnever evaluated
0
2379 } else {
never executed: end of block
0
2380 useSystemClip = true;-
2381 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2382 }-
2383-
2384 q->state()->clipTestEnabled = false;-
2385 q->state()->needsClipBufferClear = true;-
2386-
2387 q->state()->currentClip = 1;-
2388 maxClip = 1;-
2389-
2390 q->state()->rectangleClip = useSystemClip ? systemClip.boundingRect() : QRect(0, 0, width, height);
useSystemClipDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
2391 updateClipScissorTest();-
2392-
2393 if (systemClip.rectCount() == 1) {
systemClip.rectCount() == 1Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2394 if (systemClip.boundingRect() == QRect(0, 0, width, height))
systemClip.bou...width, height)Description
TRUEnever evaluated
FALSEnever evaluated
0
2395 useSystemClip = false;
never executed: useSystemClip = false;
0
2396#ifndef QT_GL_NO_SCISSOR_TEST-
2397 // scissoring takes care of the system clip-
2398 return;
never executed: return;
0
2399#endif-
2400 }-
2401-
2402 if (useSystemClip) {
useSystemClipDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
2403 clearClip(0);-
2404-
2405 QPainterPath path;-
2406 path.addRegion(systemClip);-
2407-
2408 q->state()->currentClip = 0;-
2409 writeClip(qtVectorPathForPath(q->state()->matrix.inverted().map(path)), 1);-
2410 q->state()->currentClip = 1;-
2411 q->state()->clipTestEnabled = true;-
2412 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2413}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2414-
2415void QGL2PaintEngineEx::setTranslateZ(GLfloat z)-
2416{-
2417 Q_D(QGL2PaintEngineEx);-
2418 if (d->translateZ != z) {
d->translateZ != zDescription
TRUEnever evaluated
FALSEnever evaluated
0
2419 d->translateZ = z;-
2420 d->translateZUniformDirty = true;-
2421 }
never executed: end of block
0
2422}
never executed: end of block
0
2423-
2424void QGL2PaintEngineEx::setState(QPainterState *new_state)-
2425{-
2426 // qDebug("QGL2PaintEngineEx::setState()");-
2427-
2428 Q_D(QGL2PaintEngineEx);-
2429-
2430 QGL2PaintEngineState *s = static_cast<QGL2PaintEngineState *>(new_state);-
2431 QGL2PaintEngineState *old_state = state();-
2432-
2433 QPaintEngineEx::setState(s);-
2434-
2435 if (s->isNew) {
s->isNewDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
3
2436 // Newly created state object. The call to setState()-
2437 // will either be followed by a call to begin(), or we are-
2438 // setting the state as part of a save().-
2439 s->isNew = false;-
2440 return;
executed 3 times by 1 test: return;
Executed by:
  • tst_qmdiarea - unknown status
3
2441 }-
2442-
2443 // Setting the state as part of a restore().-
2444-
2445 if (old_state == s || old_state->renderHintsChanged)
old_state == sDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
old_state->renderHintsChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0-3
2446 renderHintsChanged();
executed 3 times by 1 test: renderHintsChanged();
Executed by:
  • tst_qmdiarea - unknown status
3
2447-
2448 if (old_state == s || old_state->matrixChanged)
old_state == sDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
old_state->matrixChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0-3
2449 d->matrixDirty = true;
executed 3 times by 1 test: d->matrixDirty = true;
Executed by:
  • tst_qmdiarea - unknown status
3
2450-
2451 if (old_state == s || old_state->compositionModeChanged)
old_state == sDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
old_state->com...ionModeChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0-3
2452 d->compositionModeDirty = true;
executed 3 times by 1 test: d->compositionModeDirty = true;
Executed by:
  • tst_qmdiarea - unknown status
3
2453-
2454 if (old_state == s || old_state->opacityChanged)
old_state == sDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
old_state->opacityChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0-3
2455 d->opacityUniformDirty = true;
executed 3 times by 1 test: d->opacityUniformDirty = true;
Executed by:
  • tst_qmdiarea - unknown status
3
2456-
2457 if (old_state == s || old_state->clipChanged) {
old_state == sDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
old_state->clipChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0-3
2458 if (old_state && old_state != s && old_state->canRestoreClip) {
old_stateDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
old_state != sDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
old_state->canRestoreClipDescription
TRUEnever evaluated
FALSEnever evaluated
0-3
2459 d->updateClipScissorTest();-
2460 d->glDepthFunc(GL_LEQUAL);-
2461 } else {
never executed: end of block
0
2462 d->regenerateClip();-
2463 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2464 }-
2465}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2466-
2467QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const-
2468{-
2469 if (orig)
origDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
0-3
2470 const_cast<QGL2PaintEngineEx *>(this)->ensureActive();
never executed: const_cast<QGL2PaintEngineEx *>(this)->ensureActive();
0
2471-
2472 QGL2PaintEngineState *s;-
2473 if (!orig)
!origDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qmdiarea - unknown status
FALSEnever evaluated
0-3
2474 s = new QGL2PaintEngineState();
executed 3 times by 1 test: s = new QGL2PaintEngineState();
Executed by:
  • tst_qmdiarea - unknown status
3
2475 else-
2476 s = new QGL2PaintEngineState(*static_cast<QGL2PaintEngineState *>(orig));
never executed: s = new QGL2PaintEngineState(*static_cast<QGL2PaintEngineState *>(orig));
0
2477-
2478 s->matrixChanged = false;-
2479 s->compositionModeChanged = false;-
2480 s->opacityChanged = false;-
2481 s->renderHintsChanged = false;-
2482 s->clipChanged = false;-
2483-
2484 return s;
executed 3 times by 1 test: return s;
Executed by:
  • tst_qmdiarea - unknown status
3
2485}-
2486-
2487QGL2PaintEngineState::QGL2PaintEngineState(QGL2PaintEngineState &other)-
2488 : QPainterState(other)-
2489{-
2490 isNew = true;-
2491 needsClipBufferClear = other.needsClipBufferClear;-
2492 clipTestEnabled = other.clipTestEnabled;-
2493 currentClip = other.currentClip;-
2494 canRestoreClip = other.canRestoreClip;-
2495 rectangleClip = other.rectangleClip;-
2496}
never executed: end of block
0
2497-
2498QGL2PaintEngineState::QGL2PaintEngineState()-
2499{-
2500 isNew = true;-
2501 needsClipBufferClear = true;-
2502 clipTestEnabled = false;-
2503 canRestoreClip = true;-
2504}
executed 3 times by 1 test: end of block
Executed by:
  • tst_qmdiarea - unknown status
3
2505-
2506QGL2PaintEngineState::~QGL2PaintEngineState()-
2507{-
2508}-
2509-
2510QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9