Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickrendercontrol.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | - | |||||||
6 | - | |||||||
7 | - | |||||||
8 | - | |||||||
9 | - | |||||||
10 | - | |||||||
11 | - | |||||||
12 | extern __attribute__((visibility("default"))) QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); | - | ||||||
13 | QSGContext *QQuickRenderControlPrivate::sg = nullptr; | - | ||||||
14 | - | |||||||
15 | QQuickRenderControlPrivate::QQuickRenderControlPrivate() | - | ||||||
16 | : initialized(0), | - | ||||||
17 | window(nullptr) | - | ||||||
18 | { | - | ||||||
19 | if (!sg
| 4-114 | ||||||
20 | qAddPostRoutine(cleanup); | - | ||||||
21 | sg = QSGContext::createDefaultContext(); | - | ||||||
22 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||
23 | rc = sg->createRenderContext(); | - | ||||||
24 | } executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||
25 | - | |||||||
26 | void QQuickRenderControlPrivate::cleanup() | - | ||||||
27 | { | - | ||||||
28 | delete sg; | - | ||||||
29 | sg = nullptr; | - | ||||||
30 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||
31 | - | |||||||
32 | - | |||||||
33 | - | |||||||
34 | - | |||||||
35 | - | |||||||
36 | QQuickRenderControl::QQuickRenderControl(QObject *parent) | - | ||||||
37 | : QObject(*(new QQuickRenderControlPrivate), parent) | - | ||||||
38 | { | - | ||||||
39 | } executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||
40 | - | |||||||
41 | - | |||||||
42 | - | |||||||
43 | - | |||||||
44 | - | |||||||
45 | - | |||||||
46 | QQuickRenderControl::~QQuickRenderControl() | - | ||||||
47 | { | - | ||||||
48 | QQuickRenderControlPrivate * const d = d_func(); | - | ||||||
49 | - | |||||||
50 | invalidate(); | - | ||||||
51 | - | |||||||
52 | if (d->window
| 0-118 | ||||||
53 | QQuickWindowPrivate::get(d->window)->renderControl = nullptr; executed 118 times by 2 tests: QQuickWindowPrivate::get(d->window)->renderControl = nullptr; Executed by:
| 118 | ||||||
54 | - | |||||||
55 | - | |||||||
56 | - | |||||||
57 | - | |||||||
58 | d->windowDestroyed(); | - | ||||||
59 | - | |||||||
60 | delete d->rc; | - | ||||||
61 | } executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||
62 | - | |||||||
63 | void QQuickRenderControlPrivate::windowDestroyed() | - | ||||||
64 | { | - | ||||||
65 | if (window
| 0-118 | ||||||
66 | rc->invalidate(); | - | ||||||
67 | - | |||||||
68 | delete QQuickWindowPrivate::get(window)->animationController; | - | ||||||
69 | QQuickWindowPrivate::get(window)->animationController = nullptr; | - | ||||||
70 | - | |||||||
71 | - | |||||||
72 | QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache(); | - | ||||||
73 | - | |||||||
74 | - | |||||||
75 | window = nullptr; | - | ||||||
76 | } executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||
77 | } executed 118 times by 2 tests: end of block Executed by:
| 118 | ||||||
78 | void QQuickRenderControl::prepareThread(QThread *targetThread) | - | ||||||
79 | { | - | ||||||
80 | QQuickRenderControlPrivate * const d = d_func(); | - | ||||||
81 | d->rc->moveToThread(targetThread); | - | ||||||
82 | QQuickWindowPrivate::get(d->window)->animationController->moveToThread(targetThread); | - | ||||||
83 | } never executed: end of block | 0 | ||||||
84 | void QQuickRenderControl::initialize(QOpenGLContext *gl) | - | ||||||
85 | { | - | ||||||
86 | - | |||||||
87 | QQuickRenderControlPrivate * const d = d_func(); | - | ||||||
88 | - | |||||||
89 | if (!d->window
| 0-112 | ||||||
90 | QMessageLogger(__FILE__, 231, __PRETTY_FUNCTION__).warning("QQuickRenderControl::initialize called with no associated window"); | - | ||||||
91 | return; never executed: return; | 0 | ||||||
92 | } | - | ||||||
93 | - | |||||||
94 | if (QOpenGLContext::currentContext() != gl
| 0-112 | ||||||
95 | QMessageLogger(__FILE__, 236, __PRETTY_FUNCTION__).warning("QQuickRenderControl::initialize called with incorrect current context"); | - | ||||||
96 | return; never executed: return; | 0 | ||||||
97 | } | - | ||||||
98 | - | |||||||
99 | - | |||||||
100 | - | |||||||
101 | - | |||||||
102 | - | |||||||
103 | d->rc->initialize(gl); | - | ||||||
104 | - | |||||||
105 | - | |||||||
106 | - | |||||||
107 | d->initialized = true; | - | ||||||
108 | } executed 112 times by 2 tests: end of block Executed by:
| 112 | ||||||
109 | - | |||||||
110 | - | |||||||
111 | - | |||||||
112 | - | |||||||
113 | - | |||||||
114 | - | |||||||
115 | void QQuickRenderControl::polishItems() | - | ||||||
116 | { | - | ||||||
117 | QQuickRenderControlPrivate * const d = d_func(); | - | ||||||
118 | if (!d->window
| 0-324 | ||||||
119 | return; never executed: return; | 0 | ||||||
120 | - | |||||||
121 | QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window); | - | ||||||
122 | cd->flushFrameSynchronousEvents(); | - | ||||||
123 | if (!d->window
| 0-324 | ||||||
124 | return; never executed: return; | 0 | ||||||
125 | cd->polishItems(); | - | ||||||
126 | } executed 324 times by 2 tests: end of block Executed by:
| 324 | ||||||
127 | bool QQuickRenderControl::sync() | - | ||||||
128 | { | - | ||||||
129 | QQuickRenderControlPrivate * const d = d_func(); | - | ||||||
130 | if (!d->window
| 0-324 | ||||||
131 | return never executed: false;return false; never executed: return false; | 0 | ||||||
132 | - | |||||||
133 | QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window); | - | ||||||
134 | cd->syncSceneGraph(); | - | ||||||
135 | d->rc->endSync(); | - | ||||||
136 | - | |||||||
137 | - | |||||||
138 | return executed 324 times by 2 tests: true;return true; Executed by:
executed 324 times by 2 tests: return true; Executed by:
| 324 | ||||||
139 | } | - | ||||||
140 | void QQuickRenderControl::invalidate() | - | ||||||
141 | { | - | ||||||
142 | QQuickRenderControlPrivate * const d = d_func(); | - | ||||||
143 | if (!d->initialized
| 112-118 | ||||||
144 | return; executed 118 times by 2 tests: return; Executed by:
| 118 | ||||||
145 | - | |||||||
146 | if (!d->window
| 0-112 | ||||||
147 | return; never executed: return; | 0 | ||||||
148 | - | |||||||
149 | QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window); | - | ||||||
150 | cd->fireAboutToStop(); | - | ||||||
151 | cd->cleanupNodesOnShutdown(); | - | ||||||
152 | - | |||||||
153 | - | |||||||
154 | - | |||||||
155 | - | |||||||
156 | d->rc->invalidate(); | - | ||||||
157 | - | |||||||
158 | d->initialized = false; | - | ||||||
159 | } executed 112 times by 2 tests: end of block Executed by:
| 112 | ||||||
160 | - | |||||||
161 | - | |||||||
162 | - | |||||||
163 | - | |||||||
164 | void QQuickRenderControl::render() | - | ||||||
165 | { | - | ||||||
166 | QQuickRenderControlPrivate * const d = d_func(); | - | ||||||
167 | if (!d->window
| 0-336 | ||||||
168 | return; never executed: return; | 0 | ||||||
169 | - | |||||||
170 | QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window); | - | ||||||
171 | cd->renderSceneGraph(d->window->size()); | - | ||||||
172 | } executed 336 times by 2 tests: end of block Executed by:
| 336 | ||||||
173 | QImage QQuickRenderControl::grab() | - | ||||||
174 | { | - | ||||||
175 | QQuickRenderControlPrivate * const d = d_func(); | - | ||||||
176 | if (!d->window
| 0-8 | ||||||
177 | return never executed: QImage();return QImage(); never executed: return QImage(); | 0 | ||||||
178 | - | |||||||
179 | QImage grabContent; | - | ||||||
180 | - | |||||||
181 | if (d->window->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL
| 0-8 | ||||||
182 | - | |||||||
183 | QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window); | - | ||||||
184 | cd->polishItems(); | - | ||||||
185 | cd->syncSceneGraph(); | - | ||||||
186 | d->rc->endSync(); | - | ||||||
187 | render(); | - | ||||||
188 | grabContent = qt_gl_read_framebuffer(d->window->size() * d->window->effectiveDevicePixelRatio(), false, false); | - | ||||||
189 | if (QQuickRenderControl::renderWindowFor(d->window)
| 4 | ||||||
190 | grabContent.setDevicePixelRatio(d->window->effectiveDevicePixelRatio()); | - | ||||||
191 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||
192 | - | |||||||
193 | } executed 8 times by 1 test: else if (d->window->rendererInterface()->graphicsApi() == QSGRendererInterface::Softwareend of block Executed by:
| 0-8 | ||||||
194 | QQuickWindowPrivate *cd = QQuickWindowPrivate::get(d->window); | - | ||||||
195 | cd->polishItems(); | - | ||||||
196 | cd->syncSceneGraph(); | - | ||||||
197 | QSGSoftwareRenderer *softwareRenderer = static_cast<QSGSoftwareRenderer *>(cd->renderer); | - | ||||||
198 | if (softwareRenderer
| 0 | ||||||
199 | const qreal dpr = d->window->effectiveDevicePixelRatio(); | - | ||||||
200 | const QSize imageSize = d->window->size() * dpr; | - | ||||||
201 | grabContent = QImage(imageSize, QImage::Format_ARGB32_Premultiplied); | - | ||||||
202 | grabContent.setDevicePixelRatio(dpr); | - | ||||||
203 | QPaintDevice *prevDev = softwareRenderer->currentPaintDevice(); | - | ||||||
204 | softwareRenderer->setCurrentPaintDevice(&grabContent); | - | ||||||
205 | softwareRenderer->markDirty(); | - | ||||||
206 | d->rc->endSync(); | - | ||||||
207 | render(); | - | ||||||
208 | softwareRenderer->setCurrentPaintDevice(prevDev); | - | ||||||
209 | } never executed: end of block | 0 | ||||||
210 | } never executed: else {end of block | 0 | ||||||
211 | QMessageLogger(__FILE__, 411, __PRETTY_FUNCTION__).warning("QQuickRenderControl: grabs are not supported with the current Qt Quick backend"); | - | ||||||
212 | } never executed: end of block | 0 | ||||||
213 | - | |||||||
214 | return executed 8 times by 1 test: grabContent;return grabContent; Executed by:
executed 8 times by 1 test: return grabContent; Executed by:
| 8 | ||||||
215 | } | - | ||||||
216 | - | |||||||
217 | void QQuickRenderControlPrivate::update() | - | ||||||
218 | { | - | ||||||
219 | QQuickRenderControl * const q = q_func(); | - | ||||||
220 | q->renderRequested(); | - | ||||||
221 | } never executed: end of block | 0 | ||||||
222 | - | |||||||
223 | void QQuickRenderControlPrivate::maybeUpdate() | - | ||||||
224 | { | - | ||||||
225 | QQuickRenderControl * const q = q_func(); | - | ||||||
226 | q->sceneChanged(); | - | ||||||
227 | } executed 1290 times by 2 tests: end of block Executed by:
| 1290 | ||||||
228 | QWindow *QQuickRenderControl::renderWindowFor(QQuickWindow *win, QPoint *offset) | - | ||||||
229 | { | - | ||||||
230 | if (!win
| 0-55655 | ||||||
231 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||
232 | QQuickRenderControl *rc = QQuickWindowPrivate::get(win)->renderControl; | - | ||||||
233 | if (rc
| 694-54961 | ||||||
234 | return executed 694 times by 2 tests: rc->renderWindow(offset);return rc->renderWindow(offset); Executed by:
executed 694 times by 2 tests: return rc->renderWindow(offset); Executed by:
| 694 | ||||||
235 | return executed 54961 times by 76 tests: nullptr;return nullptr; Executed by:
executed 54961 times by 76 tests: return nullptr; Executed by:
| 54961 | ||||||
236 | } | - | ||||||
237 | - | |||||||
238 | - | |||||||
239 | - | |||||||
Switch to Source code | Preprocessed file |