qplatformbackingstore.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qplatformbackingstore.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qplatformbackingstore.h"-
35#include <qwindow.h>-
36#include <qpixmap.h>-
37#include <private/qwindow_p.h>-
38-
39#include <qopengl.h>-
40#include <qopenglcontext.h>-
41#include <QtGui/QMatrix4x4>-
42#include <QtGui/QOpenGLShaderProgram>-
43#include <QtGui/QOpenGLContext>-
44#include <QtGui/QOpenGLFunctions>-
45#ifndef QT_NO_OPENGL-
46#include <QtGui/private/qopengltextureblitter_p.h>-
47#endif-
48#include <qpa/qplatformgraphicsbuffer.h>-
49#include <qpa/qplatformgraphicsbufferhelper.h>-
50-
51#ifndef GL_TEXTURE_BASE_LEVEL-
52#define GL_TEXTURE_BASE_LEVEL 0x813C-
53#endif-
54#ifndef GL_TEXTURE_MAX_LEVEL-
55#define GL_TEXTURE_MAX_LEVEL 0x813D-
56#endif-
57#ifndef GL_UNPACK_ROW_LENGTH-
58#define GL_UNPACK_ROW_LENGTH 0x0CF2-
59#endif-
60#ifndef GL_RGB10_A2-
61#define GL_RGB10_A2 0x8059-
62#endif-
63#ifndef GL_UNSIGNED_INT_2_10_10_10_REV-
64#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368-
65#endif-
66-
67QT_BEGIN_NAMESPACE-
68-
69class QPlatformBackingStorePrivate-
70{-
71public:-
72 QPlatformBackingStorePrivate(QWindow *w)-
73 : window(w)-
74#ifndef QT_NO_OPENGL-
75 , textureId(0)-
76 , blitter(0)-
77#endif-
78 {-
79 }
never executed: end of block
0
80-
81 ~QPlatformBackingStorePrivate()-
82 {-
83#ifndef QT_NO_OPENGL-
84 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
85 if (ctx) {
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
0
86 if (textureId)
textureIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
87 ctx->functions()->glDeleteTextures(1, &textureId);
never executed: ctx->functions()->glDeleteTextures(1, &textureId);
0
88 if (blitter)
blitterDescription
TRUEnever evaluated
FALSEnever evaluated
0
89 blitter->destroy();
never executed: blitter->destroy();
0
90 } else if (textureId || blitter) {
never executed: end of block
textureIdDescription
TRUEnever evaluated
FALSEnever evaluated
blitterDescription
TRUEnever evaluated
FALSEnever evaluated
0
91 qWarning("No context current during QPlatformBackingStore destruction, OpenGL resources not released");-
92 }
never executed: end of block
0
93 delete blitter;-
94#endif-
95 }
never executed: end of block
0
96 QWindow *window;-
97#ifndef QT_NO_OPENGL-
98 mutable GLuint textureId;-
99 mutable QSize textureSize;-
100 mutable bool needsSwizzle;-
101 mutable bool premultiplied;-
102 QOpenGLTextureBlitter *blitter;-
103#endif-
104};-
105-
106#ifndef QT_NO_OPENGL-
107-
108struct QBackingstoreTextureInfo-
109{-
110 void *source; // may be null-
111 GLuint textureId;-
112 QRect rect;-
113 QRect clipRect;-
114 QPlatformTextureList::Flags flags;-
115};-
116-
117Q_DECLARE_TYPEINFO(QBackingstoreTextureInfo, Q_MOVABLE_TYPE);-
118-
119class QPlatformTextureListPrivate : public QObjectPrivate-
120{-
121public:-
122 QPlatformTextureListPrivate()-
123 : locked(false)-
124 {-
125 }
never executed: end of block
0
126-
127 QVector<QBackingstoreTextureInfo> textures;-
128 bool locked;-
129};-
130-
131QPlatformTextureList::QPlatformTextureList(QObject *parent)-
132: QObject(*new QPlatformTextureListPrivate, parent)-
133{-
134}
never executed: end of block
0
135-
136QPlatformTextureList::~QPlatformTextureList()-
137{-
138}-
139-
140int QPlatformTextureList::count() const-
141{-
142 Q_D(const QPlatformTextureList);-
143 return d->textures.count();
never executed: return d->textures.count();
0
144}-
145-
146GLuint QPlatformTextureList::textureId(int index) const-
147{-
148 Q_D(const QPlatformTextureList);-
149 return d->textures.at(index).textureId;
never executed: return d->textures.at(index).textureId;
0
150}-
151-
152void *QPlatformTextureList::source(int index)-
153{-
154 Q_D(const QPlatformTextureList);-
155 return d->textures.at(index).source;
never executed: return d->textures.at(index).source;
0
156}-
157-
158QPlatformTextureList::Flags QPlatformTextureList::flags(int index) const-
159{-
160 Q_D(const QPlatformTextureList);-
161 return d->textures.at(index).flags;
never executed: return d->textures.at(index).flags;
0
162}-
163-
164QRect QPlatformTextureList::geometry(int index) const-
165{-
166 Q_D(const QPlatformTextureList);-
167 return d->textures.at(index).rect;
never executed: return d->textures.at(index).rect;
0
168}-
169-
170QRect QPlatformTextureList::clipRect(int index) const-
171{-
172 Q_D(const QPlatformTextureList);-
173 return d->textures.at(index).clipRect;
never executed: return d->textures.at(index).clipRect;
0
174}-
175-
176void QPlatformTextureList::lock(bool on)-
177{-
178 Q_D(QPlatformTextureList);-
179 if (on != d->locked) {
on != d->lockedDescription
TRUEnever evaluated
FALSEnever evaluated
0
180 d->locked = on;-
181 emit locked(on);-
182 }
never executed: end of block
0
183}
never executed: end of block
0
184-
185bool QPlatformTextureList::isLocked() const-
186{-
187 Q_D(const QPlatformTextureList);-
188 return d->locked;
never executed: return d->locked;
0
189}-
190-
191void QPlatformTextureList::appendTexture(void *source, GLuint textureId, const QRect &geometry,-
192 const QRect &clipRect, Flags flags)-
193{-
194 Q_D(QPlatformTextureList);-
195 QBackingstoreTextureInfo bi;-
196 bi.source = source;-
197 bi.textureId = textureId;-
198 bi.rect = geometry;-
199 bi.clipRect = clipRect;-
200 bi.flags = flags;-
201 d->textures.append(bi);-
202}
never executed: end of block
0
203-
204void QPlatformTextureList::clear()-
205{-
206 Q_D(QPlatformTextureList);-
207 d->textures.clear();-
208}
never executed: end of block
0
209#endif // QT_NO_OPENGL-
210-
211/*!-
212 \class QPlatformBackingStore-
213 \since 5.0-
214 \internal-
215 \preliminary-
216 \ingroup qpa-
217-
218 \brief The QPlatformBackingStore class provides the drawing area for top-level-
219 windows.-
220*/-
221-
222/*!-
223 \fn void QPlatformBackingStore::flush(QWindow *window, const QRegion &region,-
224 const QPoint &offset)-
225-
226 Flushes the given \a region from the specified \a window onto the-
227 screen.-
228-
229 The \a offset parameter is relative to the origin of the backing-
230 store image.-
231*/-
232-
233#ifndef QT_NO_OPENGL-
234-
235static inline QRect deviceRect(const QRect &rect, QWindow *window)-
236{-
237 QRect deviceRect(rect.topLeft() * window->devicePixelRatio(),-
238 rect.size() * window->devicePixelRatio());-
239 return deviceRect;
never executed: return deviceRect;
0
240}-
241-
242static inline QPoint deviceOffset(const QPoint &pt, QWindow *window)-
243{-
244 return pt * window->devicePixelRatio();
never executed: return pt * window->devicePixelRatio();
0
245}-
246-
247static QRegion deviceRegion(const QRegion &region, QWindow *window, const QPoint &offset)-
248{-
249 if (offset.isNull() && window->devicePixelRatio() <= 1)
offset.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
window->device...elRatio() <= 1Description
TRUEnever evaluated
FALSEnever evaluated
0
250 return region;
never executed: return region;
0
251-
252 QVector<QRect> rects;-
253 const QVector<QRect> regionRects = region.rects();-
254 rects.reserve(regionRects.count());-
255 foreach (const QRect &rect, regionRects)-
256 rects.append(deviceRect(rect.translated(offset), window));
never executed: rects.append(deviceRect(rect.translated(offset), window));
0
257-
258 QRegion deviceRegion;-
259 deviceRegion.setRects(rects.constData(), rects.count());-
260 return deviceRegion;
never executed: return deviceRegion;
0
261}-
262-
263static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)-
264{-
265 return QRect(topLeftRect.x(), windowHeight - topLeftRect.bottomRight().y() - 1,
never executed: return QRect(topLeftRect.x(), windowHeight - topLeftRect.bottomRight().y() - 1, topLeftRect.width(), topLeftRect.height());
0
266 topLeftRect.width(), topLeftRect.height());
never executed: return QRect(topLeftRect.x(), windowHeight - topLeftRect.bottomRight().y() - 1, topLeftRect.width(), topLeftRect.height());
0
267}-
268-
269static void blitTextureForWidget(const QPlatformTextureList *textures, int idx, QWindow *window, const QRect &deviceWindowRect,-
270 QOpenGLTextureBlitter *blitter, const QPoint &offset)-
271{-
272 const QRect clipRect = textures->clipRect(idx);-
273 if (clipRect.isEmpty())
clipRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
274 return;
never executed: return;
0
275-
276 QRect rectInWindow = textures->geometry(idx);-
277 // relative to the TLW, not necessarily our window (if the flush is for a native child widget), have to adjust-
278 rectInWindow.translate(-offset);-
279-
280 const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());-
281 const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());-
282-
283 const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(deviceRect(clippedRectInWindow, window),-
284 deviceWindowRect);-
285-
286 const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(deviceRect(srcRect, window),-
287 deviceRect(rectInWindow, window).size(),-
288 QOpenGLTextureBlitter::OriginBottomLeft);-
289-
290 blitter->blit(textures->textureId(idx), target, source);-
291}
never executed: end of block
0
292-
293/*!-
294 Flushes the given \a region from the specified \a window onto the-
295 screen, and composes it with the specified \a textures.-
296-
297 The default implementation retrieves the contents using toTexture()-
298 and composes using OpenGL. May be reimplemented in subclasses if there-
299 is a more efficient native way to do it.-
300-
301 \note \a region is relative to the window which may not be top-level in case-
302 \a window corresponds to a native child widget. \a offset is the position of-
303 the native child relative to the top-level window.-
304 */-
305-
306void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &region,-
307 const QPoint &offset,-
308 QPlatformTextureList *textures, QOpenGLContext *context,-
309 bool translucentBackground)-
310{-
311 if (!qt_window_private(window)->receivedExpose)
!qt_window_pri...receivedExposeDescription
TRUEnever evaluated
FALSEnever evaluated
0
312 return;
never executed: return;
0
313-
314 if (!context->makeCurrent(window)) {
!context->makeCurrent(window)Description
TRUEnever evaluated
FALSEnever evaluated
0
315 qWarning("composeAndFlush: makeCurrent() failed");-
316 return;
never executed: return;
0
317 }-
318-
319 QWindowPrivate::get(window)->lastComposeTime.start();-
320-
321 QOpenGLFunctions *funcs = context->functions();-
322 funcs->glViewport(0, 0, window->width() * window->devicePixelRatio(), window->height() * window->devicePixelRatio());-
323 funcs->glClearColor(0, 0, 0, translucentBackground ? 0 : 1);-
324 funcs->glClear(GL_COLOR_BUFFER_BIT);-
325-
326 if (!d_ptr->blitter) {
!d_ptr->blitterDescription
TRUEnever evaluated
FALSEnever evaluated
0
327 d_ptr->blitter = new QOpenGLTextureBlitter;-
328 d_ptr->blitter->create();-
329 }
never executed: end of block
0
330-
331 d_ptr->blitter->bind();-
332-
333 const QRect deviceWindowRect = deviceRect(QRect(QPoint(), window->size()), window);-
334 const QPoint deviceWindowOffset = deviceOffset(offset, window);-
335-
336 // Textures for renderToTexture widgets.-
337 for (int i = 0; i < textures->count(); ++i) {
i < textures->count()Description
TRUEnever evaluated
FALSEnever evaluated
0
338 if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop))
!textures->fla...::StacksOnTop)Description
TRUEnever evaluated
FALSEnever evaluated
0
339 blitTextureForWidget(textures, i, window, deviceWindowRect, d_ptr->blitter, offset);
never executed: blitTextureForWidget(textures, i, window, deviceWindowRect, d_ptr->blitter, offset);
0
340 }
never executed: end of block
0
341-
342 // Backingstore texture with the normal widgets.-
343 GLuint textureId = 0;-
344 QOpenGLTextureBlitter::Origin origin = QOpenGLTextureBlitter::OriginTopLeft;-
345 if (QPlatformGraphicsBuffer *graphicsBuffer = this->graphicsBuffer()) {
QPlatformGraph...aphicsBuffer()Description
TRUEnever evaluated
FALSEnever evaluated
0
346 if (graphicsBuffer->size() != d_ptr->textureSize) {
graphicsBuffer...r->textureSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
347 if (d_ptr->textureId)
d_ptr->textureIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
348 funcs->glDeleteTextures(1, &d_ptr->textureId);
never executed: funcs->glDeleteTextures(1, &d_ptr->textureId);
0
349 funcs->glGenTextures(1, &d_ptr->textureId);-
350 funcs->glBindTexture(GL_TEXTURE_2D, d_ptr->textureId);-
351 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
352 if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
!ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
ctx->format()....Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
353 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);-
354 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);-
355 }
never executed: end of block
0
356 funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);-
357 funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);-
358 funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);-
359 funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);-
360-
361 if (QPlatformGraphicsBufferHelper::lockAndBindToTexture(graphicsBuffer, &d_ptr->needsSwizzle, &d_ptr->premultiplied)) {
QPlatformGraph...premultiplied)Description
TRUEnever evaluated
FALSEnever evaluated
0
362 d_ptr->textureSize = graphicsBuffer->size();-
363 } else {
never executed: end of block
0
364 d_ptr->textureSize = QSize(0,0);-
365 }
never executed: end of block
0
366-
367 graphicsBuffer->unlock();-
368 } else if (!region.isEmpty()){
never executed: end of block
!region.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
369 funcs->glBindTexture(GL_TEXTURE_2D, d_ptr->textureId);-
370 QPlatformGraphicsBufferHelper::lockAndBindToTexture(graphicsBuffer, &d_ptr->needsSwizzle, &d_ptr->premultiplied);-
371 }
never executed: end of block
0
372-
373 if (graphicsBuffer->origin() == QPlatformGraphicsBuffer::OriginBottomLeft)
graphicsBuffer...iginBottomLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
374 origin = QOpenGLTextureBlitter::OriginBottomLeft;
never executed: origin = QOpenGLTextureBlitter::OriginBottomLeft;
0
375 textureId = d_ptr->textureId;-
376 } else {
never executed: end of block
0
377 TextureFlags flags = 0;-
378 textureId = toTexture(deviceRegion(region, window, offset), &d_ptr->textureSize, &flags);-
379 d_ptr->needsSwizzle = (flags & TextureSwizzle) != 0;-
380 d_ptr->premultiplied = (flags & TexturePremultiplied) != 0;-
381 if (flags & TextureFlip)
flags & TextureFlipDescription
TRUEnever evaluated
FALSEnever evaluated
0
382 origin = QOpenGLTextureBlitter::OriginBottomLeft;
never executed: origin = QOpenGLTextureBlitter::OriginBottomLeft;
0
383 }
never executed: end of block
0
384-
385 funcs->glEnable(GL_BLEND);-
386 if (d_ptr->premultiplied)
d_ptr->premultipliedDescription
TRUEnever evaluated
FALSEnever evaluated
0
387 funcs->glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
never executed: funcs->glBlendFuncSeparate(1, 0x0303, 1, 1);
0
388 else-
389 funcs->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
never executed: funcs->glBlendFuncSeparate(0x0302, 0x0303, 1, 1);
0
390-
391 if (textureId) {
textureIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
392 if (d_ptr->needsSwizzle)
d_ptr->needsSwizzleDescription
TRUEnever evaluated
FALSEnever evaluated
0
393 d_ptr->blitter->setSwizzleRB(true);
never executed: d_ptr->blitter->setSwizzleRB(true);
0
394 // The backingstore is for the entire tlw.-
395 // In case of native children offset tells the position relative to the tlw.-
396 const QRect srcRect = toBottomLeftRect(deviceWindowRect.translated(deviceWindowOffset), d_ptr->textureSize.height());-
397 const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(srcRect,-
398 d_ptr->textureSize,-
399 origin);-
400 d_ptr->blitter->blit(textureId, QMatrix4x4(), source);-
401 if (d_ptr->needsSwizzle)
d_ptr->needsSwizzleDescription
TRUEnever evaluated
FALSEnever evaluated
0
402 d_ptr->blitter->setSwizzleRB(false);
never executed: d_ptr->blitter->setSwizzleRB(false);
0
403 }
never executed: end of block
0
404-
405 // Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set.-
406 for (int i = 0; i < textures->count(); ++i) {
i < textures->count()Description
TRUEnever evaluated
FALSEnever evaluated
0
407 if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop))
textures->flag...::StacksOnTop)Description
TRUEnever evaluated
FALSEnever evaluated
0
408 blitTextureForWidget(textures, i, window, deviceWindowRect, d_ptr->blitter, offset);
never executed: blitTextureForWidget(textures, i, window, deviceWindowRect, d_ptr->blitter, offset);
0
409 }
never executed: end of block
0
410-
411 funcs->glDisable(GL_BLEND);-
412 d_ptr->blitter->release();-
413-
414 context->swapBuffers(window);-
415}
never executed: end of block
0
416-
417/*!-
418 Implemented in subclasses to return the content of the backingstore as a QImage.-
419-
420 If QPlatformIntegration::RasterGLSurface is supported, either this function or-
421 toTexture() must be implemented.-
422-
423 \sa toTexture()-
424 */-
425QImage QPlatformBackingStore::toImage() const-
426{-
427 return QImage();
never executed: return QImage();
0
428}-
429-
430/*!-
431 May be reimplemented in subclasses to return the content of the-
432 backingstore as an OpenGL texture. \a dirtyRegion is the part of the-
433 backingstore which may have changed since the last call to this function. The-
434 caller of this function must ensure that there is a current context.-
435-
436 The size of the texture is returned in \a textureSize.-
437-
438 The ownership of the texture is not transferred. The caller must not store-
439 the return value between calls, but instead call this function before each use.-
440-
441 The default implementation returns a cached texture if \a dirtyRegion is empty and-
442 \a textureSize matches the backingstore size, otherwise it retrieves the content using-
443 toImage() and performs a texture upload. This works only if the value of \a textureSize-
444 is preserved between the calls to this function.-
445-
446 If the red and blue components have to swapped, \a flags will be set to include \c-
447 TextureSwizzle. This allows creating textures from images in formats like-
448 QImage::Format_RGB32 without any further image conversion. Instead, the swizzling will-
449 be done in the shaders when performing composition. Other formats, that do not need-
450 such swizzling due to being already byte ordered RGBA, for example-
451 QImage::Format_RGBA8888, must result in having \a needsSwizzle set to false.-
452-
453 If the image has to be flipped (e.g. because the texture is attached to an FBO), \a-
454 flags will be set to include \c TextureFlip.-
455-
456 \note \a dirtyRegion is relative to the backingstore so no adjustment is needed.-
457 */-
458GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const-
459{-
460 Q_ASSERT(textureSize);-
461 Q_ASSERT(flags);-
462-
463 QImage image = toImage();-
464 QSize imageSize = image.size();-
465-
466 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
467 GLenum internalFormat = GL_RGBA;-
468 GLuint pixelType = GL_UNSIGNED_BYTE;-
469-
470 bool needsConversion = false;-
471 *flags = 0;-
472 switch (image.format()) {-
473 case QImage::Format_ARGB32_Premultiplied:
never executed: case QImage::Format_ARGB32_Premultiplied:
0
474 *flags |= TexturePremultiplied;-
475 // no break-
476 case QImage::Format_RGB32:
code before this statement never executed: case QImage::Format_RGB32:
never executed: case QImage::Format_RGB32:
0
477 case QImage::Format_ARGB32:
never executed: case QImage::Format_ARGB32:
0
478 *flags |= TextureSwizzle;-
479 break;
never executed: break;
0
480 case QImage::Format_RGBA8888_Premultiplied:
never executed: case QImage::Format_RGBA8888_Premultiplied:
0
481 *flags |= TexturePremultiplied;-
482 // no break-
483 case QImage::Format_RGBX8888:
code before this statement never executed: case QImage::Format_RGBX8888:
never executed: case QImage::Format_RGBX8888:
0
484 case QImage::Format_RGBA8888:
never executed: case QImage::Format_RGBA8888:
0
485 break;
never executed: break;
0
486 case QImage::Format_BGR30:
never executed: case QImage::Format_BGR30:
0
487 case QImage::Format_A2BGR30_Premultiplied:
never executed: case QImage::Format_A2BGR30_Premultiplied:
0
488 if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
!ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
ctx->format()....Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
489 pixelType = GL_UNSIGNED_INT_2_10_10_10_REV;-
490 internalFormat = GL_RGB10_A2;-
491 *flags |= TexturePremultiplied;-
492 } else {
never executed: end of block
0
493 needsConversion = true;-
494 }
never executed: end of block
0
495 break;
never executed: break;
0
496 case QImage::Format_RGB30:
never executed: case QImage::Format_RGB30:
0
497 case QImage::Format_A2RGB30_Premultiplied:
never executed: case QImage::Format_A2RGB30_Premultiplied:
0
498 if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
!ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
ctx->format()....Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
499 pixelType = GL_UNSIGNED_INT_2_10_10_10_REV;-
500 internalFormat = GL_RGB10_A2;-
501 *flags |= TextureSwizzle | TexturePremultiplied;-
502 } else {
never executed: end of block
0
503 needsConversion = true;-
504 }
never executed: end of block
0
505 break;
never executed: break;
0
506 default:
never executed: default:
0
507 needsConversion = true;-
508 break;
never executed: break;
0
509 }-
510 if (imageSize.isEmpty()) {
imageSize.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
511 *textureSize = imageSize;-
512 return 0;
never executed: return 0;
0
513 }-
514-
515 // Must rely on the input only, not d_ptr.-
516 // With the default composeAndFlush() textureSize is &d_ptr->textureSize.-
517 bool resized = *textureSize != imageSize;-
518 if (dirtyRegion.isEmpty() && !resized)
dirtyRegion.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!resizedDescription
TRUEnever evaluated
FALSEnever evaluated
0
519 return d_ptr->textureId;
never executed: return d_ptr->textureId;
0
520-
521 *textureSize = imageSize;-
522-
523 if (needsConversion)
needsConversionDescription
TRUEnever evaluated
FALSEnever evaluated
0
524 image = image.convertToFormat(QImage::Format_RGBA8888);
never executed: image = image.convertToFormat(QImage::Format_RGBA8888);
0
525-
526 // The image provided by the backingstore may have a stride larger than width * 4, for-
527 // instance on platforms that manually implement client-side decorations.-
528 static const int bytesPerPixel = 4;-
529 const int strideInPixels = image.bytesPerLine() / bytesPerPixel;-
530 const bool hasUnpackRowLength = !ctx->isOpenGLES() || ctx->format().majorVersion() >= 3;
!ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
ctx->format()....Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
531-
532 QOpenGLFunctions *funcs = ctx->functions();-
533-
534 if (hasUnpackRowLength) {
hasUnpackRowLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
535 funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, strideInPixels);-
536 } else if (strideInPixels != image.width()) {
never executed: end of block
strideInPixels... image.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
537 // No UNPACK_ROW_LENGTH on ES 2.0 and yet we would need it. This case is typically-
538 // hit with QtWayland which is rarely used in combination with a ES2.0-only GL-
539 // implementation. Therefore, accept the performance hit and do a copy.-
540 image = image.copy();-
541 }
never executed: end of block
0
542-
543 if (resized) {
resizedDescription
TRUEnever evaluated
FALSEnever evaluated
0
544 if (d_ptr->textureId)
d_ptr->textureIdDescription
TRUEnever evaluated
FALSEnever evaluated
0
545 funcs->glDeleteTextures(1, &d_ptr->textureId);
never executed: funcs->glDeleteTextures(1, &d_ptr->textureId);
0
546 funcs->glGenTextures(1, &d_ptr->textureId);-
547 funcs->glBindTexture(GL_TEXTURE_2D, d_ptr->textureId);-
548 if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
!ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
ctx->format()....Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
549 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);-
550 funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);-
551 }
never executed: end of block
0
552 funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);-
553 funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);-
554 funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);-
555 funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);-
556-
557 funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, imageSize.width(), imageSize.height(), 0, GL_RGBA, pixelType,-
558 const_cast<uchar*>(image.constBits()));-
559 } else {
never executed: end of block
0
560 funcs->glBindTexture(GL_TEXTURE_2D, d_ptr->textureId);-
561 QRect imageRect = image.rect();-
562 QRect rect = dirtyRegion.boundingRect() & imageRect;-
563-
564 if (hasUnpackRowLength) {
hasUnpackRowLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
565 funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, pixelType,-
566 image.constScanLine(rect.y()) + rect.x() * bytesPerPixel);-
567 } else {
never executed: end of block
0
568 // if the rect is wide enough it's cheaper to just-
569 // extend it instead of doing an image copy-
570 if (rect.width() >= imageRect.width() / 2) {
rect.width() >...ct.width() / 2Description
TRUEnever evaluated
FALSEnever evaluated
0
571 rect.setX(0);-
572 rect.setWidth(imageRect.width());-
573 }
never executed: end of block
0
574-
575 // if the sub-rect is full-width we can pass the image data directly to-
576 // OpenGL instead of copying, since there's no gap between scanlines-
577-
578 if (rect.width() == imageRect.width()) {
rect.width() =...geRect.width()Description
TRUEnever evaluated
FALSEnever evaluated
0
579 funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, rect.y(), rect.width(), rect.height(), GL_RGBA, pixelType,-
580 image.constScanLine(rect.y()));-
581 } else {
never executed: end of block
0
582 funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, pixelType,-
583 image.copy(rect).constBits());-
584 }
never executed: end of block
0
585 }-
586 }-
587-
588 if (hasUnpackRowLength)
hasUnpackRowLengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
589 funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
never executed: funcs->glPixelStorei(0x0CF2, 0);
0
590-
591 return d_ptr->textureId;
never executed: return d_ptr->textureId;
0
592}-
593#endif // QT_NO_OPENGL-
594-
595/*!-
596 \fn QPaintDevice* QPlatformBackingStore::paintDevice()-
597-
598 Implement this function to return the appropriate paint device.-
599*/-
600-
601/*!-
602 Constructs an empty surface for the given top-level \a window.-
603*/-
604QPlatformBackingStore::QPlatformBackingStore(QWindow *window)-
605 : d_ptr(new QPlatformBackingStorePrivate(window))-
606{-
607}
never executed: end of block
0
608-
609/*!-
610 Destroys this surface.-
611*/-
612QPlatformBackingStore::~QPlatformBackingStore()-
613{-
614 delete d_ptr;-
615}
never executed: end of block
0
616-
617/*!-
618 Returns a pointer to the top-level window associated with this-
619 surface.-
620*/-
621QWindow* QPlatformBackingStore::window() const-
622{-
623 return d_ptr->window;
never executed: return d_ptr->window;
0
624}-
625-
626/*!-
627 This function is called before painting onto the surface begins,-
628 with the \a region in which the painting will occur.-
629-
630 \sa endPaint(), paintDevice()-
631*/-
632-
633void QPlatformBackingStore::beginPaint(const QRegion &)-
634{-
635}-
636-
637/*!-
638 This function is called after painting onto the surface has ended.-
639-
640 \sa beginPaint(), paintDevice()-
641*/-
642-
643void QPlatformBackingStore::endPaint()-
644{-
645}-
646-
647/*!-
648 Accessor for a backingstores graphics buffer abstraction-
649*/-
650QPlatformGraphicsBuffer *QPlatformBackingStore::graphicsBuffer() const-
651{-
652 return Q_NULLPTR;
never executed: return nullptr;
0
653}-
654-
655/*!-
656 Scrolls the given \a area \a dx pixels to the right and \a dy-
657 downward; both \a dx and \a dy may be negative.-
658-
659 Returns \c true if the area was scrolled successfully; false otherwise.-
660*/-
661bool QPlatformBackingStore::scroll(const QRegion &area, int dx, int dy)-
662{-
663 Q_UNUSED(area);-
664 Q_UNUSED(dx);-
665 Q_UNUSED(dy);-
666-
667 return false;
never executed: return false;
0
668}-
669-
670QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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