summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/opengl/qopenglpaintdevice.cpp12
-rw-r--r--src/gui/opengl/qopenglpaintengine.cpp2
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp48
-rw-r--r--src/gui/painting/qplatformbackingstore.h3
4 files changed, 43 insertions, 22 deletions
diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
index 6750458f83..96fc992b45 100644
--- a/src/gui/opengl/qopenglpaintdevice.cpp
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
@@ -63,9 +63,9 @@ QT_BEGIN_NAMESPACE
\ingroup painting-3D
- The QOpenGLPaintDevice uses the current QOpenGL context to render
- QPainter draw commands. It requires OpenGL (ES) 2.0 support or
- higher.
+ The QOpenGLPaintDevice uses the \b current QOpenGL context to render
+ QPainter draw commands. The context is captured upon construction. It
+ requires support for OpenGL (ES) 2.0 or higher.
\section1 Performance
@@ -359,9 +359,9 @@ bool QOpenGLPaintDevice::paintFlipped() const
}
/*!
- This virtual method is provided as a callback to allow re-binding a
- target frame buffer object when different QOpenGLPaintDevice instances
- are issuing draw calls alternately on the same OpenGL context.
+ This virtual method is provided as a callback to allow re-binding a target
+ frame buffer object or context when different QOpenGLPaintDevice instances
+ are issuing draw calls alternately.
QPainter::beginNativePainting will also trigger this method.
*/
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index de5b6be492..d0590ca521 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -1972,6 +1972,8 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
if (!d->device)
return false;
+ d->device->ensureActiveTarget();
+
if (d->device->context() != QOpenGLContext::currentContext()) {
qWarning("QPainter::begin(): QOpenGLPaintDevice's context needs to be current");
return false;
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index 3728b0bddd..e5b06f499c 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -90,6 +90,7 @@ struct QBackingstoreTextureInfo
{
GLuint textureId;
QRect rect;
+ bool stacksOnTop;
};
Q_DECLARE_TYPEINFO(QBackingstoreTextureInfo, Q_MOVABLE_TYPE);
@@ -127,6 +128,12 @@ GLuint QPlatformTextureList::textureId(int index) const
return d->textures.at(index).textureId;
}
+bool QPlatformTextureList::stacksOnTop(int index) const
+{
+ Q_D(const QPlatformTextureList);
+ return d->textures.at(index).stacksOnTop;
+}
+
QRect QPlatformTextureList::geometry(int index) const
{
Q_D(const QPlatformTextureList);
@@ -148,12 +155,13 @@ bool QPlatformTextureList::isLocked() const
return d->locked;
}
-void QPlatformTextureList::appendTexture(GLuint textureId, const QRect &geometry)
+void QPlatformTextureList::appendTexture(GLuint textureId, const QRect &geometry, bool stacksOnTop)
{
Q_D(QPlatformTextureList);
QBackingstoreTextureInfo bi;
bi.textureId = textureId;
bi.rect = geometry;
+ bi.stacksOnTop = stacksOnTop;
d->textures.append(bi);
}
@@ -238,29 +246,39 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
QRect windowRect(QPoint(), window->size() * window->devicePixelRatio());
+ // Textures for renderToTexture widgets.
for (int i = 0; i < textures->count(); ++i) {
- GLuint textureId = textures->textureId(i);
- funcs->glBindTexture(GL_TEXTURE_2D, textureId);
-
- QRect targetRect = deviceRect(textures->geometry(i), window);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect);
- d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginBottomLeft);
+ if (!textures->stacksOnTop(i)) {
+ QRect targetRect = deviceRect(textures->geometry(i), window);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect);
+ d_ptr->blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft);
+ }
}
- GLuint textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize);
- if (!textureId)
- return;
-
funcs->glEnable(GL_BLEND);
funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), windowRect);
- d_ptr->blitter->setSwizzleRB(true);
- d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
- d_ptr->blitter->setSwizzleRB(false);
+ // Backingstore texture with the normal widgets.
+ GLuint textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize);
+ if (textureId) {
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), windowRect);
+ d_ptr->blitter->setSwizzleRB(true);
+ d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
+ d_ptr->blitter->setSwizzleRB(false);
+ }
+
+ // Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set.
+ for (int i = 0; i < textures->count(); ++i) {
+ if (textures->stacksOnTop(i)) {
+ QRect targetRect = deviceRect(textures->geometry(i), window);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect);
+ d_ptr->blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft);
+ }
+ }
funcs->glDisable(GL_BLEND);
d_ptr->blitter->release();
+
context->swapBuffers(window);
}
diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h
index 4728622cac..fe0f460ed9 100644
--- a/src/gui/painting/qplatformbackingstore.h
+++ b/src/gui/painting/qplatformbackingstore.h
@@ -84,10 +84,11 @@ public:
bool isEmpty() const { return count() == 0; }
GLuint textureId(int index) const;
QRect geometry(int index) const;
+ bool stacksOnTop(int index) const;
void lock(bool on);
bool isLocked() const;
- void appendTexture(GLuint textureId, const QRect &geometry);
+ void appendTexture(GLuint textureId, const QRect &geometry, bool stacksOnTop = false);
void clear();
Q_SIGNALS: