summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@digia.com>2013-04-15 15:40:54 +0200
committerSamuel Rødal <samuel.rodal@digia.com>2013-04-16 16:32:44 +0200
commite5601d283c4d9a5c43352b6f1acd0e1968a31b83 (patch)
tree5050e2459f168588e734b7c5e313fccd6eda9104
parentc5435f57950df7b193c2375345a269f3e82baaae (diff)
Fix threaded resizing once more :)
This time make Scenegraph also play along nicely Change-Id: I8d52fe2fc514466cef40e247e978434d8014e18b Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp23
-rw-r--r--src/plugins/platforms/qwayland-egl/qwaylandglcontext.h1
-rw-r--r--src/plugins/platforms/wayland_common/qwaylandwindow.cpp24
-rw-r--r--src/plugins/platforms/wayland_common/qwaylandwindow.h8
4 files changed, 41 insertions, 15 deletions
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp
index 61ee2f10a..3dccb7b21 100644
--- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp
+++ b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.cpp
@@ -64,6 +64,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat
, m_format(q_glFormatFromConfig(m_eglDisplay, m_config))
, m_blitProgram(0)
, m_textureCache(0)
+ , m_currentOnSurface(0)
{
m_shareEGLContext = share ? static_cast<QWaylandGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
@@ -92,9 +93,20 @@ QWaylandGLContext::~QWaylandGLContext()
bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface)
{
QWaylandEglWindow *window = static_cast<QWaylandEglWindow *>(surface);
+ if (m_currentOnSurface != window) {
+ if (m_currentOnSurface) {
+ QWaylandWindow *oldWindow = m_currentOnSurface;
+ m_currentOnSurface = 0;
+ oldWindow->resizeMutex()->unlock();
+ }
+ window->resizeMutex()->lock();
+ m_currentOnSurface = window;
+ }
+
EGLSurface eglSurface = window->eglSurface();
if (!eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_context)) {
qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this);
+ m_currentOnSurface->resizeMutex()->unlock();
return false;
}
@@ -106,11 +118,17 @@ bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface)
void QWaylandGLContext::doneCurrent()
{
eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ if (m_currentOnSurface) {
+ QWaylandWindow *window = m_currentOnSurface;
+ m_currentOnSurface = 0;
+ window->resizeMutex()->unlock();
+ }
}
void QWaylandGLContext::swapBuffers(QPlatformSurface *surface)
{
QWaylandEglWindow *window = static_cast<QWaylandEglWindow *>(surface);
+
EGLSurface eglSurface = window->eglSurface();
if (window->decoration()) {
@@ -200,8 +218,11 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface)
}
eglSwapBuffers(m_eglDisplay, eglSurface);
+ if (m_currentOnSurface == window) {
+ m_currentOnSurface = 0;
+ window->resizeMutex()->unlock();
+ }
- window->doResize();
}
GLuint QWaylandGLContext::defaultFramebufferObject(QPlatformSurface *surface) const
diff --git a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h
index f6909a74c..b42168303 100644
--- a/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h
+++ b/src/plugins/platforms/qwayland-egl/qwaylandglcontext.h
@@ -87,6 +87,7 @@ private:
QOpenGLShaderProgram *m_blitProgram;
QOpenGLTextureCache *m_textureCache;
+ QWaylandWindow *m_currentOnSurface;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland_common/qwaylandwindow.cpp b/src/plugins/platforms/wayland_common/qwaylandwindow.cpp
index 631bcf931..e452f4db3 100644
--- a/src/plugins/platforms/wayland_common/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland_common/qwaylandwindow.cpp
@@ -66,7 +66,8 @@
QT_USE_NAMESPACE
QWaylandWindow::QWaylandWindow(QWindow *window)
- : QPlatformWindow(window)
+ : QObject()
+ , QPlatformWindow(window)
, mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display())
, mSurface(mDisplay->createSurface(this))
, mShellSurface(0)
@@ -102,8 +103,8 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
QString className = exeFileInfo.baseName() + QLatin1String(".desktop");
mShellSurface->setClassName(className.toUtf8().constData());
- if (parent() && mSubSurfaceWindow) {
- mSubSurfaceWindow->setParent(static_cast<const QWaylandWindow *>(parent()));
+ if (QPlatformWindow::parent() && mSubSurfaceWindow) {
+ mSubSurfaceWindow->setParent(static_cast<const QWaylandWindow *>(QPlatformWindow::parent()));
} else if (window->transientParent()) {
if (window->transientParent()) {
mShellSurface->updateTransientParent(window->transientParent());
@@ -180,7 +181,6 @@ void QWaylandWindow::setVisible(bool visible)
if (!mSentInitialResize) {
QWindowSystemInterface::handleGeometryChange(window(), geometry());
- QWindowSystemInterface::flushWindowSystemEvents();
mSentInitialResize = true;
}
@@ -208,23 +208,23 @@ bool QWaylandWindow::isExposed() const
void QWaylandWindow::configure(uint32_t edges, int32_t width, int32_t height)
{
- QMutexLocker resizeLocker(&mResizeLock);
mConfigure.edges |= edges;
mConfigure.width = width;
mConfigure.height = height;
if (!mResizeExposedSent) {
mResizeExposedSent = true;
- QWindowSystemInterface::handleExposeEvent(window(),QRegion(geometry()));
+ QMetaObject::invokeMethod(this, "doResize", Qt::QueuedConnection);
}
}
void QWaylandWindow::doResize()
{
- if (mConfigure.isEmpty())
+ mResizeExposedSent = false;
+ if (mConfigure.isEmpty()) {
return;
+ }
- QMutexLocker resizeLocker(&mResizeLock);
int widthWithoutMargins = qMax(mConfigure.width-(frameMargins().left() +frameMargins().right()),1);
int heightWithoutMargins = qMax(mConfigure.height-(frameMargins().top()+frameMargins().bottom()),1);
@@ -243,14 +243,14 @@ void QWaylandWindow::doResize()
}
mOffset += QPoint(x, y);
+ mResizeLock.lock();
setGeometry(geometry);
-
- mResizeExposedSent = false;
+ mResizeLock.unlock();
mConfigure.clear();
-
- resizeLocker.unlock();
QWindowSystemInterface::handleGeometryChange(window(), geometry);
+ QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry));
+ QWindowSystemInterface::flushWindowSystemEvents();
}
void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
diff --git a/src/plugins/platforms/wayland_common/qwaylandwindow.h b/src/plugins/platforms/wayland_common/qwaylandwindow.h
index 37dad1c4d..613f17e70 100644
--- a/src/plugins/platforms/wayland_common/qwaylandwindow.h
+++ b/src/plugins/platforms/wayland_common/qwaylandwindow.h
@@ -81,8 +81,9 @@ public:
uint32_t edges;
};
-class QWaylandWindow : public QPlatformWindow
+class QWaylandWindow : public QObject, public QPlatformWindow
{
+ Q_OBJECT
public:
enum WindowType {
Shm,
@@ -105,7 +106,6 @@ public:
void setGeometry(const QRect &rect);
void configure(uint32_t edges, int32_t width, int32_t height);
- void doResize();
void attach(QWaylandBuffer *buffer, int x, int y);
void attachOffset(QWaylandBuffer *buffer);
@@ -149,6 +149,10 @@ public:
inline bool isMaximized() const { return mState == Qt::WindowMaximized; }
inline bool isFullscreen() const { return mState == Qt::WindowFullScreen; }
+ QMutex *resizeMutex() { return &mResizeLock; }
+public slots:
+ void doResize();
+
protected:
QWaylandDisplay *mDisplay;
struct wl_surface *mSurface;