qopenglcompositorbackingstore.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8QOpenGLCompositorBackingStore::QOpenGLCompositorBackingStore(QWindow *window)-
9 : QPlatformBackingStore(window),-
10 m_window(window),-
11 m_bsTexture(0),-
12 m_bsTextureContext(0),-
13 m_textures(new QPlatformTextureList),-
14 m_lockedWidgetTextures(0)-
15{-
16}
never executed: end of block
0
17-
18QOpenGLCompositorBackingStore::~QOpenGLCompositorBackingStore()-
19{-
20 if (m_bsTexture
m_bsTextureDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
21 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
22-
23-
24-
25 QScopedPointer<QOffscreenSurface> tempSurface;-
26 if (!ctx
!ctxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
27 ctx = QOpenGLCompositor::instance()->context();-
28 tempSurface.reset(new QOffscreenSurface);-
29 tempSurface->setFormat(ctx->format());-
30 tempSurface->create();-
31 ctx->makeCurrent(tempSurface.data());-
32 }
never executed: end of block
0
33-
34 if (ctx
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
&& m_bsTextureContext
m_bsTextureContextDescription
TRUEnever evaluated
FALSEnever evaluated
&& ctx->shareGroup() == m_bsTextureContext->shareGroup()
ctx->shareGrou...->shareGroup()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
35 glDeleteTextures(1, &m_bsTexture);
never executed: glDeleteTextures(1, &m_bsTexture);
0
36 else-
37 QMessageLogger(__FILE__, 107, __PRETTY_FUNCTION__).warning("QOpenGLCompositorBackingStore: Texture is not valid in the current context");
never executed: QMessageLogger(__FILE__, 107, __PRETTY_FUNCTION__).warning("QOpenGLCompositorBackingStore: Texture is not valid in the current context");
0
38-
39 if (tempSurface
tempSurfaceDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
40 ctx->doneCurrent();
never executed: ctx->doneCurrent();
0
41 }
never executed: end of block
0
42-
43 delete m_textures;-
44}
never executed: end of block
0
45-
46QPaintDevice *QOpenGLCompositorBackingStore::paintDevice()-
47{-
48 return
never executed: return &m_image;
&m_image;
never executed: return &m_image;
0
49}-
50-
51void QOpenGLCompositorBackingStore::updateTexture()-
52{-
53 if (!m_bsTexture
!m_bsTextureDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
54 m_bsTextureContext = QOpenGLContext::currentContext();-
55 ((!(m_bsTextureContext)) ? qt_assert("m_bsTextureContext",__FILE__,125) : qt_noop());-
56 glGenTextures(1, &m_bsTexture);-
57 glBindTexture(0x0DE1, m_bsTexture);-
58 glTexParameterf(0x0DE1, 0x2801, 0x2600);-
59 glTexParameterf(0x0DE1, 0x2800, 0x2600);-
60 glTexParameterf(0x0DE1, 0x2802, 0x812F);-
61 glTexParameterf(0x0DE1, 0x2803, 0x812F);-
62 glTexImage2D(0x0DE1, 0, 0x1908, m_image.width(), m_image.height(), 0, 0x1908, 0x1401, 0);-
63 }
never executed: end of block
else {
0
64 glBindTexture(0x0DE1, m_bsTexture);-
65 }
never executed: end of block
0
66-
67 if (!m_dirty.isNull()
!m_dirty.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
68 QRegion fixed;-
69 QRect imageRect = m_image.rect();-
70-
71 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
72 if (!ctx->isOpenGLES()
!ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
|| ctx->format().majorVersion() >= 3
ctx->format()....Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
73 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_dirty.rects())>::type> _container_((m_dirty.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0) {-
74 QRect r = imageRect & rect;-
75 glPixelStorei(0x0CF2, m_image.width());-
76 glTexSubImage2D(0x0DE1, 0, r.x(), r.y(), r.width(), r.height(), 0x1908, 0x1401,-
77 m_image.constScanLine(r.y()) + r.x() * 4);-
78 glPixelStorei(0x0CF2, 0);-
79 }
never executed: end of block
0
80 }
never executed: end of block
else {
0
81 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(m_dirty.rects())>::type> _container_((m_dirty.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0) {-
82-
83 QRect r = imageRect & rect;-
84-
85-
86-
87 if (r.width() >= imageRect.width() / 2
r.width() >= i...ct.width() / 2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
88 r.setX(0);-
89 r.setWidth(imageRect.width());-
90 }
never executed: end of block
0
91-
92 fixed |= r;-
93 }
never executed: end of block
0
94 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(fixed.rects())>::type> _container_((fixed.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &rect = *_container_.i; _container_.control; _container_.control = 0) {-
95-
96-
97 if (rect.width() == imageRect.width()
rect.width() =...geRect.width()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
98 glTexSubImage2D(0x0DE1, 0, 0, rect.y(), rect.width(), rect.height(), 0x1908, 0x1401,-
99 m_image.constScanLine(rect.y()));-
100 }
never executed: end of block
else {
0
101 glTexSubImage2D(0x0DE1, 0, rect.x(), rect.y(), rect.width(), rect.height(), 0x1908, 0x1401,-
102 m_image.copy(rect).constBits());-
103 }
never executed: end of block
0
104 }-
105 }
never executed: end of block
0
106-
107 m_dirty = QRegion();-
108 }
never executed: end of block
0
109}
never executed: end of block
0
110-
111void QOpenGLCompositorBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)-
112{-
113-
114-
115 (void)region;;-
116 (void)offset;;-
117-
118 QOpenGLCompositor *compositor = QOpenGLCompositor::instance();-
119 QOpenGLContext *dstCtx = compositor->context();-
120 ((!(dstCtx)) ? qt_assert("dstCtx",__FILE__,190) : qt_noop());-
121-
122 QWindow *dstWin = compositor->targetWindow();-
123 if (!dstWin
!dstWinDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
124 return;
never executed: return;
0
125-
126 dstCtx->makeCurrent(dstWin);-
127 updateTexture();-
128 m_textures->clear();-
129 m_textures->appendTexture(nullptr, m_bsTexture, window->geometry());-
130-
131 compositor->update();-
132}
never executed: end of block
0
133-
134void QOpenGLCompositorBackingStore::composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,-
135 QPlatformTextureList *textures, QOpenGLContext *context,-
136 bool translucentBackground)-
137{-
138-
139-
140 (void)region;;-
141 (void)offset;;-
142 (void)context;;-
143 (void)translucentBackground;;-
144-
145 QOpenGLCompositor *compositor = QOpenGLCompositor::instance();-
146 QOpenGLContext *dstCtx = compositor->context();-
147 ((!(dstCtx)) ? qt_assert("dstCtx",__FILE__,217) : qt_noop());-
148-
149-
150-
151 ((!(context->shareGroup() == dstCtx->shareGroup())) ? qt_assert("context->shareGroup() == dstCtx->shareGroup()",__FILE__,221) : qt_noop());-
152-
153 QWindow *dstWin = compositor->targetWindow();-
154 if (!dstWin
!dstWinDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
155 return;
never executed: return;
0
156-
157 dstCtx->makeCurrent(dstWin);-
158-
159 QWindowPrivate::get(window)->lastComposeTime.start();-
160-
161 m_textures->clear();-
162 for (int i = 0; i < textures->count()
i < textures->count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
163 m_textures->appendTexture(textures->source(i), textures->textureId(i), textures->geometry(i),
never executed: m_textures->appendTexture(textures->source(i), textures->textureId(i), textures->geometry(i), textures->clipRect(i), textures->flags(i));
0
164 textures->clipRect(i), textures->flags(i));
never executed: m_textures->appendTexture(textures->source(i), textures->textureId(i), textures->geometry(i), textures->clipRect(i), textures->flags(i));
0
165-
166 updateTexture();-
167 m_textures->appendTexture(nullptr, m_bsTexture, window->geometry());-
168-
169 textures->lock(true);-
170 m_lockedWidgetTextures = textures;-
171-
172 compositor->update();-
173}
never executed: end of block
0
174-
175void QOpenGLCompositorBackingStore::notifyComposited()-
176{-
177 if (m_lockedWidgetTextures
m_lockedWidgetTexturesDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
178 QPlatformTextureList *textureList = m_lockedWidgetTextures;-
179 m_lockedWidgetTextures = 0;-
180 textureList->lock(false);-
181 }
never executed: end of block
0
182}
never executed: end of block
0
183-
184void QOpenGLCompositorBackingStore::beginPaint(const QRegion &region)-
185{-
186 m_dirty |= region;-
187-
188 if (m_image.hasAlphaChannel()
m_image.hasAlphaChannel()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
189 QPainter p(&m_image);-
190 p.setCompositionMode(QPainter::CompositionMode_Source);-
191 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(region.rects())>::type> _container_((region.rects())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QRect &r = *_container_.i; _container_.control; _container_.control = 0)-
192 p.fillRect(r, Qt::transparent);
never executed: p.fillRect(r, Qt::transparent);
0
193 }
never executed: end of block
0
194}
never executed: end of block
0
195-
196void QOpenGLCompositorBackingStore::resize(const QSize &size, const QRegion &staticContents)-
197{-
198 (void)staticContents;;-
199-
200 QOpenGLCompositor *compositor = QOpenGLCompositor::instance();-
201 QOpenGLContext *dstCtx = compositor->context();-
202 QWindow *dstWin = compositor->targetWindow();-
203 if (!dstWin
!dstWinDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
204 return;
never executed: return;
0
205-
206 m_image = QImage(size, QImage::Format_RGBA8888);-
207-
208 m_window->create();-
209-
210 dstCtx->makeCurrent(dstWin);-
211 if (m_bsTexture
m_bsTextureDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
212 glDeleteTextures(1, &m_bsTexture);-
213 m_bsTexture = 0;-
214 m_bsTextureContext = nullptr;-
215 }
never executed: end of block
0
216}
never executed: end of block
0
217-
218QImage QOpenGLCompositorBackingStore::toImage() const-
219{-
220 return
never executed: return m_image;
m_image;
never executed: return m_image;
0
221}-
222-
223-
Switch to Source codePreprocessed file

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