From e453484bca5add5973602044ff0fbc224f819a07 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 20 Jun 2014 11:58:34 +0200 Subject: Make QOpenGLWidget public QOpenGLWidget is now public. In addition Qt::WA_AlwaysStackOnTop is introduced to support the special case of semi-transparent QOpenGLWidget or QQuickWidget on top of regular widgets. hellogl_es2 becomes the qopenglwidget example. This example performs painting both via QPainter and native GL commands and has the OpenGL widget combined with other, normal widgets. The widget stack receives some changes when it comes to renderToTexture widgets like QQuickWidget and QOpenGLWidget. Calling update() will now result in a paint event, which is essential for QOpenGLWidget since we want it to behave like a regular widget. The dirty region handling is extended specially for such widgets due to performance reasons. (an OpenGL content update must not result in any backingstore painting, and is thus handled as a different kind of dirtiness) [ChangeLog] Added QOpenGLWidget. This widget serves as a replacement for QGLWidget. Task-number: QTBUG-36899 Task-number: QTBUG-40086 Change-Id: Ibf7f82fea99b39edfffd2fc088e7e0eadbca25cf Reviewed-by: Paul Olav Tvete --- src/platformsupport/eglconvenience/qeglcompositor.cpp | 11 +++++++++-- .../eglconvenience/qeglplatformbackingstore.cpp | 7 ++----- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/eglconvenience/qeglcompositor.cpp b/src/platformsupport/eglconvenience/qeglcompositor.cpp index 028f92f3cf..0deb8d3c39 100644 --- a/src/platformsupport/eglconvenience/qeglcompositor.cpp +++ b/src/platformsupport/eglconvenience/qeglcompositor.cpp @@ -142,7 +142,6 @@ void QEGLCompositor::render(QEGLPlatformWindow *window) for (int i = 0; i < textures->count(); ++i) { uint textureId = textures->textureId(i); - glBindTexture(GL_TEXTURE_2D, textureId); QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect); const float opacity = window->window()->opacity(); @@ -160,13 +159,21 @@ void QEGLCompositor::render(QEGLPlatformWindow *window) const bool translucent = window->window()->requestedFormat().alphaBufferSize() > 0; blend.set(translucent); m_blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft); - } else { + } else if (!textures->stacksOnTop(i)) { // Texture from an FBO belonging to a QOpenGLWidget blend.set(false); m_blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginBottomLeft); } } + for (int i = 0; i < textures->count(); ++i) { + if (textures->stacksOnTop(i)) { + QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect); + blend.set(true); + m_blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft); + } + } + m_blitter->setOpacity(1.0f); } diff --git a/src/platformsupport/eglconvenience/qeglplatformbackingstore.cpp b/src/platformsupport/eglconvenience/qeglplatformbackingstore.cpp index 3cb31e36ec..7b627f85ae 100644 --- a/src/platformsupport/eglconvenience/qeglplatformbackingstore.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformbackingstore.cpp @@ -181,11 +181,8 @@ void QEGLPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &r screen->compositingContext()->makeCurrent(dstWin->window()); m_textures->clear(); - for (int i = 0; i < textures->count(); ++i) { - uint textureId = textures->textureId(i); - QRect geom = textures->geometry(i); - m_textures->appendTexture(textureId, geom); - } + for (int i = 0; i < textures->count(); ++i) + m_textures->appendTexture(textures->textureId(i), textures->geometry(i), textures->stacksOnTop(i)); updateTexture(); m_textures->appendTexture(m_bsTexture, window->geometry()); -- cgit v1.2.3