Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/util/qsgdefaultpainternode.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
5 | ** | - | ||||||||||||||||||||||||
6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||||||||||||||
7 | ** | - | ||||||||||||||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
16 | ** | - | ||||||||||||||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
24 | ** | - | ||||||||||||||||||||||||
25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
35 | ** | - | ||||||||||||||||||||||||
36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
37 | ** | - | ||||||||||||||||||||||||
38 | ****************************************************************************/ | - | ||||||||||||||||||||||||
39 | - | |||||||||||||||||||||||||
40 | #include "qsgdefaultpainternode_p.h" | - | ||||||||||||||||||||||||
41 | - | |||||||||||||||||||||||||
42 | #include <QtQuick/private/qquickpainteditem_p.h> | - | ||||||||||||||||||||||||
43 | - | |||||||||||||||||||||||||
44 | #include <QtQuick/private/qsgdefaultrendercontext_p.h> | - | ||||||||||||||||||||||||
45 | #include <QtQuick/private/qsgcontext_p.h> | - | ||||||||||||||||||||||||
46 | #include <private/qopenglextensions_p.h> | - | ||||||||||||||||||||||||
47 | #include <qopenglframebufferobject.h> | - | ||||||||||||||||||||||||
48 | #include <qopenglfunctions.h> | - | ||||||||||||||||||||||||
49 | #include <qopenglpaintdevice.h> | - | ||||||||||||||||||||||||
50 | #include <qmath.h> | - | ||||||||||||||||||||||||
51 | #include <qpainter.h> | - | ||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||
53 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
54 | - | |||||||||||||||||||||||||
55 | #define QT_MINIMUM_DYNAMIC_FBO_SIZE 64U | - | ||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||
57 | QSGPainterTexture::QSGPainterTexture() | - | ||||||||||||||||||||||||
58 | : QSGPlainTexture() | - | ||||||||||||||||||||||||
59 | { | - | ||||||||||||||||||||||||
60 | m_retain_image = true; | - | ||||||||||||||||||||||||
61 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||
62 | - | |||||||||||||||||||||||||
63 | void QSGPainterTexture::bind() | - | ||||||||||||||||||||||||
64 | { | - | ||||||||||||||||||||||||
65 | if (m_dirty_rect.isNull()) {
| 0-50 | ||||||||||||||||||||||||
66 | QSGPlainTexture::bind(); | - | ||||||||||||||||||||||||
67 | return; never executed: return; | 0 | ||||||||||||||||||||||||
68 | } | - | ||||||||||||||||||||||||
69 | - | |||||||||||||||||||||||||
70 | setImage(m_image); | - | ||||||||||||||||||||||||
71 | QSGPlainTexture::bind(); | - | ||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | m_dirty_rect = QRect(); | - | ||||||||||||||||||||||||
74 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | QSGDefaultPainterNode::QSGDefaultPainterNode(QQuickPaintedItem *item) | - | ||||||||||||||||||||||||
77 | : QSGPainterNode() | - | ||||||||||||||||||||||||
78 | , m_preferredRenderTarget(QQuickPaintedItem::Image) | - | ||||||||||||||||||||||||
79 | , m_actualRenderTarget(QQuickPaintedItem::Image) | - | ||||||||||||||||||||||||
80 | , m_item(item) | - | ||||||||||||||||||||||||
81 | , m_fbo(nullptr) | - | ||||||||||||||||||||||||
82 | , m_multisampledFbo(nullptr) | - | ||||||||||||||||||||||||
83 | , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) | - | ||||||||||||||||||||||||
84 | , m_texture(nullptr) | - | ||||||||||||||||||||||||
85 | , m_gl_device(nullptr) | - | ||||||||||||||||||||||||
86 | , m_fillColor(Qt::transparent) | - | ||||||||||||||||||||||||
87 | , m_contentsScale(1.0) | - | ||||||||||||||||||||||||
88 | , m_dirtyContents(false) | - | ||||||||||||||||||||||||
89 | , m_opaquePainting(false) | - | ||||||||||||||||||||||||
90 | , m_linear_filtering(false) | - | ||||||||||||||||||||||||
91 | , m_mipmapping(false) | - | ||||||||||||||||||||||||
92 | , m_smoothPainting(false) | - | ||||||||||||||||||||||||
93 | , m_extensionsChecked(false) | - | ||||||||||||||||||||||||
94 | , m_multisamplingSupported(false) | - | ||||||||||||||||||||||||
95 | , m_fastFBOResizing(false) | - | ||||||||||||||||||||||||
96 | , m_dirtyGeometry(false) | - | ||||||||||||||||||||||||
97 | , m_dirtyRenderTarget(false) | - | ||||||||||||||||||||||||
98 | , m_dirtyTexture(false) | - | ||||||||||||||||||||||||
99 | { | - | ||||||||||||||||||||||||
100 | m_context = static_cast<QSGDefaultRenderContext *>(static_cast<QQuickPaintedItemPrivate *>(QObjectPrivate::get(item))->sceneGraphRenderContext()); | - | ||||||||||||||||||||||||
101 | - | |||||||||||||||||||||||||
102 | setMaterial(&m_materialO); | - | ||||||||||||||||||||||||
103 | setOpaqueMaterial(&m_material); | - | ||||||||||||||||||||||||
104 | setGeometry(&m_geometry); | - | ||||||||||||||||||||||||
105 | - | |||||||||||||||||||||||||
106 | #ifdef QSG_RUNTIME_DESCRIPTION | - | ||||||||||||||||||||||||
107 | qsgnode_set_description(this, QString::fromLatin1("QQuickPaintedItem(%1):%2").arg(QString::fromLatin1(item->metaObject()->className())).arg(item->objectName())); | - | ||||||||||||||||||||||||
108 | #endif | - | ||||||||||||||||||||||||
109 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
110 | - | |||||||||||||||||||||||||
111 | QSGDefaultPainterNode::~QSGDefaultPainterNode() | - | ||||||||||||||||||||||||
112 | { | - | ||||||||||||||||||||||||
113 | delete m_texture; | - | ||||||||||||||||||||||||
114 | delete m_fbo; | - | ||||||||||||||||||||||||
115 | delete m_multisampledFbo; | - | ||||||||||||||||||||||||
116 | delete m_gl_device; | - | ||||||||||||||||||||||||
117 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
118 | - | |||||||||||||||||||||||||
119 | void QSGDefaultPainterNode::paint() | - | ||||||||||||||||||||||||
120 | { | - | ||||||||||||||||||||||||
121 | QRect dirtyRect = m_dirtyRect.isNull() ? QRect(0, 0, m_size.width(), m_size.height()) : m_dirtyRect;
| 4-46 | ||||||||||||||||||||||||
122 | - | |||||||||||||||||||||||||
123 | QPainter painter; | - | ||||||||||||||||||||||||
124 | if (m_actualRenderTarget == QQuickPaintedItem::Image) {
| 0-50 | ||||||||||||||||||||||||
125 | if (m_image.isNull())
| 0-50 | ||||||||||||||||||||||||
126 | return; never executed: return; | 0 | ||||||||||||||||||||||||
127 | painter.begin(&m_image); | - | ||||||||||||||||||||||||
128 | } else { executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||||||||||||||
129 | if (!m_gl_device) {
| 0 | ||||||||||||||||||||||||
130 | m_gl_device = new QOpenGLPaintDevice(m_fboSize); | - | ||||||||||||||||||||||||
131 | m_gl_device->setPaintFlipped(true); | - | ||||||||||||||||||||||||
132 | } never executed: end of block | 0 | ||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||
134 | if (m_multisampledFbo)
| 0 | ||||||||||||||||||||||||
135 | m_multisampledFbo->bind(); never executed: m_multisampledFbo->bind(); | 0 | ||||||||||||||||||||||||
136 | else | - | ||||||||||||||||||||||||
137 | m_fbo->bind(); never executed: m_fbo->bind(); | 0 | ||||||||||||||||||||||||
138 | - | |||||||||||||||||||||||||
139 | painter.begin(m_gl_device); | - | ||||||||||||||||||||||||
140 | } never executed: end of block | 0 | ||||||||||||||||||||||||
141 | - | |||||||||||||||||||||||||
142 | if (m_smoothPainting) {
| 2-48 | ||||||||||||||||||||||||
143 | painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); | - | ||||||||||||||||||||||||
144 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
145 | - | |||||||||||||||||||||||||
146 | QRect clipRect; | - | ||||||||||||||||||||||||
147 | QRect dirtyTextureRect; | - | ||||||||||||||||||||||||
148 | - | |||||||||||||||||||||||||
149 | if (m_contentsScale == 1) {
| 10-40 | ||||||||||||||||||||||||
150 | qreal scaleX = m_textureSize.width() / (qreal) m_size.width(); | - | ||||||||||||||||||||||||
151 | qreal scaleY = m_textureSize.height() / (qreal) m_size.height(); | - | ||||||||||||||||||||||||
152 | painter.scale(scaleX, scaleY); | - | ||||||||||||||||||||||||
153 | clipRect = dirtyRect; | - | ||||||||||||||||||||||||
154 | dirtyTextureRect = QRectF(dirtyRect.x() * scaleX, | - | ||||||||||||||||||||||||
155 | dirtyRect.y() * scaleY, | - | ||||||||||||||||||||||||
156 | dirtyRect.width() * scaleX, | - | ||||||||||||||||||||||||
157 | dirtyRect.height() * scaleY).toAlignedRect(); | - | ||||||||||||||||||||||||
158 | } else { executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||
159 | painter.scale(m_contentsScale, m_contentsScale); | - | ||||||||||||||||||||||||
160 | QRect sclip(qFloor(dirtyRect.x()/m_contentsScale), | - | ||||||||||||||||||||||||
161 | qFloor(dirtyRect.y()/m_contentsScale), | - | ||||||||||||||||||||||||
162 | qCeil(dirtyRect.width()/m_contentsScale+dirtyRect.x()/m_contentsScale-qFloor(dirtyRect.x()/m_contentsScale)), | - | ||||||||||||||||||||||||
163 | qCeil(dirtyRect.height()/m_contentsScale+dirtyRect.y()/m_contentsScale-qFloor(dirtyRect.y()/m_contentsScale))); | - | ||||||||||||||||||||||||
164 | clipRect = sclip; | - | ||||||||||||||||||||||||
165 | dirtyTextureRect = dirtyRect; | - | ||||||||||||||||||||||||
166 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||||||||
167 | - | |||||||||||||||||||||||||
168 | // only clip if we were originally updating only a subrect | - | ||||||||||||||||||||||||
169 | if (!m_dirtyRect.isNull()) {
| 4-46 | ||||||||||||||||||||||||
170 | painter.setClipRect(clipRect); | - | ||||||||||||||||||||||||
171 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
172 | - | |||||||||||||||||||||||||
173 | painter.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||||||||||||||
174 | painter.fillRect(clipRect, m_fillColor); | - | ||||||||||||||||||||||||
175 | painter.setCompositionMode(QPainter::CompositionMode_SourceOver); | - | ||||||||||||||||||||||||
176 | - | |||||||||||||||||||||||||
177 | m_item->paint(&painter); | - | ||||||||||||||||||||||||
178 | painter.end(); | - | ||||||||||||||||||||||||
179 | - | |||||||||||||||||||||||||
180 | if (m_actualRenderTarget == QQuickPaintedItem::Image) {
| 0-50 | ||||||||||||||||||||||||
181 | m_texture->setImage(m_image); | - | ||||||||||||||||||||||||
182 | m_texture->setDirtyRect(dirtyTextureRect); | - | ||||||||||||||||||||||||
183 | } else if (m_multisampledFbo) { executed 50 times by 1 test: end of block Executed by:
| 0-50 | ||||||||||||||||||||||||
184 | QOpenGLFramebufferObject::blitFramebuffer(m_fbo, dirtyTextureRect, m_multisampledFbo, dirtyTextureRect); | - | ||||||||||||||||||||||||
185 | } never executed: end of block | 0 | ||||||||||||||||||||||||
186 | - | |||||||||||||||||||||||||
187 | if (m_multisampledFbo)
| 0-50 | ||||||||||||||||||||||||
188 | m_multisampledFbo->release(); never executed: m_multisampledFbo->release(); | 0 | ||||||||||||||||||||||||
189 | else if (m_fbo)
| 0-50 | ||||||||||||||||||||||||
190 | m_fbo->release(); never executed: m_fbo->release(); | 0 | ||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||
192 | m_dirtyRect = QRect(); | - | ||||||||||||||||||||||||
193 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||||||||||||||
194 | - | |||||||||||||||||||||||||
195 | void QSGDefaultPainterNode::update() | - | ||||||||||||||||||||||||
196 | { | - | ||||||||||||||||||||||||
197 | if (m_dirtyRenderTarget)
| 24-26 | ||||||||||||||||||||||||
198 | updateRenderTarget(); executed 26 times by 1 test: updateRenderTarget(); Executed by:
| 26 | ||||||||||||||||||||||||
199 | if (m_dirtyGeometry)
| 22-28 | ||||||||||||||||||||||||
200 | updateGeometry(); executed 22 times by 1 test: updateGeometry(); Executed by:
| 22 | ||||||||||||||||||||||||
201 | if (m_dirtyTexture)
| 20-30 | ||||||||||||||||||||||||
202 | updateTexture(); executed 30 times by 1 test: updateTexture(); Executed by:
| 30 | ||||||||||||||||||||||||
203 | - | |||||||||||||||||||||||||
204 | if (m_dirtyContents)
| 0-50 | ||||||||||||||||||||||||
205 | paint(); executed 50 times by 1 test: paint(); Executed by:
| 50 | ||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||
207 | m_dirtyGeometry = false; | - | ||||||||||||||||||||||||
208 | m_dirtyRenderTarget = false; | - | ||||||||||||||||||||||||
209 | m_dirtyTexture = false; | - | ||||||||||||||||||||||||
210 | m_dirtyContents = false; | - | ||||||||||||||||||||||||
211 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||||||||||||||
212 | - | |||||||||||||||||||||||||
213 | void QSGDefaultPainterNode::updateTexture() | - | ||||||||||||||||||||||||
214 | { | - | ||||||||||||||||||||||||
215 | m_texture->setHasAlphaChannel(!m_opaquePainting); | - | ||||||||||||||||||||||||
216 | m_material.setTexture(m_texture); | - | ||||||||||||||||||||||||
217 | m_materialO.setTexture(m_texture); | - | ||||||||||||||||||||||||
218 | - | |||||||||||||||||||||||||
219 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
220 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||
221 | - | |||||||||||||||||||||||||
222 | void QSGDefaultPainterNode::updateGeometry() | - | ||||||||||||||||||||||||
223 | { | - | ||||||||||||||||||||||||
224 | QRectF source; | - | ||||||||||||||||||||||||
225 | if (m_actualRenderTarget == QQuickPaintedItem::Image)
| 0-22 | ||||||||||||||||||||||||
226 | source = QRectF(0, 0, 1, 1); executed 22 times by 1 test: source = QRectF(0, 0, 1, 1); Executed by:
| 22 | ||||||||||||||||||||||||
227 | else | - | ||||||||||||||||||||||||
228 | source = QRectF(0, 0, qreal(m_textureSize.width()) / m_fboSize.width(), qreal(m_textureSize.height()) / m_fboSize.height()); never executed: source = QRectF(0, 0, qreal(m_textureSize.width()) / m_fboSize.width(), qreal(m_textureSize.height()) / m_fboSize.height()); | 0 | ||||||||||||||||||||||||
229 | QRectF dest(0, 0, m_size.width(), m_size.height()); | - | ||||||||||||||||||||||||
230 | if (m_actualRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject)
| 0-22 | ||||||||||||||||||||||||
231 | dest = QRectF(QPointF(0, m_size.height()), QPointF(m_size.width(), 0)); never executed: dest = QRectF(QPointF(0, m_size.height()), QPointF(m_size.width(), 0)); | 0 | ||||||||||||||||||||||||
232 | QSGGeometry::updateTexturedRectGeometry(&m_geometry, | - | ||||||||||||||||||||||||
233 | dest, | - | ||||||||||||||||||||||||
234 | source); | - | ||||||||||||||||||||||||
235 | markDirty(DirtyGeometry); | - | ||||||||||||||||||||||||
236 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||
237 | - | |||||||||||||||||||||||||
238 | void QSGDefaultPainterNode::updateRenderTarget() | - | ||||||||||||||||||||||||
239 | { | - | ||||||||||||||||||||||||
240 | if (!m_extensionsChecked) {
| 10-16 | ||||||||||||||||||||||||
241 | QOpenGLExtensions *e = static_cast<QOpenGLExtensions *>(QOpenGLContext::currentContext()->functions()); | - | ||||||||||||||||||||||||
242 | m_multisamplingSupported = e->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
| 0-16 | ||||||||||||||||||||||||
243 | && e->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);
| 0-16 | ||||||||||||||||||||||||
244 | m_extensionsChecked = true; | - | ||||||||||||||||||||||||
245 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | m_dirtyContents = true; | - | ||||||||||||||||||||||||
248 | - | |||||||||||||||||||||||||
249 | QQuickPaintedItem::RenderTarget oldTarget = m_actualRenderTarget; | - | ||||||||||||||||||||||||
250 | if (m_preferredRenderTarget == QQuickPaintedItem::Image) {
| 0-26 | ||||||||||||||||||||||||
251 | m_actualRenderTarget = QQuickPaintedItem::Image; | - | ||||||||||||||||||||||||
252 | } else { executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||
253 | if (!m_multisamplingSupported && m_smoothPainting)
| 0 | ||||||||||||||||||||||||
254 | m_actualRenderTarget = QQuickPaintedItem::Image; never executed: m_actualRenderTarget = QQuickPaintedItem::Image; | 0 | ||||||||||||||||||||||||
255 | else | - | ||||||||||||||||||||||||
256 | m_actualRenderTarget = m_preferredRenderTarget; never executed: m_actualRenderTarget = m_preferredRenderTarget; | 0 | ||||||||||||||||||||||||
257 | } | - | ||||||||||||||||||||||||
258 | if (oldTarget != m_actualRenderTarget) {
| 0-26 | ||||||||||||||||||||||||
259 | m_image = QImage(); | - | ||||||||||||||||||||||||
260 | delete m_fbo; | - | ||||||||||||||||||||||||
261 | delete m_multisampledFbo; | - | ||||||||||||||||||||||||
262 | delete m_gl_device; | - | ||||||||||||||||||||||||
263 | m_fbo = m_multisampledFbo = nullptr; | - | ||||||||||||||||||||||||
264 | m_gl_device = nullptr; | - | ||||||||||||||||||||||||
265 | } never executed: end of block | 0 | ||||||||||||||||||||||||
266 | - | |||||||||||||||||||||||||
267 | if (m_actualRenderTarget == QQuickPaintedItem::FramebufferObject ||
| 0-26 | ||||||||||||||||||||||||
268 | m_actualRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject) {
| 0-26 | ||||||||||||||||||||||||
269 | const QOpenGLContext *ctx = m_context->openglContext(); | - | ||||||||||||||||||||||||
270 | if (m_fbo && !m_dirtyGeometry && (!ctx->format().samples() || !m_multisamplingSupported))
| 0 | ||||||||||||||||||||||||
271 | return; never executed: return; | 0 | ||||||||||||||||||||||||
272 | - | |||||||||||||||||||||||||
273 | if (m_fboSize.isEmpty())
| 0 | ||||||||||||||||||||||||
274 | updateFBOSize(); never executed: updateFBOSize(); | 0 | ||||||||||||||||||||||||
275 | - | |||||||||||||||||||||||||
276 | delete m_fbo; | - | ||||||||||||||||||||||||
277 | delete m_multisampledFbo; | - | ||||||||||||||||||||||||
278 | m_fbo = m_multisampledFbo = nullptr; | - | ||||||||||||||||||||||||
279 | if (m_gl_device)
| 0 | ||||||||||||||||||||||||
280 | m_gl_device->setSize(m_fboSize); never executed: m_gl_device->setSize(m_fboSize); | 0 | ||||||||||||||||||||||||
281 | - | |||||||||||||||||||||||||
282 | if (m_smoothPainting && ctx->format().samples() && m_multisamplingSupported) {
| 0 | ||||||||||||||||||||||||
283 | { | - | ||||||||||||||||||||||||
284 | QOpenGLFramebufferObjectFormat format; | - | ||||||||||||||||||||||||
285 | format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); | - | ||||||||||||||||||||||||
286 | format.setSamples(8); | - | ||||||||||||||||||||||||
287 | m_multisampledFbo = new QOpenGLFramebufferObject(m_fboSize, format); | - | ||||||||||||||||||||||||
288 | } | - | ||||||||||||||||||||||||
289 | { | - | ||||||||||||||||||||||||
290 | QOpenGLFramebufferObjectFormat format; | - | ||||||||||||||||||||||||
291 | format.setAttachment(QOpenGLFramebufferObject::NoAttachment); | - | ||||||||||||||||||||||||
292 | m_fbo = new QOpenGLFramebufferObject(m_fboSize, format); | - | ||||||||||||||||||||||||
293 | } | - | ||||||||||||||||||||||||
294 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
295 | QOpenGLFramebufferObjectFormat format; | - | ||||||||||||||||||||||||
296 | format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); | - | ||||||||||||||||||||||||
297 | m_fbo = new QOpenGLFramebufferObject(m_fboSize, format); | - | ||||||||||||||||||||||||
298 | } never executed: end of block | 0 | ||||||||||||||||||||||||
299 | } else { | - | ||||||||||||||||||||||||
300 | if (!m_image.isNull() && !m_dirtyGeometry)
| 4-16 | ||||||||||||||||||||||||
301 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||
302 | - | |||||||||||||||||||||||||
303 | m_image = QImage(m_textureSize, QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||||||||
304 | m_image.fill(Qt::transparent); | - | ||||||||||||||||||||||||
305 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||
306 | - | |||||||||||||||||||||||||
307 | QSGPainterTexture *texture = new QSGPainterTexture; | - | ||||||||||||||||||||||||
308 | if (m_actualRenderTarget == QQuickPaintedItem::Image) {
| 0-22 | ||||||||||||||||||||||||
309 | texture->setOwnsTexture(true); | - | ||||||||||||||||||||||||
310 | texture->setTextureSize(m_textureSize); | - | ||||||||||||||||||||||||
311 | } else { executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||
312 | texture->setTextureId(m_fbo->texture()); | - | ||||||||||||||||||||||||
313 | texture->setOwnsTexture(false); | - | ||||||||||||||||||||||||
314 | texture->setTextureSize(m_fboSize); | - | ||||||||||||||||||||||||
315 | } never executed: end of block | 0 | ||||||||||||||||||||||||
316 | - | |||||||||||||||||||||||||
317 | if (m_texture)
| 6-16 | ||||||||||||||||||||||||
318 | delete m_texture; executed 6 times by 1 test: delete m_texture; Executed by:
| 6 | ||||||||||||||||||||||||
319 | - | |||||||||||||||||||||||||
320 | m_texture = texture; | - | ||||||||||||||||||||||||
321 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||
322 | - | |||||||||||||||||||||||||
323 | void QSGDefaultPainterNode::updateFBOSize() | - | ||||||||||||||||||||||||
324 | { | - | ||||||||||||||||||||||||
325 | int fboWidth; | - | ||||||||||||||||||||||||
326 | int fboHeight; | - | ||||||||||||||||||||||||
327 | if (m_fastFBOResizing) {
| 2-24 | ||||||||||||||||||||||||
328 | fboWidth = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qNextPowerOfTwo(m_textureSize.width() - 1)); | - | ||||||||||||||||||||||||
329 | fboHeight = qMax(QT_MINIMUM_DYNAMIC_FBO_SIZE, qNextPowerOfTwo(m_textureSize.height() - 1)); | - | ||||||||||||||||||||||||
330 | } else { executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
331 | QSize minimumFBOSize = m_context->sceneGraphContext()->minimumFBOSize(); | - | ||||||||||||||||||||||||
332 | fboWidth = qMax(minimumFBOSize.width(), m_textureSize.width()); | - | ||||||||||||||||||||||||
333 | fboHeight = qMax(minimumFBOSize.height(), m_textureSize.height()); | - | ||||||||||||||||||||||||
334 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||||||||||||||||||||
335 | - | |||||||||||||||||||||||||
336 | m_fboSize = QSize(fboWidth, fboHeight); | - | ||||||||||||||||||||||||
337 | } executed 26 times by 1 test: end of block Executed by:
| 26 | ||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||
339 | void QSGDefaultPainterNode::setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) | - | ||||||||||||||||||||||||
340 | { | - | ||||||||||||||||||||||||
341 | if (m_preferredRenderTarget == target)
| 0-50 | ||||||||||||||||||||||||
342 | return; executed 50 times by 1 test: return; Executed by:
| 50 | ||||||||||||||||||||||||
343 | - | |||||||||||||||||||||||||
344 | m_preferredRenderTarget = target; | - | ||||||||||||||||||||||||
345 | - | |||||||||||||||||||||||||
346 | m_dirtyRenderTarget = true; | - | ||||||||||||||||||||||||
347 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
348 | m_dirtyTexture = true; | - | ||||||||||||||||||||||||
349 | } never executed: end of block | 0 | ||||||||||||||||||||||||
350 | - | |||||||||||||||||||||||||
351 | void QSGDefaultPainterNode::setSize(const QSize &size) | - | ||||||||||||||||||||||||
352 | { | - | ||||||||||||||||||||||||
353 | if (size == m_size)
| 22-28 | ||||||||||||||||||||||||
354 | return; executed 28 times by 1 test: return; Executed by:
| 28 | ||||||||||||||||||||||||
355 | - | |||||||||||||||||||||||||
356 | m_size = size; | - | ||||||||||||||||||||||||
357 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
358 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||
359 | - | |||||||||||||||||||||||||
360 | void QSGDefaultPainterNode::setTextureSize(const QSize &size) | - | ||||||||||||||||||||||||
361 | { | - | ||||||||||||||||||||||||
362 | if (size == m_textureSize)
| 22-28 | ||||||||||||||||||||||||
363 | return; executed 28 times by 1 test: return; Executed by:
| 28 | ||||||||||||||||||||||||
364 | - | |||||||||||||||||||||||||
365 | m_textureSize = size; | - | ||||||||||||||||||||||||
366 | updateFBOSize(); | - | ||||||||||||||||||||||||
367 | - | |||||||||||||||||||||||||
368 | if (m_fbo)
| 0-22 | ||||||||||||||||||||||||
369 | m_dirtyRenderTarget = m_fbo->size() != m_fboSize || m_dirtyRenderTarget; never executed: m_dirtyRenderTarget = m_fbo->size() != m_fboSize || m_dirtyRenderTarget;
| 0 | ||||||||||||||||||||||||
370 | else | - | ||||||||||||||||||||||||
371 | m_dirtyRenderTarget = true; executed 22 times by 1 test: m_dirtyRenderTarget = true; Executed by:
| 22 | ||||||||||||||||||||||||
372 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
373 | m_dirtyTexture = true; | - | ||||||||||||||||||||||||
374 | } executed 22 times by 1 test: end of block Executed by:
| 22 | ||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | void QSGDefaultPainterNode::setDirty(const QRect &dirtyRect) | - | ||||||||||||||||||||||||
377 | { | - | ||||||||||||||||||||||||
378 | m_dirtyContents = true; | - | ||||||||||||||||||||||||
379 | m_dirtyRect = dirtyRect; | - | ||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||
381 | if (m_mipmapping)
| 2-48 | ||||||||||||||||||||||||
382 | m_dirtyTexture = true; executed 2 times by 1 test: m_dirtyTexture = true; Executed by:
| 2 | ||||||||||||||||||||||||
383 | - | |||||||||||||||||||||||||
384 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
385 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||||||||||||||
386 | - | |||||||||||||||||||||||||
387 | void QSGDefaultPainterNode::setOpaquePainting(bool opaque) | - | ||||||||||||||||||||||||
388 | { | - | ||||||||||||||||||||||||
389 | if (opaque == m_opaquePainting)
| 4-46 | ||||||||||||||||||||||||
390 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | m_opaquePainting = opaque; | - | ||||||||||||||||||||||||
393 | m_dirtyTexture = true; | - | ||||||||||||||||||||||||
394 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | void QSGDefaultPainterNode::setLinearFiltering(bool linearFiltering) | - | ||||||||||||||||||||||||
397 | { | - | ||||||||||||||||||||||||
398 | if (linearFiltering == m_linear_filtering)
| 16-34 | ||||||||||||||||||||||||
399 | return; executed 34 times by 1 test: return; Executed by:
| 34 | ||||||||||||||||||||||||
400 | - | |||||||||||||||||||||||||
401 | m_linear_filtering = linearFiltering; | - | ||||||||||||||||||||||||
402 | - | |||||||||||||||||||||||||
403 | m_material.setFiltering(linearFiltering ? QSGTexture::Linear : QSGTexture::Nearest); | - | ||||||||||||||||||||||||
404 | m_materialO.setFiltering(linearFiltering ? QSGTexture::Linear : QSGTexture::Nearest); | - | ||||||||||||||||||||||||
405 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
406 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||||||||
407 | - | |||||||||||||||||||||||||
408 | void QSGDefaultPainterNode::setMipmapping(bool mipmapping) | - | ||||||||||||||||||||||||
409 | { | - | ||||||||||||||||||||||||
410 | if (mipmapping == m_mipmapping)
| 4-46 | ||||||||||||||||||||||||
411 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
412 | - | |||||||||||||||||||||||||
413 | m_mipmapping = mipmapping; | - | ||||||||||||||||||||||||
414 | m_material.setMipmapFiltering(mipmapping ? QSGTexture::Linear : QSGTexture::None); | - | ||||||||||||||||||||||||
415 | m_materialO.setMipmapFiltering(mipmapping ? QSGTexture::Linear : QSGTexture::None); | - | ||||||||||||||||||||||||
416 | m_dirtyTexture = true; | - | ||||||||||||||||||||||||
417 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | void QSGDefaultPainterNode::setSmoothPainting(bool s) | - | ||||||||||||||||||||||||
420 | { | - | ||||||||||||||||||||||||
421 | if (s == m_smoothPainting)
| 4-46 | ||||||||||||||||||||||||
422 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
423 | - | |||||||||||||||||||||||||
424 | m_smoothPainting = s; | - | ||||||||||||||||||||||||
425 | m_dirtyRenderTarget = true; | - | ||||||||||||||||||||||||
426 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
427 | - | |||||||||||||||||||||||||
428 | void QSGDefaultPainterNode::setFillColor(const QColor &c) | - | ||||||||||||||||||||||||
429 | { | - | ||||||||||||||||||||||||
430 | if (c == m_fillColor)
| 4-46 | ||||||||||||||||||||||||
431 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
432 | - | |||||||||||||||||||||||||
433 | m_fillColor = c; | - | ||||||||||||||||||||||||
434 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
435 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | void QSGDefaultPainterNode::setContentsScale(qreal s) | - | ||||||||||||||||||||||||
438 | { | - | ||||||||||||||||||||||||
439 | if (s == m_contentsScale)
| 8-42 | ||||||||||||||||||||||||
440 | return; executed 42 times by 1 test: return; Executed by:
| 42 | ||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | m_contentsScale = s; | - | ||||||||||||||||||||||||
443 | markDirty(DirtyMaterial); | - | ||||||||||||||||||||||||
444 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||
446 | void QSGDefaultPainterNode::setFastFBOResizing(bool fastResizing) | - | ||||||||||||||||||||||||
447 | { | - | ||||||||||||||||||||||||
448 | if (m_fastFBOResizing == fastResizing)
| 4-46 | ||||||||||||||||||||||||
449 | return; executed 46 times by 1 test: return; Executed by:
| 46 | ||||||||||||||||||||||||
450 | - | |||||||||||||||||||||||||
451 | m_fastFBOResizing = fastResizing; | - | ||||||||||||||||||||||||
452 | updateFBOSize(); | - | ||||||||||||||||||||||||
453 | - | |||||||||||||||||||||||||
454 | if ((m_preferredRenderTarget == QQuickPaintedItem::FramebufferObject
| 0-4 | ||||||||||||||||||||||||
455 | || m_preferredRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject)
| 0-4 | ||||||||||||||||||||||||
456 | && (!m_fbo || (m_fbo && m_fbo->size() != m_fboSize))) {
| 0 | ||||||||||||||||||||||||
457 | m_dirtyRenderTarget = true; | - | ||||||||||||||||||||||||
458 | m_dirtyGeometry = true; | - | ||||||||||||||||||||||||
459 | m_dirtyTexture = true; | - | ||||||||||||||||||||||||
460 | } never executed: end of block | 0 | ||||||||||||||||||||||||
461 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
462 | - | |||||||||||||||||||||||||
463 | QImage QSGDefaultPainterNode::toImage() const | - | ||||||||||||||||||||||||
464 | { | - | ||||||||||||||||||||||||
465 | if (m_actualRenderTarget == QQuickPaintedItem::Image)
| 0 | ||||||||||||||||||||||||
466 | return m_image; never executed: return m_image; | 0 | ||||||||||||||||||||||||
467 | else | - | ||||||||||||||||||||||||
468 | return m_fbo->toImage(); never executed: return m_fbo->toImage(); | 0 | ||||||||||||||||||||||||
469 | } | - | ||||||||||||||||||||||||
470 | - | |||||||||||||||||||||||||
471 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |