Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quickwidgets/qquickwidget.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | - | |||||||||||||||||||
10 | - | |||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | - | |||||||||||||||||||
14 | - | |||||||||||||||||||
15 | - | |||||||||||||||||||
16 | - | |||||||||||||||||||
17 | - | |||||||||||||||||||
18 | class QQuickWidgetRenderControl : public QQuickRenderControl | - | ||||||||||||||||||
19 | { | - | ||||||||||||||||||
20 | public: | - | ||||||||||||||||||
21 | QQuickWidgetRenderControl(QQuickWidget *quickwidget) : m_quickWidget(quickwidget) {} executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||||||||||||||
22 | QWindow *renderWindow(QPoint *offset) override { | - | ||||||||||||||||||
23 | if (offset
| 0-694 | ||||||||||||||||||
24 | * never executed: offset = m_quickWidget->mapTo(m_quickWidget->window(), QPoint());*offset = m_quickWidget->mapTo(m_quickWidget->window(), QPoint()); never executed: *offset = m_quickWidget->mapTo(m_quickWidget->window(), QPoint()); | 0 | ||||||||||||||||||
25 | return executed 694 times by 2 tests: m_quickWidget->window()->windowHandle();return m_quickWidget->window()->windowHandle(); Executed by:
executed 694 times by 2 tests: return m_quickWidget->window()->windowHandle(); Executed by:
| 694 | ||||||||||||||||||
26 | } | - | ||||||||||||||||||
27 | private: | - | ||||||||||||||||||
28 | QQuickWidget *m_quickWidget; | - | ||||||||||||||||||
29 | }; | - | ||||||||||||||||||
30 | - | |||||||||||||||||||
31 | void QQuickWidgetPrivate::init(QQmlEngine* e) | - | ||||||||||||||||||
32 | { | - | ||||||||||||||||||
33 | QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
34 | - | |||||||||||||||||||
35 | renderControl = new QQuickWidgetRenderControl(q); | - | ||||||||||||||||||
36 | offscreenWindow = new QQuickWindow(renderControl); | - | ||||||||||||||||||
37 | offscreenWindow->setTitle(QString::fromLatin1("Offscreen")); | - | ||||||||||||||||||
38 | - | |||||||||||||||||||
39 | - | |||||||||||||||||||
40 | - | |||||||||||||||||||
41 | auto sgRendererInterface = offscreenWindow->rendererInterface(); | - | ||||||||||||||||||
42 | if (sgRendererInterface
| 0-118 | ||||||||||||||||||
43 | useSoftwareRenderer = true; never executed: useSoftwareRenderer = true; | 0 | ||||||||||||||||||
44 | - | |||||||||||||||||||
45 | if (!useSoftwareRenderer
| 0-118 | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface)
| 0-118 | ||||||||||||||||||
48 | setRenderToTexture(); executed 118 times by 2 tests: setRenderToTexture(); Executed by:
| 118 | ||||||||||||||||||
49 | else | - | ||||||||||||||||||
50 | - | |||||||||||||||||||
51 | QMessageLogger(__FILE__, 112, __PRETTY_FUNCTION__).warning("QQuickWidget is not supported on this platform."); never executed: QMessageLogger(__FILE__, 112, __PRETTY_FUNCTION__).warning("QQuickWidget is not supported on this platform."); | 0 | ||||||||||||||||||
52 | } | - | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | engine = e; | - | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | if (!engine.isNull()
| 0-114 | ||||||||||||||||||
57 | engine.data()->setIncubationController(offscreenWindow->incubationController()); executed 4 times by 1 test: engine.data()->setIncubationController(offscreenWindow->incubationController()); Executed by:
| 4 | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | - | |||||||||||||||||||
60 | q->setAcceptDrops(true); | - | ||||||||||||||||||
61 | - | |||||||||||||||||||
62 | - | |||||||||||||||||||
63 | QWidget::connect(offscreenWindow, qFlagLocation("2""sceneGraphInitialized()" "\0" __FILE__ ":" "124"), q, qFlagLocation("1""createFramebufferObject()" "\0" __FILE__ ":" "124")); | - | ||||||||||||||||||
64 | QWidget::connect(offscreenWindow, qFlagLocation("2""sceneGraphInvalidated()" "\0" __FILE__ ":" "125"), q, qFlagLocation("1""destroyFramebufferObject()" "\0" __FILE__ ":" "125")); | - | ||||||||||||||||||
65 | QObject::connect(renderControl, qFlagLocation("2""renderRequested()" "\0" __FILE__ ":" "126"), q, qFlagLocation("1""triggerUpdate()" "\0" __FILE__ ":" "126")); | - | ||||||||||||||||||
66 | QObject::connect(renderControl, qFlagLocation("2""sceneChanged()" "\0" __FILE__ ":" "127"), q, qFlagLocation("1""triggerUpdate()" "\0" __FILE__ ":" "127")); | - | ||||||||||||||||||
67 | } executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||||||||||||||
68 | - | |||||||||||||||||||
69 | void QQuickWidgetPrivate::ensureEngine() const | - | ||||||||||||||||||
70 | { | - | ||||||||||||||||||
71 | const QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
72 | if (!engine.isNull()
| 12-104 | ||||||||||||||||||
73 | return; executed 12 times by 1 test: return; Executed by:
| 12 | ||||||||||||||||||
74 | - | |||||||||||||||||||
75 | engine = new QQmlEngine(const_cast<QQuickWidget*>(q)); | - | ||||||||||||||||||
76 | engine.data()->setIncubationController(offscreenWindow->incubationController()); | - | ||||||||||||||||||
77 | } executed 104 times by 2 tests: end of block Executed by:
| 104 | ||||||||||||||||||
78 | - | |||||||||||||||||||
79 | void QQuickWidgetPrivate::invalidateRenderControl() | - | ||||||||||||||||||
80 | { | - | ||||||||||||||||||
81 | - | |||||||||||||||||||
82 | if (!useSoftwareRenderer
| 0-126 | ||||||||||||||||||
83 | if (!context
| 14-112 | ||||||||||||||||||
84 | return; executed 14 times by 1 test: return; Executed by:
| 14 | ||||||||||||||||||
85 | - | |||||||||||||||||||
86 | bool success = context->makeCurrent(offscreenSurface); | - | ||||||||||||||||||
87 | if (!success
| 0-112 | ||||||||||||||||||
88 | QMessageLogger(__FILE__, 149, __PRETTY_FUNCTION__).warning("QQuickWidget::invalidateRenderControl could not make context current"); | - | ||||||||||||||||||
89 | return; never executed: return; | 0 | ||||||||||||||||||
90 | } | - | ||||||||||||||||||
91 | } executed 112 times by 2 tests: end of block Executed by:
| 112 | ||||||||||||||||||
92 | - | |||||||||||||||||||
93 | - | |||||||||||||||||||
94 | renderControl->invalidate(); | - | ||||||||||||||||||
95 | - | |||||||||||||||||||
96 | - | |||||||||||||||||||
97 | - | |||||||||||||||||||
98 | - | |||||||||||||||||||
99 | - | |||||||||||||||||||
100 | if (!useSoftwareRenderer
| 0-112 | ||||||||||||||||||
101 | if (QOpenGLContext::currentContext() != context
| 0-112 | ||||||||||||||||||
102 | context->makeCurrent(offscreenSurface); never executed: context->makeCurrent(offscreenSurface); | 0 | ||||||||||||||||||
103 | } executed 112 times by 2 tests: end of block Executed by:
| 112 | ||||||||||||||||||
104 | - | |||||||||||||||||||
105 | } executed 112 times by 2 tests: end of block Executed by:
| 112 | ||||||||||||||||||
106 | - | |||||||||||||||||||
107 | void QQuickWidgetPrivate::handleWindowChange() | - | ||||||||||||||||||
108 | { | - | ||||||||||||||||||
109 | if (offscreenWindow->isPersistentSceneGraph()
| 0-8 | ||||||||||||||||||
110 | return; never executed: return; | 0 | ||||||||||||||||||
111 | invalidateRenderControl(); | - | ||||||||||||||||||
112 | - | |||||||||||||||||||
113 | if (!useSoftwareRenderer
| 0-8 | ||||||||||||||||||
114 | destroyContext(); executed 8 times by 1 test: destroyContext(); Executed by:
| 8 | ||||||||||||||||||
115 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
116 | - | |||||||||||||||||||
117 | QQuickWidgetPrivate::QQuickWidgetPrivate() | - | ||||||||||||||||||
118 | : root(nullptr) | - | ||||||||||||||||||
119 | , component(nullptr) | - | ||||||||||||||||||
120 | , offscreenWindow(nullptr) | - | ||||||||||||||||||
121 | , offscreenSurface(nullptr) | - | ||||||||||||||||||
122 | , renderControl(nullptr) | - | ||||||||||||||||||
123 | - | |||||||||||||||||||
124 | , fbo(nullptr) | - | ||||||||||||||||||
125 | , resolvedFbo(nullptr) | - | ||||||||||||||||||
126 | , context(nullptr) | - | ||||||||||||||||||
127 | - | |||||||||||||||||||
128 | , resizeMode(QQuickWidget::SizeViewToRootObject) | - | ||||||||||||||||||
129 | , initialSize(0,0) | - | ||||||||||||||||||
130 | , eventPending(false) | - | ||||||||||||||||||
131 | , updatePending(false) | - | ||||||||||||||||||
132 | , fakeHidden(false) | - | ||||||||||||||||||
133 | , requestedSamples(0) | - | ||||||||||||||||||
134 | , useSoftwareRenderer(false) | - | ||||||||||||||||||
135 | , forceFullUpdate(false) | - | ||||||||||||||||||
136 | { | - | ||||||||||||||||||
137 | } executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||||||||||||||
138 | - | |||||||||||||||||||
139 | QQuickWidgetPrivate::~QQuickWidgetPrivate() | - | ||||||||||||||||||
140 | { | - | ||||||||||||||||||
141 | invalidateRenderControl(); | - | ||||||||||||||||||
142 | - | |||||||||||||||||||
143 | if (useSoftwareRenderer
| 0-118 | ||||||||||||||||||
144 | delete renderControl; | - | ||||||||||||||||||
145 | delete offscreenWindow; | - | ||||||||||||||||||
146 | } never executed: else {end of block | 0 | ||||||||||||||||||
147 | - | |||||||||||||||||||
148 | - | |||||||||||||||||||
149 | ((!context || (QOpenGLContext::currentContext() == context && context->surface() == offscreenSurface)) ? static_cast<void>(0) : qt_assert("!context || (QOpenGLContext::currentContext() == context && context->surface() == offscreenSurface)", __FILE__, 218)); | - | ||||||||||||||||||
150 | delete renderControl; | - | ||||||||||||||||||
151 | delete offscreenWindow; | - | ||||||||||||||||||
152 | delete resolvedFbo; | - | ||||||||||||||||||
153 | delete fbo; | - | ||||||||||||||||||
154 | - | |||||||||||||||||||
155 | destroyContext(); | - | ||||||||||||||||||
156 | - | |||||||||||||||||||
157 | } executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||||||||||||||
158 | } | - | ||||||||||||||||||
159 | - | |||||||||||||||||||
160 | void QQuickWidgetPrivate::execute() | - | ||||||||||||||||||
161 | { | - | ||||||||||||||||||
162 | QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
163 | ensureEngine(); | - | ||||||||||||||||||
164 | - | |||||||||||||||||||
165 | if (root
| 0-102 | ||||||||||||||||||
166 | delete root; | - | ||||||||||||||||||
167 | root = nullptr; | - | ||||||||||||||||||
168 | } never executed: end of block | 0 | ||||||||||||||||||
169 | if (component
| 0-102 | ||||||||||||||||||
170 | delete component; | - | ||||||||||||||||||
171 | component = nullptr; | - | ||||||||||||||||||
172 | } never executed: end of block | 0 | ||||||||||||||||||
173 | if (!source.isEmpty()
| 0-102 | ||||||||||||||||||
174 | QQmlMemoryScope _qml_memory_scope(engine.data()->baseUrl().resolved(source)); | - | ||||||||||||||||||
175 | component = new QQmlComponent(engine.data(), source, q); | - | ||||||||||||||||||
176 | if (!component->isLoading()
| 0-102 | ||||||||||||||||||
177 | q->continueExecute(); | - | ||||||||||||||||||
178 | } executed 102 times by 2 tests: else {end of block Executed by:
| 102 | ||||||||||||||||||
179 | QObject::connect(component, qFlagLocation("2""statusChanged(QQmlComponent::Status)" "\0" __FILE__ ":" "248"), | - | ||||||||||||||||||
180 | q, qFlagLocation("1""continueExecute()" "\0" __FILE__ ":" "249")); | - | ||||||||||||||||||
181 | } never executed: end of block | 0 | ||||||||||||||||||
182 | } | - | ||||||||||||||||||
183 | } executed 102 times by 2 tests: end of block Executed by:
| 102 | ||||||||||||||||||
184 | - | |||||||||||||||||||
185 | void QQuickWidgetPrivate::itemGeometryChanged(QQuickItem *resizeItem, QQuickGeometryChange change, | - | ||||||||||||||||||
186 | const QRectF &oldGeometry) | - | ||||||||||||||||||
187 | { | - | ||||||||||||||||||
188 | QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
189 | if (resizeItem == root
| 0-10 | ||||||||||||||||||
190 | - | |||||||||||||||||||
191 | resizetimer.start(0,q); | - | ||||||||||||||||||
192 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||
193 | QQuickItemChangeListener::itemGeometryChanged(resizeItem, change, oldGeometry); | - | ||||||||||||||||||
194 | } executed 10 times by 1 test: end of block Executed by:
| 10 | ||||||||||||||||||
195 | - | |||||||||||||||||||
196 | void QQuickWidgetPrivate::render(bool needsSync) | - | ||||||||||||||||||
197 | { | - | ||||||||||||||||||
198 | if (!useSoftwareRenderer
| 0-332 | ||||||||||||||||||
199 | - | |||||||||||||||||||
200 | - | |||||||||||||||||||
201 | - | |||||||||||||||||||
202 | if (!fbo
| 4-328 | ||||||||||||||||||
203 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||
204 | - | |||||||||||||||||||
205 | ((context) ? static_cast<void>(0) : qt_assert("context", __FILE__, 274)); | - | ||||||||||||||||||
206 | - | |||||||||||||||||||
207 | if (!context->makeCurrent(offscreenSurface)
| 0-328 | ||||||||||||||||||
208 | QMessageLogger(__FILE__, 277, __PRETTY_FUNCTION__).warning("QQuickWidget: Cannot render due to failing makeCurrent()"); | - | ||||||||||||||||||
209 | return; never executed: return; | 0 | ||||||||||||||||||
210 | } | - | ||||||||||||||||||
211 | - | |||||||||||||||||||
212 | QOpenGLContextPrivate::get(context)->defaultFboRedirect = fbo->handle(); | - | ||||||||||||||||||
213 | - | |||||||||||||||||||
214 | if (needsSync
| 4-324 | ||||||||||||||||||
215 | renderControl->polishItems(); | - | ||||||||||||||||||
216 | renderControl->sync(); | - | ||||||||||||||||||
217 | } executed 324 times by 2 tests: end of block Executed by:
| 324 | ||||||||||||||||||
218 | - | |||||||||||||||||||
219 | renderControl->render(); | - | ||||||||||||||||||
220 | - | |||||||||||||||||||
221 | if (resolvedFbo
| 0-328 | ||||||||||||||||||
222 | QRect rect(QPoint(0, 0), fbo->size()); | - | ||||||||||||||||||
223 | QOpenGLFramebufferObject::blitFramebuffer(resolvedFbo, rect, fbo, rect); | - | ||||||||||||||||||
224 | } never executed: end of block | 0 | ||||||||||||||||||
225 | - | |||||||||||||||||||
226 | static_cast<QOpenGLExtensions *>(context->functions())->flushShared(); | - | ||||||||||||||||||
227 | - | |||||||||||||||||||
228 | QOpenGLContextPrivate::get(context)->defaultFboRedirect = 0; | - | ||||||||||||||||||
229 | - | |||||||||||||||||||
230 | } executed 328 times by 2 tests: else {end of block Executed by:
| 328 | ||||||||||||||||||
231 | - | |||||||||||||||||||
232 | if (needsSync
| 0 | ||||||||||||||||||
233 | renderControl->polishItems(); | - | ||||||||||||||||||
234 | renderControl->sync(); | - | ||||||||||||||||||
235 | } never executed: end of block | 0 | ||||||||||||||||||
236 | - | |||||||||||||||||||
237 | QQuickWindowPrivate *cd = QQuickWindowPrivate::get(offscreenWindow); | - | ||||||||||||||||||
238 | auto softwareRenderer = static_cast<QSGSoftwareRenderer*>(cd->renderer); | - | ||||||||||||||||||
239 | if (softwareRenderer
| 0 | ||||||||||||||||||
240 | softwareRenderer->setCurrentPaintDevice(&softwareImage); | - | ||||||||||||||||||
241 | if (forceFullUpdate
| 0 | ||||||||||||||||||
242 | softwareRenderer->markDirty(); | - | ||||||||||||||||||
243 | forceFullUpdate = false; | - | ||||||||||||||||||
244 | } never executed: end of block | 0 | ||||||||||||||||||
245 | renderControl->render(); | - | ||||||||||||||||||
246 | - | |||||||||||||||||||
247 | updateRegion += softwareRenderer->flushRegion(); | - | ||||||||||||||||||
248 | } never executed: end of block | 0 | ||||||||||||||||||
249 | } never executed: end of block | 0 | ||||||||||||||||||
250 | } | - | ||||||||||||||||||
251 | - | |||||||||||||||||||
252 | void QQuickWidgetPrivate::renderSceneGraph() | - | ||||||||||||||||||
253 | { | - | ||||||||||||||||||
254 | QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
255 | updatePending = false; | - | ||||||||||||||||||
256 | - | |||||||||||||||||||
257 | if (!q->isVisible()
| 0-102 | ||||||||||||||||||
258 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||
259 | - | |||||||||||||||||||
260 | if (!useSoftwareRenderer
| 0-98 | ||||||||||||||||||
261 | QOpenGLContext *context = offscreenWindow->openglContext(); | - | ||||||||||||||||||
262 | if (!context
| 0-98 | ||||||||||||||||||
263 | QMessageLogger(__FILE__, 332, __PRETTY_FUNCTION__).warning("QQuickWidget: Attempted to render scene with no context"); | - | ||||||||||||||||||
264 | return; never executed: return; | 0 | ||||||||||||||||||
265 | } | - | ||||||||||||||||||
266 | - | |||||||||||||||||||
267 | ((offscreenSurface) ? static_cast<void>(0) : qt_assert("offscreenSurface", __FILE__, 336)); | - | ||||||||||||||||||
268 | } executed 98 times by 2 tests: end of block Executed by:
| 98 | ||||||||||||||||||
269 | - | |||||||||||||||||||
270 | render(true); | - | ||||||||||||||||||
271 | - | |||||||||||||||||||
272 | - | |||||||||||||||||||
273 | if (q->window()->graphicsProxyWidget()
| 0-98 | ||||||||||||||||||
274 | QWidgetPrivate::nearestGraphicsProxyWidget(q)->update(); never executed: QWidgetPrivate::nearestGraphicsProxyWidget(q)->update(); | 0 | ||||||||||||||||||
275 | else | - | ||||||||||||||||||
276 | - | |||||||||||||||||||
277 | { | - | ||||||||||||||||||
278 | if (!useSoftwareRenderer
| 0-98 | ||||||||||||||||||
279 | q->update(); executed 98 times by 2 tests: q->update(); Executed by:
| 98 | ||||||||||||||||||
280 | else if (!updateRegion.isEmpty()
| 0 | ||||||||||||||||||
281 | q->update(updateRegion); never executed: q->update(updateRegion); | 0 | ||||||||||||||||||
282 | } executed 98 times by 2 tests: end of block Executed by:
| 98 | ||||||||||||||||||
283 | } | - | ||||||||||||||||||
284 | - | |||||||||||||||||||
285 | QImage QQuickWidgetPrivate::grabFramebuffer() | - | ||||||||||||||||||
286 | { | - | ||||||||||||||||||
287 | if (!useSoftwareRenderer
| 0-8 | ||||||||||||||||||
288 | - | |||||||||||||||||||
289 | if (!context
| 0-8 | ||||||||||||||||||
290 | return never executed: QImage();return QImage(); never executed: return QImage(); | 0 | ||||||||||||||||||
291 | - | |||||||||||||||||||
292 | context->makeCurrent(offscreenSurface); | - | ||||||||||||||||||
293 | - | |||||||||||||||||||
294 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
295 | return executed 8 times by 1 test: renderControl->grab();return renderControl->grab(); Executed by:
executed 8 times by 1 test: return renderControl->grab(); Executed by:
| 8 | ||||||||||||||||||
296 | } | - | ||||||||||||||||||
297 | QQuickWidget::QQuickWidget(QWidget *parent) | - | ||||||||||||||||||
298 | : QWidget(*(new QQuickWidgetPrivate), parent, nullptr) | - | ||||||||||||||||||
299 | { | - | ||||||||||||||||||
300 | setMouseTracking(true); | - | ||||||||||||||||||
301 | setFocusPolicy(Qt::StrongFocus); | - | ||||||||||||||||||
302 | d_func()->init(); | - | ||||||||||||||||||
303 | } executed 114 times by 2 tests: end of block Executed by:
| 114 | ||||||||||||||||||
304 | - | |||||||||||||||||||
305 | - | |||||||||||||||||||
306 | - | |||||||||||||||||||
307 | - | |||||||||||||||||||
308 | - | |||||||||||||||||||
309 | - | |||||||||||||||||||
310 | QQuickWidget::QQuickWidget(const QUrl &source, QWidget *parent) | - | ||||||||||||||||||
311 | : QQuickWidget(parent) | - | ||||||||||||||||||
312 | { | - | ||||||||||||||||||
313 | setSource(source); | - | ||||||||||||||||||
314 | } never executed: end of block | 0 | ||||||||||||||||||
315 | QQuickWidget::QQuickWidget(QQmlEngine* engine, QWidget *parent) | - | ||||||||||||||||||
316 | : QWidget(*(new QQuickWidgetPrivate), parent, nullptr) | - | ||||||||||||||||||
317 | { | - | ||||||||||||||||||
318 | setMouseTracking(true); | - | ||||||||||||||||||
319 | setFocusPolicy(Qt::StrongFocus); | - | ||||||||||||||||||
320 | d_func()->init(engine); | - | ||||||||||||||||||
321 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
322 | - | |||||||||||||||||||
323 | - | |||||||||||||||||||
324 | - | |||||||||||||||||||
325 | - | |||||||||||||||||||
326 | QQuickWidget::~QQuickWidget() | - | ||||||||||||||||||
327 | { | - | ||||||||||||||||||
328 | - | |||||||||||||||||||
329 | - | |||||||||||||||||||
330 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
331 | delete d->root; | - | ||||||||||||||||||
332 | d->root = nullptr; | - | ||||||||||||||||||
333 | } executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||||||||||||||
334 | void QQuickWidget::setSource(const QUrl& url) | - | ||||||||||||||||||
335 | { | - | ||||||||||||||||||
336 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
337 | d->source = url; | - | ||||||||||||||||||
338 | d->execute(); | - | ||||||||||||||||||
339 | } executed 102 times by 2 tests: end of block Executed by:
| 102 | ||||||||||||||||||
340 | - | |||||||||||||||||||
341 | - | |||||||||||||||||||
342 | - | |||||||||||||||||||
343 | - | |||||||||||||||||||
344 | - | |||||||||||||||||||
345 | - | |||||||||||||||||||
346 | void QQuickWidget::setContent(const QUrl& url, QQmlComponent *component, QObject* item) | - | ||||||||||||||||||
347 | { | - | ||||||||||||||||||
348 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
349 | d->source = url; | - | ||||||||||||||||||
350 | d->component = component; | - | ||||||||||||||||||
351 | - | |||||||||||||||||||
352 | if (d->component
| 0-8 | ||||||||||||||||||
353 | const QList<QQmlError> errorList = d->component->errors(); | - | ||||||||||||||||||
354 | for (const QQmlError &error : errorList) { | - | ||||||||||||||||||
355 | QMessageLogger(error.url().toString().toLatin1().constData(), error.line(), nullptr).warning() | - | ||||||||||||||||||
356 | << error; | - | ||||||||||||||||||
357 | } never executed: end of block | 0 | ||||||||||||||||||
358 | statusChanged(status()); | - | ||||||||||||||||||
359 | return; never executed: return; | 0 | ||||||||||||||||||
360 | } | - | ||||||||||||||||||
361 | - | |||||||||||||||||||
362 | d->setRootObject(item); | - | ||||||||||||||||||
363 | statusChanged(status()); | - | ||||||||||||||||||
364 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | - | |||||||||||||||||||
367 | - | |||||||||||||||||||
368 | - | |||||||||||||||||||
369 | - | |||||||||||||||||||
370 | - | |||||||||||||||||||
371 | QUrl QQuickWidget::source() const | - | ||||||||||||||||||
372 | { | - | ||||||||||||||||||
373 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
374 | return never executed: d->source;return d->source; never executed: return d->source; | 0 | ||||||||||||||||||
375 | } | - | ||||||||||||||||||
376 | - | |||||||||||||||||||
377 | - | |||||||||||||||||||
378 | - | |||||||||||||||||||
379 | - | |||||||||||||||||||
380 | - | |||||||||||||||||||
381 | QQmlEngine* QQuickWidget::engine() const | - | ||||||||||||||||||
382 | { | - | ||||||||||||||||||
383 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
384 | d->ensureEngine(); | - | ||||||||||||||||||
385 | return executed 12 times by 1 test: const_cast<QQmlEngine *>(d->engine.data());return const_cast<QQmlEngine *>(d->engine.data()); Executed by:
executed 12 times by 1 test: return const_cast<QQmlEngine *>(d->engine.data()); Executed by:
| 12 | ||||||||||||||||||
386 | } | - | ||||||||||||||||||
387 | QQmlContext* QQuickWidget::rootContext() const | - | ||||||||||||||||||
388 | { | - | ||||||||||||||||||
389 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
390 | d->ensureEngine(); | - | ||||||||||||||||||
391 | return executed 2 times by 1 test: d->engine.data()->rootContext();return d->engine.data()->rootContext(); Executed by:
executed 2 times by 1 test: return d->engine.data()->rootContext(); Executed by:
| 2 | ||||||||||||||||||
392 | } | - | ||||||||||||||||||
393 | QQuickWidget::Status QQuickWidget::status() const | - | ||||||||||||||||||
394 | { | - | ||||||||||||||||||
395 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
396 | if (!d->engine
| 0-104 | ||||||||||||||||||
397 | return never executed: QQuickWidget::Error;return QQuickWidget::Error; never executed: return QQuickWidget::Error; | 0 | ||||||||||||||||||
398 | - | |||||||||||||||||||
399 | if (!d->component
| 10-104 | ||||||||||||||||||
400 | return executed 10 times by 1 test: QQuickWidget::Null;return QQuickWidget::Null; Executed by:
executed 10 times by 1 test: return QQuickWidget::Null; Executed by:
| 10 | ||||||||||||||||||
401 | - | |||||||||||||||||||
402 | if (d->component->status() == QQmlComponent::Ready
| 0-100 | ||||||||||||||||||
403 | return never executed: QQuickWidget::Error;return QQuickWidget::Error; never executed: return QQuickWidget::Error; | 0 | ||||||||||||||||||
404 | - | |||||||||||||||||||
405 | return executed 104 times by 2 tests: QQuickWidget::Status(d->component->status());return QQuickWidget::Status(d->component->status()); Executed by:
executed 104 times by 2 tests: return QQuickWidget::Status(d->component->status()); Executed by:
| 104 | ||||||||||||||||||
406 | } | - | ||||||||||||||||||
407 | - | |||||||||||||||||||
408 | - | |||||||||||||||||||
409 | - | |||||||||||||||||||
410 | - | |||||||||||||||||||
411 | - | |||||||||||||||||||
412 | - | |||||||||||||||||||
413 | - | |||||||||||||||||||
414 | QList<QQmlError> QQuickWidget::errors() const | - | ||||||||||||||||||
415 | { | - | ||||||||||||||||||
416 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
417 | QList<QQmlError> errs; | - | ||||||||||||||||||
418 | - | |||||||||||||||||||
419 | if (d->component
| 2-4 | ||||||||||||||||||
420 | errs = d->component->errors(); executed 2 times by 1 test: errs = d->component->errors(); Executed by:
| 2 | ||||||||||||||||||
421 | - | |||||||||||||||||||
422 | if (!d->engine
| 0-4 | ||||||||||||||||||
423 | QQmlError error; | - | ||||||||||||||||||
424 | error.setDescription(QLatin1String("QQuickWidget: invalid qml engine.")); | - | ||||||||||||||||||
425 | errs << error; | - | ||||||||||||||||||
426 | } never executed: end of block | 0 | ||||||||||||||||||
427 | if (d->component
| 0-4 | ||||||||||||||||||
428 | QQmlError error; | - | ||||||||||||||||||
429 | error.setDescription(QLatin1String("QQuickWidget: invalid root object.")); | - | ||||||||||||||||||
430 | errs << error; | - | ||||||||||||||||||
431 | } never executed: end of block | 0 | ||||||||||||||||||
432 | - | |||||||||||||||||||
433 | return executed 6 times by 1 test: errs;return errs; Executed by:
executed 6 times by 1 test: return errs; Executed by:
| 6 | ||||||||||||||||||
434 | } | - | ||||||||||||||||||
435 | void QQuickWidget::setResizeMode(ResizeMode mode) | - | ||||||||||||||||||
436 | { | - | ||||||||||||||||||
437 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
438 | if (d->resizeMode == mode
| 4-8 | ||||||||||||||||||
439 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||
440 | - | |||||||||||||||||||
441 | if (d->root
| 4 | ||||||||||||||||||
442 | if (d->resizeMode == SizeViewToRootObject
| 2 | ||||||||||||||||||
443 | QQuickItemPrivate *p = QQuickItemPrivate::get(d->root); | - | ||||||||||||||||||
444 | p->removeItemChangeListener(d, QQuickItemPrivate::Geometry); | - | ||||||||||||||||||
445 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
446 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
447 | - | |||||||||||||||||||
448 | d->resizeMode = mode; | - | ||||||||||||||||||
449 | if (d->root
| 4 | ||||||||||||||||||
450 | d->initResize(); | - | ||||||||||||||||||
451 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||
452 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||||||||
453 | - | |||||||||||||||||||
454 | void QQuickWidgetPrivate::initResize() | - | ||||||||||||||||||
455 | { | - | ||||||||||||||||||
456 | if (root
| 0-112 | ||||||||||||||||||
457 | if (resizeMode == QQuickWidget::SizeViewToRootObject
| 6-106 | ||||||||||||||||||
458 | QQuickItemPrivate *p = QQuickItemPrivate::get(root); | - | ||||||||||||||||||
459 | p->addItemChangeListener(this, QQuickItemPrivate::Geometry); | - | ||||||||||||||||||
460 | } executed 106 times by 2 tests: end of block Executed by:
| 106 | ||||||||||||||||||
461 | } executed 112 times by 2 tests: end of block Executed by:
| 112 | ||||||||||||||||||
462 | updateSize(); | - | ||||||||||||||||||
463 | } executed 112 times by 2 tests: end of block Executed by:
| 112 | ||||||||||||||||||
464 | - | |||||||||||||||||||
465 | void QQuickWidgetPrivate::updateSize() | - | ||||||||||||||||||
466 | { | - | ||||||||||||||||||
467 | QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
468 | if (!root
| 0-126 | ||||||||||||||||||
469 | return; never executed: return; | 0 | ||||||||||||||||||
470 | - | |||||||||||||||||||
471 | if (resizeMode == QQuickWidget::SizeViewToRootObject
| 14-112 | ||||||||||||||||||
472 | QSize newSize = QSize(root->width(), root->height()); | - | ||||||||||||||||||
473 | if (newSize.isValid()
| 0-112 | ||||||||||||||||||
474 | q->resize(newSize); | - | ||||||||||||||||||
475 | q->updateGeometry(); | - | ||||||||||||||||||
476 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||
477 | } executed 112 times by 2 tests: else if (resizeMode == QQuickWidget::SizeRootObjectToViewend of block Executed by:
| 0-112 | ||||||||||||||||||
478 | bool needToUpdateWidth = !qFuzzyCompare(q->width(), root->width()); | - | ||||||||||||||||||
479 | bool needToUpdateHeight = !qFuzzyCompare(q->height(), root->height()); | - | ||||||||||||||||||
480 | - | |||||||||||||||||||
481 | if (needToUpdateWidth
| 0-8 | ||||||||||||||||||
482 | root->setSize(QSizeF(q->width(), q->height())); executed 6 times by 1 test: root->setSize(QSizeF(q->width(), q->height())); Executed by:
| 6 | ||||||||||||||||||
483 | else if (needToUpdateWidth
| 0-8 | ||||||||||||||||||
484 | root->setWidth(q->width()); never executed: root->setWidth(q->width()); | 0 | ||||||||||||||||||
485 | else if (needToUpdateHeight
| 0-8 | ||||||||||||||||||
486 | root->setHeight(q->height()); never executed: root->setHeight(q->height()); | 0 | ||||||||||||||||||
487 | } executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||
488 | } executed 126 times by 2 tests: end of block Executed by:
| 126 | ||||||||||||||||||
489 | - | |||||||||||||||||||
490 | - | |||||||||||||||||||
491 | - | |||||||||||||||||||
492 | - | |||||||||||||||||||
493 | - | |||||||||||||||||||
494 | - | |||||||||||||||||||
495 | void QQuickWidgetPrivate::updatePosition() | - | ||||||||||||||||||
496 | { | - | ||||||||||||||||||
497 | QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
498 | if (offscreenWindow == nullptr
| 0-222 | ||||||||||||||||||
499 | return; never executed: return; | 0 | ||||||||||||||||||
500 | - | |||||||||||||||||||
501 | const QPoint &pos = q->mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
502 | if (offscreenWindow->position() != pos
| 8-214 | ||||||||||||||||||
503 | offscreenWindow->setPosition(pos); executed 8 times by 1 test: offscreenWindow->setPosition(pos); Executed by:
| 8 | ||||||||||||||||||
504 | } executed 222 times by 2 tests: end of block Executed by:
| 222 | ||||||||||||||||||
505 | - | |||||||||||||||||||
506 | QSize QQuickWidgetPrivate::rootObjectSize() const | - | ||||||||||||||||||
507 | { | - | ||||||||||||||||||
508 | QSize rootObjectSize(0,0); | - | ||||||||||||||||||
509 | int widthCandidate = -1; | - | ||||||||||||||||||
510 | int heightCandidate = -1; | - | ||||||||||||||||||
511 | if (root
| 2-128 | ||||||||||||||||||
512 | widthCandidate = root->width(); | - | ||||||||||||||||||
513 | heightCandidate = root->height(); | - | ||||||||||||||||||
514 | } executed 128 times by 2 tests: end of block Executed by:
| 128 | ||||||||||||||||||
515 | if (widthCandidate > 0
| 6-124 | ||||||||||||||||||
516 | rootObjectSize.setWidth(widthCandidate); | - | ||||||||||||||||||
517 | } executed 124 times by 2 tests: end of block Executed by:
| 124 | ||||||||||||||||||
518 | if (heightCandidate > 0
| 6-124 | ||||||||||||||||||
519 | rootObjectSize.setHeight(heightCandidate); | - | ||||||||||||||||||
520 | } executed 124 times by 2 tests: end of block Executed by:
| 124 | ||||||||||||||||||
521 | return executed 130 times by 2 tests: rootObjectSize;return rootObjectSize; Executed by:
executed 130 times by 2 tests: return rootObjectSize; Executed by:
| 130 | ||||||||||||||||||
522 | } | - | ||||||||||||||||||
523 | - | |||||||||||||||||||
524 | void QQuickWidgetPrivate::handleContextCreationFailure(const QSurfaceFormat &format, bool isEs) | - | ||||||||||||||||||
525 | { | - | ||||||||||||||||||
526 | QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
527 | - | |||||||||||||||||||
528 | QString translatedMessage; | - | ||||||||||||||||||
529 | QString untranslatedMessage; | - | ||||||||||||||||||
530 | QQuickWindowPrivate::contextCreationFailureMessage(format, &translatedMessage, &untranslatedMessage, isEs); | - | ||||||||||||||||||
531 | - | |||||||||||||||||||
532 | static const QMetaMethod errorSignal = QMetaMethod::fromSignal(&QQuickWidget::sceneGraphError); | - | ||||||||||||||||||
533 | const bool signalConnected = q->isSignalConnected(errorSignal); | - | ||||||||||||||||||
534 | if (signalConnected
| 0 | ||||||||||||||||||
535 | q->sceneGraphError(QQuickWindow::ContextNotAvailable, translatedMessage); never executed: q->sceneGraphError(QQuickWindow::ContextNotAvailable, translatedMessage); | 0 | ||||||||||||||||||
536 | - | |||||||||||||||||||
537 | - | |||||||||||||||||||
538 | - | |||||||||||||||||||
539 | - | |||||||||||||||||||
540 | - | |||||||||||||||||||
541 | if (!signalConnected
| 0 | ||||||||||||||||||
542 | QMessageLogger(__FILE__, 850, __PRETTY_FUNCTION__).fatal("%s", QtPrivate::asString(untranslatedMessage).toLocal8Bit().constData()); never executed: QMessageLogger(__FILE__, 850, __PRETTY_FUNCTION__).fatal("%s", QtPrivate::asString(untranslatedMessage).toLocal8Bit().constData()); | 0 | ||||||||||||||||||
543 | } never executed: end of block | 0 | ||||||||||||||||||
544 | - | |||||||||||||||||||
545 | - | |||||||||||||||||||
546 | void QQuickWidgetPrivate::createContext() | - | ||||||||||||||||||
547 | { | - | ||||||||||||||||||
548 | - | |||||||||||||||||||
549 | QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
550 | - | |||||||||||||||||||
551 | - | |||||||||||||||||||
552 | - | |||||||||||||||||||
553 | const bool reinit = context
| 0-112 | ||||||||||||||||||
554 | - | |||||||||||||||||||
555 | if (!reinit
| 0-214 | ||||||||||||||||||
556 | if (context
| 102-112 | ||||||||||||||||||
557 | return; executed 102 times by 2 tests: return; Executed by:
| 102 | ||||||||||||||||||
558 | - | |||||||||||||||||||
559 | context = new QOpenGLContext; | - | ||||||||||||||||||
560 | context->setFormat(offscreenWindow->requestedFormat()); | - | ||||||||||||||||||
561 | - | |||||||||||||||||||
562 | QOpenGLContext *shareContext = qt_gl_global_share_context(); | - | ||||||||||||||||||
563 | if (!shareContext
| 0-112 | ||||||||||||||||||
564 | shareContext = QWidgetPrivate::get(q->window())->shareContext(); executed 112 times by 2 tests: shareContext = QWidgetPrivate::get(q->window())->shareContext(); Executed by:
| 112 | ||||||||||||||||||
565 | if (shareContext
| 4-108 | ||||||||||||||||||
566 | context->setShareContext(shareContext); | - | ||||||||||||||||||
567 | context->setScreen(shareContext->screen()); | - | ||||||||||||||||||
568 | } executed 108 times by 2 tests: end of block Executed by:
| 108 | ||||||||||||||||||
569 | if (!context->create()
| 0-112 | ||||||||||||||||||
570 | const bool isEs = context->isOpenGLES(); | - | ||||||||||||||||||
571 | delete context; | - | ||||||||||||||||||
572 | context = nullptr; | - | ||||||||||||||||||
573 | handleContextCreationFailure(offscreenWindow->requestedFormat(), isEs); | - | ||||||||||||||||||
574 | return; never executed: return; | 0 | ||||||||||||||||||
575 | } | - | ||||||||||||||||||
576 | - | |||||||||||||||||||
577 | offscreenSurface = new QOffscreenSurface; | - | ||||||||||||||||||
578 | - | |||||||||||||||||||
579 | - | |||||||||||||||||||
580 | - | |||||||||||||||||||
581 | offscreenSurface->setFormat(context->format()); | - | ||||||||||||||||||
582 | offscreenSurface->setScreen(context->screen()); | - | ||||||||||||||||||
583 | offscreenSurface->create(); | - | ||||||||||||||||||
584 | } executed 112 times by 2 tests: end of block Executed by:
| 112 | ||||||||||||||||||
585 | - | |||||||||||||||||||
586 | if (context->makeCurrent(offscreenSurface)
| 0-112 | ||||||||||||||||||
587 | if (!offscreenWindow->openglContext()
| 0-112 | ||||||||||||||||||
588 | renderControl->initialize(context); executed 112 times by 2 tests: renderControl->initialize(context); Executed by:
| 112 | ||||||||||||||||||
589 | } executed 112 times by 2 tests: elseend of block Executed by:
| 112 | ||||||||||||||||||
590 | - | |||||||||||||||||||
591 | QMessageLogger(__FILE__, 899, __PRETTY_FUNCTION__).warning("QQuickWidget: Failed to make context current"); never executed: QMessageLogger(__FILE__, 899, __PRETTY_FUNCTION__).warning("QQuickWidget: Failed to make context current"); | 0 | ||||||||||||||||||
592 | } | - | ||||||||||||||||||
593 | - | |||||||||||||||||||
594 | - | |||||||||||||||||||
595 | void QQuickWidgetPrivate::destroyContext() | - | ||||||||||||||||||
596 | { | - | ||||||||||||||||||
597 | delete offscreenSurface; | - | ||||||||||||||||||
598 | offscreenSurface = nullptr; | - | ||||||||||||||||||
599 | - | |||||||||||||||||||
600 | delete context; | - | ||||||||||||||||||
601 | context = nullptr; | - | ||||||||||||||||||
602 | - | |||||||||||||||||||
603 | } executed 126 times by 2 tests: end of block Executed by:
| 126 | ||||||||||||||||||
604 | - | |||||||||||||||||||
605 | void QQuickWidget::createFramebufferObject() | - | ||||||||||||||||||
606 | { | - | ||||||||||||||||||
607 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
608 | - | |||||||||||||||||||
609 | - | |||||||||||||||||||
610 | - | |||||||||||||||||||
611 | if (size().isEmpty()
| 4-124 | ||||||||||||||||||
612 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||
613 | - | |||||||||||||||||||
614 | - | |||||||||||||||||||
615 | - | |||||||||||||||||||
616 | - | |||||||||||||||||||
617 | const QPoint &globalPos = mapToGlobal(QPoint(0, 0)); | - | ||||||||||||||||||
618 | d->offscreenWindow->setGeometry(globalPos.x(), globalPos.y(), width(), height()); | - | ||||||||||||||||||
619 | - | |||||||||||||||||||
620 | if (d->useSoftwareRenderer
| 0-124 | ||||||||||||||||||
621 | const QSize imageSize = size() * devicePixelRatioF(); | - | ||||||||||||||||||
622 | d->softwareImage = QImage(imageSize, QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||||||||
623 | d->softwareImage.setDevicePixelRatio(devicePixelRatioF()); | - | ||||||||||||||||||
624 | d->forceFullUpdate = true; | - | ||||||||||||||||||
625 | return; never executed: return; | 0 | ||||||||||||||||||
626 | } | - | ||||||||||||||||||
627 | - | |||||||||||||||||||
628 | - | |||||||||||||||||||
629 | QOpenGLContext *context = d->offscreenWindow->openglContext(); | - | ||||||||||||||||||
630 | - | |||||||||||||||||||
631 | if (!context
| 0-124 | ||||||||||||||||||
632 | QMessageLogger(__FILE__, 940, __PRETTY_FUNCTION__).warning("QQuickWidget: Attempted to create FBO with no context"); | - | ||||||||||||||||||
633 | return; never executed: return; | 0 | ||||||||||||||||||
634 | } | - | ||||||||||||||||||
635 | - | |||||||||||||||||||
636 | QOpenGLContext *shareWindowContext = QWidgetPrivate::get(window())->shareContext(); | - | ||||||||||||||||||
637 | if (shareWindowContext
| 0-120 | ||||||||||||||||||
638 | context->setShareContext(shareWindowContext); | - | ||||||||||||||||||
639 | context->setScreen(shareWindowContext->screen()); | - | ||||||||||||||||||
640 | if (!context->create()
| 0 | ||||||||||||||||||
641 | QMessageLogger(__FILE__, 949, __PRETTY_FUNCTION__).warning("QQuickWidget: Failed to recreate context"); never executed: QMessageLogger(__FILE__, 949, __PRETTY_FUNCTION__).warning("QQuickWidget: Failed to recreate context"); | 0 | ||||||||||||||||||
642 | - | |||||||||||||||||||
643 | - | |||||||||||||||||||
644 | d->offscreenSurface->destroy(); | - | ||||||||||||||||||
645 | d->offscreenSurface->setScreen(context->screen()); | - | ||||||||||||||||||
646 | d->offscreenSurface->create(); | - | ||||||||||||||||||
647 | } never executed: end of block | 0 | ||||||||||||||||||
648 | - | |||||||||||||||||||
649 | context->makeCurrent(d->offscreenSurface); | - | ||||||||||||||||||
650 | - | |||||||||||||||||||
651 | int samples = d->requestedSamples; | - | ||||||||||||||||||
652 | if (!QOpenGLExtensions(context).hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
| 0-124 | ||||||||||||||||||
653 | samples = 0; never executed: samples = 0; | 0 | ||||||||||||||||||
654 | - | |||||||||||||||||||
655 | QOpenGLFramebufferObjectFormat format; | - | ||||||||||||||||||
656 | format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); | - | ||||||||||||||||||
657 | format.setSamples(samples); | - | ||||||||||||||||||
658 | const QSize fboSize = size() * devicePixelRatioF(); | - | ||||||||||||||||||
659 | - | |||||||||||||||||||
660 | - | |||||||||||||||||||
661 | if (!d->fbo
| 0-108 | ||||||||||||||||||
662 | delete d->fbo; | - | ||||||||||||||||||
663 | d->fbo = new QOpenGLFramebufferObject(fboSize, format); | - | ||||||||||||||||||
664 | } executed 124 times by 2 tests: end of block Executed by:
| 124 | ||||||||||||||||||
665 | d->offscreenWindow->setRenderTarget(d->fbo); | - | ||||||||||||||||||
666 | - | |||||||||||||||||||
667 | if (samples > 0
| 0-124 | ||||||||||||||||||
668 | d->resolvedFbo = new QOpenGLFramebufferObject(fboSize); never executed: d->resolvedFbo = new QOpenGLFramebufferObject(fboSize); | 0 | ||||||||||||||||||
669 | - | |||||||||||||||||||
670 | - | |||||||||||||||||||
671 | - | |||||||||||||||||||
672 | - | |||||||||||||||||||
673 | ((!d->offscreenWindow->handle()) ? static_cast<void>(0) : qt_assert("!d->offscreenWindow->handle()", __FILE__, 1004)); | - | ||||||||||||||||||
674 | - | |||||||||||||||||||
675 | } executed 124 times by 2 tests: end of block Executed by:
| 124 | ||||||||||||||||||
676 | - | |||||||||||||||||||
677 | void QQuickWidget::destroyFramebufferObject() | - | ||||||||||||||||||
678 | { | - | ||||||||||||||||||
679 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
680 | - | |||||||||||||||||||
681 | if (d->useSoftwareRenderer
| 0-2 | ||||||||||||||||||
682 | d->softwareImage = QImage(); | - | ||||||||||||||||||
683 | return; never executed: return; | 0 | ||||||||||||||||||
684 | } | - | ||||||||||||||||||
685 | - | |||||||||||||||||||
686 | - | |||||||||||||||||||
687 | delete d->fbo; | - | ||||||||||||||||||
688 | d->fbo = nullptr; | - | ||||||||||||||||||
689 | delete d->resolvedFbo; | - | ||||||||||||||||||
690 | d->resolvedFbo = nullptr; | - | ||||||||||||||||||
691 | - | |||||||||||||||||||
692 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
693 | - | |||||||||||||||||||
694 | QQuickWidget::ResizeMode QQuickWidget::resizeMode() const | - | ||||||||||||||||||
695 | { | - | ||||||||||||||||||
696 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
697 | return never executed: d->resizeMode;return d->resizeMode; never executed: return d->resizeMode; | 0 | ||||||||||||||||||
698 | } | - | ||||||||||||||||||
699 | - | |||||||||||||||||||
700 | - | |||||||||||||||||||
701 | - | |||||||||||||||||||
702 | - | |||||||||||||||||||
703 | void QQuickWidget::continueExecute() | - | ||||||||||||||||||
704 | { | - | ||||||||||||||||||
705 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
706 | disconnect(d->component, qFlagLocation("2""statusChanged(QQmlComponent::Status)" "\0" __FILE__ ":" "1037"), this, qFlagLocation("1""continueExecute()" "\0" __FILE__ ":" "1037")); | - | ||||||||||||||||||
707 | - | |||||||||||||||||||
708 | if (d->component->isError()
| 2-100 | ||||||||||||||||||
709 | const QList<QQmlError> errorList = d->component->errors(); | - | ||||||||||||||||||
710 | for (const QQmlError &error : errorList) { | - | ||||||||||||||||||
711 | QMessageLogger(error.url().toString().toLatin1().constData(), error.line(), nullptr).warning() | - | ||||||||||||||||||
712 | << error; | - | ||||||||||||||||||
713 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
714 | statusChanged(status()); | - | ||||||||||||||||||
715 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||||||||||||||
716 | } | - | ||||||||||||||||||
717 | - | |||||||||||||||||||
718 | QObject *obj = d->component->create(); | - | ||||||||||||||||||
719 | - | |||||||||||||||||||
720 | if (d->component->isError()
| 0-100 | ||||||||||||||||||
721 | const QList<QQmlError> errorList = d->component->errors(); | - | ||||||||||||||||||
722 | for (const QQmlError &error : errorList) { | - | ||||||||||||||||||
723 | QMessageLogger(error.url().toString().toLatin1().constData(), error.line(), nullptr).warning() | - | ||||||||||||||||||
724 | << error; | - | ||||||||||||||||||
725 | } never executed: end of block | 0 | ||||||||||||||||||
726 | statusChanged(status()); | - | ||||||||||||||||||
727 | return; never executed: return; | 0 | ||||||||||||||||||
728 | } | - | ||||||||||||||||||
729 | - | |||||||||||||||||||
730 | d->setRootObject(obj); | - | ||||||||||||||||||
731 | statusChanged(status()); | - | ||||||||||||||||||
732 | } executed 100 times by 2 tests: end of block Executed by:
| 100 | ||||||||||||||||||
733 | - | |||||||||||||||||||
734 | - | |||||||||||||||||||
735 | - | |||||||||||||||||||
736 | - | |||||||||||||||||||
737 | - | |||||||||||||||||||
738 | void QQuickWidgetPrivate::setRootObject(QObject *obj) | - | ||||||||||||||||||
739 | { | - | ||||||||||||||||||
740 | QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
741 | if (root == obj
| 0-108 | ||||||||||||||||||
742 | return; never executed: return; | 0 | ||||||||||||||||||
743 | if (QQuickItem *sgItem = qobject_cast<QQuickItem *>(obj)
| 0-108 | ||||||||||||||||||
744 | root = sgItem; | - | ||||||||||||||||||
745 | sgItem->setParentItem(offscreenWindow->contentItem()); | - | ||||||||||||||||||
746 | } executed 108 times by 2 tests: else if (qobject_cast<QWindow *>(obj)end of block Executed by:
| 0-108 | ||||||||||||||||||
747 | QMessageLogger(__FILE__, 1078, __PRETTY_FUNCTION__).warning() << "QQuickWidget does not support using windows as a root item." << endl | - | ||||||||||||||||||
748 | << endl | - | ||||||||||||||||||
749 | << "If you wish to create your root window from QML, consider using QQmlApplicationEngine instead." << endl; | - | ||||||||||||||||||
750 | } never executed: else {end of block | 0 | ||||||||||||||||||
751 | QMessageLogger(__FILE__, 1082, __PRETTY_FUNCTION__).warning() << "QQuickWidget only supports loading of root objects that derive from QQuickItem." << endl | - | ||||||||||||||||||
752 | << endl | - | ||||||||||||||||||
753 | << "Ensure your QML code is written for QtQuick 2, and uses a root that is or" << endl | - | ||||||||||||||||||
754 | << "inherits from QtQuick's Item (not a Timer, QtObject, etc)." << endl; | - | ||||||||||||||||||
755 | delete obj; | - | ||||||||||||||||||
756 | root = nullptr; | - | ||||||||||||||||||
757 | } never executed: end of block | 0 | ||||||||||||||||||
758 | if (root
| 0-108 | ||||||||||||||||||
759 | initialSize = rootObjectSize(); | - | ||||||||||||||||||
760 | bool resized = q->testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||
761 | if ((resizeMode == QQuickWidget::SizeViewToRootObject
| 2-104 | ||||||||||||||||||
762 | initialSize != q->size()
| 42-64 | ||||||||||||||||||
763 | q->resize(initialSize); | - | ||||||||||||||||||
764 | } executed 42 times by 1 test: end of block Executed by:
| 42 | ||||||||||||||||||
765 | initResize(); | - | ||||||||||||||||||
766 | } executed 108 times by 2 tests: end of block Executed by:
| 108 | ||||||||||||||||||
767 | } executed 108 times by 2 tests: end of block Executed by:
| 108 | ||||||||||||||||||
768 | - | |||||||||||||||||||
769 | - | |||||||||||||||||||
770 | uint QQuickWidgetPrivate::textureId() const | - | ||||||||||||||||||
771 | { | - | ||||||||||||||||||
772 | const QQuickWidget * const q = q_func(); | - | ||||||||||||||||||
773 | if (!q->isWindow()
| 0-148 | ||||||||||||||||||
774 | QMessageLogger(__FILE__, 1105, __PRETTY_FUNCTION__).warning() << "QQuickWidget cannot be used as a native child widget." | - | ||||||||||||||||||
775 | << "Consider setting Qt::AA_DontCreateNativeWidgetSiblings"; | - | ||||||||||||||||||
776 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
777 | } | - | ||||||||||||||||||
778 | return executed 198 times by 2 tests: resolvedFbo ? resolvedFbo->texture()return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0); Executed by:
executed 198 times by 2 tests: return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0); Executed by:
| 198 | ||||||||||||||||||
779 | : (fbo ? fbo->texture() : 0); executed 198 times by 2 tests: return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0); Executed by:
| 198 | ||||||||||||||||||
780 | } | - | ||||||||||||||||||
781 | - | |||||||||||||||||||
782 | - | |||||||||||||||||||
783 | - | |||||||||||||||||||
784 | - | |||||||||||||||||||
785 | - | |||||||||||||||||||
786 | - | |||||||||||||||||||
787 | void QQuickWidget::timerEvent(QTimerEvent* e) | - | ||||||||||||||||||
788 | { | - | ||||||||||||||||||
789 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
790 | if (!e
| 0-108 | ||||||||||||||||||
791 | d->updateSize(); | - | ||||||||||||||||||
792 | d->resizetimer.stop(); | - | ||||||||||||||||||
793 | } executed 6 times by 1 test: else if (e->timerId() == d->updateTimer.timerId()end of block Executed by:
| 0-102 | ||||||||||||||||||
794 | d->eventPending = false; | - | ||||||||||||||||||
795 | d->updateTimer.stop(); | - | ||||||||||||||||||
796 | if (d->updatePending
| 0-102 | ||||||||||||||||||
797 | d->renderSceneGraph(); executed 102 times by 2 tests: d->renderSceneGraph(); Executed by:
| 102 | ||||||||||||||||||
798 | } executed 102 times by 2 tests: end of block Executed by:
| 102 | ||||||||||||||||||
799 | } executed 108 times by 2 tests: end of block Executed by:
| 108 | ||||||||||||||||||
800 | - | |||||||||||||||||||
801 | - | |||||||||||||||||||
802 | - | |||||||||||||||||||
803 | - | |||||||||||||||||||
804 | - | |||||||||||||||||||
805 | QSize QQuickWidget::sizeHint() const | - | ||||||||||||||||||
806 | { | - | ||||||||||||||||||
807 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
808 | QSize rootObjectSize = d->rootObjectSize(); | - | ||||||||||||||||||
809 | if (rootObjectSize.isEmpty()
| 2-20 | ||||||||||||||||||
810 | return executed 2 times by 1 test: size();return size(); Executed by:
executed 2 times by 1 test: return size(); Executed by:
| 2 | ||||||||||||||||||
811 | } else { | - | ||||||||||||||||||
812 | return executed 20 times by 1 test: rootObjectSize;return rootObjectSize; Executed by:
executed 20 times by 1 test: return rootObjectSize; Executed by:
| 20 | ||||||||||||||||||
813 | } | - | ||||||||||||||||||
814 | } | - | ||||||||||||||||||
815 | QSize QQuickWidget::initialSize() const | - | ||||||||||||||||||
816 | { | - | ||||||||||||||||||
817 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
818 | return executed 12 times by 1 test: d->initialSize;return d->initialSize; Executed by:
executed 12 times by 1 test: return d->initialSize; Executed by:
| 12 | ||||||||||||||||||
819 | } | - | ||||||||||||||||||
820 | - | |||||||||||||||||||
821 | - | |||||||||||||||||||
822 | - | |||||||||||||||||||
823 | - | |||||||||||||||||||
824 | - | |||||||||||||||||||
825 | - | |||||||||||||||||||
826 | QQuickItem *QQuickWidget::rootObject() const | - | ||||||||||||||||||
827 | { | - | ||||||||||||||||||
828 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
829 | return executed 12 times by 1 test: d->root;return d->root; Executed by:
executed 12 times by 1 test: return d->root; Executed by:
| 12 | ||||||||||||||||||
830 | } | - | ||||||||||||||||||
831 | - | |||||||||||||||||||
832 | - | |||||||||||||||||||
833 | - | |||||||||||||||||||
834 | - | |||||||||||||||||||
835 | - | |||||||||||||||||||
836 | - | |||||||||||||||||||
837 | void QQuickWidget::resizeEvent(QResizeEvent *e) | - | ||||||||||||||||||
838 | { | - | ||||||||||||||||||
839 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
840 | if (d->resizeMode == SizeRootObjectToView
| 8-122 | ||||||||||||||||||
841 | d->updateSize(); executed 8 times by 1 test: d->updateSize(); Executed by:
| 8 | ||||||||||||||||||
842 | - | |||||||||||||||||||
843 | if (e->size().isEmpty()
| 4-126 | ||||||||||||||||||
844 | - | |||||||||||||||||||
845 | d->fakeHidden = true; | - | ||||||||||||||||||
846 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||
847 | } | - | ||||||||||||||||||
848 | - | |||||||||||||||||||
849 | bool needsSync = false; | - | ||||||||||||||||||
850 | if (d->fakeHidden
| 0-126 | ||||||||||||||||||
851 | - | |||||||||||||||||||
852 | d->fakeHidden = false; | - | ||||||||||||||||||
853 | needsSync = true; | - | ||||||||||||||||||
854 | } never executed: end of block | 0 | ||||||||||||||||||
855 | - | |||||||||||||||||||
856 | - | |||||||||||||||||||
857 | if (d->useSoftwareRenderer
| 0-126 | ||||||||||||||||||
858 | needsSync = true; | - | ||||||||||||||||||
859 | if (d->softwareImage.size() != size() * devicePixelRatioF()
| 0 | ||||||||||||||||||
860 | createFramebufferObject(); | - | ||||||||||||||||||
861 | } never executed: end of block | 0 | ||||||||||||||||||
862 | } never executed: else {end of block | 0 | ||||||||||||||||||
863 | - | |||||||||||||||||||
864 | if (d->context
| 20-106 | ||||||||||||||||||
865 | - | |||||||||||||||||||
866 | - | |||||||||||||||||||
867 | if (!d->fbo
| 0-20 | ||||||||||||||||||
868 | return; never executed: return; | 0 | ||||||||||||||||||
869 | if (!d->fbo
| 0-20 | ||||||||||||||||||
870 | needsSync = true; | - | ||||||||||||||||||
871 | createFramebufferObject(); | - | ||||||||||||||||||
872 | } executed 16 times by 1 test: end of block Executed by:
| 16 | ||||||||||||||||||
873 | } executed 20 times by 1 test: else {end of block Executed by:
| 20 | ||||||||||||||||||
874 | - | |||||||||||||||||||
875 | - | |||||||||||||||||||
876 | needsSync = true; | - | ||||||||||||||||||
877 | d->createContext(); | - | ||||||||||||||||||
878 | } executed 106 times by 2 tests: end of block Executed by:
| 106 | ||||||||||||||||||
879 | - | |||||||||||||||||||
880 | QOpenGLContext *context = d->offscreenWindow->openglContext(); | - | ||||||||||||||||||
881 | if (!context
| 0-126 | ||||||||||||||||||
882 | QMessageLogger(__FILE__, 1221, __PRETTY_FUNCTION__).warning("QQuickWidget::resizeEvent() no OpenGL context"); | - | ||||||||||||||||||
883 | return; never executed: return; | 0 | ||||||||||||||||||
884 | } | - | ||||||||||||||||||
885 | - | |||||||||||||||||||
886 | } executed 126 times by 2 tests: end of block Executed by:
| 126 | ||||||||||||||||||
887 | - | |||||||||||||||||||
888 | d->render(needsSync); | - | ||||||||||||||||||
889 | } executed 126 times by 2 tests: end of block Executed by:
| 126 | ||||||||||||||||||
890 | - | |||||||||||||||||||
891 | - | |||||||||||||||||||
892 | bool QQuickWidget::focusNextPrevChild(bool next) | - | ||||||||||||||||||
893 | { | - | ||||||||||||||||||
894 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
895 | QKeyEvent event(QEvent::KeyPress, next ? Qt::Key_Tab : Qt::Key_Backtab, Qt::NoModifier); | - | ||||||||||||||||||
896 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileInputEvents)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||
897 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||
898 | QCoreApplication::sendEvent(d->offscreenWindow, &event); | - | ||||||||||||||||||
899 | - | |||||||||||||||||||
900 | QKeyEvent releaseEvent(QEvent::KeyRelease, next ? Qt::Key_Tab : Qt::Key_Backtab, Qt::NoModifier); | - | ||||||||||||||||||
901 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileInputEvents)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||
902 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||
903 | QCoreApplication::sendEvent(d->offscreenWindow, &releaseEvent); | - | ||||||||||||||||||
904 | return never executed: event.isAccepted();return event.isAccepted(); never executed: return event.isAccepted(); | 0 | ||||||||||||||||||
905 | } | - | ||||||||||||||||||
906 | - | |||||||||||||||||||
907 | - | |||||||||||||||||||
908 | void QQuickWidget::keyPressEvent(QKeyEvent *e) | - | ||||||||||||||||||
909 | { | - | ||||||||||||||||||
910 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
911 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileInputEvents)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||
912 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||
913 | - | |||||||||||||||||||
914 | QCoreApplication::sendEvent(d->offscreenWindow, e); | - | ||||||||||||||||||
915 | } never executed: end of block | 0 | ||||||||||||||||||
916 | - | |||||||||||||||||||
917 | - | |||||||||||||||||||
918 | void QQuickWidget::keyReleaseEvent(QKeyEvent *e) | - | ||||||||||||||||||
919 | { | - | ||||||||||||||||||
920 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
921 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileInputEvents)
never executed: else (end of block executed 2 times by 1 test: void)0(void)0 ; Executed by:
executed 2 times by 1 test: (void)0 ; Executed by:
| 0-2 | ||||||||||||||||||
922 | ; executed 2 times by 1 test: (void)0 ; Executed by:
| 2 | ||||||||||||||||||
923 | - | |||||||||||||||||||
924 | QCoreApplication::sendEvent(d->offscreenWindow, e); | - | ||||||||||||||||||
925 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
926 | - | |||||||||||||||||||
927 | - | |||||||||||||||||||
928 | void QQuickWidget::mouseMoveEvent(QMouseEvent *e) | - | ||||||||||||||||||
929 | { | - | ||||||||||||||||||
930 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
931 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileInputEvents)
never executed: else (end of block executed 2 times by 1 test: void)0(void)0 ; Executed by:
executed 2 times by 1 test: (void)0 ; Executed by:
| 0-2 | ||||||||||||||||||
932 | ; executed 2 times by 1 test: (void)0 ; Executed by:
| 2 | ||||||||||||||||||
933 | - | |||||||||||||||||||
934 | - | |||||||||||||||||||
935 | - | |||||||||||||||||||
936 | - | |||||||||||||||||||
937 | - | |||||||||||||||||||
938 | QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), | - | ||||||||||||||||||
939 | e->button(), e->buttons(), e->modifiers(), e->source()); | - | ||||||||||||||||||
940 | QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); | - | ||||||||||||||||||
941 | e->setAccepted(mappedEvent.isAccepted()); | - | ||||||||||||||||||
942 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||
943 | - | |||||||||||||||||||
944 | - | |||||||||||||||||||
945 | void QQuickWidget::mouseDoubleClickEvent(QMouseEvent *e) | - | ||||||||||||||||||
946 | { | - | ||||||||||||||||||
947 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
948 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileInputEvents)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||
949 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||
950 | - | |||||||||||||||||||
951 | - | |||||||||||||||||||
952 | - | |||||||||||||||||||
953 | QMouseEvent pressEvent(QEvent::MouseButtonPress, e->localPos(), e->localPos(), e->screenPos(), | - | ||||||||||||||||||
954 | e->button(), e->buttons(), e->modifiers(), e->source()); | - | ||||||||||||||||||
955 | QCoreApplication::sendEvent(d->offscreenWindow, &pressEvent); | - | ||||||||||||||||||
956 | e->setAccepted(pressEvent.isAccepted()); | - | ||||||||||||||||||
957 | QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), | - | ||||||||||||||||||
958 | e->button(), e->buttons(), e->modifiers(), e->source()); | - | ||||||||||||||||||
959 | QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); | - | ||||||||||||||||||
960 | } never executed: end of block | 0 | ||||||||||||||||||
961 | - | |||||||||||||||||||
962 | - | |||||||||||||||||||
963 | void QQuickWidget::showEvent(QShowEvent *) | - | ||||||||||||||||||
964 | { | - | ||||||||||||||||||
965 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
966 | if (!d->useSoftwareRenderer
| 0-108 | ||||||||||||||||||
967 | d->createContext(); | - | ||||||||||||||||||
968 | if (d->offscreenWindow->openglContext()
| 0-108 | ||||||||||||||||||
969 | d->render(true); | - | ||||||||||||||||||
970 | - | |||||||||||||||||||
971 | - | |||||||||||||||||||
972 | - | |||||||||||||||||||
973 | - | |||||||||||||||||||
974 | - | |||||||||||||||||||
975 | - | |||||||||||||||||||
976 | - | |||||||||||||||||||
977 | if (!d->eventPending
| 0-108 | ||||||||||||||||||
978 | d->updatePending = false; | - | ||||||||||||||||||
979 | update(); | - | ||||||||||||||||||
980 | } never executed: end of block | 0 | ||||||||||||||||||
981 | } executed 108 times by 2 tests: else {end of block Executed by:
| 108 | ||||||||||||||||||
982 | triggerUpdate(); | - | ||||||||||||||||||
983 | } never executed: end of block | 0 | ||||||||||||||||||
984 | } | - | ||||||||||||||||||
985 | QWindowPrivate *offscreenPrivate = QWindowPrivate::get(d->offscreenWindow); | - | ||||||||||||||||||
986 | if (!offscreenPrivate->visible
| 0-108 | ||||||||||||||||||
987 | offscreenPrivate->visible = true; | - | ||||||||||||||||||
988 | d->offscreenWindow->visibleChanged(true); | - | ||||||||||||||||||
989 | offscreenPrivate->updateVisibility(); | - | ||||||||||||||||||
990 | } executed 108 times by 2 tests: end of block Executed by:
| 108 | ||||||||||||||||||
991 | if (QQmlInspectorService *service = QQmlDebugConnector::service<QQmlInspectorService>()
| 0-108 | ||||||||||||||||||
992 | service->setParentWindow(d->offscreenWindow, window()->windowHandle()); never executed: service->setParentWindow(d->offscreenWindow, window()->windowHandle()); | 0 | ||||||||||||||||||
993 | } executed 108 times by 2 tests: end of block Executed by:
| 108 | ||||||||||||||||||
994 | - | |||||||||||||||||||
995 | - | |||||||||||||||||||
996 | void QQuickWidget::hideEvent(QHideEvent *) | - | ||||||||||||||||||
997 | { | - | ||||||||||||||||||
998 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
999 | if (!d->offscreenWindow->isPersistentSceneGraph()
| 0-20 | ||||||||||||||||||
1000 | d->invalidateRenderControl(); never executed: d->invalidateRenderControl(); | 0 | ||||||||||||||||||
1001 | QWindowPrivate *offscreenPrivate = QWindowPrivate::get(d->offscreenWindow); | - | ||||||||||||||||||
1002 | if (offscreenPrivate->visible
| 0-20 | ||||||||||||||||||
1003 | offscreenPrivate->visible = false; | - | ||||||||||||||||||
1004 | d->offscreenWindow->visibleChanged(false); | - | ||||||||||||||||||
1005 | offscreenPrivate->updateVisibility(); | - | ||||||||||||||||||
1006 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||
1007 | if (QQmlInspectorService *service = QQmlDebugConnector::service<QQmlInspectorService>()
| 0-20 | ||||||||||||||||||
1008 | service->setParentWindow(d->offscreenWindow, d->offscreenWindow); never executed: service->setParentWindow(d->offscreenWindow, d->offscreenWindow); | 0 | ||||||||||||||||||
1009 | } executed 20 times by 1 test: end of block Executed by:
| 20 | ||||||||||||||||||
1010 | - | |||||||||||||||||||
1011 | - | |||||||||||||||||||
1012 | void QQuickWidget::mousePressEvent(QMouseEvent *e) | - | ||||||||||||||||||
1013 | { | - | ||||||||||||||||||
1014 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1015 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileInputEvents)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||
1016 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||
1017 | - | |||||||||||||||||||
1018 | QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), | - | ||||||||||||||||||
1019 | e->button(), e->buttons(), e->modifiers(), e->source()); | - | ||||||||||||||||||
1020 | QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); | - | ||||||||||||||||||
1021 | e->setAccepted(mappedEvent.isAccepted()); | - | ||||||||||||||||||
1022 | } never executed: end of block | 0 | ||||||||||||||||||
1023 | - | |||||||||||||||||||
1024 | - | |||||||||||||||||||
1025 | void QQuickWidget::mouseReleaseEvent(QMouseEvent *e) | - | ||||||||||||||||||
1026 | { | - | ||||||||||||||||||
1027 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1028 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileInputEvents)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||
1029 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||
1030 | - | |||||||||||||||||||
1031 | QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), | - | ||||||||||||||||||
1032 | e->button(), e->buttons(), e->modifiers(), e->source()); | - | ||||||||||||||||||
1033 | QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); | - | ||||||||||||||||||
1034 | e->setAccepted(mappedEvent.isAccepted()); | - | ||||||||||||||||||
1035 | } never executed: end of block | 0 | ||||||||||||||||||
1036 | - | |||||||||||||||||||
1037 | - | |||||||||||||||||||
1038 | - | |||||||||||||||||||
1039 | void QQuickWidget::wheelEvent(QWheelEvent *e) | - | ||||||||||||||||||
1040 | { | - | ||||||||||||||||||
1041 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1042 | if (QQuickProfiler::featuresEnabled & (1 << QQuickProfiler::ProfileInputEvents)
never executed: else (end of block never executed: void)0(void)0 ; never executed: (void)0 ; | 0 | ||||||||||||||||||
1043 | ; never executed: (void)0 ; | 0 | ||||||||||||||||||
1044 | - | |||||||||||||||||||
1045 | - | |||||||||||||||||||
1046 | QCoreApplication::sendEvent(d->offscreenWindow, e); | - | ||||||||||||||||||
1047 | } never executed: end of block | 0 | ||||||||||||||||||
1048 | - | |||||||||||||||||||
1049 | - | |||||||||||||||||||
1050 | - | |||||||||||||||||||
1051 | - | |||||||||||||||||||
1052 | - | |||||||||||||||||||
1053 | void QQuickWidget::focusInEvent(QFocusEvent * event) | - | ||||||||||||||||||
1054 | { | - | ||||||||||||||||||
1055 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1056 | d->offscreenWindow->focusInEvent(event); | - | ||||||||||||||||||
1057 | } never executed: end of block | 0 | ||||||||||||||||||
1058 | - | |||||||||||||||||||
1059 | - | |||||||||||||||||||
1060 | - | |||||||||||||||||||
1061 | - | |||||||||||||||||||
1062 | void QQuickWidget::focusOutEvent(QFocusEvent * event) | - | ||||||||||||||||||
1063 | { | - | ||||||||||||||||||
1064 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1065 | d->offscreenWindow->focusOutEvent(event); | - | ||||||||||||||||||
1066 | } never executed: end of block | 0 | ||||||||||||||||||
1067 | - | |||||||||||||||||||
1068 | static Qt::WindowState resolveWindowState(Qt::WindowStates states) | - | ||||||||||||||||||
1069 | { | - | ||||||||||||||||||
1070 | - | |||||||||||||||||||
1071 | if (states & Qt::WindowMinimized
| 0 | ||||||||||||||||||
1072 | return never executed: Qt::WindowMinimized;return Qt::WindowMinimized; never executed: return Qt::WindowMinimized; | 0 | ||||||||||||||||||
1073 | if (states & Qt::WindowMaximized
| 0 | ||||||||||||||||||
1074 | return never executed: Qt::WindowMaximized;return Qt::WindowMaximized; never executed: return Qt::WindowMaximized; | 0 | ||||||||||||||||||
1075 | if (states & Qt::WindowFullScreen
| 0 | ||||||||||||||||||
1076 | return never executed: Qt::WindowFullScreen;return Qt::WindowFullScreen; never executed: return Qt::WindowFullScreen; | 0 | ||||||||||||||||||
1077 | - | |||||||||||||||||||
1078 | - | |||||||||||||||||||
1079 | return never executed: Qt::WindowNoState;return Qt::WindowNoState; never executed: return Qt::WindowNoState; | 0 | ||||||||||||||||||
1080 | } | - | ||||||||||||||||||
1081 | - | |||||||||||||||||||
1082 | static void remapInputMethodQueryEvent(QObject *object, QInputMethodQueryEvent *e) | - | ||||||||||||||||||
1083 | { | - | ||||||||||||||||||
1084 | auto item = qobject_cast<QQuickItem *>(object); | - | ||||||||||||||||||
1085 | if (!item
| 0 | ||||||||||||||||||
1086 | return; never executed: return; | 0 | ||||||||||||||||||
1087 | - | |||||||||||||||||||
1088 | - | |||||||||||||||||||
1089 | for (auto query : {Qt::ImCursorRectangle, Qt::ImAnchorRectangle, Qt::ImInputItemClipRectangle}) { | - | ||||||||||||||||||
1090 | if (e->queries() & query
| 0 | ||||||||||||||||||
1091 | auto value = e->value(query); | - | ||||||||||||||||||
1092 | if (value.canConvert<QRectF>()
| 0 | ||||||||||||||||||
1093 | e->setValue(query, item->mapRectToScene(value.toRectF())); never executed: e->setValue(query, item->mapRectToScene(value.toRectF())); | 0 | ||||||||||||||||||
1094 | } never executed: end of block | 0 | ||||||||||||||||||
1095 | } never executed: end of block | 0 | ||||||||||||||||||
1096 | - | |||||||||||||||||||
1097 | if (e->queries() & Qt::ImCursorPosition
| 0 | ||||||||||||||||||
1098 | auto value = e->value(Qt::ImCursorPosition); | - | ||||||||||||||||||
1099 | if (value.canConvert<QPointF>()
| 0 | ||||||||||||||||||
1100 | e->setValue(Qt::ImCursorPosition, item->mapToScene(value.toPointF())); never executed: e->setValue(Qt::ImCursorPosition, item->mapToScene(value.toPointF())); | 0 | ||||||||||||||||||
1101 | } never executed: end of block | 0 | ||||||||||||||||||
1102 | } never executed: end of block | 0 | ||||||||||||||||||
1103 | - | |||||||||||||||||||
1104 | - | |||||||||||||||||||
1105 | bool QQuickWidget::event(QEvent *e) | - | ||||||||||||||||||
1106 | { | - | ||||||||||||||||||
1107 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1108 | - | |||||||||||||||||||
1109 | switch (e->type()) { | - | ||||||||||||||||||
1110 | - | |||||||||||||||||||
1111 | case executed 2 times by 1 test: QEvent::Leave:case QEvent::Leave: Executed by:
executed 2 times by 1 test: case QEvent::Leave: Executed by:
| 2 | ||||||||||||||||||
1112 | case never executed: QEvent::TouchBegin:case QEvent::TouchBegin: never executed: case QEvent::TouchBegin: | 0 | ||||||||||||||||||
1113 | case never executed: QEvent::TouchEnd:case QEvent::TouchEnd: never executed: case QEvent::TouchEnd: | 0 | ||||||||||||||||||
1114 | case never executed: QEvent::TouchUpdate:case QEvent::TouchUpdate: never executed: case QEvent::TouchUpdate: | 0 | ||||||||||||||||||
1115 | case never executed: QEvent::TouchCancel:case QEvent::TouchCancel: never executed: case QEvent::TouchCancel: | 0 | ||||||||||||||||||
1116 | - | |||||||||||||||||||
1117 | return executed 2 times by 1 test: QCoreApplication::sendEvent(d->offscreenWindow, e);return QCoreApplication::sendEvent(d->offscreenWindow, e); Executed by:
executed 2 times by 1 test: return QCoreApplication::sendEvent(d->offscreenWindow, e); Executed by:
| 2 | ||||||||||||||||||
1118 | - | |||||||||||||||||||
1119 | case never executed: QEvent::InputMethod:case QEvent::InputMethod: never executed: case QEvent::InputMethod: | 0 | ||||||||||||||||||
1120 | return never executed: QCoreApplication::sendEvent(d->offscreenWindow->focusObject(), e);return QCoreApplication::sendEvent(d->offscreenWindow->focusObject(), e); never executed: return QCoreApplication::sendEvent(d->offscreenWindow->focusObject(), e); | 0 | ||||||||||||||||||
1121 | case never executed: QEvent::InputMethodQuery:case QEvent::InputMethodQuery: never executed: case QEvent::InputMethodQuery: | 0 | ||||||||||||||||||
1122 | { | - | ||||||||||||||||||
1123 | bool eventResult = QCoreApplication::sendEvent(d->offscreenWindow->focusObject(), e); | - | ||||||||||||||||||
1124 | - | |||||||||||||||||||
1125 | - | |||||||||||||||||||
1126 | - | |||||||||||||||||||
1127 | - | |||||||||||||||||||
1128 | remapInputMethodQueryEvent(d->offscreenWindow->focusObject(), static_cast<QInputMethodQueryEvent *>(e)); | - | ||||||||||||||||||
1129 | return never executed: eventResult;return eventResult; never executed: return eventResult; | 0 | ||||||||||||||||||
1130 | } | - | ||||||||||||||||||
1131 | - | |||||||||||||||||||
1132 | case executed 8 times by 1 test: QEvent::WindowChangeInternal:case QEvent::WindowChangeInternal: Executed by:
executed 8 times by 1 test: case QEvent::WindowChangeInternal: Executed by:
| 8 | ||||||||||||||||||
1133 | d->handleWindowChange(); | - | ||||||||||||||||||
1134 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||||||||
1135 | - | |||||||||||||||||||
1136 | case never executed: QEvent::ScreenChangeInternal:case QEvent::ScreenChangeInternal: never executed: case QEvent::ScreenChangeInternal: | 0 | ||||||||||||||||||
1137 | if (QWindow *window = this->window()->windowHandle()
| 0 | ||||||||||||||||||
1138 | QScreen *newScreen = window->screen(); | - | ||||||||||||||||||
1139 | - | |||||||||||||||||||
1140 | if (d->offscreenWindow
| 0 | ||||||||||||||||||
1141 | d->offscreenWindow->setScreen(newScreen); never executed: d->offscreenWindow->setScreen(newScreen); | 0 | ||||||||||||||||||
1142 | if (d->offscreenSurface
| 0 | ||||||||||||||||||
1143 | d->offscreenSurface->setScreen(newScreen); never executed: d->offscreenSurface->setScreen(newScreen); | 0 | ||||||||||||||||||
1144 | - | |||||||||||||||||||
1145 | if (d->context
| 0 | ||||||||||||||||||
1146 | d->context->setScreen(newScreen); never executed: d->context->setScreen(newScreen); | 0 | ||||||||||||||||||
1147 | - | |||||||||||||||||||
1148 | } never executed: end of block | 0 | ||||||||||||||||||
1149 | - | |||||||||||||||||||
1150 | if (d->useSoftwareRenderer
| 0 | ||||||||||||||||||
1151 | - | |||||||||||||||||||
1152 | || d->fbo
| 0 | ||||||||||||||||||
1153 | - | |||||||||||||||||||
1154 | ) { | - | ||||||||||||||||||
1155 | - | |||||||||||||||||||
1156 | - | |||||||||||||||||||
1157 | createFramebufferObject(); | - | ||||||||||||||||||
1158 | d->render(true); | - | ||||||||||||||||||
1159 | } never executed: end of block | 0 | ||||||||||||||||||
1160 | break; never executed: break; | 0 | ||||||||||||||||||
1161 | - | |||||||||||||||||||
1162 | case executed 108 times by 2 tests: QEvent::Show:case QEvent::Show: Executed by:
executed 108 times by 2 tests: case QEvent::Show: Executed by:
| 108 | ||||||||||||||||||
1163 | case executed 114 times by 2 tests: QEvent::Move:case QEvent::Move: Executed by:
executed 114 times by 2 tests: case QEvent::Move: Executed by:
| 114 | ||||||||||||||||||
1164 | d->updatePosition(); | - | ||||||||||||||||||
1165 | break; executed 222 times by 2 tests: break; Executed by:
| 222 | ||||||||||||||||||
1166 | - | |||||||||||||||||||
1167 | case never executed: QEvent::WindowStateChange:case QEvent::WindowStateChange: never executed: case QEvent::WindowStateChange: | 0 | ||||||||||||||||||
1168 | d->offscreenWindow->setWindowState(resolveWindowState(windowState())); | - | ||||||||||||||||||
1169 | break; never executed: break; | 0 | ||||||||||||||||||
1170 | - | |||||||||||||||||||
1171 | case executed 4 times by 1 test: QEvent::ShortcutOverride:case QEvent::ShortcutOverride: Executed by:
executed 4 times by 1 test: case QEvent::ShortcutOverride: Executed by:
| 4 | ||||||||||||||||||
1172 | return executed 4 times by 1 test: QCoreApplication::sendEvent(d->offscreenWindow, e);return QCoreApplication::sendEvent(d->offscreenWindow, e); Executed by:
executed 4 times by 1 test: return QCoreApplication::sendEvent(d->offscreenWindow, e); Executed by:
| 4 | ||||||||||||||||||
1173 | - | |||||||||||||||||||
1174 | case executed 12 times by 1 test: QEvent::Enter:case QEvent::Enter: Executed by:
executed 12 times by 1 test: {case QEvent::Enter: Executed by:
| 12 | ||||||||||||||||||
1175 | QEnterEvent *enterEvent = static_cast<QEnterEvent *>(e); | - | ||||||||||||||||||
1176 | QEnterEvent mappedEvent(enterEvent->localPos(), enterEvent->windowPos(), | - | ||||||||||||||||||
1177 | enterEvent->screenPos()); | - | ||||||||||||||||||
1178 | const bool ret = QCoreApplication::sendEvent(d->offscreenWindow, &mappedEvent); | - | ||||||||||||||||||
1179 | e->setAccepted(mappedEvent.isAccepted()); | - | ||||||||||||||||||
1180 | return executed 12 times by 1 test: ret;return ret; Executed by:
executed 12 times by 1 test: return ret; Executed by:
| 12 | ||||||||||||||||||
1181 | } | - | ||||||||||||||||||
1182 | default executed 1716 times by 2 tests: :default: Executed by:
executed 1716 times by 2 tests: default: Executed by:
| 1716 | ||||||||||||||||||
1183 | break; executed 1716 times by 2 tests: break; Executed by:
| 1716 | ||||||||||||||||||
1184 | } | - | ||||||||||||||||||
1185 | - | |||||||||||||||||||
1186 | return executed 1946 times by 2 tests: QWidget::event(e);return QWidget::event(e); Executed by:
executed 1946 times by 2 tests: return QWidget::event(e); Executed by:
| 1946 | ||||||||||||||||||
1187 | } | - | ||||||||||||||||||
1188 | - | |||||||||||||||||||
1189 | - | |||||||||||||||||||
1190 | - | |||||||||||||||||||
1191 | - | |||||||||||||||||||
1192 | void QQuickWidget::dragEnterEvent(QDragEnterEvent *e) | - | ||||||||||||||||||
1193 | { | - | ||||||||||||||||||
1194 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1195 | - | |||||||||||||||||||
1196 | - | |||||||||||||||||||
1197 | d->offscreenWindow->event(e); | - | ||||||||||||||||||
1198 | e->accept(); | - | ||||||||||||||||||
1199 | } never executed: end of block | 0 | ||||||||||||||||||
1200 | - | |||||||||||||||||||
1201 | - | |||||||||||||||||||
1202 | void QQuickWidget::dragMoveEvent(QDragMoveEvent *e) | - | ||||||||||||||||||
1203 | { | - | ||||||||||||||||||
1204 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1205 | - | |||||||||||||||||||
1206 | - | |||||||||||||||||||
1207 | d->offscreenWindow->event(e); | - | ||||||||||||||||||
1208 | } never executed: end of block | 0 | ||||||||||||||||||
1209 | - | |||||||||||||||||||
1210 | - | |||||||||||||||||||
1211 | void QQuickWidget::dragLeaveEvent(QDragLeaveEvent *e) | - | ||||||||||||||||||
1212 | { | - | ||||||||||||||||||
1213 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1214 | d->offscreenWindow->event(e); | - | ||||||||||||||||||
1215 | } never executed: end of block | 0 | ||||||||||||||||||
1216 | - | |||||||||||||||||||
1217 | - | |||||||||||||||||||
1218 | void QQuickWidget::dropEvent(QDropEvent *e) | - | ||||||||||||||||||
1219 | { | - | ||||||||||||||||||
1220 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1221 | d->offscreenWindow->event(e); | - | ||||||||||||||||||
1222 | } never executed: end of block | 0 | ||||||||||||||||||
1223 | - | |||||||||||||||||||
1224 | - | |||||||||||||||||||
1225 | - | |||||||||||||||||||
1226 | - | |||||||||||||||||||
1227 | - | |||||||||||||||||||
1228 | - | |||||||||||||||||||
1229 | void QQuickWidget::triggerUpdate() | - | ||||||||||||||||||
1230 | { | - | ||||||||||||||||||
1231 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1232 | d->updatePending = true; | - | ||||||||||||||||||
1233 | if (!d->eventPending
| 208-974 | ||||||||||||||||||
1234 | const int exhaustDelay = 5; | - | ||||||||||||||||||
1235 | d->updateTimer.start(exhaustDelay, Qt::PreciseTimer, this); | - | ||||||||||||||||||
1236 | d->eventPending = true; | - | ||||||||||||||||||
1237 | } executed 208 times by 2 tests: end of block Executed by:
| 208 | ||||||||||||||||||
1238 | } executed 1182 times by 2 tests: end of block Executed by:
| 1182 | ||||||||||||||||||
1239 | void QQuickWidget::setFormat(const QSurfaceFormat &format) | - | ||||||||||||||||||
1240 | { | - | ||||||||||||||||||
1241 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1242 | QSurfaceFormat currentFormat = d->offscreenWindow->format(); | - | ||||||||||||||||||
1243 | QSurfaceFormat newFormat = format; | - | ||||||||||||||||||
1244 | newFormat.setDepthBufferSize(qMax(newFormat.depthBufferSize(), currentFormat.depthBufferSize())); | - | ||||||||||||||||||
1245 | newFormat.setStencilBufferSize(qMax(newFormat.stencilBufferSize(), currentFormat.stencilBufferSize())); | - | ||||||||||||||||||
1246 | newFormat.setAlphaBufferSize(qMax(newFormat.alphaBufferSize(), currentFormat.alphaBufferSize())); | - | ||||||||||||||||||
1247 | - | |||||||||||||||||||
1248 | - | |||||||||||||||||||
1249 | - | |||||||||||||||||||
1250 | - | |||||||||||||||||||
1251 | - | |||||||||||||||||||
1252 | d->requestedSamples = newFormat.samples(); | - | ||||||||||||||||||
1253 | newFormat.setSamples(0); | - | ||||||||||||||||||
1254 | - | |||||||||||||||||||
1255 | d->offscreenWindow->setFormat(newFormat); | - | ||||||||||||||||||
1256 | } never executed: end of block | 0 | ||||||||||||||||||
1257 | QSurfaceFormat QQuickWidget::format() const | - | ||||||||||||||||||
1258 | { | - | ||||||||||||||||||
1259 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1260 | return never executed: d->offscreenWindow->format();return d->offscreenWindow->format(); never executed: return d->offscreenWindow->format(); | 0 | ||||||||||||||||||
1261 | } | - | ||||||||||||||||||
1262 | - | |||||||||||||||||||
1263 | - | |||||||||||||||||||
1264 | - | |||||||||||||||||||
1265 | - | |||||||||||||||||||
1266 | - | |||||||||||||||||||
1267 | - | |||||||||||||||||||
1268 | QImage QQuickWidget::grabFramebuffer() const | - | ||||||||||||||||||
1269 | { | - | ||||||||||||||||||
1270 | return executed 4 times by 1 test: const_cast<QQuickWidgetPrivate *>(d_func())->grabFramebuffer();return const_cast<QQuickWidgetPrivate *>(d_func())->grabFramebuffer(); Executed by:
executed 4 times by 1 test: return const_cast<QQuickWidgetPrivate *>(d_func())->grabFramebuffer(); Executed by:
| 4 | ||||||||||||||||||
1271 | } | - | ||||||||||||||||||
1272 | void QQuickWidget::setClearColor(const QColor &color) | - | ||||||||||||||||||
1273 | { | - | ||||||||||||||||||
1274 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1275 | d->offscreenWindow->setColor(color); | - | ||||||||||||||||||
1276 | } never executed: end of block | 0 | ||||||||||||||||||
1277 | QQuickWindow *QQuickWidget::quickWindow() const | - | ||||||||||||||||||
1278 | { | - | ||||||||||||||||||
1279 | const QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1280 | return executed 14 times by 1 test: d->offscreenWindow;return d->offscreenWindow; Executed by:
executed 14 times by 1 test: return d->offscreenWindow; Executed by:
| 14 | ||||||||||||||||||
1281 | } | - | ||||||||||||||||||
1282 | - | |||||||||||||||||||
1283 | - | |||||||||||||||||||
1284 | - | |||||||||||||||||||
1285 | - | |||||||||||||||||||
1286 | void QQuickWidget::paintEvent(QPaintEvent *event) | - | ||||||||||||||||||
1287 | { | - | ||||||||||||||||||
1288 | QQuickWidgetPrivate * const d = d_func(); | - | ||||||||||||||||||
1289 | if (d->useSoftwareRenderer
| 0-160 | ||||||||||||||||||
1290 | QPainter painter(this); | - | ||||||||||||||||||
1291 | d->updateRegion = d->updateRegion.united(event->region()); | - | ||||||||||||||||||
1292 | if (d->updateRegion.isNull()
| 0 | ||||||||||||||||||
1293 | - | |||||||||||||||||||
1294 | painter.drawImage(rect(), d->softwareImage); | - | ||||||||||||||||||
1295 | } never executed: else {end of block | 0 | ||||||||||||||||||
1296 | QTransform transform; | - | ||||||||||||||||||
1297 | transform.scale(devicePixelRatioF(), devicePixelRatioF()); | - | ||||||||||||||||||
1298 | - | |||||||||||||||||||
1299 | QRegion targetRegion; | - | ||||||||||||||||||
1300 | d->updateRegion.swap(targetRegion); | - | ||||||||||||||||||
1301 | for (auto targetRect : targetRegion) { | - | ||||||||||||||||||
1302 | auto sourceRect = transform.mapRect(QRectF(targetRect)); | - | ||||||||||||||||||
1303 | painter.drawImage(targetRect, d->softwareImage, sourceRect); | - | ||||||||||||||||||
1304 | } never executed: end of block | 0 | ||||||||||||||||||
1305 | } never executed: end of block | 0 | ||||||||||||||||||
1306 | } | - | ||||||||||||||||||
1307 | } executed 160 times by 2 tests: end of block Executed by:
| 160 | ||||||||||||||||||
1308 | - | |||||||||||||||||||
1309 | - | |||||||||||||||||||
1310 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |