Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/context2d/qquickcontext2dtexture.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | const QLoggingCategory &lcCanvas() { static const QLoggingCategory category("qt.quick.canvas"); return never executed: category;return category; never executed: }return category; | 0 | ||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | - | |||||||||||||
12 | static inline int qt_next_power_of_two(int v) | - | ||||||||||||
13 | { | - | ||||||||||||
14 | v--; | - | ||||||||||||
15 | v |= v >> 1; | - | ||||||||||||
16 | v |= v >> 2; | - | ||||||||||||
17 | v |= v >> 4; | - | ||||||||||||
18 | v |= v >> 8; | - | ||||||||||||
19 | v |= v >> 16; | - | ||||||||||||
20 | ++v; | - | ||||||||||||
21 | return never executed: v;return v; never executed: return v; | 0 | ||||||||||||
22 | } | - | ||||||||||||
23 | - | |||||||||||||
24 | struct GLAcquireContext { | - | ||||||||||||
25 | GLAcquireContext(QOpenGLContext *c, QSurface *s):ctx(c) { | - | ||||||||||||
26 | if (ctx
| 0 | ||||||||||||
27 | ((s) ? static_cast<void>(0) : qt_assert("s", __FILE__, 78)); | - | ||||||||||||
28 | if (!ctx->isValid()
| 0 | ||||||||||||
29 | ctx->create(); never executed: ctx->create(); | 0 | ||||||||||||
30 | - | |||||||||||||
31 | if (!ctx->isValid()
| 0 | ||||||||||||
32 | QMessageLogger(__FILE__, 83, __PRETTY_FUNCTION__).warning() << "Unable to create GL context"; never executed: QMessageLogger(__FILE__, 83, __PRETTY_FUNCTION__).warning() << "Unable to create GL context"; | 0 | ||||||||||||
33 | else if (!ctx->makeCurrent(s)
| 0 | ||||||||||||
34 | QMessageLogger(__FILE__, 85, __PRETTY_FUNCTION__).warning() << "Can't make current GL context"; never executed: QMessageLogger(__FILE__, 85, __PRETTY_FUNCTION__).warning() << "Can't make current GL context"; | 0 | ||||||||||||
35 | } never executed: end of block | 0 | ||||||||||||
36 | } never executed: end of block | 0 | ||||||||||||
37 | ~GLAcquireContext() { | - | ||||||||||||
38 | if (ctx
| 0 | ||||||||||||
39 | ctx->doneCurrent(); never executed: ctx->doneCurrent(); | 0 | ||||||||||||
40 | } never executed: end of block | 0 | ||||||||||||
41 | QOpenGLContext *ctx; | - | ||||||||||||
42 | }; | - | ||||||||||||
43 | - | |||||||||||||
44 | QQuickContext2DTexture::QQuickContext2DTexture() | - | ||||||||||||
45 | : m_context(nullptr) | - | ||||||||||||
46 | - | |||||||||||||
47 | , m_gl(nullptr) | - | ||||||||||||
48 | - | |||||||||||||
49 | , m_surface(nullptr) | - | ||||||||||||
50 | , m_item(nullptr) | - | ||||||||||||
51 | , m_canvasDevicePixelRatio(1) | - | ||||||||||||
52 | , m_canvasWindowChanged(false) | - | ||||||||||||
53 | , m_dirtyTexture(false) | - | ||||||||||||
54 | , m_smooth(true) | - | ||||||||||||
55 | , m_antialiasing(false) | - | ||||||||||||
56 | , m_tiledCanvas(false) | - | ||||||||||||
57 | , m_painting(false) | - | ||||||||||||
58 | { | - | ||||||||||||
59 | } never executed: end of block | 0 | ||||||||||||
60 | - | |||||||||||||
61 | QQuickContext2DTexture::~QQuickContext2DTexture() | - | ||||||||||||
62 | { | - | ||||||||||||
63 | clearTiles(); | - | ||||||||||||
64 | } never executed: end of block | 0 | ||||||||||||
65 | - | |||||||||||||
66 | void QQuickContext2DTexture::markDirtyTexture() | - | ||||||||||||
67 | { | - | ||||||||||||
68 | if (m_onCustomThread
| 0 | ||||||||||||
69 | m_mutex.lock(); never executed: m_mutex.lock(); | 0 | ||||||||||||
70 | m_dirtyTexture = true; | - | ||||||||||||
71 | textureChanged(); | - | ||||||||||||
72 | if (m_onCustomThread
| 0 | ||||||||||||
73 | m_mutex.unlock(); never executed: m_mutex.unlock(); | 0 | ||||||||||||
74 | } never executed: end of block | 0 | ||||||||||||
75 | - | |||||||||||||
76 | bool QQuickContext2DTexture::setCanvasSize(const QSize &size) | - | ||||||||||||
77 | { | - | ||||||||||||
78 | if (m_canvasSize != size
| 0 | ||||||||||||
79 | m_canvasSize = size; | - | ||||||||||||
80 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
81 | } | - | ||||||||||||
82 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
83 | } | - | ||||||||||||
84 | - | |||||||||||||
85 | bool QQuickContext2DTexture::setTileSize(const QSize &size) | - | ||||||||||||
86 | { | - | ||||||||||||
87 | if (m_tileSize != size
| 0 | ||||||||||||
88 | m_tileSize = size; | - | ||||||||||||
89 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
90 | } | - | ||||||||||||
91 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
92 | } | - | ||||||||||||
93 | - | |||||||||||||
94 | void QQuickContext2DTexture::setSmooth(bool smooth) | - | ||||||||||||
95 | { | - | ||||||||||||
96 | m_smooth = smooth; | - | ||||||||||||
97 | } never executed: end of block | 0 | ||||||||||||
98 | - | |||||||||||||
99 | void QQuickContext2DTexture::setAntialiasing(bool antialiasing) | - | ||||||||||||
100 | { | - | ||||||||||||
101 | m_antialiasing = antialiasing; | - | ||||||||||||
102 | } never executed: end of block | 0 | ||||||||||||
103 | - | |||||||||||||
104 | void QQuickContext2DTexture::setItem(QQuickCanvasItem* item) | - | ||||||||||||
105 | { | - | ||||||||||||
106 | m_item = item; | - | ||||||||||||
107 | if (m_item
| 0 | ||||||||||||
108 | m_context = (QQuickContext2D*) item->rawContext(); | - | ||||||||||||
109 | m_state = m_context->state; | - | ||||||||||||
110 | } never executed: else {end of block | 0 | ||||||||||||
111 | m_context = nullptr; | - | ||||||||||||
112 | } never executed: end of block | 0 | ||||||||||||
113 | } | - | ||||||||||||
114 | - | |||||||||||||
115 | bool QQuickContext2DTexture::setCanvasWindow(const QRect& r) | - | ||||||||||||
116 | { | - | ||||||||||||
117 | qreal canvasDevicePixelRatio = (m_item
| 0 | ||||||||||||
118 | m_item->window()->effectiveDevicePixelRatio() : (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio(); | - | ||||||||||||
119 | if (!qFuzzyCompare(m_canvasDevicePixelRatio, canvasDevicePixelRatio)
| 0 | ||||||||||||
120 | for (bool qt_category_enabled = lcCanvas().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 173 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s device pixel ratio %.1lf -> %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_canvasDevicePixelRatio, canvasDevicePixelRatio) ; | 0 | ||||||||||||
121 | 0 | |||||||||||||
122 | __FILE__ never executed: QMessageLogger( __FILE__ , 173 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s device pixel ratio %.1lf -> %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_canvasDevicePixelRatio, canvasDevicePixelRatio) ; | 0 | ||||||||||||
123 | , never executed: QMessageLogger( __FILE__ , 173 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s device pixel ratio %.1lf -> %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_canvasDevicePixelRatio, canvasDevicePixelRatio) ; | 0 | ||||||||||||
124 | 0 | |||||||||||||
125 | 173 never executed: QMessageLogger( __FILE__ , 173 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s device pixel ratio %.1lf -> %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_canvasDevicePixelRatio, canvasDevicePixelRatio) ; | 0 | ||||||||||||
126 | , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s device pixel ratio %.1lf -> %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_canvasDevicePixelRatio, canvasDevicePixelRatio) never executed: QMessageLogger( __FILE__ , 173 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s device pixel ratio %.1lf -> %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_canvasDevicePixelRatio, canvasDevicePixelRatio) ; | 0 | ||||||||||||
127 | 0 | |||||||||||||
128 | ; never executed: QMessageLogger( __FILE__ , 173 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s device pixel ratio %.1lf -> %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_canvasDevicePixelRatio, canvasDevicePixelRatio) ; | 0 | ||||||||||||
129 | m_canvasDevicePixelRatio = canvasDevicePixelRatio; | - | ||||||||||||
130 | m_canvasWindowChanged = true; | - | ||||||||||||
131 | } never executed: end of block | 0 | ||||||||||||
132 | - | |||||||||||||
133 | if (m_canvasWindow != r
| 0 | ||||||||||||
134 | m_canvasWindow = r; | - | ||||||||||||
135 | m_canvasWindowChanged = true; | - | ||||||||||||
136 | } never executed: end of block | 0 | ||||||||||||
137 | - | |||||||||||||
138 | return never executed: m_canvasWindowChanged;return m_canvasWindowChanged; never executed: return m_canvasWindowChanged; | 0 | ||||||||||||
139 | } | - | ||||||||||||
140 | - | |||||||||||||
141 | bool QQuickContext2DTexture::setDirtyRect(const QRect &r) | - | ||||||||||||
142 | { | - | ||||||||||||
143 | bool doDirty = false; | - | ||||||||||||
144 | if (m_tiledCanvas
| 0 | ||||||||||||
145 | for (QQuickContext2DTile* t : qAsConst(m_tiles)) { | - | ||||||||||||
146 | bool dirty = t->rect().intersected(r).isValid(); | - | ||||||||||||
147 | t->markDirty(dirty); | - | ||||||||||||
148 | if (dirty
| 0 | ||||||||||||
149 | doDirty = true; never executed: doDirty = true; | 0 | ||||||||||||
150 | } never executed: end of block | 0 | ||||||||||||
151 | } never executed: else {end of block | 0 | ||||||||||||
152 | doDirty = m_canvasWindow.intersected(r).isValid(); | - | ||||||||||||
153 | } never executed: end of block | 0 | ||||||||||||
154 | return never executed: doDirty;return doDirty; never executed: return doDirty; | 0 | ||||||||||||
155 | } | - | ||||||||||||
156 | - | |||||||||||||
157 | void QQuickContext2DTexture::canvasChanged(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing) | - | ||||||||||||
158 | { | - | ||||||||||||
159 | QSize ts = tileSize; | - | ||||||||||||
160 | if (ts.width() > canvasSize.width()
| 0 | ||||||||||||
161 | ts.setWidth(canvasSize.width()); never executed: ts.setWidth(canvasSize.width()); | 0 | ||||||||||||
162 | - | |||||||||||||
163 | if (ts.height() > canvasSize.height()
| 0 | ||||||||||||
164 | ts.setHeight(canvasSize.height()); never executed: ts.setHeight(canvasSize.height()); | 0 | ||||||||||||
165 | - | |||||||||||||
166 | setCanvasSize(canvasSize); | - | ||||||||||||
167 | setTileSize(ts); | - | ||||||||||||
168 | setCanvasWindow(canvasWindow); | - | ||||||||||||
169 | - | |||||||||||||
170 | if (canvasSize == canvasWindow.size()
| 0 | ||||||||||||
171 | m_tiledCanvas = false; | - | ||||||||||||
172 | } never executed: else {end of block | 0 | ||||||||||||
173 | m_tiledCanvas = true; | - | ||||||||||||
174 | } never executed: end of block | 0 | ||||||||||||
175 | - | |||||||||||||
176 | if (dirtyRect.isValid()
| 0 | ||||||||||||
177 | setDirtyRect(dirtyRect); never executed: setDirtyRect(dirtyRect); | 0 | ||||||||||||
178 | - | |||||||||||||
179 | setSmooth(smooth); | - | ||||||||||||
180 | setAntialiasing(antialiasing); | - | ||||||||||||
181 | } never executed: end of block | 0 | ||||||||||||
182 | - | |||||||||||||
183 | void QQuickContext2DTexture::paintWithoutTiles(QQuickContext2DCommandBuffer *ccb) | - | ||||||||||||
184 | { | - | ||||||||||||
185 | if (!ccb
| 0 | ||||||||||||
186 | return; never executed: return; | 0 | ||||||||||||
187 | - | |||||||||||||
188 | QPaintDevice* device = beginPainting(); | - | ||||||||||||
189 | if (!device
| 0 | ||||||||||||
190 | endPainting(); | - | ||||||||||||
191 | return; never executed: return; | 0 | ||||||||||||
192 | } | - | ||||||||||||
193 | - | |||||||||||||
194 | QPainter p; | - | ||||||||||||
195 | p.begin(device); | - | ||||||||||||
196 | if (m_antialiasing
| 0 | ||||||||||||
197 | p.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing, true); never executed: p.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing, true); | 0 | ||||||||||||
198 | else | - | ||||||||||||
199 | p.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing, false); never executed: p.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing, false); | 0 | ||||||||||||
200 | - | |||||||||||||
201 | if (m_smooth
| 0 | ||||||||||||
202 | p.setRenderHint(QPainter::SmoothPixmapTransform, true); never executed: p.setRenderHint(QPainter::SmoothPixmapTransform, true); | 0 | ||||||||||||
203 | else | - | ||||||||||||
204 | p.setRenderHint(QPainter::SmoothPixmapTransform, false); never executed: p.setRenderHint(QPainter::SmoothPixmapTransform, false); | 0 | ||||||||||||
205 | - | |||||||||||||
206 | p.setCompositionMode(QPainter::CompositionMode_SourceOver); | - | ||||||||||||
207 | - | |||||||||||||
208 | ccb->replay(&p, m_state, scaleFactor()); | - | ||||||||||||
209 | endPainting(); | - | ||||||||||||
210 | markDirtyTexture(); | - | ||||||||||||
211 | } never executed: end of block | 0 | ||||||||||||
212 | - | |||||||||||||
213 | bool QQuickContext2DTexture::canvasDestroyed() | - | ||||||||||||
214 | { | - | ||||||||||||
215 | return never executed: m_item == nullptr;return m_item == nullptr; never executed: return m_item == nullptr; | 0 | ||||||||||||
216 | } | - | ||||||||||||
217 | - | |||||||||||||
218 | void QQuickContext2DTexture::paint(QQuickContext2DCommandBuffer *ccb) | - | ||||||||||||
219 | { | - | ||||||||||||
220 | QQuickContext2D::mutex.lock(); | - | ||||||||||||
221 | if (canvasDestroyed()
| 0 | ||||||||||||
222 | delete ccb; | - | ||||||||||||
223 | QQuickContext2D::mutex.unlock(); | - | ||||||||||||
224 | return; never executed: return; | 0 | ||||||||||||
225 | } | - | ||||||||||||
226 | QQuickContext2D::mutex.unlock(); | - | ||||||||||||
227 | - | |||||||||||||
228 | GLAcquireContext currentContext(m_gl, m_surface); | - | ||||||||||||
229 | - | |||||||||||||
230 | if (!m_tiledCanvas
| 0 | ||||||||||||
231 | paintWithoutTiles(ccb); | - | ||||||||||||
232 | delete ccb; | - | ||||||||||||
233 | return; never executed: return; | 0 | ||||||||||||
234 | } | - | ||||||||||||
235 | - | |||||||||||||
236 | QRect tiledRegion = createTiles(m_canvasWindow.intersected(QRect(QPoint(0, 0), m_canvasSize))); | - | ||||||||||||
237 | if (!tiledRegion.isEmpty()
| 0 | ||||||||||||
238 | QRect dirtyRect; | - | ||||||||||||
239 | for (QQuickContext2DTile* tile : qAsConst(m_tiles)) { | - | ||||||||||||
240 | if (tile->dirty()
| 0 | ||||||||||||
241 | if (dirtyRect.isEmpty()
| 0 | ||||||||||||
242 | dirtyRect = tile->rect(); never executed: dirtyRect = tile->rect(); | 0 | ||||||||||||
243 | else | - | ||||||||||||
244 | dirtyRect |= tile->rect(); never executed: dirtyRect |= tile->rect(); | 0 | ||||||||||||
245 | } | - | ||||||||||||
246 | } never executed: end of block | 0 | ||||||||||||
247 | - | |||||||||||||
248 | if (beginPainting()
| 0 | ||||||||||||
249 | QQuickContext2D::State oldState = m_state; | - | ||||||||||||
250 | for (QQuickContext2DTile* tile : qAsConst(m_tiles)) { | - | ||||||||||||
251 | if (tile->dirty()
| 0 | ||||||||||||
252 | ccb->replay(tile->createPainter(m_smooth, m_antialiasing), oldState, scaleFactor()); | - | ||||||||||||
253 | tile->drawFinished(); | - | ||||||||||||
254 | tile->markDirty(false); | - | ||||||||||||
255 | } never executed: end of block | 0 | ||||||||||||
256 | compositeTile(tile); | - | ||||||||||||
257 | } never executed: end of block | 0 | ||||||||||||
258 | endPainting(); | - | ||||||||||||
259 | m_state = oldState; | - | ||||||||||||
260 | markDirtyTexture(); | - | ||||||||||||
261 | } never executed: end of block | 0 | ||||||||||||
262 | } never executed: end of block | 0 | ||||||||||||
263 | delete ccb; | - | ||||||||||||
264 | } never executed: end of block | 0 | ||||||||||||
265 | - | |||||||||||||
266 | QRect QQuickContext2DTexture::tiledRect(const QRectF& window, const QSize& tileSize) | - | ||||||||||||
267 | { | - | ||||||||||||
268 | if (window.isEmpty()
| 0 | ||||||||||||
269 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||
270 | - | |||||||||||||
271 | const int tw = tileSize.width(); | - | ||||||||||||
272 | const int th = tileSize.height(); | - | ||||||||||||
273 | const int h1 = window.left() / tw; | - | ||||||||||||
274 | const int v1 = window.top() / th; | - | ||||||||||||
275 | - | |||||||||||||
276 | const int htiles = ((window.right() - h1 * tw) + tw - 1)/tw; | - | ||||||||||||
277 | const int vtiles = ((window.bottom() - v1 * th) + th - 1)/th; | - | ||||||||||||
278 | - | |||||||||||||
279 | return never executed: QRect(h1 * tw, v1 * th, htiles * tw, vtiles * th);return QRect(h1 * tw, v1 * th, htiles * tw, vtiles * th); never executed: return QRect(h1 * tw, v1 * th, htiles * tw, vtiles * th); | 0 | ||||||||||||
280 | } | - | ||||||||||||
281 | - | |||||||||||||
282 | QRect QQuickContext2DTexture::createTiles(const QRect& window) | - | ||||||||||||
283 | { | - | ||||||||||||
284 | QList<QQuickContext2DTile*> oldTiles = m_tiles; | - | ||||||||||||
285 | m_tiles.clear(); | - | ||||||||||||
286 | - | |||||||||||||
287 | if (window.isEmpty()
| 0 | ||||||||||||
288 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||
289 | } | - | ||||||||||||
290 | - | |||||||||||||
291 | QRect r = tiledRect(window, adjustedTileSize(m_tileSize)); | - | ||||||||||||
292 | - | |||||||||||||
293 | const int tw = m_tileSize.width(); | - | ||||||||||||
294 | const int th = m_tileSize.height(); | - | ||||||||||||
295 | const int h1 = window.left() / tw; | - | ||||||||||||
296 | const int v1 = window.top() / th; | - | ||||||||||||
297 | - | |||||||||||||
298 | - | |||||||||||||
299 | const int htiles = r.width() / tw; | - | ||||||||||||
300 | const int vtiles = r.height() / th; | - | ||||||||||||
301 | - | |||||||||||||
302 | for (int yy = 0; yy < vtiles
| 0 | ||||||||||||
303 | for (int xx = 0; xx < htiles
| 0 | ||||||||||||
304 | int ht = xx + h1; | - | ||||||||||||
305 | int vt = yy + v1; | - | ||||||||||||
306 | - | |||||||||||||
307 | QQuickContext2DTile* tile = nullptr; | - | ||||||||||||
308 | - | |||||||||||||
309 | QPoint pos(ht * tw, vt * th); | - | ||||||||||||
310 | QRect rect(pos, m_tileSize); | - | ||||||||||||
311 | - | |||||||||||||
312 | for (int i = 0; i < oldTiles.size()
| 0 | ||||||||||||
313 | if (oldTiles[i]->rect() == rect
| 0 | ||||||||||||
314 | tile = oldTiles.takeAt(i); | - | ||||||||||||
315 | break; never executed: break; | 0 | ||||||||||||
316 | } | - | ||||||||||||
317 | } never executed: end of block | 0 | ||||||||||||
318 | - | |||||||||||||
319 | if (!tile
| 0 | ||||||||||||
320 | tile = createTile(); never executed: tile = createTile(); | 0 | ||||||||||||
321 | - | |||||||||||||
322 | tile->setRect(rect); | - | ||||||||||||
323 | m_tiles.append(tile); | - | ||||||||||||
324 | } never executed: end of block | 0 | ||||||||||||
325 | } never executed: end of block | 0 | ||||||||||||
326 | - | |||||||||||||
327 | qDeleteAll(oldTiles); | - | ||||||||||||
328 | - | |||||||||||||
329 | return never executed: r;return r; never executed: return r; | 0 | ||||||||||||
330 | } | - | ||||||||||||
331 | - | |||||||||||||
332 | void QQuickContext2DTexture::clearTiles() | - | ||||||||||||
333 | { | - | ||||||||||||
334 | qDeleteAll(m_tiles); | - | ||||||||||||
335 | m_tiles.clear(); | - | ||||||||||||
336 | } never executed: end of block | 0 | ||||||||||||
337 | - | |||||||||||||
338 | QSize QQuickContext2DTexture::adjustedTileSize(const QSize &ts) | - | ||||||||||||
339 | { | - | ||||||||||||
340 | return never executed: ts;return ts; never executed: return ts; | 0 | ||||||||||||
341 | } | - | ||||||||||||
342 | - | |||||||||||||
343 | bool QQuickContext2DTexture::event(QEvent *e) | - | ||||||||||||
344 | { | - | ||||||||||||
345 | if ((
| 0 | ||||||||||||
346 | PaintEvent *pe = static_cast<PaintEvent *>(e); | - | ||||||||||||
347 | paint(pe->buffer); | - | ||||||||||||
348 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
349 | } else if ((
| 0 | ||||||||||||
350 | CanvasChangeEvent *ce = static_cast<CanvasChangeEvent *>(e); | - | ||||||||||||
351 | canvasChanged(ce->canvasSize, ce->tileSize, ce->canvasWindow, ce->dirtyRect, ce->smooth, ce->antialiasing); | - | ||||||||||||
352 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
353 | } | - | ||||||||||||
354 | return never executed: QObject::event(e);return QObject::event(e); never executed: return QObject::event(e); | 0 | ||||||||||||
355 | } | - | ||||||||||||
356 | - | |||||||||||||
357 | static inline QSize npotAdjustedSize(const QSize &size) | - | ||||||||||||
358 | { | - | ||||||||||||
359 | static bool checked = false; | - | ||||||||||||
360 | static bool npotSupported = false; | - | ||||||||||||
361 | - | |||||||||||||
362 | if (!checked
| 0 | ||||||||||||
363 | npotSupported = QOpenGLContext::currentContext()->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures); | - | ||||||||||||
364 | checked = true; | - | ||||||||||||
365 | } never executed: end of block | 0 | ||||||||||||
366 | - | |||||||||||||
367 | if (npotSupported
| 0 | ||||||||||||
368 | return never executed: QSize(qMax(64, size.width()),return QSize(qMax(64, size.width()), qMax(64, size.height())); never executed: return QSize(qMax(64, size.width()), qMax(64, size.height())); | 0 | ||||||||||||
369 | qMax(64, size.height())); never executed: return QSize(qMax(64, size.width()), qMax(64, size.height())); | 0 | ||||||||||||
370 | } | - | ||||||||||||
371 | - | |||||||||||||
372 | return never executed: QSize(qMax(64, qt_next_power_of_two(size.width())),return QSize(qMax(64, qt_next_power_of_two(size.width())), qMax(64, qt_next_power_of_two(size.height()))); never executed: return QSize(qMax(64, qt_next_power_of_two(size.width())), qMax(64, qt_next_power_of_two(size.height()))); | 0 | ||||||||||||
373 | qMax(64, qt_next_power_of_two(size.height()))); never executed: return QSize(qMax(64, qt_next_power_of_two(size.width())), qMax(64, qt_next_power_of_two(size.height()))); | 0 | ||||||||||||
374 | } | - | ||||||||||||
375 | - | |||||||||||||
376 | QQuickContext2DFBOTexture::QQuickContext2DFBOTexture() | - | ||||||||||||
377 | : QQuickContext2DTexture() | - | ||||||||||||
378 | , m_fbo(nullptr) | - | ||||||||||||
379 | , m_multisampledFbo(nullptr) | - | ||||||||||||
380 | , m_paint_device(nullptr) | - | ||||||||||||
381 | { | - | ||||||||||||
382 | m_displayTextures[0] = 0; | - | ||||||||||||
383 | m_displayTextures[1] = 0; | - | ||||||||||||
384 | m_displayTexture = -1; | - | ||||||||||||
385 | } never executed: end of block | 0 | ||||||||||||
386 | - | |||||||||||||
387 | QQuickContext2DFBOTexture::~QQuickContext2DFBOTexture() | - | ||||||||||||
388 | { | - | ||||||||||||
389 | if (m_multisampledFbo
| 0 | ||||||||||||
390 | m_multisampledFbo->release(); never executed: m_multisampledFbo->release(); | 0 | ||||||||||||
391 | else if (m_fbo
| 0 | ||||||||||||
392 | m_fbo->release(); never executed: m_fbo->release(); | 0 | ||||||||||||
393 | - | |||||||||||||
394 | delete m_fbo; | - | ||||||||||||
395 | delete m_multisampledFbo; | - | ||||||||||||
396 | delete m_paint_device; | - | ||||||||||||
397 | - | |||||||||||||
398 | if (QOpenGLContext::currentContext()
| 0 | ||||||||||||
399 | QOpenGLContext::currentContext()->functions()->glDeleteTextures(2, m_displayTextures); never executed: QOpenGLContext::currentContext()->functions()->glDeleteTextures(2, m_displayTextures); | 0 | ||||||||||||
400 | } never executed: end of block | 0 | ||||||||||||
401 | - | |||||||||||||
402 | QVector2D QQuickContext2DFBOTexture::scaleFactor() const | - | ||||||||||||
403 | { | - | ||||||||||||
404 | if (!m_fbo
| 0 | ||||||||||||
405 | return never executed: QVector2D(1, 1);return QVector2D(1, 1); never executed: return QVector2D(1, 1); | 0 | ||||||||||||
406 | return never executed: QVector2D(m_fbo->width() / m_fboSize.width(),return QVector2D(m_fbo->width() / m_fboSize.width(), m_fbo->height() / m_fboSize.height()); never executed: return QVector2D(m_fbo->width() / m_fboSize.width(), m_fbo->height() / m_fboSize.height()); | 0 | ||||||||||||
407 | m_fbo->height() / m_fboSize.height()); never executed: return QVector2D(m_fbo->width() / m_fboSize.width(), m_fbo->height() / m_fboSize.height()); | 0 | ||||||||||||
408 | } | - | ||||||||||||
409 | - | |||||||||||||
410 | QSGTexture *QQuickContext2DFBOTexture::textureForNextFrame(QSGTexture *lastTexture, QQuickWindow *) | - | ||||||||||||
411 | { | - | ||||||||||||
412 | QSGPlainTexture *texture = static_cast<QSGPlainTexture *>(lastTexture); | - | ||||||||||||
413 | - | |||||||||||||
414 | if (m_onCustomThread
| 0 | ||||||||||||
415 | m_mutex.lock(); never executed: m_mutex.lock(); | 0 | ||||||||||||
416 | - | |||||||||||||
417 | if (m_fbo
| 0 | ||||||||||||
418 | if (!texture
| 0 | ||||||||||||
419 | texture = new QSGPlainTexture(); | - | ||||||||||||
420 | texture->setHasAlphaChannel(true); | - | ||||||||||||
421 | texture->setOwnsTexture(false); | - | ||||||||||||
422 | m_dirtyTexture = true; | - | ||||||||||||
423 | } never executed: end of block | 0 | ||||||||||||
424 | - | |||||||||||||
425 | if (m_dirtyTexture
| 0 | ||||||||||||
426 | if (!m_gl
| 0 | ||||||||||||
427 | - | |||||||||||||
428 | texture->setTextureId(m_fbo->texture()); | - | ||||||||||||
429 | } never executed: else {end of block | 0 | ||||||||||||
430 | - | |||||||||||||
431 | m_displayTexture = m_displayTexture == 0
| 0 | ||||||||||||
432 | texture->setTextureId(m_displayTextures[m_displayTexture]); | - | ||||||||||||
433 | } never executed: end of block | 0 | ||||||||||||
434 | texture->setTextureSize(m_fbo->size()); | - | ||||||||||||
435 | m_dirtyTexture = false; | - | ||||||||||||
436 | } never executed: end of block | 0 | ||||||||||||
437 | - | |||||||||||||
438 | } never executed: end of block | 0 | ||||||||||||
439 | - | |||||||||||||
440 | if (m_onCustomThread
| 0 | ||||||||||||
441 | m_condition.wakeOne(); | - | ||||||||||||
442 | m_mutex.unlock(); | - | ||||||||||||
443 | } never executed: end of block | 0 | ||||||||||||
444 | - | |||||||||||||
445 | return never executed: texture;return texture; never executed: return texture; | 0 | ||||||||||||
446 | } | - | ||||||||||||
447 | - | |||||||||||||
448 | QSize QQuickContext2DFBOTexture::adjustedTileSize(const QSize &ts) | - | ||||||||||||
449 | { | - | ||||||||||||
450 | return never executed: npotAdjustedSize(ts);return npotAdjustedSize(ts); never executed: return npotAdjustedSize(ts); | 0 | ||||||||||||
451 | } | - | ||||||||||||
452 | - | |||||||||||||
453 | QRectF QQuickContext2DFBOTexture::normalizedTextureSubRect() const | - | ||||||||||||
454 | { | - | ||||||||||||
455 | return never executed: QRectF(0return QRectF(0 , 0 , qreal(m_canvasWindow.width()) / m_fboSize.width() , qreal(m_canvasWindow.height()) / m_fboSize.height()); never executed: return QRectF(0 , 0 , qreal(m_canvasWindow.width()) / m_fboSize.width() , qreal(m_canvasWindow.height()) / m_fboSize.height()); | 0 | ||||||||||||
456 | , 0 never executed: return QRectF(0 , 0 , qreal(m_canvasWindow.width()) / m_fboSize.width() , qreal(m_canvasWindow.height()) / m_fboSize.height()); | 0 | ||||||||||||
457 | , qreal(m_canvasWindow.width()) / m_fboSize.width() never executed: return QRectF(0 , 0 , qreal(m_canvasWindow.width()) / m_fboSize.width() , qreal(m_canvasWindow.height()) / m_fboSize.height()); | 0 | ||||||||||||
458 | , qreal(m_canvasWindow.height()) / m_fboSize.height()); never executed: return QRectF(0 , 0 , qreal(m_canvasWindow.width()) / m_fboSize.width() , qreal(m_canvasWindow.height()) / m_fboSize.height()); | 0 | ||||||||||||
459 | } | - | ||||||||||||
460 | - | |||||||||||||
461 | QQuickContext2DTile* QQuickContext2DFBOTexture::createTile() const | - | ||||||||||||
462 | { | - | ||||||||||||
463 | return never executed: new QQuickContext2DFBOTile();return new QQuickContext2DFBOTile(); never executed: return new QQuickContext2DFBOTile(); | 0 | ||||||||||||
464 | } | - | ||||||||||||
465 | - | |||||||||||||
466 | bool QQuickContext2DFBOTexture::doMultisampling() const | - | ||||||||||||
467 | { | - | ||||||||||||
468 | static bool extensionsChecked = false; | - | ||||||||||||
469 | static bool multisamplingSupported = false; | - | ||||||||||||
470 | - | |||||||||||||
471 | if (!extensionsChecked
| 0 | ||||||||||||
472 | QOpenGLExtensions *e = static_cast<QOpenGLExtensions *>(QOpenGLContext::currentContext()->functions()); | - | ||||||||||||
473 | multisamplingSupported = e->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
| 0 | ||||||||||||
474 | && e->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit)
| 0 | ||||||||||||
475 | extensionsChecked = true; | - | ||||||||||||
476 | } never executed: end of block | 0 | ||||||||||||
477 | - | |||||||||||||
478 | return never executed: multisamplingSupported && m_antialiasing;return multisamplingSupported && m_antialiasing; never executed: return multisamplingSupported && m_antialiasing; | 0 | ||||||||||||
479 | } | - | ||||||||||||
480 | - | |||||||||||||
481 | void QQuickContext2DFBOTexture::grabImage(const QRectF& rf) | - | ||||||||||||
482 | { | - | ||||||||||||
483 | ((rf.isValid()) ? static_cast<void>(0) : qt_assert("rf.isValid()", __FILE__, 528)); | - | ||||||||||||
484 | QQuickContext2D::mutex.lock(); | - | ||||||||||||
485 | if (m_context
| 0 | ||||||||||||
486 | if (!m_fbo
| 0 | ||||||||||||
487 | m_context->setGrabbedImage(QImage()); | - | ||||||||||||
488 | } never executed: else {end of block | 0 | ||||||||||||
489 | QImage grabbed; | - | ||||||||||||
490 | GLAcquireContext ctx(m_gl, m_surface); | - | ||||||||||||
491 | grabbed = m_fbo->toImage().scaled(m_fboSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).mirrored().copy(rf.toRect()); | - | ||||||||||||
492 | m_context->setGrabbedImage(grabbed); | - | ||||||||||||
493 | } never executed: end of block | 0 | ||||||||||||
494 | } | - | ||||||||||||
495 | QQuickContext2D::mutex.unlock(); | - | ||||||||||||
496 | } never executed: end of block | 0 | ||||||||||||
497 | - | |||||||||||||
498 | void QQuickContext2DFBOTexture::compositeTile(QQuickContext2DTile* tile) | - | ||||||||||||
499 | { | - | ||||||||||||
500 | QQuickContext2DFBOTile* t = static_cast<QQuickContext2DFBOTile*>(tile); | - | ||||||||||||
501 | QRect target = t->rect().intersected(m_canvasWindow); | - | ||||||||||||
502 | if (target.isValid()
| 0 | ||||||||||||
503 | QRect source = target; | - | ||||||||||||
504 | - | |||||||||||||
505 | source.moveTo(source.topLeft() - t->rect().topLeft()); | - | ||||||||||||
506 | target.moveTo(target.topLeft() - m_canvasWindow.topLeft()); | - | ||||||||||||
507 | - | |||||||||||||
508 | QOpenGLFramebufferObject::blitFramebuffer(m_fbo, target, t->fbo(), source); | - | ||||||||||||
509 | } never executed: end of block | 0 | ||||||||||||
510 | } never executed: end of block | 0 | ||||||||||||
511 | - | |||||||||||||
512 | QQuickCanvasItem::RenderTarget QQuickContext2DFBOTexture::renderTarget() const | - | ||||||||||||
513 | { | - | ||||||||||||
514 | return never executed: QQuickCanvasItem::FramebufferObject;return QQuickCanvasItem::FramebufferObject; never executed: return QQuickCanvasItem::FramebufferObject; | 0 | ||||||||||||
515 | } | - | ||||||||||||
516 | - | |||||||||||||
517 | QPaintDevice* QQuickContext2DFBOTexture::beginPainting() | - | ||||||||||||
518 | { | - | ||||||||||||
519 | QQuickContext2DTexture::beginPainting(); | - | ||||||||||||
520 | - | |||||||||||||
521 | if (m_canvasWindow.size().isEmpty()
| 0 | ||||||||||||
522 | delete m_fbo; | - | ||||||||||||
523 | delete m_multisampledFbo; | - | ||||||||||||
524 | delete m_paint_device; | - | ||||||||||||
525 | m_fbo = nullptr; | - | ||||||||||||
526 | m_multisampledFbo = nullptr; | - | ||||||||||||
527 | m_paint_device = nullptr; | - | ||||||||||||
528 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
529 | } else if (!m_fbo
| 0 | ||||||||||||
530 | delete m_fbo; | - | ||||||||||||
531 | delete m_multisampledFbo; | - | ||||||||||||
532 | delete m_paint_device; | - | ||||||||||||
533 | m_paint_device = nullptr; | - | ||||||||||||
534 | - | |||||||||||||
535 | m_fboSize = npotAdjustedSize(m_canvasWindow.size() * m_canvasDevicePixelRatio); | - | ||||||||||||
536 | m_canvasWindowChanged = false; | - | ||||||||||||
537 | - | |||||||||||||
538 | if (doMultisampling()
| 0 | ||||||||||||
539 | { | - | ||||||||||||
540 | QOpenGLFramebufferObjectFormat format; | - | ||||||||||||
541 | format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); | - | ||||||||||||
542 | format.setSamples(8); | - | ||||||||||||
543 | m_multisampledFbo = new QOpenGLFramebufferObject(m_fboSize, format); | - | ||||||||||||
544 | } | - | ||||||||||||
545 | { | - | ||||||||||||
546 | QOpenGLFramebufferObjectFormat format; | - | ||||||||||||
547 | format.setAttachment(QOpenGLFramebufferObject::NoAttachment); | - | ||||||||||||
548 | m_fbo = new QOpenGLFramebufferObject(m_fboSize, format); | - | ||||||||||||
549 | } | - | ||||||||||||
550 | } never executed: else {end of block | 0 | ||||||||||||
551 | QOpenGLFramebufferObjectFormat format; | - | ||||||||||||
552 | format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); | - | ||||||||||||
553 | QSize s = m_fboSize; | - | ||||||||||||
554 | if (m_antialiasing
| 0 | ||||||||||||
555 | GLint max; | - | ||||||||||||
556 | QOpenGLContext::currentContext()->functions()->glGetIntegerv( | - | ||||||||||||
557 | 0x0D33 | - | ||||||||||||
558 | , &max); | - | ||||||||||||
559 | if (s.width() * 2 <= max
| 0 | ||||||||||||
560 | s = s * 2; never executed: s = s * 2; | 0 | ||||||||||||
561 | } never executed: end of block | 0 | ||||||||||||
562 | m_fbo = new QOpenGLFramebufferObject(s, format); | - | ||||||||||||
563 | } never executed: end of block | 0 | ||||||||||||
564 | } | - | ||||||||||||
565 | - | |||||||||||||
566 | if (doMultisampling()
| 0 | ||||||||||||
567 | m_multisampledFbo->bind(); never executed: m_multisampledFbo->bind(); | 0 | ||||||||||||
568 | else | - | ||||||||||||
569 | m_fbo->bind(); never executed: m_fbo->bind(); | 0 | ||||||||||||
570 | - | |||||||||||||
571 | if (!m_paint_device
| 0 | ||||||||||||
572 | QOpenGLPaintDevice *gl_device = new QOpenGLPaintDevice(m_fbo->size()); | - | ||||||||||||
573 | gl_device->setPaintFlipped(true); | - | ||||||||||||
574 | gl_device->setSize(m_fbo->size()); | - | ||||||||||||
575 | gl_device->setDevicePixelRatio(m_canvasDevicePixelRatio); | - | ||||||||||||
576 | for (bool qt_category_enabled = lcCanvas().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 621 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_fbo->size().width(), m_fbo->size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
577 | 0 | |||||||||||||
578 | __FILE__ never executed: QMessageLogger( __FILE__ , 621 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_fbo->size().width(), m_fbo->size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
579 | , never executed: QMessageLogger( __FILE__ , 621 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_fbo->size().width(), m_fbo->size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
580 | 0 | |||||||||||||
581 | 621 never executed: QMessageLogger( __FILE__ , 621 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_fbo->size().width(), m_fbo->size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
582 | , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_fbo->size().width(), m_fbo->size().height(), m_canvasDevicePixelRatio) never executed: QMessageLogger( __FILE__ , 621 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_fbo->size().width(), m_fbo->size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
583 | 0 | |||||||||||||
584 | ; never executed: QMessageLogger( __FILE__ , 621 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_fbo->size().width(), m_fbo->size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
585 | m_paint_device = gl_device; | - | ||||||||||||
586 | } never executed: end of block | 0 | ||||||||||||
587 | - | |||||||||||||
588 | return never executed: m_paint_device;return m_paint_device; never executed: return m_paint_device; | 0 | ||||||||||||
589 | } | - | ||||||||||||
590 | - | |||||||||||||
591 | void QQuickContext2DFBOTexture::endPainting() | - | ||||||||||||
592 | { | - | ||||||||||||
593 | QQuickContext2DTexture::endPainting(); | - | ||||||||||||
594 | - | |||||||||||||
595 | - | |||||||||||||
596 | if (!m_fbo
| 0 | ||||||||||||
597 | return; never executed: return; | 0 | ||||||||||||
598 | - | |||||||||||||
599 | if (m_multisampledFbo
| 0 | ||||||||||||
600 | QOpenGLFramebufferObject::blitFramebuffer(m_fbo, m_multisampledFbo); never executed: QOpenGLFramebufferObject::blitFramebuffer(m_fbo, m_multisampledFbo); | 0 | ||||||||||||
601 | - | |||||||||||||
602 | if (m_gl
| 0 | ||||||||||||
603 | if (m_onCustomThread
| 0 | ||||||||||||
604 | m_mutex.lock(); never executed: m_mutex.lock(); | 0 | ||||||||||||
605 | - | |||||||||||||
606 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||
607 | if (m_displayTextures[0] == 0
| 0 | ||||||||||||
608 | m_displayTexture = 1; | - | ||||||||||||
609 | funcs->glGenTextures(2, m_displayTextures); | - | ||||||||||||
610 | } never executed: end of block | 0 | ||||||||||||
611 | - | |||||||||||||
612 | m_fbo->bind(); | - | ||||||||||||
613 | GLuint target = m_displayTexture == 0
| 0 | ||||||||||||
614 | funcs->glBindTexture( | - | ||||||||||||
615 | 0x0DE1 | - | ||||||||||||
616 | , m_displayTextures[target]); | - | ||||||||||||
617 | funcs->glCopyTexImage2D( | - | ||||||||||||
618 | 0x0DE1 | - | ||||||||||||
619 | , 0, | - | ||||||||||||
620 | 0x1908 | - | ||||||||||||
621 | , 0, 0, m_fbo->width(), m_fbo->height(), 0); | - | ||||||||||||
622 | - | |||||||||||||
623 | if (m_onCustomThread
| 0 | ||||||||||||
624 | m_mutex.unlock(); never executed: m_mutex.unlock(); | 0 | ||||||||||||
625 | } never executed: end of block | 0 | ||||||||||||
626 | - | |||||||||||||
627 | m_fbo->bindDefault(); | - | ||||||||||||
628 | } never executed: end of block | 0 | ||||||||||||
629 | - | |||||||||||||
630 | - | |||||||||||||
631 | QQuickContext2DImageTexture::QQuickContext2DImageTexture() | - | ||||||||||||
632 | : QQuickContext2DTexture() | - | ||||||||||||
633 | { | - | ||||||||||||
634 | } never executed: end of block | 0 | ||||||||||||
635 | - | |||||||||||||
636 | QQuickContext2DImageTexture::~QQuickContext2DImageTexture() | - | ||||||||||||
637 | { | - | ||||||||||||
638 | } | - | ||||||||||||
639 | - | |||||||||||||
640 | QQuickCanvasItem::RenderTarget QQuickContext2DImageTexture::renderTarget() const | - | ||||||||||||
641 | { | - | ||||||||||||
642 | return never executed: QQuickCanvasItem::Image;return QQuickCanvasItem::Image; never executed: return QQuickCanvasItem::Image; | 0 | ||||||||||||
643 | } | - | ||||||||||||
644 | - | |||||||||||||
645 | QQuickContext2DTile* QQuickContext2DImageTexture::createTile() const | - | ||||||||||||
646 | { | - | ||||||||||||
647 | return never executed: new QQuickContext2DImageTile();return new QQuickContext2DImageTile(); never executed: return new QQuickContext2DImageTile(); | 0 | ||||||||||||
648 | } | - | ||||||||||||
649 | - | |||||||||||||
650 | void QQuickContext2DImageTexture::grabImage(const QRectF& rf) | - | ||||||||||||
651 | { | - | ||||||||||||
652 | ((rf.isValid()) ? static_cast<void>(0) : qt_assert("rf.isValid()", __FILE__, 695)); | - | ||||||||||||
653 | QQuickContext2D::mutex.lock(); | - | ||||||||||||
654 | if (m_context
| 0 | ||||||||||||
655 | QImage grabbed = m_displayImage.copy(rf.toRect()); | - | ||||||||||||
656 | m_context->setGrabbedImage(grabbed); | - | ||||||||||||
657 | } never executed: end of block | 0 | ||||||||||||
658 | QQuickContext2D::mutex.unlock(); | - | ||||||||||||
659 | } never executed: end of block | 0 | ||||||||||||
660 | - | |||||||||||||
661 | QSGTexture *QQuickContext2DImageTexture::textureForNextFrame(QSGTexture *last, QQuickWindow *window) | - | ||||||||||||
662 | { | - | ||||||||||||
663 | if (m_onCustomThread
| 0 | ||||||||||||
664 | m_mutex.lock(); never executed: m_mutex.lock(); | 0 | ||||||||||||
665 | - | |||||||||||||
666 | delete last; | - | ||||||||||||
667 | - | |||||||||||||
668 | QSGTexture *texture = window->createTextureFromImage(m_displayImage, QQuickWindow::TextureCanUseAtlas); | - | ||||||||||||
669 | m_dirtyTexture = false; | - | ||||||||||||
670 | - | |||||||||||||
671 | if (m_onCustomThread
| 0 | ||||||||||||
672 | m_mutex.unlock(); never executed: m_mutex.unlock(); | 0 | ||||||||||||
673 | - | |||||||||||||
674 | return never executed: texture;return texture; never executed: return texture; | 0 | ||||||||||||
675 | } | - | ||||||||||||
676 | - | |||||||||||||
677 | QPaintDevice* QQuickContext2DImageTexture::beginPainting() | - | ||||||||||||
678 | { | - | ||||||||||||
679 | QQuickContext2DTexture::beginPainting(); | - | ||||||||||||
680 | - | |||||||||||||
681 | if (m_canvasWindow.size().isEmpty()
| 0 | ||||||||||||
682 | return never executed: nullptr;return nullptr; never executed: return nullptr; | 0 | ||||||||||||
683 | - | |||||||||||||
684 | - | |||||||||||||
685 | if (m_canvasWindowChanged
| 0 | ||||||||||||
686 | m_image = QImage(m_canvasWindow.size() * m_canvasDevicePixelRatio, QImage::Format_ARGB32_Premultiplied); | - | ||||||||||||
687 | m_image.setDevicePixelRatio(m_canvasDevicePixelRatio); | - | ||||||||||||
688 | m_image.fill(0x00000000); | - | ||||||||||||
689 | m_canvasWindowChanged = false; | - | ||||||||||||
690 | for (bool qt_category_enabled = lcCanvas().isDebugEnabled(); qt_category_enabled
never executed: QMessageLogger( __FILE__ , 735 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_image.size().width(), m_image.size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
691 | 0 | |||||||||||||
692 | __FILE__ never executed: QMessageLogger( __FILE__ , 735 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_image.size().width(), m_image.size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
693 | , never executed: QMessageLogger( __FILE__ , 735 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_image.size().width(), m_image.size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
694 | 0 | |||||||||||||
695 | 735 never executed: QMessageLogger( __FILE__ , 735 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_image.size().width(), m_image.size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
696 | , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_image.size().width(), m_image.size().height(), m_canvasDevicePixelRatio) never executed: QMessageLogger( __FILE__ , 735 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_image.size().width(), m_image.size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
697 | 0 | |||||||||||||
698 | ; never executed: QMessageLogger( __FILE__ , 735 , __PRETTY_FUNCTION__, lcCanvas().categoryName()).debug("%s size %.1lf x %.1lf painting with size %d x %d DPR %.1lf", (m_item->objectName().isEmpty() ? "Canvas" : QtPrivate::asString(m_item->objectName()).toLocal8Bit().constData()), m_item->width(), m_item->height(), m_image.size().width(), m_image.size().height(), m_canvasDevicePixelRatio) ; | 0 | ||||||||||||
699 | } never executed: end of block | 0 | ||||||||||||
700 | - | |||||||||||||
701 | return never executed: &m_image;return &m_image; never executed: return &m_image; | 0 | ||||||||||||
702 | } | - | ||||||||||||
703 | - | |||||||||||||
704 | void QQuickContext2DImageTexture::endPainting() | - | ||||||||||||
705 | { | - | ||||||||||||
706 | QQuickContext2DTexture::endPainting(); | - | ||||||||||||
707 | if (m_onCustomThread
| 0 | ||||||||||||
708 | m_mutex.lock(); never executed: m_mutex.lock(); | 0 | ||||||||||||
709 | m_displayImage = m_image; | - | ||||||||||||
710 | if (m_onCustomThread
| 0 | ||||||||||||
711 | m_mutex.unlock(); never executed: m_mutex.unlock(); | 0 | ||||||||||||
712 | } never executed: end of block | 0 | ||||||||||||
713 | - | |||||||||||||
714 | void QQuickContext2DImageTexture::compositeTile(QQuickContext2DTile* tile) | - | ||||||||||||
715 | { | - | ||||||||||||
716 | ((!tile->dirty()) ? static_cast<void>(0) : qt_assert("!tile->dirty()", __FILE__, 753)); | - | ||||||||||||
717 | QQuickContext2DImageTile* t = static_cast<QQuickContext2DImageTile*>(tile); | - | ||||||||||||
718 | QRect target = t->rect().intersected(m_canvasWindow); | - | ||||||||||||
719 | if (target.isValid()
| 0 | ||||||||||||
720 | QRect source = target; | - | ||||||||||||
721 | source.moveTo(source.topLeft() - t->rect().topLeft()); | - | ||||||||||||
722 | target.moveTo(target.topLeft() - m_canvasWindow.topLeft()); | - | ||||||||||||
723 | - | |||||||||||||
724 | m_painter.begin(&m_image); | - | ||||||||||||
725 | m_painter.setCompositionMode(QPainter::CompositionMode_Source); | - | ||||||||||||
726 | m_painter.drawImage(target, t->image(), source); | - | ||||||||||||
727 | m_painter.end(); | - | ||||||||||||
728 | } never executed: end of block | 0 | ||||||||||||
729 | } never executed: end of block | 0 | ||||||||||||
730 | - | |||||||||||||
731 | - | |||||||||||||
732 | - | |||||||||||||
Switch to Source code | Preprocessed file |