summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/qwayland-egl
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@digia.com>2013-03-20 12:57:46 +0100
committerJørgen Lind <jorgen.lind@digia.com>2013-04-05 10:35:33 +0200
commit076673dfe3d967e42c8d92b08165e2ac0e166b9b (patch)
tree14e47471563ea69d22842837a23a3ffc4ad4b908 /src/plugins/platforms/qwayland-egl
parent77248e2765e4db5cd7fe6e53e07a612d75b91011 (diff)
Fix window decorations to be thread safe
Rather than have window decorations that paint directly to the paint device representing the window surface, window decorations are now generated on demand into a backing store based on their current state, and then are rendered to a surface when needed. There is still a problem with resizing though that needs to be addressed. Change-Id: I7516628239eb0f9ae46d49bcb4bb2cb94ec6a617 Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/plugins/platforms/qwayland-egl')
-rw-r--r--src/plugins/platforms/qwayland-egl/qwayland-egl.pro2
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandegldecoration.cpp67
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandegldecoration.h63
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp12
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h6
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp46
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandglcontext.h3
7 files changed, 42 insertions, 157 deletions
diff --git a/src/plugins/platforms/qwayland-egl/qwayland-egl.pro b/src/plugins/platforms/qwayland-egl/qwayland-egl.pro
index cdebf9bbc..339f94616 100644
--- a/src/plugins/platforms/qwayland-egl/qwayland-egl.pro
+++ b/src/plugins/platforms/qwayland-egl/qwayland-egl.pro
@@ -16,11 +16,9 @@ OTHER_FILES += \
SOURCES += qwaylandeglintegration.cpp \
qwaylandglcontext.cpp \
qwaylandeglwindow.cpp \
- qwaylandegldecoration.cpp \
main.cpp
HEADERS += qwaylandeglintegration.h \
qwaylandglcontext.h \
qwaylandeglwindow.h \
- qwaylandegldecoration.h \
qwaylandeglinclude.h
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.cpp b/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.cpp
deleted file mode 100644
index 7724f2833..000000000
--- a/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwaylandegldecoration.h"
-
-#include "qwaylandeglwindow.h"
-
-#include <QtGui/QPainter>
-#include <QtGui/QOpenGLPaintDevice>
-
-QT_USE_NAMESPACE
-
-QWaylandEglDecoration::QWaylandEglDecoration(QWaylandEglWindow *window)
- : QWaylandDecoration(window)
-{
-}
-
-QWaylandEglDecoration::~QWaylandEglDecoration()
-{
-}
-
-void QWaylandEglDecoration::paintDecoration()
-{
- glClearColor(backgroundColor().redF(), backgroundColor().greenF(), backgroundColor().blueF(), backgroundColor().alphaF());
- glClear(GL_COLOR_BUFFER_BIT);
-
- QOpenGLPaintDevice device(window()->frameGeometry().size());
- paint(&device);
-}
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.h b/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.h
deleted file mode 100644
index 3039b7285..000000000
--- a/src/plugins/platforms/qwayland-egl/qwaylandegldecoration.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWAYLANDEGLDECORATION_H
-#define QWAYLANDEGLDECORATION_H
-
-#include "qwaylanddecoration.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWaylandEglWindow;
-
-class QWaylandEglDecoration : public QWaylandDecoration
-{
-public:
- QWaylandEglDecoration(QWaylandEglWindow *window);
- ~QWaylandEglDecoration();
-
- void paintDecoration();
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QWAYLANDEGLDECORATION_H
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp
index 6edf74832..162d9316c 100644
--- a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp
+++ b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.cpp
@@ -43,7 +43,6 @@
#include "qwaylandscreen.h"
#include "qwaylandglcontext.h"
-#include "qwaylandegldecoration.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
@@ -89,11 +88,11 @@ QWaylandWindow::WindowType QWaylandEglWindow::windowType() const
return QWaylandWindow::Egl;
}
-void QWaylandEglWindow::redraw()
+void QWaylandEglWindow::setGeometry(const QRect &rect)
{
createDecoration();
QMargins margins = frameMargins();
- QSize sizeWithMargins = geometry().size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
+ QSize sizeWithMargins = rect.size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
if (m_waylandEglWindow) {
int current_width, current_height;
@@ -108,6 +107,8 @@ void QWaylandEglWindow::redraw()
} else {
m_waylandEglWindow = wl_egl_window_create(mSurface, sizeWithMargins.width(), sizeWithMargins.height());
}
+
+ QWaylandWindow::setGeometry(rect);
}
QRect QWaylandEglWindow::contentsRect() const
@@ -170,8 +171,3 @@ void QWaylandEglWindow::bindContentFBO()
m_contentFBO->bind();
}
}
-
-void QWaylandEglWindow::createDecorationInstance()
-{
- new QWaylandEglDecoration(this);
-}
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h
index dfc5a26d9..f973547a7 100644
--- a/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h
+++ b/src/plugins/platforms/qwayland-egl/qwaylandeglwindow.h
@@ -58,6 +58,7 @@ public:
~QWaylandEglWindow();
WindowType windowType() const;
+ virtual void setGeometry(const QRect &rect);
QRect contentsRect() const;
EGLSurface eglSurface() const;
@@ -68,11 +69,6 @@ public:
void bindContentFBO();
- void redraw();
-
-protected:
- void createDecorationInstance();
-
private:
QWaylandEglIntegration *m_eglIntegration;
mutable struct wl_egl_window *m_waylandEglWindow;
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp
index 4d8017dc2..a0024745e 100644
--- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp
+++ b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp
@@ -49,6 +49,7 @@
#include <QDebug>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtGui/private/qopenglcontext_p.h>
+#include <QtGui/private/qopengltexturecache_p.h>
#include <qpa/qplatformopenglcontext.h>
#include <QtGui/QSurfaceFormat>
@@ -62,6 +63,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat
, m_config(q_configFromGLFormat(m_eglDisplay, format, true))
, m_format(q_glFormatFromConfig(m_eglDisplay, m_config))
, m_blitProgram(0)
+ , m_textureCache(0)
{
m_shareEGLContext = share ? static_cast<QWaylandGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
@@ -83,6 +85,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat
QWaylandGLContext::~QWaylandGLContext()
{
delete m_blitProgram;
+ delete m_textureCache;
eglDestroyContext(m_eglDisplay, m_context);
}
@@ -137,23 +140,28 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface)
}
}
+ if (!m_textureCache) {
+ m_textureCache = new QOpenGLTextureCache(this->context());
+ }
+
glDisable(GL_DEPTH_TEST);
+ glDisable(GL_BLEND);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
- if (window->decoration())
- window->decoration()->paintDecoration();
-
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, window->contentTexture());
- QRect r = window->contentsRect();
- glViewport(r.x(), r.y(), r.width(), r.height());
-
static const GLfloat squareVertices[] = {
-1.f, -1.f,
1.0f, -1.f,
-1.f, 1.0f,
- 1.0f, 1.0f,
+ 1.0f, 1.0f
+ };
+
+ static const GLfloat inverseSquareVertices[] = {
+ -1.f, 1.f,
+ 1.f, 1.f,
+ -1.f, -1.f,
+ 1.f, -1.f
};
+
static const GLfloat textureVertices[] = {
0.0f, 0.0f,
1.0f, 0.0f,
@@ -161,19 +169,33 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface)
1.0f, 1.0f,
};
- m_blitProgram->bind();
-
m_blitProgram->setUniformValue("texture", 0);
m_blitProgram->enableAttributeArray("position");
m_blitProgram->enableAttributeArray("texCoords");
- m_blitProgram->setAttributeArray("position", squareVertices, 2);
m_blitProgram->setAttributeArray("texCoords", textureVertices, 2);
m_blitProgram->bind();
+ glActiveTexture(GL_TEXTURE0);
+ //Draw Decoration
+ m_blitProgram->setAttributeArray("position", inverseSquareVertices, 2);
+ QImage decorationImage = window->decoration()->contentImage();
+ m_textureCache->bindTexture(context(), decorationImage);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ QRect windowRect = window->window()->frameGeometry();
+ glViewport(0, 0, windowRect.width(), windowRect.height());
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ //Draw Content
+ m_blitProgram->setAttributeArray("position", squareVertices, 2);
+ glBindTexture(GL_TEXTURE_2D, window->contentTexture());
+ QRect r = window->contentsRect();
+ glViewport(r.x(), r.y(), r.width(), r.height());
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ //Cleanup
m_blitProgram->disableAttributeArray("position");
m_blitProgram->disableAttributeArray("texCoords");
m_blitProgram->release();
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h
index 696a0b918..f6909a74c 100644
--- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h
+++ b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h
@@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE
class QWaylandWindow;
class QWaylandGLWindowSurface;
class QOpenGLShaderProgram;
+class QOpenGLTextureCache;
class QWaylandGLContext : public QPlatformOpenGLContext {
public:
@@ -84,6 +85,8 @@ private:
EGLConfig m_config;
QSurfaceFormat m_format;
QOpenGLShaderProgram *m_blitProgram;
+ QOpenGLTextureCache *m_textureCache;
+
};
QT_END_NAMESPACE