From 61c6f64872a363cbde209e6f9a7cd05e79713c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 26 Apr 2011 17:32:02 +0200 Subject: Dont call QPlatformGLContext::makeCurrent from subclass (cherry picked from commit fc0a6ab220ab97b8f6acf90bf04b46de513a4d96) --- .../wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp | 2 +- .../platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp | 2 +- .../gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp index d63087d934..7e84b5d3ab 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp @@ -145,7 +145,7 @@ void * QWaylandReadbackEglContext::getProcAddress(const QString &procName) QPlatformWindowFormat QWaylandReadbackEglContext::platformWindowFormat() const { - return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); + return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); } void QWaylandReadbackEglContext::geometryChanged() diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp index d293019909..5c5e88afb1 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -55,7 +55,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindo , mEglDisplay(eglDisplay) , mSurface(EGL_NO_SURFACE) , mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true)) - , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig)) + , mFormat(q_windowFormatFromConfig(mEglDisplay,mConfig)) { QPlatformGLContext *sharePlatformContext = 0; sharePlatformContext = format.sharedGLContext(); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index 92acf752e4..1536b2e5ca 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -102,7 +102,7 @@ void * QWaylandXCompositeEGLContext::getProcAddress(const QString &procName) QPlatformWindowFormat QWaylandXCompositeEGLContext::platformWindowFormat() const { - return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); + return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); } void QWaylandXCompositeEGLContext::sync_function(void *data) -- cgit v1.2.3 From 6e2bbb58fd779d3e969c0adb1cc98f64c8c7b2ee Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 29 Apr 2011 13:04:43 +0200 Subject: include file fix for wayland --- .../gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp | 1 + .../gl_integration/xcomposite_share/qwaylandxcompositebuffer.h | 4 +++- src/plugins/platforms/wayland/qwaylandbuffer.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp index 4b0d3a073f..81c18058dd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp @@ -42,6 +42,7 @@ #include "qwaylandxcompositebuffer.h" #include "wayland-client.h" +#include "wayland-xcomposite-client-protocol.h" QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(wl_xcomposite *xcomposite, uint32_t window, const QSize &size, wl_visual *visual) :mSize(size) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h index b346651957..c51f6bbf4c 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h @@ -43,8 +43,10 @@ #define QWAYLANDXCOMPOSITEBUFFER_H #include "qwaylandbuffer.h" +#include -#include "wayland-xcomposite-client-protocol.h" +struct wl_xcomposite; +struct wl_visual; class QWaylandXCompositeBuffer : public QWaylandBuffer { diff --git a/src/plugins/platforms/wayland/qwaylandbuffer.h b/src/plugins/platforms/wayland/qwaylandbuffer.h index 8779d5fda0..e97a07b211 100644 --- a/src/plugins/platforms/wayland/qwaylandbuffer.h +++ b/src/plugins/platforms/wayland/qwaylandbuffer.h @@ -44,7 +44,7 @@ #include -#include +struct wl_buffer; class QWaylandBuffer { public: -- cgit v1.2.3 From a90d1b432c32becb9066e1542e44c0d7e0147fcc Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 29 Apr 2011 16:02:36 +0200 Subject: Make the wayland plugin compile --- .../wayland/gl_integration/qwaylandglintegration.h | 4 ++-- .../gl_integration/qwaylandglwindowsurface.cpp | 18 +++++++++--------- .../wayland/gl_integration/qwaylandglwindowsurface.h | 4 ++-- .../readback_egl/qwaylandreadbackeglcontext.h | 1 - .../readback_egl/qwaylandreadbackeglintegration.cpp | 2 +- .../readback_egl/qwaylandreadbackeglintegration.h | 3 +-- .../readback_egl/qwaylandreadbackeglwindow.cpp | 2 +- .../readback_egl/qwaylandreadbackeglwindow.h | 2 +- .../readback_glx/qwaylandreadbackglxintegration.cpp | 4 ++-- .../readback_glx/qwaylandreadbackglxintegration.h | 4 ++-- .../readback_glx/qwaylandreadbackglxwindow.cpp | 2 +- .../readback_glx/qwaylandreadbackglxwindow.h | 2 +- .../wayland_egl/qwaylandeglintegration.cpp | 2 +- .../wayland_egl/qwaylandeglintegration.h | 4 ++-- .../gl_integration/wayland_egl/qwaylandeglwindow.cpp | 2 +- .../gl_integration/wayland_egl/qwaylandeglwindow.h | 2 +- .../qwaylandxcompositeeglintegration.cpp | 4 ++-- .../qwaylandxcompositeeglintegration.h | 4 ++-- .../xcomposite_egl/qwaylandxcompositeeglwindow.cpp | 2 +- .../xcomposite_egl/qwaylandxcompositeeglwindow.h | 2 +- .../xcomposite_glx/qwaylandxcompositeglxcontext.cpp | 5 +++-- .../xcomposite_glx/qwaylandxcompositeglxcontext.h | 2 +- .../qwaylandxcompositeglxintegration.cpp | 4 ++-- .../qwaylandxcompositeglxintegration.h | 4 ++-- .../xcomposite_glx/qwaylandxcompositeglxwindow.cpp | 2 +- .../xcomposite_glx/qwaylandxcompositeglxwindow.h | 2 +- src/plugins/platforms/wayland/qwaylandcursor.cpp | 4 ++-- src/plugins/platforms/wayland/qwaylandcursor.h | 2 +- .../platforms/wayland/qwaylandinputdevice.cpp | 12 ++++++------ .../platforms/wayland/qwaylandintegration.cpp | 20 +++++++++----------- src/plugins/platforms/wayland/qwaylandintegration.h | 4 ++-- src/plugins/platforms/wayland/qwaylandscreen.cpp | 4 ++-- src/plugins/platforms/wayland/qwaylandscreen.h | 2 +- src/plugins/platforms/wayland/qwaylandshmsurface.cpp | 16 ++++++++-------- src/plugins/platforms/wayland/qwaylandshmsurface.h | 6 +++--- src/plugins/platforms/wayland/qwaylandshmwindow.cpp | 4 ++-- src/plugins/platforms/wayland/qwaylandshmwindow.h | 2 +- src/plugins/platforms/wayland/qwaylandwindow.cpp | 8 ++++---- src/plugins/platforms/wayland/qwaylandwindow.h | 2 +- 39 files changed, 86 insertions(+), 89 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h index ac16039c9d..bb829a15fb 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h @@ -44,7 +44,7 @@ class QWaylandWindow; class QWaylandDisplay; -class QWidget; +class QWindow; class QWaylandGLIntegration { @@ -54,7 +54,7 @@ public: virtual void initialize() = 0; - virtual QWaylandWindow *createEglWindow(QWidget *widget) = 0; + virtual QWaylandWindow *createEglWindow(QWindow *window) = 0; static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay); }; diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp index ebe4c7bf86..3fc063aab7 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp @@ -47,6 +47,7 @@ #include #include +#include #include @@ -133,9 +134,9 @@ static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, drawTexture(r, texture, texSize, sourceRect); } -QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWidget *window) +QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWindow *window) : QWindowSurface(window) - , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) + , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) , mPaintDevice(0) { @@ -153,30 +154,29 @@ QPaintDevice *QWaylandGLWindowSurface::paintDevice() void QWaylandGLWindowSurface::beginPaint(const QRegion &) { - window()->platformWindow()->glContext()->makeCurrent(); + window()->handle()->glContext()->makeCurrent(); glClearColor(0,0,0,0xff); glClear(GL_COLOR_BUFFER_BIT); } -void QWaylandGLWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QWaylandGLWindowSurface::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(offset); Q_UNUSED(region); - QWaylandWindow *ww = (QWaylandWindow *) widget->platformWindow(); - + if (mPaintDevice->isBound()) mPaintDevice->release(); QRect rect(0,0,size().width(),size().height()); - QGLContext *ctx = QGLContext::fromPlatformGLContext(ww->glContext()); + QGLContext *ctx = QGLContext::fromWindowContext(window->glContext()); blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect); - ww->glContext()->swapBuffers(); + window->glContext()->swapBuffers(); } void QWaylandGLWindowSurface::resize(const QSize &size) { QWindowSurface::resize(size); - window()->platformWindow()->glContext()->makeCurrent(); + window()->glContext()->makeCurrent(); delete mPaintDevice; mPaintDevice = new QGLFramebufferObject(size); } diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h index 8d53b42a56..1de449b4dc 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h @@ -51,13 +51,13 @@ class QGLFramebufferObject; class QWaylandGLWindowSurface : public QWindowSurface { public: - QWaylandGLWindowSurface(QWidget *window); + QWaylandGLWindowSurface(QWindow *window); ~QWaylandGLWindowSurface(); void beginPaint(const QRegion &); QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); void resize(const QSize &size); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h index ac682759e9..1540b92080 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h @@ -43,7 +43,6 @@ #define QWAYLANDREADBACKEGLGLCONTEXT_H #include -#include #include "qwaylandreadbackeglintegration.h" #include "qwaylandreadbackeglwindow.h" diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp index 20f7ffb609..8a3d769e65 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp @@ -81,7 +81,7 @@ void QWaylandReadbackEglIntegration::initialize() } } -QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWidget *widget) +QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWindow *window) { return new QWaylandReadbackEglWindow(widget,this); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h index 84fa64fd34..767634bbc2 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h @@ -48,7 +48,6 @@ #include #include #include -#include #include @@ -61,7 +60,7 @@ public: ~QWaylandReadbackEglIntegration(); void initialize(); - QWaylandWindow *createEglWindow(QWidget *widget); + QWaylandWindow *createEglWindow(QWindow *window); QWaylandDisplay *waylandDisplay() const; Display *xDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp index 2ae212ba67..134f431c3d 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp @@ -43,7 +43,7 @@ #include "qwaylandreadbackeglcontext.h" -QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration) +QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWindow *window, QWaylandReadbackEglIntegration *eglIntegration) : QWaylandShmWindow(window) , mEglIntegration(eglIntegration) , mContext(0) diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h index 453ad27cd9..6fd09659dc 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h @@ -50,7 +50,7 @@ class QWaylandReadbackEglContext; class QWaylandReadbackEglWindow : public QWaylandShmWindow { public: - QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration); + QWaylandReadbackEglWindow(QWindow *window, QWaylandReadbackEglIntegration *eglIntegration); WindowType windowType() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp index 4651f0c30e..25422d6c4f 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp @@ -66,9 +66,9 @@ void QWaylandReadbackGlxIntegration::initialize() { } -QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWidget *widget) +QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWindow *window) { - return new QWaylandReadbackGlxWindow(widget,this); + return new QWaylandReadbackGlxWindow(window,this); } QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h index 9056393905..c706da7f79 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include @@ -60,7 +60,7 @@ public: void initialize(); - QWaylandWindow *createEglWindow(QWidget *widget); + QWaylandWindow *createEglWindow(QWindow *window); QWaylandDisplay *waylandDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp index ca1603c649..f095862227 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp @@ -41,7 +41,7 @@ #include "qwaylandreadbackglxwindow.h" -QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration) +QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration) : QWaylandShmWindow(window) , mGlxIntegration(glxIntegration) , mContext(0) diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h index 4d7bb3ee74..47a1ce9ab4 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h @@ -49,7 +49,7 @@ class QWaylandReadbackGlxWindow : public QWaylandShmWindow { public: - QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration); + QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration); WindowType windowType() const; QPlatformGLContext *glContext() const; diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp index 39e7be5ac6..4e4cc51e5f 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -74,7 +74,7 @@ void QWaylandEglIntegration::initialize() } } -QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWidget *window) +QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWindow *window) { return new QWaylandEglWindow(window); } diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h index bf4c3fe45c..0f116c3ab5 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h @@ -47,7 +47,7 @@ #include "qwaylandeglinclude.h" class QWaylandWindow; -class QWidget; +class QWindow; class QWaylandEglIntegration : public QWaylandGLIntegration { @@ -57,7 +57,7 @@ public: void initialize(); - QWaylandWindow *createEglWindow(QWidget *window); + QWaylandWindow *createEglWindow(QWindow *window); EGLDisplay eglDisplay() const; struct wl_egl_display *nativeDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp index d7cf0a55e1..a3f5dc2558 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp @@ -44,7 +44,7 @@ #include "qwaylandscreen.h" #include "qwaylandglcontext.h" -QWaylandEglWindow::QWaylandEglWindow(QWidget *window) +QWaylandEglWindow::QWaylandEglWindow(QWindow *window) : QWaylandWindow(window) , mGLContext(0) , mWaylandEglWindow(0) diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h index 549d039bf8..8e4c65c6b5 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h @@ -51,7 +51,7 @@ class QWaylandGLContext; class QWaylandEglWindow : public QWaylandWindow { public: - QWaylandEglWindow(QWidget *window); + QWaylandEglWindow(QWindow *window); ~QWaylandEglWindow(); WindowType windowType() const; void setGeometry(const QRect &rect); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp index 95b4112cdc..5f515144cd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp @@ -70,9 +70,9 @@ void QWaylandXCompositeEGLIntegration::initialize() { } -QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWidget *widget) +QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWindow *window) { - return new QWaylandXCompositeEGLWindow(widget,this); + return new QWaylandXCompositeEGLWindow(window,this); } Display * QWaylandXCompositeEGLIntegration::xDisplay() const diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h index 590ae3754c..8edaa2becd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include @@ -66,7 +66,7 @@ public: void initialize(); - QWaylandWindow *createEglWindow(QWidget *widget); + QWaylandWindow *createEglWindow(QWindow *window); QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp index 1c9d36fe92..19cbbd2d49 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp @@ -43,7 +43,7 @@ #include -QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration) +QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration) : QWaylandWindow(window) , mGlxIntegration(glxIntegration) , mContext(0) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h index fc33b32322..111e751815 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h @@ -49,7 +49,7 @@ class QWaylandXCompositeEGLWindow : public QWaylandWindow { public: - QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration); + QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration); WindowType windowType() const; QPlatformGLContext *glContext() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp index caf51170a6..fbe8d38fa6 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -46,6 +46,7 @@ #include "wayland-xcomposite-client-protocol.h" #include +#include #include @@ -55,7 +56,7 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLX , mWindow(window) , mBuffer(0) , mXWindow(0) - , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat())) + , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->window()->format())) , mWaitingForSyncCallback(false) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); @@ -90,7 +91,7 @@ void * QWaylandXCompositeGLXContext::getProcAddress(const QString &procName) return (void *) glXGetProcAddress(reinterpret_cast(procName.toLatin1().data())); } -QPlatformWindowFormat QWaylandXCompositeGLXContext::platformWindowFormat() const +QWindowFormat QWaylandXCompositeGLXContext::windowFormat() const { return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h index eb2e5a518e..2a94bd1c00 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -64,7 +64,7 @@ public: void swapBuffers(); void* getProcAddress(const QString& procName); - QPlatformWindowFormat platformWindowFormat() const; + QWindowFormat windowFormat() const; void geometryChanged(); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp index 43c0135c6e..7dabbdfbd0 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -70,9 +70,9 @@ void QWaylandXCompositeGLXIntegration::initialize() { } -QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWidget *widget) +QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *window) { - return new QWaylandXCompositeGLXWindow(widget,this); + return new QWaylandXCompositeGLXWindow(window,this); } Display * QWaylandXCompositeGLXIntegration::xDisplay() const diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h index 24a40167e2..4f53449915 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include @@ -63,7 +63,7 @@ public: void initialize(); - QWaylandWindow *createEglWindow(QWidget *widget); + QWaylandWindow *createEglWindow(QWindow *window); QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp index db0f254a20..40b72186f0 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp @@ -43,7 +43,7 @@ #include -QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration) +QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration) : QWaylandWindow(window) , mGlxIntegration(glxIntegration) , mContext(0) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h index 536153dbcf..f1bab465d4 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h @@ -49,7 +49,7 @@ class QWaylandXCompositeGLXWindow : public QWaylandWindow { public: - QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration); + QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration); WindowType windowType() const; QPlatformGLContext *glContext() const; diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp index 614686f971..72274a28f9 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp @@ -108,11 +108,11 @@ QWaylandCursor::QWaylandCursor(QWaylandScreen *screen) { } -void QWaylandCursor::changeCursor(QCursor *cursor, QWidget *widget) +void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window) { const struct pointer_image *p; - if (widget == NULL) + if (window == NULL) return; p = NULL; diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h index 254cb9473a..9f7d871249 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.h +++ b/src/plugins/platforms/wayland/qwaylandcursor.h @@ -52,7 +52,7 @@ class QWaylandCursor : QPlatformCursor { public: QWaylandCursor(QWaylandScreen *screen); - void changeCursor(QCursor *cursor, QWidget *widget); + void changeCursor(QCursor *cursor, QWindow *window); QWaylandShmBuffer *mBuffer; QWaylandDisplay *mDisplay; }; diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 6c2f341f64..cd2a389e2b 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -104,7 +104,7 @@ void QWaylandInputDevice::inputHandleMotion(void *data, inputDevice->mSurfacePos = QPoint(surface_x, surface_y); inputDevice->mGlobalPos = QPoint(x, y); inputDevice->mTime = time; - QWindowSystemInterface::handleMouseEvent(window->widget(), + QWindowSystemInterface::handleMouseEvent(window->window(), time, inputDevice->mSurfacePos, inputDevice->mGlobalPos, @@ -140,7 +140,7 @@ void QWaylandInputDevice::inputHandleButton(void *data, inputDevice->mButtons &= ~qt_button; inputDevice->mTime = time; - QWindowSystemInterface::handleMouseEvent(window->widget(), + QWindowSystemInterface::handleMouseEvent(window->window(), time, inputDevice->mSurfacePos, inputDevice->mGlobalPos, @@ -254,7 +254,7 @@ void QWaylandInputDevice::inputHandleKey(void *data, code, sym, s[0], (int) inputDevice->mModifiers); if (window) { - QWindowSystemInterface::handleKeyEvent(window->widget(), + QWindowSystemInterface::handleKeyEvent(window->window(), time, type, sym, inputDevice->mModifiers, QString::fromLatin1(s)); @@ -277,13 +277,13 @@ void QWaylandInputDevice::inputHandlePointerFocus(void *data, if (inputDevice->mPointerFocus) { window = inputDevice->mPointerFocus; - QWindowSystemInterface::handleLeaveEvent(window->widget()); + QWindowSystemInterface::handleLeaveEvent(window->window()); inputDevice->mPointerFocus = NULL; } if (surface) { window = (QWaylandWindow *) wl_surface_get_user_data(surface); - QWindowSystemInterface::handleEnterEvent(window->widget()); + QWindowSystemInterface::handleEnterEvent(window->window()); inputDevice->mPointerFocus = window; } @@ -315,7 +315,7 @@ void QWaylandInputDevice::inputHandleKeyboardFocus(void *data, if (surface) { window = (QWaylandWindow *) wl_surface_get_user_data(surface); inputDevice->mKeyboardFocus = window; - QWindowSystemInterface::handleWindowActivated(window->widget()); + QWindowSystemInterface::handleWindowActivated(window->window()); } else { inputDevice->mKeyboardFocus = NULL; QWindowSystemInterface::handleWindowActivated(0); diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 3f3ee5e571..5d60136b35 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -49,7 +49,7 @@ #include #include -#include +#include #include #ifdef QT_WAYLAND_GL_SUPPORT @@ -89,27 +89,25 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) return new QRasterPixmapData(type); } -QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const +QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const { - Q_UNUSED(winId); #ifdef QT_WAYLAND_GL_SUPPORT - bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL); + bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface; if (useOpenGL) - return mDisplay->eglIntegration()->createEglWindow(widget); + return mDisplay->eglIntegration()->createEglWindow(window); #endif - return new QWaylandShmWindow(widget); + return new QWaylandShmWindow(window); } -QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId winId) const +QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const { Q_UNUSED(winId); - Q_UNUSED(winId); #ifdef QT_WAYLAND_GL_SUPPORT - bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL); + bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface; if (useOpenGL) - return new QWaylandGLWindowSurface(widget); + return new QWaylandGLWindowSurface(window); #endif - return new QWaylandShmWindowSurface(widget); + return new QWaylandShmWindowSurface(window); } QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index fc9b8d6a6e..b375804387 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -56,8 +56,8 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; - QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; + QPlatformWindow *createPlatformWindow(QWindow *window) const; + QWindowSurface *createWindowSurface(QWindow *window, WId winId) const; QList screens() const; diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index 4f50cb61e6..8888f256ce 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -81,9 +81,9 @@ QImage::Format QWaylandScreen::format() const return mFormat; } -QWaylandScreen * QWaylandScreen::waylandScreenFromWidget(QWidget *widget) +QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window) { - QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWidget(widget); + QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(window); return static_cast(platformScreen); } diff --git a/src/plugins/platforms/wayland/qwaylandscreen.h b/src/plugins/platforms/wayland/qwaylandscreen.h index 7784646da9..ec52e37166 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.h +++ b/src/plugins/platforms/wayland/qwaylandscreen.h @@ -62,7 +62,7 @@ public: wl_visual *visual() const; - static QWaylandScreen *waylandScreenFromWidget(QWidget *widget); + static QWaylandScreen *waylandScreenFromWindow(QWindow *window); private: QWaylandDisplay *mWaylandDisplay; diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp index 34f4436f25..69e5076a50 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp @@ -91,10 +91,10 @@ QWaylandShmBuffer::~QWaylandShmBuffer(void) wl_buffer_destroy(mBuffer); } -QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window) +QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWindow *window) : QWindowSurface(window) , mBuffer(0) - , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) + , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) { } @@ -109,27 +109,27 @@ QPaintDevice *QWaylandShmWindowSurface::paintDevice() void QWaylandShmWindowSurface::beginPaint(const QRegion &) { - QWaylandShmWindow *waylandWindow = static_cast(window()->platformWindow()); + QWaylandShmWindow *waylandWindow = static_cast(window()->handle()); Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); waylandWindow->waitForFrameSync(); } -void QWaylandShmWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) +void QWaylandShmWindowSurface::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { - Q_UNUSED(widget); + Q_UNUSED(window); Q_UNUSED(offset); - QWaylandShmWindow *waylandWindow = static_cast(window()->platformWindow()); + QWaylandShmWindow *waylandWindow = static_cast(window->handle()); Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); waylandWindow->damage(region); } void QWaylandShmWindowSurface::resize(const QSize &size) { - QWaylandShmWindow *waylandWindow = static_cast(window()->platformWindow()); + QWaylandShmWindow *waylandWindow = static_cast(window()->handle()); Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); QWindowSurface::resize(size); - QImage::Format format = QPlatformScreen::platformScreenForWidget(window())->format(); + QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format(); if (mBuffer != NULL && mBuffer->size() == size) return; diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmsurface.h index b29ceaf1b8..ce3e5ff5b9 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.h +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.h @@ -44,7 +44,7 @@ #include "qwaylandbuffer.h" #include - +#include #include QT_BEGIN_NAMESPACE @@ -65,11 +65,11 @@ private: class QWaylandShmWindowSurface : public QWindowSurface { public: - QWaylandShmWindowSurface(QWidget *window); + QWaylandShmWindowSurface(QWindow *window); ~QWaylandShmWindowSurface(); QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); void resize(const QSize &size); void beginPaint(const QRegion &); diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp index c083e58305..c298668dfe 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp @@ -47,8 +47,8 @@ #include -QWaylandShmWindow::QWaylandShmWindow(QWidget *widget) - : QWaylandWindow(widget) +QWaylandShmWindow::QWaylandShmWindow(QWindow *window) + : QWaylandWindow(window) { newSurfaceCreated(); } diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h index 5dc6351c46..473c6df2ee 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.h +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h @@ -48,7 +48,7 @@ class QWaylandShmWindow : public QWaylandWindow { public: - QWaylandShmWindow(QWidget *widget); + QWaylandShmWindow(QWindow *window); ~QWaylandShmWindow(); WindowType windowType() const; diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 6f522911d7..35abeafd63 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -46,14 +46,14 @@ #include "qwaylandinputdevice.h" #include "qwaylandscreen.h" -#include +#include #include #include -QWaylandWindow::QWaylandWindow(QWidget *window) +QWaylandWindow::QWaylandWindow(QWindow *window) : QPlatformWindow(window) - , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) + , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) , mBuffer(0) , mWaitingForFrameSync(false) { @@ -109,7 +109,7 @@ void QWaylandWindow::configure(uint32_t time, uint32_t edges, setGeometry(geometry); - QWindowSystemInterface::handleGeometryChange(widget(), geometry); + QWindowSystemInterface::handleGeometryChange(window(), geometry); } void QWaylandWindow::attach(QWaylandBuffer *buffer) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h index 1e605088ad..954d5f2199 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.h +++ b/src/plugins/platforms/wayland/qwaylandwindow.h @@ -59,7 +59,7 @@ public: Egl }; - QWaylandWindow(QWidget *window); + QWaylandWindow(QWindow *window); ~QWaylandWindow(); virtual WindowType windowType() const = 0; -- cgit v1.2.3 From 86f20c89af906ecd58a4da74f82bd895ec8392e8 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 3 May 2011 14:11:45 +0200 Subject: Track QPlatformGLContext API changes --- .../gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp | 4 +--- .../gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp | 4 +--- .../wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp | 1 - .../gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp | 2 -- .../gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp | 1 - 5 files changed, 2 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp index 7e84b5d3ab..6971459659 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp @@ -97,8 +97,6 @@ QWaylandReadbackEglContext::~QWaylandReadbackEglContext() void QWaylandReadbackEglContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); - mWindow->waitForFrameSync(); eglMakeCurrent(mEglIntegration->eglDisplay(),mPixmapSurface,mPixmapSurface,mContext); @@ -114,7 +112,7 @@ void QWaylandReadbackEglContext::swapBuffers() { eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface); - if (QPlatformGLContext::currentContext() != this) { + if (QWindowContext::currentContext().handle() != this) { makeCurrent(); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp index 08c5cf6c51..5bafd418df 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp @@ -85,8 +85,6 @@ QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegr void QWaylandReadbackGlxContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); - glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext); } @@ -97,7 +95,7 @@ void QWaylandReadbackGlxContext::doneCurrent() void QWaylandReadbackGlxContext::swapBuffers() { - if (QPlatformGLContext::currentContext() != this) { + if (QWindowContext::currentContext().handle() != this) { makeCurrent(); } diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp index 5c5e88afb1..d8cff1f8c1 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -90,7 +90,6 @@ QWaylandGLContext::~QWaylandGLContext() void QWaylandGLContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); if (mSurface == EGL_NO_SURFACE) { qWarning("makeCurrent with EGL_NO_SURFACE"); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index 1536b2e5ca..21b369d0ae 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -75,8 +75,6 @@ QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(QWaylandXCompositeEGL void QWaylandXCompositeEGLContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); - eglMakeCurrent(mEglIntegration->eglDisplay(),mEglWindowSurface,mEglWindowSurface,mContext); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp index fbe8d38fa6..39316adf6c 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -67,7 +67,6 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLX void QWaylandXCompositeGLXContext::makeCurrent() { - QPlatformGLContext::makeCurrent(); glXMakeCurrent(mGlxIntegration->xDisplay(),mXWindow,mContext); } -- cgit v1.2.3 From f9442d7c51f35362f22b39a53dd019e26884bfd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 6 May 2011 12:12:00 +0200 Subject: Fixed compilation of Wayland plugin. --- src/plugins/platforms/wayland/qwaylandnativeinterface.cpp | 12 ++++++------ src/plugins/platforms/wayland/qwaylandnativeinterface.h | 6 +++--- src/plugins/platforms/wayland/wayland.pro | 4 ++++ 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp index c3bfba03cc..d056f75125 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp @@ -45,26 +45,26 @@ #include "qwaylandwindow.h" #include -void *QWaylandNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget) +void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { QByteArray lowerCaseResource = resourceString.toLower(); if (lowerCaseResource == "display") - return qPlatformScreenForWidget(widget)->display()->wl_display(); + return qPlatformScreenForWindow(window)->display()->wl_display(); if (lowerCaseResource == "surface") { - return ((QWaylandWindow *) widget->platformWindow())->wl_surface(); + return ((QWaylandWindow *) window->handle())->wl_surface(); } return NULL; } -QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWidget(QWidget *widget) +QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWindow(QWindow *window) { QWaylandScreen *screen; - if (widget) { - screen = static_cast(QPlatformScreen::platformScreenForWidget(widget)); + if (window) { + screen = static_cast(QPlatformScreen::platformScreenForWindow(window)); } else { screen = static_cast(QApplicationPrivate::platformIntegration()->screens()[0]); } diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.h b/src/plugins/platforms/wayland/qwaylandnativeinterface.h index ac4cdb9a22..dbb17a63a9 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.h +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.h @@ -49,11 +49,11 @@ class QWaylandNativeInterface : public QPlatformNativeInterface { public: - void *nativeResourceForWidget(const QByteArray &resourceString, - QWidget *widget); + void *nativeResourceForWindow(const QByteArray &resourceString, + QWindow *window); private: - static QWaylandScreen *qPlatformScreenForWidget(QWidget *widget); + static QWaylandScreen *qPlatformScreenForWindow(QWindow *window); }; diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 3139232afe..fa93f8878b 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -33,6 +33,10 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND INCLUDEPATH += $$PWD +QT += gui-private +QT += opengl-private +QT += core-private + include ($$PWD/gl_integration/gl_integration.pri) include (../fontdatabases/genericunix/genericunix.pri) -- cgit v1.2.3 From 9474f82f8a4ca4abfc349c17debd84f26148fc20 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 7 May 2011 22:25:30 +0200 Subject: QTDIR/src compiles again --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 876b46ae9a..3e8039fd9f 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -51,7 +51,7 @@ #endif #include -#include +#include #include #include -- cgit v1.2.3 From 5dc3a46a2ac56321a888ada4c15d95cabd3a4159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 9 May 2011 14:08:19 +0200 Subject: Wayland plugin compile fixes. --- src/plugins/platforms/wayland/qwaylandnativeinterface.cpp | 4 ++-- src/plugins/platforms/wayland/qwaylandshmsurface.cpp | 1 - src/plugins/platforms/wayland/wayland.pro | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp index d056f75125..8a7799e7a9 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp @@ -43,7 +43,7 @@ #include "qwaylanddisplay.h" #include "qwaylandwindow.h" -#include +#include void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { @@ -66,7 +66,7 @@ QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWindow(QWindow *wind if (window) { screen = static_cast(QPlatformScreen::platformScreenForWindow(window)); } else { - screen = static_cast(QApplicationPrivate::platformIntegration()->screens()[0]); + screen = static_cast(QGuiApplicationPrivate::platformIntegration()->screens()[0]); } return screen; } diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp index 69e5076a50..4bc54399ee 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp @@ -41,7 +41,6 @@ #include "qwaylandshmsurface.h" #include -#include #include "qwaylanddisplay.h" #include "qwaylandshmwindow.h" diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index fa93f8878b..8372d7ac6f 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -36,6 +36,7 @@ INCLUDEPATH += $$PWD QT += gui-private QT += opengl-private QT += core-private +QT += widgets-private include ($$PWD/gl_integration/gl_integration.pri) -- cgit v1.2.3 From 0719af99b7041e024a4fdf0fbdc26b1ca0dd787d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 11 May 2011 12:39:14 +0200 Subject: Compile fixes after merge. --- src/plugins/platforms/wayland/qwaylandclipboard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandclipboard.cpp b/src/plugins/platforms/wayland/qwaylandclipboard.cpp index 47ca22865b..e463af5d47 100644 --- a/src/plugins/platforms/wayland/qwaylandclipboard.cpp +++ b/src/plugins/platforms/wayland/qwaylandclipboard.cpp @@ -43,12 +43,12 @@ #include "qwaylanddisplay.h" #include "qwaylandinputdevice.h" #include -#include +#include #include #include #include #include -#include +#include static QWaylandClipboard *clipboard; -- cgit v1.2.3 From c5d1f239426b4cf9b3ddc0f34fd1514504dfb985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 23 May 2011 09:52:14 +0200 Subject: Remove superfluous setter / getter for QWindowFormat in QWindow. --- .../gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp index 39bd99e5a0..d4d7d8aff0 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -56,7 +56,7 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLX , mWindow(window) , mBuffer(0) , mXWindow(0) - , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->window()->format())) + , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->window()->requestedWindowFormat())) , mWaitingForSyncCallback(false) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); -- cgit v1.2.3 From d0beb0d95b63c230e965cf151a39ac6e7b779ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 31 May 2011 15:47:02 +0200 Subject: Fix the egl path for xcb and wayland plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Samuel Rødal --- .../readback_egl/qwaylandreadbackeglcontext.cpp | 10 ++++++---- .../gl_integration/readback_egl/qwaylandreadbackeglcontext.h | 2 +- .../readback_egl/qwaylandreadbackeglintegration.cpp | 2 +- .../readback_egl/qwaylandreadbackeglintegration.h | 2 ++ .../wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp | 6 ++++-- .../wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp | 11 +++-------- .../wayland/gl_integration/wayland_egl/qwaylandglcontext.h | 6 +++--- .../xcomposite_egl/qwaylandxcompositeeglcontext.cpp | 5 +++-- .../xcomposite_egl/qwaylandxcompositeeglcontext.h | 4 +--- 9 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp index a3a86880f9..8769752d5f 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp @@ -43,12 +43,14 @@ #include "../../../eglconvenience/qeglconvenience.h" +#include +#include + #include #include #include "qwaylandshmsurface.h" -#include static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) { @@ -77,7 +79,7 @@ QWaylandReadbackEglContext::QWaylandReadbackEglContext(QWaylandReadbackEglIntegr , mWindow(window) , mBuffer(0) , mPixmap(0) - , mConfig(q_configFromQPlatformWindowFormat(eglIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_PIXMAP_BIT)) + , mConfig(q_configFromQWindowFormat(eglIntegration->eglDisplay(),window->window()->requestedWindowFormat(),true,EGL_PIXMAP_BIT)) , mPixmapSurface(EGL_NO_SURFACE) { QVector eglContextAttrs; @@ -112,7 +114,7 @@ void QWaylandReadbackEglContext::swapBuffers() { eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface); - if (QWindowContext::currentContext().handle() != this) { + if (QWindowContext::currentContext()->handle() != this) { makeCurrent(); } @@ -141,7 +143,7 @@ void * QWaylandReadbackEglContext::getProcAddress(const QString &procName) return (void *) eglGetProcAddress(procName.toLatin1().data()); } -QPlatformWindowFormat QWaylandReadbackEglContext::platformWindowFormat() const +QWindowFormat QWaylandReadbackEglContext::windowFormat() const { return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h index 4a71ef08a7..f57ac46667 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h @@ -60,7 +60,7 @@ public: void swapBuffers(); void* getProcAddress(const QString& procName); - virtual QPlatformWindowFormat platformWindowFormat() const; + virtual QWindowFormat windowFormat() const; void geometryChanged(); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp index b77671317d..50a1170f79 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp @@ -83,7 +83,7 @@ void QWaylandReadbackEglIntegration::initialize() QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWindow *window) { - return new QWaylandReadbackEglWindow(widget,this); + return new QWaylandReadbackEglWindow(window,this); } EGLDisplay QWaylandReadbackEglIntegration::eglDisplay() diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h index 20e1636b7e..649f96e9cc 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp index 90d4aa59a9..4a085ae0bd 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp @@ -44,6 +44,8 @@ #include "qwaylandscreen.h" #include "qwaylandglcontext.h" +#include + QWaylandEglWindow::QWaylandEglWindow(QWindow *window) : QWaylandWindow(window) , mGLContext(0) @@ -83,7 +85,7 @@ QPlatformGLContext * QWaylandEglWindow::glContext() const { if (!mGLContext) { QWaylandEglWindow *that = const_cast(this); - that->mGLContext = new QWaylandGLContext(mEglIntegration->eglDisplay(),widget()->platformWindowFormat()); + that->mGLContext = new QWaylandGLContext(mEglIntegration->eglDisplay(),this->window()->requestedWindowFormat()); EGLNativeWindowType window(reinterpret_cast(mWaylandEglWindow)); EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL); @@ -98,7 +100,7 @@ void QWaylandEglWindow::newSurfaceCreated() if (mWaylandEglWindow) { wl_egl_window_destroy(mWaylandEglWindow); } - wl_visual *visual = QWaylandScreen::waylandScreenFromWidget(widget())->visual(); + wl_visual *visual = QWaylandScreen::waylandScreenFromWindow(window())->visual(); QSize size = geometry().size(); if (!size.isValid()) size = QSize(0,0); diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp index 172722d85c..0cff704ab1 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -47,22 +47,17 @@ #include "../../../eglconvenience/qeglconvenience.h" #include -#include +#include #include -QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format) +QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QWindowFormat &format) : QPlatformGLContext() , mEglDisplay(eglDisplay) , mSurface(EGL_NO_SURFACE) - , mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true)) + , mConfig(q_configFromQWindowFormat(mEglDisplay,format,true)) , mFormat(q_windowFormatFromConfig(mEglDisplay,mConfig)) { - QPlatformGLContext *sharePlatformContext = 0; - sharePlatformContext = format.sharedGLContext(); - mFormat.setSharedContext(sharePlatformContext); EGLContext shareEGLContext = EGL_NO_CONTEXT; - if (sharePlatformContext) - shareEGLContext = static_cast(sharePlatformContext)->mContext; eglBindAPI(EGL_OPENGL_ES_API); diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h index 2c6feb498c..47070f54b1 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h @@ -53,14 +53,14 @@ class QWaylandGLWindowSurface; class QWaylandGLContext : public QPlatformGLContext { public: - QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format); + QWaylandGLContext(EGLDisplay eglDisplay, const QWindowFormat &format); ~QWaylandGLContext(); void makeCurrent(); void doneCurrent(); void swapBuffers(); void* getProcAddress(const QString&); - QPlatformWindowFormat platformWindowFormat() const { return mFormat; } + QWindowFormat windowFormat() const { return mFormat; } void setEglSurface(EGLSurface surface); EGLConfig eglConfig() const; @@ -70,7 +70,7 @@ private: EGLContext mContext; EGLSurface mSurface; EGLConfig mConfig; - QPlatformWindowFormat mFormat; + QWindowFormat mFormat; QWaylandGLContext(); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index 7cdd2b8c5e..e61ee69d37 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -46,6 +46,7 @@ #include "wayland-xcomposite-client-protocol.h" #include +#include #include "qeglconvenience.h" #include "qxlibeglintegration.h" @@ -58,7 +59,7 @@ QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(QWaylandXCompositeEGL , mWindow(window) , mBuffer(0) , mXWindow(0) - , mConfig(q_configFromQPlatformWindowFormat(glxIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_WINDOW_BIT)) + , mConfig(q_configFromQWindowFormat(glxIntegration->eglDisplay(),window->window()->requestedWindowFormat(),true,EGL_WINDOW_BIT)) , mWaitingForSync(false) { QVector eglContextAttrs; @@ -98,7 +99,7 @@ void * QWaylandXCompositeEGLContext::getProcAddress(const QString &procName) return (void *)eglGetProcAddress(qPrintable(procName)); } -QPlatformWindowFormat QWaylandXCompositeEGLContext::platformWindowFormat() const +QWindowFormat QWaylandXCompositeEGLContext::windowFormat() const { return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h index 9d9dd53e0b..528faf07c5 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h @@ -44,8 +44,6 @@ #include -#include - #include "qwaylandbuffer.h" #include "qwaylandxcompositeeglintegration.h" @@ -61,7 +59,7 @@ public: void swapBuffers(); void* getProcAddress(const QString& procName); - QPlatformWindowFormat platformWindowFormat() const; + QWindowFormat windowFormat() const; void geometryChanged(); -- cgit v1.2.3 From fc9a648dc03ec4531553bc3d65ae4dba3c5b5980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 6 Jun 2011 08:45:02 +0200 Subject: Make building of platform plugins indifferent if its out of source This requires some source files to be shipped with the Qt install They are now copied into QT_INSTALL_DATA/platform --- .../platforms/wayland/gl_integration/readback_egl/readback_egl.pri | 4 +--- .../platforms/wayland/gl_integration/readback_glx/readback_glx.pri | 2 +- .../platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri | 2 +- .../wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri | 4 ++-- .../wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri | 2 +- src/plugins/platforms/wayland/wayland.pro | 5 +++-- 6 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri b/src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri index 0d8e01b6bb..3325fe8ec9 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri @@ -1,14 +1,12 @@ - LIBS += -lX11 -lXext -lEGL +load(qpa/egl/convenience) HEADERS += \ $$PWD/qwaylandreadbackeglintegration.h \ $$PWD/qwaylandreadbackeglcontext.h \ $$PWD/qwaylandreadbackeglwindow.h \ - $$PWD/../../../eglconvenience/qeglconvenience.h SOURCES += \ $$PWD/qwaylandreadbackeglintegration.cpp \ $$PWD/qwaylandreadbackeglwindow.cpp \ $$PWD/qwaylandreadbackeglcontext.cpp \ - $$PWD/../../../eglconvenience/qeglconvenience.cpp diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri b/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri index f8ea005937..dc84d1c9e9 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri @@ -1,4 +1,4 @@ -include (../../../glxconvenience/glxconvenience.pri) +load(qpa/glx/convenience) HEADERS += \ $$PWD/qwaylandreadbackglxintegration.h \ $$PWD/qwaylandreadbackglxwindow.h \ diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri index cd0701150f..6f4edb08a6 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri @@ -1,4 +1,4 @@ -include (../../../eglconvenience/eglconvenience.pri) +load(qpa/egl/convenience) LIBS += -lwayland-egl -lEGL INCLUDEPATH += $$PWD diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri index c3533f9ce3..7d2f8ad443 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri @@ -1,6 +1,6 @@ include (../xcomposite_share/xcomposite_share.pri) -include (../../../eglconvenience/eglconvenience.pri) -include (../../../eglconvenience/xlibeglintegration.pri) +load(qpa/egl/convenience) +load(qpa/egl/xlibintegration) LIBS += -lXcomposite -lEGL diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri index 43295e91e7..9aae32c41b 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri @@ -1,5 +1,5 @@ include (../xcomposite_share/xcomposite_share.pri) -include (../../../glxconvenience/glxconvenience.pri) +load(qpa/glx/convenience) LIBS += -lXcomposite SOURCES += \ diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 5bf751b6e9..b37bfbbb3b 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -1,5 +1,5 @@ TARGET = qwayland -load(qt_plugin) +load(qpa/plugin) QT+=gui-private core-private opengl-private @@ -45,9 +45,10 @@ QT += core-private QT += widgets-private include ($$PWD/gl_integration/gl_integration.pri) + include ($$PWD/windowmanager_integration/windowmanager_integration.pri) -include (../fontdatabases/genericunix/genericunix.pri) +load(qpa/fontdatabases/genericunix) target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target -- cgit v1.2.3 From 4a189c188ccd2fb5f8d1d5ddadf06cbd6bc0916f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 7 Jun 2011 17:25:22 +0200 Subject: QWindowContext / QWindowFormat refactor. To enable having a single GL context used for multiple drawables we need to de-couple the context class a bit more from the window class in the plugin API. Now contexts are created stand-alone based on a GL format and a share context, and when calling makeCurrent() a desired surface is specified. This maps well to GLX, EGL, Cocoa, AGL, and WGL, which all support this use case. QWindowContext is renamed to QGuiGLContext, and QWindowFormat is renamed to QGuiGLFormat. We have the ability to introduce a pbuffer or similar other offscreen GL drawable abstraction in the future. --- .../wayland/gl_integration/qwaylandglintegration.h | 4 + .../gl_integration/qwaylandglwindowsurface.cpp | 24 +++-- .../gl_integration/qwaylandglwindowsurface.h | 3 + .../qwaylandreadbackeglintegration.cpp | 7 +- .../readback_egl/qwaylandreadbackeglintegration.h | 1 + .../readback_glx/qwaylandreadbackglxcontext.cpp | 111 ++++++++----------- .../readback_glx/qwaylandreadbackglxcontext.h | 39 ++++--- .../qwaylandreadbackglxintegration.cpp | 5 + .../readback_glx/qwaylandreadbackglxintegration.h | 1 + .../readback_glx/qwaylandreadbackglxwindow.cpp | 60 +++++++++-- .../readback_glx/qwaylandreadbackglxwindow.h | 15 ++- .../qwaylandxcompositeeglcontext.cpp | 118 +++------------------ .../xcomposite_egl/qwaylandxcompositeeglcontext.h | 34 +++--- .../qwaylandxcompositeeglintegration.cpp | 5 + .../qwaylandxcompositeeglintegration.h | 3 + .../xcomposite_egl/qwaylandxcompositeeglwindow.cpp | 101 +++++++++++++++--- .../xcomposite_egl/qwaylandxcompositeeglwindow.h | 20 +++- .../xcomposite_egl/xcomposite_egl.pri | 1 + .../qwaylandxcompositeglxcontext.cpp | 117 ++++++-------------- .../xcomposite_glx/qwaylandxcompositeglxcontext.h | 44 ++++---- .../qwaylandxcompositeglxintegration.cpp | 7 +- .../qwaylandxcompositeglxintegration.h | 1 + .../xcomposite_glx/qwaylandxcompositeglxwindow.cpp | 91 +++++++++++++--- .../xcomposite_glx/qwaylandxcompositeglxwindow.h | 22 +++- .../platforms/wayland/qwaylandintegration.cpp | 10 +- .../platforms/wayland/qwaylandintegration.h | 1 + .../platforms/wayland/qwaylandshmwindow.cpp | 4 +- src/plugins/platforms/wayland/qwaylandshmwindow.h | 2 +- 28 files changed, 486 insertions(+), 365 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h index 250fdccf41..2960d64eea 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h @@ -46,6 +46,9 @@ class QWaylandWindow; class QWaylandDisplay; class QWindow; +class QPlatformGLContext; +class QGuiGLFormat; + class QWaylandGLIntegration { public: @@ -55,6 +58,7 @@ public: virtual void initialize() = 0; virtual QWaylandWindow *createEglWindow(QWindow *window) = 0; + virtual QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const = 0; static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay); }; diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp index 57da38ed3c..1d6e79e94c 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp @@ -138,13 +138,14 @@ QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWindow *window) : QWindowSurface(window) , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) , mPaintDevice(0) + , mContext(0) { - } QWaylandGLWindowSurface::~QWaylandGLWindowSurface() { delete mPaintDevice; + delete mContext; } QPaintDevice *QWaylandGLWindowSurface::paintDevice() @@ -152,31 +153,38 @@ QPaintDevice *QWaylandGLWindowSurface::paintDevice() return mPaintDevice; } +QGuiGLContext *QWaylandGLWindowSurface::context() const +{ + if (!mContext) + const_cast(mContext) = new QGuiGLContext(window()->glFormat()); + return mContext; +} + void QWaylandGLWindowSurface::beginPaint(const QRegion &) { - window()->handle()->glContext()->makeCurrent(); - glClearColor(0,0,0,0xff); + context()->makeCurrent(window()->glSurface()); + glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); } -void QWaylandGLWindowSurface::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) +void QWaylandGLWindowSurface::flush(QWindow *, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(offset); Q_UNUSED(region); - + if (mPaintDevice->isBound()) mPaintDevice->release(); QRect rect(0,0,size().width(),size().height()); - QGLContext *ctx = QGLContext::fromWindowContext(window->glContext()); + QGLContext *ctx = QGLContext::fromGuiGLContext(context()); blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect); - window->glContext()->swapBuffers(); + context()->swapBuffers(window()->glSurface()); } void QWaylandGLWindowSurface::resize(const QSize &size) { QWindowSurface::resize(size); - window()->glContext()->makeCurrent(); + context()->makeCurrent(window()->glSurface()); delete mPaintDevice; mPaintDevice = new QGLFramebufferObject(size); } diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h index 31c0fd2daa..3703869a60 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h @@ -61,9 +61,12 @@ public: void resize(const QSize &size); + QGuiGLContext *context() const; + private: QWaylandDisplay *mDisplay; QGLFramebufferObject *mPaintDevice; + QGuiGLContext *mContext; }; #endif // QWAYLANDDRMSURFACE_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp index 50a1170f79..7fbe5cc725 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp @@ -83,7 +83,12 @@ void QWaylandReadbackEglIntegration::initialize() QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWindow *window) { - return new QWaylandReadbackEglWindow(window,this); + return new QWaylandReadbackEglWindow(window, this); +} + +QPlatformGLContext *QWaylandReadbackEglWindow::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +{ + return new QWaylandReadbackEglContext(glFormat, share, this); } EGLDisplay QWaylandReadbackEglIntegration::eglDisplay() diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h index 649f96e9cc..8945cdab38 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h @@ -63,6 +63,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); + QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; QWaylandDisplay *waylandDisplay() const; Display *xDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp index 5750c948cd..54b7d322f8 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp @@ -44,8 +44,19 @@ #include "qwaylandshmsurface.h" #include "qwaylandreadbackglxwindow.h" +#include #include +QWaylandReadbackGlxSurface::QWaylandReadbackGlxSurface(QWaylandReadbackGlxWindow *window) + : m_window(window) +{ +} + +GLXPixmap QWaylandReadbackGlxSurface::glxPixmap() const +{ + return m_window->glxPixmap(); +} + static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) { const int width = img.width(); @@ -68,94 +79,66 @@ static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) } } -QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegration *glxIntegration, QWaylandReadbackGlxWindow *window) - : QPlatformGLContext() - , mGlxIntegration(glxIntegration) - , mWindow(window) - , mBuffer(0) - , mPixmap(0) - , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat(),GLX_PIXMAP_BIT)) - , mGlxPixmap(0) +QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QGuiGLFormat &format, + QPlatformGLContext *share, Display *display, int screen) + : m_display(display) { - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); - mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE); + GLXFBConfig config = qglx_findConfig(display, screen, format, GLX_PIXMAP_BIT); - geometryChanged(); + GLXContext shareContext = share ? static_cast(share)->m_context : 0; + + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config); + m_context = glXCreateContext(display, visualInfo, shareContext, TRUE); + m_format = qglx_guiGLFormatFromGLXFBConfig(display, config, m_context); } -void QWaylandReadbackGlxContext::makeCurrent() +QGuiGLFormat QWaylandReadbackGlxContext::format() const { - glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext); + return m_format; +} + +bool QWaylandReadbackGlxContext::makeCurrent(const QPlatformGLSurface &surface) +{ + GLXPixmap glxPixmap = static_cast(surface).glxPixmap(); + + return glXMakeCurrent(m_display, glxPixmap, m_context); } void QWaylandReadbackGlxContext::doneCurrent() { - QPlatformGLContext::doneCurrent(); + glXMakeCurrent(m_display, 0, 0); } -void QWaylandReadbackGlxContext::swapBuffers() +void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface) { - if (QWindowContext::currentContext().handle() != this) { - makeCurrent(); - } + // #### makeCurrent() directly on the platform context doesn't update QGuiGLContext::currentContext() + if (QGuiGLContext::currentContext()->handle() != this) + makeCurrent(surface, surface); - QSize size = mWindow->geometry().size(); + const QWaylandReadbackGlxSurface &s = + static_cast(surface); - QImage img(size,QImage::Format_ARGB32); + QSize size = s.window()->geometry().size(); + + QImage img(size, QImage::Format_ARGB32); const uchar *constBits = img.bits(); void *pixels = const_cast(constBits); - glReadPixels(0,0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels); + glReadPixels(0, 0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels); img = img.mirrored(); - qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV); + qgl_byteSwapImage(img, GL_UNSIGNED_INT_8_8_8_8_REV); constBits = img.bits(); - const uchar *constDstBits = mBuffer->image()->bits(); + const uchar *constDstBits = s.window()->buffer(); uchar *dstBits = const_cast(constDstBits); - memcpy(dstBits,constBits,(img.width()*4) * img.height()); - - - mWindow->damage(QRegion(QRect(QPoint(0,0),size))); - mWindow->waitForFrameSync(); + memcpy(dstBits, constBits, (img.width() * 4) * img.height()); + s.window()->damage(QRect(QPoint(), size)); + s.window()->waitForFrameSync(); } -void * QWaylandReadbackGlxContext::getProcAddress(const QString &procName) +void (*QWaylandReadbackGlxContext::getProcAddress(const QByteArray &procName)) () { - return (void *) glXGetProcAddress(reinterpret_cast(procName.toLatin1().data())); -} - -QPlatformWindowFormat QWaylandReadbackGlxContext::platformWindowFormat() const -{ - return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); -} - -void QWaylandReadbackGlxContext::geometryChanged() -{ - QSize size(mWindow->geometry().size()); - if (size.isEmpty()) { - //QGLWidget wants a context for a window without geometry - size = QSize(1,1); - } - - mWindow->waitForFrameSync(); - - delete mBuffer; - //XFreePixmap deletes the glxPixmap as well - if (mPixmap) { - XFreePixmap(mGlxIntegration->xDisplay(),mPixmap); - } - - mBuffer = new QWaylandShmBuffer(mGlxIntegration->waylandDisplay(),size,QImage::Format_ARGB32); - mWindow->attach(mBuffer); - int depth = XDefaultDepth(mGlxIntegration->xDisplay(),mGlxIntegration->screen()); - mPixmap = XCreatePixmap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),size.width(),size.height(),depth); - XSync(mGlxIntegration->xDisplay(),False); - - mGlxPixmap = glXCreatePixmap(mGlxIntegration->xDisplay(),mConfig,mPixmap,0); - - if (!mGlxPixmap) { - qDebug() << "Could not make egl surface out of pixmap :("; - } + return glXGetProcAddress(reinterpret_cast(procName.constData())); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h index 07e0f620de..27a7287b07 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h @@ -43,6 +43,7 @@ #define QWAYLANDREADBACKGLXCONTEXT_H #include +#include #include "qwaylandreadbackglxintegration.h" @@ -51,29 +52,37 @@ class QWaylandReadbackGlxWindow; class QWaylandShmBuffer; +class QWaylandReadbackGlxSurface : public QPlatformGLSurface +{ +public: + QWaylandReadbackGlxSurface(QWaylandReadbackGlxWindow *window); + + QWaylandReadbackGlxWindow *window() const { return m_window; } + GLXPixmap glxPixmap() const; + +private: + QWaylandReadbackGlxWindow *m_window; +}; + class QWaylandReadbackGlxContext : public QPlatformGLContext { public: - QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegration *glxIntegration, QWaylandReadbackGlxWindow *window); + QWaylandReadbackGlxContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen); - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString& procName); + QGuiGLFormat format() const; - QPlatformWindowFormat platformWindowFormat() const; + void swapBuffers(const QPlatformGLSurface &surface); - void geometryChanged(); + bool makeCurrent(const QPlatformGLSurface &surface); + void doneCurrent(); + + void (*getProcAddress(const QByteArray &procName)) (); private: - QWaylandReadbackGlxIntegration *mGlxIntegration; - QWaylandReadbackGlxWindow *mWindow; - QWaylandShmBuffer *mBuffer; - - Pixmap mPixmap; - GLXFBConfig mConfig; - GLXContext mContext; - GLXPixmap mGlxPixmap; + GLXContext m_context; + + Display *m_display; + QGuiGLFormat m_format; }; #endif // QWAYLANDREADBACKGLXCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp index e17e3f87a0..6fb2a178c8 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp @@ -71,6 +71,11 @@ QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWindow *window return new QWaylandReadbackGlxWindow(window,this); } +QPlatformGLContext *QWaylandReadbackGlxIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +{ + return new QWaylandReadbackGlxContext(glFormat, share, mDisplay, mScreen); +} + QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) { return new QWaylandReadbackGlxIntegration(waylandDisplay); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h index 3055169c0a..0b3d0cc2cc 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h @@ -61,6 +61,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); + QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; QWaylandDisplay *waylandDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp index b70ed43e69..f878bef0c4 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp @@ -39,12 +39,19 @@ ** ****************************************************************************/ +#include + #include "qwaylandreadbackglxwindow.h" +#include "qwaylandshmsurface.h" + QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration) : QWaylandShmWindow(window) - , mGlxIntegration(glxIntegration) - , mContext(0) + , m_glxIntegration(glxIntegration) + , m_buffer(0) + , m_pixmap(0) + , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->glFormat())) + , m_glxPixmap(0) { } @@ -54,20 +61,51 @@ QWaylandWindow::WindowType QWaylandReadbackGlxWindow::windowType() const return QWaylandWindow::Egl; } -QPlatformGLContext * QWaylandReadbackGlxWindow::glContext() const +void QWaylandReadbackGlxWindow::setGeometry(const QRect &rect) { - if (!mContext) { - QWaylandReadbackGlxWindow *that = const_cast(this); - that->mContext = new QWaylandReadbackGlxContext(mGlxIntegration,that); + QWaylandShmWindow::setGeometry(rect); + + if (m_pixmap) { + delete mBuffer; + //XFreePixmap deletes the glxPixmap as well + XFreePixmap(m_glxIntegration->xDisplay(), m_pixmap); + m_pixmap = 0; } - return mContext; } -void QWaylandReadbackGlxWindow::setGeometry(const QRect &rect) +GLXPixmap QWaylandReadbackGlxWindow::glxPixmap() const { - QWaylandShmWindow::setGeometry(rect); + if (!m_pixmap) + const_cast(this)->createSurface(); - if (mContext) { - mContext->geometryChanged(); + return m_glxPixmap; +} + +uchar *QWaylandReadbackGlxWindow::buffer() +{ + return m_buffer->image()->bits(); +} + +void QWaylandReadbackGlxWindow::createSurface() +{ + QSize size(geometry().size()); + if (size.isEmpty()) { + //QGLWidget wants a context for a window without geometry + size = QSize(1,1); } + + waitForFrameSync(); + + m_buffer = new QWaylandShmBuffer(m_glxIntegration->waylandDisplay(), size, QImage::Format_ARGB32); + attach(m_buffer); + + int depth = XDefaultDepth(m_glxIntegration->xDisplay(), m_glxIntegration->screen()); + m_pixmap = XCreatePixmap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(), size.width(), size.height(), depth); + XSync(m_glxIntegration->xDisplay(), False); + + m_glxPixmap = glXCreatePixmap(m_glxIntegration->xDisplay(), m_config, m_pixmap,0); + + if (!m_glxPixmap) + qDebug() << "Could not make glx surface out of pixmap :("; } + diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h index 3f20a0e2fc..60b22a4408 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h @@ -52,14 +52,23 @@ public: QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration); WindowType windowType() const; - QPlatformGLContext *glContext() const; + QPlatformGLSurface *createGLSurface() const; void setGeometry(const QRect &rect); + Pixmap glxPixmap() const; + + uchar *buffer(); + private: - QWaylandReadbackGlxIntegration *mGlxIntegration; - QWaylandReadbackGlxContext *mContext; + void createSurface(); + + QWaylandReadbackGlxIntegration *m_glxIntegration; + QWaylandShmBuffer *m_buffer; + Pixmap m_pixmap; + GLXFBConfig m_config; + GLXPixmap m_glxPixmap; }; #endif // QWAYLANDREADBACKGLXWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index e61ee69d37..08b6f76daf 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -42,127 +42,37 @@ #include "qwaylandxcompositeeglcontext.h" #include "qwaylandxcompositeeglwindow.h" -#include "qwaylandxcompositebuffer.h" -#include "wayland-xcomposite-client-protocol.h" #include #include #include "qeglconvenience.h" -#include "qxlibeglintegration.h" -#include - -QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(QWaylandXCompositeEGLIntegration *glxIntegration, QWaylandXCompositeEGLWindow *window) - : QPlatformGLContext() - , mEglIntegration(glxIntegration) - , mWindow(window) - , mBuffer(0) - , mXWindow(0) - , mConfig(q_configFromQWindowFormat(glxIntegration->eglDisplay(),window->window()->requestedWindowFormat(),true,EGL_WINDOW_BIT)) - , mWaitingForSync(false) -{ - QVector eglContextAttrs; - eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); eglContextAttrs.append(2); - eglContextAttrs.append(EGL_NONE); - - mContext = eglCreateContext(glxIntegration->eglDisplay(),mConfig,EGL_NO_CONTEXT,eglContextAttrs.constData()); - if (mContext == EGL_NO_CONTEXT) { - qFatal("failed to find context"); - } - - geometryChanged(); -} - -void QWaylandXCompositeEGLContext::makeCurrent() +QWaylandXCompositeEGLSurface::QWaylandXCompositeEGLSurface(QWaylandXCompositeEGLWindow *window) + : QEGLSurface(window->eglSurface(), window->window()->glFormat()) + , m_window(window) { - eglMakeCurrent(mEglIntegration->eglDisplay(),mEglWindowSurface,mEglWindowSurface,mContext); } -void QWaylandXCompositeEGLContext::doneCurrent() +EGLSurface QWaylandXCompositeEGLSurface::eglSurface() const { - QPlatformGLContext::doneCurrent(); - eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT); + return m_window->eglSurface(); } -void QWaylandXCompositeEGLContext::swapBuffers() +QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display) + : QEGLPlatformContext(format, share, display) { - QSize size = mWindow->geometry().size(); - - eglSwapBuffers(mEglIntegration->eglDisplay(),mEglWindowSurface); - mWindow->damage(QRegion(QRect(QPoint(0,0),size))); - mWindow->waitForFrameSync(); -} - -void * QWaylandXCompositeEGLContext::getProcAddress(const QString &procName) -{ - return (void *)eglGetProcAddress(qPrintable(procName)); } -QWindowFormat QWaylandXCompositeEGLContext::windowFormat() const +void QWaylandXCompositeEGLContext::swapBuffers(const QPlatformGLSurface &surface) { - return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); -} - -void QWaylandXCompositeEGLContext::sync_function(void *data) -{ - QWaylandXCompositeEGLContext *that = static_cast(data); - that->mWaitingForSync = false; -} - -void QWaylandXCompositeEGLContext::geometryChanged() -{ - QSize size(mWindow->geometry().size()); - if (size.isEmpty()) { - //QGLWidget wants a context for a window without geometry - size = QSize(1,1); - } - - delete mBuffer; - //XFreePixmap deletes the glxPixmap as well - if (mXWindow) { - XDestroyWindow(mEglIntegration->xDisplay(),mXWindow); - } - - VisualID visualId = QXlibEglIntegration::getCompatibleVisualId(mEglIntegration->xDisplay(),mEglIntegration->eglDisplay(),mConfig); - - XVisualInfo visualInfoTemplate; - memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - visualInfoTemplate.visualid = visualId; - - int matchingCount = 0; - XVisualInfo *visualInfo = XGetVisualInfo(mEglIntegration->xDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount); - - Colormap cmap = XCreateColormap(mEglIntegration->xDisplay(),mEglIntegration->rootWindow(),visualInfo->visual,AllocNone); - - XSetWindowAttributes a; - a.colormap = cmap; - mXWindow = XCreateWindow(mEglIntegration->xDisplay(), mEglIntegration->rootWindow(),0, 0, size.width(), size.height(), - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); - - XCompositeRedirectWindow(mEglIntegration->xDisplay(), mXWindow, CompositeRedirectManual); - XMapWindow(mEglIntegration->xDisplay(), mXWindow); + QEGLPlatformContext::swapBuffers(surface); - mEglWindowSurface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mConfig,mXWindow,0); - if (mEglWindowSurface == EGL_NO_SURFACE) { - qFatal("Could not make eglsurface"); - } + const QWaylandXCompositeEGLSurface &s = + static_cast(surface); - XSync(mEglIntegration->xDisplay(),False); - mBuffer = new QWaylandXCompositeBuffer(mEglIntegration->waylandXComposite(), - (uint32_t)mXWindow, - size, - mEglIntegration->waylandDisplay()->argbVisual()); - mWindow->attach(mBuffer); - wl_display_sync_callback(mEglIntegration->waylandDisplay()->wl_display(), - QWaylandXCompositeEGLContext::sync_function, - this); + QSize size = s.window()->geometry().size(); - mWaitingForSync = true; - wl_display_sync(mEglIntegration->waylandDisplay()->wl_display(),0); - mEglIntegration->waylandDisplay()->flushRequests(); - while (mWaitingForSync) { - mEglIntegration->waylandDisplay()->readEvents(); - } + s.window()->damage(QRect(QPoint(), size)); + s.window()->waitForFrameSync(); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h index 528faf07c5..bd7039f284 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h @@ -44,37 +44,29 @@ #include -#include "qwaylandbuffer.h" #include "qwaylandxcompositeeglintegration.h" +#include "qeglplatformcontext.h" + class QWaylandXCompositeEGLWindow; -class QWaylandXCompositeEGLContext : public QPlatformGLContext +class QWaylandXCompositeEGLSurface : public QEGLSurface { public: - QWaylandXCompositeEGLContext(QWaylandXCompositeEGLIntegration *glxIntegration, QWaylandXCompositeEGLWindow *window); - - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString& procName); - - QWindowFormat windowFormat() const; - - void geometryChanged(); + QWaylandXCompositeEGLSurface(QWaylandXCompositeEGLWindow *window); + EGLSurface eglSurface() const; + QWaylandXCompositeEGLWindow *window() const { return m_window; } private: - QWaylandXCompositeEGLIntegration *mEglIntegration; - QWaylandXCompositeEGLWindow *mWindow; - QWaylandBuffer *mBuffer; + QWaylandXCompositeEGLWindow *m_window; +}; - Window mXWindow; - EGLConfig mConfig; - EGLContext mContext; - EGLSurface mEglWindowSurface; +class QWaylandXCompositeEGLContext : public QEGLPlatformContext +{ +public: + QWaylandXCompositeEGLContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display); - static void sync_function(void *data); - bool mWaitingForSync; + void swapBuffers(const QPlatformGLSurface &surface); }; #endif // QWAYLANDXCOMPOSITEEGLCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp index 239ec8963d..90d5bea770 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp @@ -75,6 +75,11 @@ QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWindow *wind return new QWaylandXCompositeEGLWindow(window,this); } +QPlatformGLContext *QWaylandXCompositeEGLIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +{ + return new QWaylandXCompositeEGLContext(glFormat, share, eglDisplay()); +} + Display * QWaylandXCompositeEGLIntegration::xDisplay() const { return mDisplay; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h index 3252ce741e..ac302ef89f 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h @@ -51,6 +51,8 @@ #include #include +#include + #include #include @@ -67,6 +69,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); + QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp index e57203f772..5c6717eb0c 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp @@ -40,15 +40,27 @@ ****************************************************************************/ #include "qwaylandxcompositeeglwindow.h" +#include "qwaylandxcompositebuffer.h" + +#include "qeglconvenience.h" + +#include "wayland-xcomposite-client-protocol.h" +#include "qxlibeglintegration.h" + +#include #include QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration) : QWaylandWindow(window) - , mGlxIntegration(glxIntegration) - , mContext(0) + , m_glxIntegration(glxIntegration) + , m_context(0) + , m_buffer(0) + , m_xWindow(0) + , m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->glFormat(), true)) + , m_surface(0) + , m_waitingForSync(false) { - } QWaylandWindow::WindowType QWaylandXCompositeEGLWindow::windowType() const @@ -57,21 +69,86 @@ QWaylandWindow::WindowType QWaylandXCompositeEGLWindow::windowType() const return QWaylandWindow::Egl; } -QPlatformGLContext * QWaylandXCompositeEGLWindow::glContext() const +QPlatformGLSurface *QWaylandXCompositeEGLWindow::createGLSurface() const { - if (!mContext) { - qDebug() << "creating glcontext;"; - QWaylandXCompositeEGLWindow *that = const_cast(this); - that->mContext = new QWaylandXCompositeEGLContext(mGlxIntegration,that); - } - return mContext; + return new QWaylandXCompositeEGLSurface(const_cast(this)); } void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect) { QWaylandWindow::setGeometry(rect); - if (mContext) { - mContext->geometryChanged(); + if (m_surface) { + eglDestroySurface(m_glxIntegration->eglDisplay(), m_surface); + m_surface = 0; + } +} + +EGLSurface QWaylandXCompositeEGLWindow::eglSurface() const +{ + if (!m_surface) + const_cast(this)->createEglSurface(); + return m_surface; +} + +void QWaylandXCompositeEGLWindow::createEglSurface() +{ + QSize size(geometry().size()); + if (size.isEmpty()) { + // QGLWidget wants a context for a window without geometry + size = QSize(1,1); + } + + delete m_buffer; + //XFreePixmap deletes the glxPixmap as well + if (m_xWindow) { + XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow); } + + VisualID visualId = QXlibEglIntegration::getCompatibleVisualId(m_glxIntegration->xDisplay(), m_glxIntegration->eglDisplay(), m_config); + + XVisualInfo visualInfoTemplate; + memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); + visualInfoTemplate.visualid = visualId; + + int matchingCount = 0; + XVisualInfo *visualInfo = XGetVisualInfo(m_glxIntegration->xDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount); + + Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(),m_glxIntegration->rootWindow(),visualInfo->visual,AllocNone); + + XSetWindowAttributes a; + a.colormap = cmap; + m_xWindow = XCreateWindow(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),0, 0, size.width(), size.height(), + 0, visualInfo->depth, InputOutput, visualInfo->visual, + CWColormap, &a); + + XCompositeRedirectWindow(m_glxIntegration->xDisplay(), m_xWindow, CompositeRedirectManual); + XMapWindow(m_glxIntegration->xDisplay(), m_xWindow); + + m_surface = eglCreateWindowSurface(m_glxIntegration->eglDisplay(), m_config, m_xWindow,0); + if (m_surface == EGL_NO_SURFACE) { + qFatal("Could not make eglsurface"); + } + + XSync(m_glxIntegration->xDisplay(),False); + mBuffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(), + (uint32_t)m_xWindow, + size, + m_glxIntegration->waylandDisplay()->argbVisual()); + attach(m_buffer); + wl_display_sync_callback(m_glxIntegration->waylandDisplay()->wl_display(), + QWaylandXCompositeEGLWindow::sync_function, + this); + + m_waitingForSync = true; + wl_display_sync(m_glxIntegration->waylandDisplay()->wl_display(),0); + m_glxIntegration->waylandDisplay()->flushRequests(); + while (m_waitingForSync) + m_glxIntegration->waylandDisplay()->readEvents(); +} + +void QWaylandXCompositeEGLWindow::sync_function(void *data) +{ + QWaylandXCompositeEGLWindow *that = static_cast(data); + that->m_waitingForSync = false; } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h index 6efe556fb5..16188ca3e0 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h @@ -43,6 +43,8 @@ #define QWAYLANDXCOMPOSITEEGLWINDOW_H #include "qwaylandwindow.h" +#include "qwaylandbuffer.h" + #include "qwaylandxcompositeeglintegration.h" #include "qwaylandxcompositeeglcontext.h" @@ -52,14 +54,26 @@ public: QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration); WindowType windowType() const; - QPlatformGLContext *glContext() const; + QPlatformGLSurface *createGLSurface() const; void setGeometry(const QRect &rect); + EGLSurface eglSurface() const; + private: - QWaylandXCompositeEGLIntegration *mGlxIntegration; - QWaylandXCompositeEGLContext *mContext; + void createEglSurface(); + + QWaylandXCompositeEGLIntegration *m_glxIntegration; + QWaylandXCompositeEGLContext *m_context; + QWaylandBuffer *m_buffer; + + Window m_xWindow; + EGLConfig m_config; + EGLSurface m_surface; + + bool m_waitingForSync; + static void sync_function(void *data); }; #endif // QWAYLANDXCOMPOSITEEGLWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri index 7d2f8ad443..a61391b2d1 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri @@ -1,5 +1,6 @@ include (../xcomposite_share/xcomposite_share.pri) load(qpa/egl/convenience) +load(qpa/egl/context) load(qpa/egl/xlibintegration) LIBS += -lXcomposite -lEGL diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp index aa26971021..5d4cf7a567 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -39,114 +39,67 @@ ** ****************************************************************************/ +#include + #include "qwaylandxcompositeglxcontext.h" #include "qwaylandxcompositeglxwindow.h" -#include "qwaylandxcompositebuffer.h" -#include "wayland-xcomposite-client-protocol.h" -#include -#include - -#include - -QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLXIntegration *glxIntegration, QWaylandXCompositeGLXWindow *window) - : QPlatformGLContext() - , mGlxIntegration(glxIntegration) - , mWindow(window) - , mBuffer(0) - , mXWindow(0) - , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->window()->requestedWindowFormat())) - , mWaitingForSyncCallback(false) -{ - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); - mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE); +#include - geometryChanged(); -} - -void QWaylandXCompositeGLXContext::makeCurrent() +QWaylandXCompositeGLXSurface::QWaylandXCompositeGLXSurface(QWaylandXCompositeGLXWindow *window) + : m_window(window) { - glXMakeCurrent(mGlxIntegration->xDisplay(),mXWindow,mContext); } -void QWaylandXCompositeGLXContext::doneCurrent() +Window QWaylandXCompositeGLXSurface::xWindow() const { - glXMakeCurrent(mGlxIntegration->xDisplay(),0,0); - QPlatformGLContext::doneCurrent(); + return m_window->xWindow(); } -void QWaylandXCompositeGLXContext::swapBuffers() +QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen) + : m_display(display) { - QSize size = mWindow->geometry().size(); + GLXContext shareContext = share ? static_cast(share)->m_context : 0; - glXSwapBuffers(mGlxIntegration->xDisplay(),mXWindow); - mWindow->damage(QRegion(QRect(QPoint(0,0),size))); - mWindow->waitForFrameSync(); + GLXFBConfig config = qglx_findConfig(display, screen, format); + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config); + m_context = glXCreateContext(display, visualInfo, shareContext, true); + m_format = qglx_guiGLFormatFromGLXFBConfig(display, config, m_context); } -void * QWaylandXCompositeGLXContext::getProcAddress(const QString &procName) +bool QWaylandXCompositeGLXContext::makeCurrent(const QPlatformGLSurface &surface) { - return (void *) glXGetProcAddress(reinterpret_cast(procName.toLatin1().data())); + Window xWindow = static_cast(surface).xWindow(); + + return glXMakeCurrent(m_display, xWindow, m_context); } -QWindowFormat QWaylandXCompositeGLXContext::windowFormat() const +void QWaylandXCompositeGLXContext::doneCurrent() { - return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); + glXMakeCurrent(m_display, 0, 0); } -void QWaylandXCompositeGLXContext::sync_function(void *data) +void QWaylandXCompositeGLXContext::swapBuffers(const QPlatformGLSurface &surface) { - QWaylandXCompositeGLXContext *that = static_cast(data); - that->mWaitingForSyncCallback = false; + const QWaylandXCompositeGLXSurface &s = + static_cast(surface); + + QSize size = s.window()->geometry().size(); + + glXSwapBuffers(m_display, s.xWindow()); + + s.window()->damage(QRect(QPoint(), size)); + s.window()->waitForFrameSync(); } -void QWaylandXCompositeGLXContext::waitForSync() +void (*QWaylandXCompositeGLXContext::getProcAddress(const QByteArray &procName)) () { - wl_display_sync_callback(mGlxIntegration->waylandDisplay()->wl_display(), - QWaylandXCompositeGLXContext::sync_function, - this); - mWaitingForSyncCallback = true; - wl_display_sync(mGlxIntegration->waylandDisplay()->wl_display(),0); - mGlxIntegration->waylandDisplay()->flushRequests(); - while (mWaitingForSyncCallback) { - mGlxIntegration->waylandDisplay()->readEvents(); - } + return glXGetProcAddress(reinterpret_cast(procName.constData())); } -void QWaylandXCompositeGLXContext::geometryChanged() +QGuiGLFormat QWaylandXCompositeGLXContext::format() const { - QSize size(mWindow->geometry().size()); - if (size.isEmpty()) { - //QGLWidget wants a context for a window without geometry - size = QSize(1,1); - } - - delete mBuffer; - //XFreePixmap deletes the glxPixmap as well - if (mXWindow) { - XDestroyWindow(mGlxIntegration->xDisplay(),mXWindow); - } - - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(mGlxIntegration->xDisplay(),mConfig); - Colormap cmap = XCreateColormap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),visualInfo->visual,AllocNone); - - XSetWindowAttributes a; - a.background_pixel = WhitePixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen()); - a.border_pixel = BlackPixel(mGlxIntegration->xDisplay(), mGlxIntegration->screen()); - a.colormap = cmap; - mXWindow = XCreateWindow(mGlxIntegration->xDisplay(), mGlxIntegration->rootWindow(),0, 0, size.width(), size.height(), - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWBackPixel|CWBorderPixel|CWColormap, &a); - - XCompositeRedirectWindow(mGlxIntegration->xDisplay(), mXWindow, CompositeRedirectManual); - XMapWindow(mGlxIntegration->xDisplay(), mXWindow); - - XSync(mGlxIntegration->xDisplay(),False); - mBuffer = new QWaylandXCompositeBuffer(mGlxIntegration->waylandXComposite(), - (uint32_t)mXWindow, - size, - mGlxIntegration->waylandDisplay()->argbVisual()); - mWindow->attach(mBuffer); - waitForSync(); + return m_format; } + diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h index 49ae73de40..e0de801a5e 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -44,42 +44,44 @@ #include -#include - -#include "qwaylandbuffer.h" #include "qwaylandxcompositeglxintegration.h" - #include "qglxconvenience.h" class QWaylandXCompositeGLXWindow; class QWaylandShmBuffer; +class QWaylandXCompositeGLXSurface : public QPlatformGLSurface +{ +public: + QWaylandXCompositeGLXSurface(QWaylandXCompositeGLXWindow *window); + + QWaylandXCompositeGLXWindow *window() const { return m_window; } + Window xWindow() const; + +private: + QWaylandXCompositeGLXWindow *m_window; +}; + + class QWaylandXCompositeGLXContext : public QPlatformGLContext { public: - QWaylandXCompositeGLXContext(QWaylandXCompositeGLXIntegration *glxIntegration, QWaylandXCompositeGLXWindow *window); + QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen); - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString& procName); + QGuiGLFormat format() const; - QWindowFormat windowFormat() const; + void swapBuffers(const QPlatformGLSurface &surface); - void geometryChanged(); + bool makeCurrent(const QPlatformGLSurface &surface); + void doneCurrent(); -private: - QWaylandXCompositeGLXIntegration *mGlxIntegration; - QWaylandXCompositeGLXWindow *mWindow; - QWaylandBuffer *mBuffer; + void (*getProcAddress(const QByteArray &procName)) (); - Window mXWindow; - GLXFBConfig mConfig; - GLXContext mContext; +private: + GLXContext m_context; - static void sync_function(void *data); - void waitForSync(); - bool mWaitingForSyncCallback; + Display *m_display; + QGuiGLFormat m_format; }; #endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp index e5f4feb436..a80a595768 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -72,7 +72,12 @@ void QWaylandXCompositeGLXIntegration::initialize() QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *window) { - return new QWaylandXCompositeGLXWindow(window,this); + return new QWaylandXCompositeGLXWindow(window, this); +} + +QPlatformGLContext *QWaylandXCompositeGLXIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +{ + return new QWaylandXCompositeGLXContext(glFormat, share, mDisplay, mScreen); } Display * QWaylandXCompositeGLXIntegration::xDisplay() const diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h index f934a9a4d2..c347b110c6 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h @@ -64,6 +64,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); + QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp index 6eec1d4eb8..41a14e3f66 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp @@ -40,15 +40,24 @@ ****************************************************************************/ #include "qwaylandxcompositeglxwindow.h" +#include "qwaylandxcompositebuffer.h" #include +#include "wayland-xcomposite-client-protocol.h" +#include + +#include + + QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration) : QWaylandWindow(window) - , mGlxIntegration(glxIntegration) - , mContext(0) + , m_glxIntegration(glxIntegration) + , m_xWindow(0) + , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->glFormat())) + , m_buffer(0) + , m_waitingForSync(false) { - } QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const @@ -57,21 +66,79 @@ QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const return QWaylandWindow::Egl; } -QPlatformGLContext * QWaylandXCompositeGLXWindow::glContext() const +QPlatformGLSurface *QWaylandXCompositeGLXWindow::createGLSurface() const { - if (!mContext) { - qDebug() << "creating glcontext;"; - QWaylandXCompositeGLXWindow *that = const_cast(this); - that->mContext = new QWaylandXCompositeGLXContext(mGlxIntegration,that); - } - return mContext; + return new QWaylandXCompositeGLXSurface(const_cast(this)); } void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect) { QWaylandWindow::setGeometry(rect); - if (mContext) { - mContext->geometryChanged(); + if (m_xWindow) { + delete m_buffer; + + XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow); + m_xWindow = 0; + } +} + +Window QWaylandXCompositeGLXWindow::xWindow() const +{ + if (!m_xWindow) + const_cast(this)->createSurface(); + + return m_xWindow; +} + +void QWaylandXCompositeGLXWindow::waitForSync() +{ + wl_display_sync_callback(m_glxIntegration->waylandDisplay()->wl_display(), + QWaylandXCompositeGLXWindow::sync_function, + this); + m_waitingForSync= true; + wl_display_sync(m_glxIntegration->waylandDisplay()->wl_display(), 0); + m_glxIntegration->waylandDisplay()->flushRequests(); + while (m_waitingForSync) + m_glxIntegration->waylandDisplay()->readEvents(); +} + + +void QWaylandXCompositeGLXWindow::createSurface() +{ + QSize size(geometry().size()); + if (size.isEmpty()) { + //QGLWidget wants a context for a window without geometry + size = QSize(1,1); } + + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(m_glxIntegration->xDisplay(), m_config); + Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(), + visualInfo->visual, AllocNone); + + XSetWindowAttributes a; + a.background_pixel = WhitePixel(m_glxIntegration->xDisplay(), m_glxIntegration->screen()); + a.border_pixel = BlackPixel(m_glxIntegration->xDisplay(), m_glxIntegration->screen()); + a.colormap = cmap; + m_xWindow = XCreateWindow(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),0, 0, size.width(), size.height(), + 0, visualInfo->depth, InputOutput, visualInfo->visual, + CWBackPixel|CWBorderPixel|CWColormap, &a); + + XCompositeRedirectWindow(m_glxIntegration->xDisplay(), m_xWindow, CompositeRedirectManual); + XMapWindow(m_glxIntegration->xDisplay(), m_xWindow); + + XSync(m_glxIntegration->xDisplay(), False); + m_buffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(), + (uint32_t)m_xWindow, + size, + m_glxIntegration->waylandDisplay()->argbVisual()); + attach(m_buffer); + waitForSync(); +} + +void QWaylandXCompositeGLXWindow::sync_function(void *data) +{ + QWaylandXCompositeGLXWindow *that = static_cast(data); + that->m_waitingForSync = false; } + diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h index 3305c12fa7..7a19c7175a 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h @@ -46,20 +46,36 @@ #include "qwaylandxcompositeglxintegration.h" #include "qwaylandxcompositeglxcontext.h" +#include + +#include "qwaylandbuffer.h" + class QWaylandXCompositeGLXWindow : public QWaylandWindow { public: QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration); WindowType windowType() const; - QPlatformGLContext *glContext() const; + QPlatformGLSurface *createGLSurface() const; void setGeometry(const QRect &rect); + Window xWindow() const; + private: - QWaylandXCompositeGLXIntegration *mGlxIntegration; - QWaylandXCompositeGLXContext *mContext; + void createSurface(); + + QWaylandXCompositeGLXIntegration *m_glxIntegration; + + Window m_xWindow; + GLXFBConfig m_config; + + QWaylandBuffer *m_buffer; + + void waitForSync(); + bool m_waitingForSync; + static void sync_function(void *data); }; #endif // QWAYLANDXCOMPOSITEGLXWINDOW_H diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 9aa512b38d..226bfd44d5 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -51,7 +51,7 @@ #include #include -#include +#include #include #ifdef QT_WAYLAND_GL_SUPPORT @@ -108,6 +108,14 @@ QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) cons return new QWaylandShmWindow(window); } +QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +{ +#ifdef QT_WAYLAND_GL_SUPPORT + return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share); +#endif + return 0; +} + QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const { Q_UNUSED(winId); diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 1ca468cca4..2e05faf677 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -57,6 +57,7 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; + QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; QWindowSurface *createWindowSurface(QWindow *window, WId winId) const; QList screens() const; diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp index 087139e0b3..bd1e61fa4c 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp @@ -63,9 +63,9 @@ QWaylandWindow::WindowType QWaylandShmWindow::windowType() const return QWaylandWindow::Shm; } -QPlatformGLContext * QWaylandShmWindow::glContext() const +QPlatformGLSurface * QWaylandShmWindow::glSurface() const { - qWarning("Trying to retrieve a glContext from a Raster window surface!"); + qWarning("Raster window does not have a GL drawable"); return 0; } diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h index e964e0d933..db26c5c928 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.h +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h @@ -52,7 +52,7 @@ public: ~QWaylandShmWindow(); WindowType windowType() const; - QPlatformGLContext *glContext() const; + QPlatformGLSurface *glSurface() const; }; #endif // QWAYLANDSHMWINDOW_H -- cgit v1.2.3 From 6ee65dc4785b9f38cfd7405a5535c88feb3a0ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 9 Jun 2011 15:56:55 +0200 Subject: QtPlatformSupport: A helper library for platform plugins QtPlatformSupport is a static library. Platform plugins are meant to link against this library to pull in dependencies such as fontengines and convenience functions for finding the right GL configs. The linker will only pull in the symbols used, so the size of the library doesn't really matter --- .../xcomposite_egl/qwaylandxcompositeeglcontext.cpp | 2 +- src/plugins/platforms/wayland/qwaylandintegration.cpp | 2 +- src/plugins/platforms/wayland/wayland.pro | 19 +++---------------- 3 files changed, 5 insertions(+), 18 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index 08b6f76daf..c5db44da4b 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -46,7 +46,7 @@ #include #include -#include "qeglconvenience.h" +#include "QtPlatformSupport/private/qeglconvenience_p.h" QWaylandXCompositeEGLSurface::QWaylandXCompositeEGLSurface(QWaylandXCompositeEGLWindow *window) : QEGLSurface(window->eglSurface(), window->window()->glFormat()) diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 226bfd44d5..4c2eaa631c 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -47,7 +47,7 @@ #include "qwaylandnativeinterface.h" #include "qwaylandclipboard.h" -#include "qgenericunixfontdatabase.h" +#include "QtPlatformSupport/private/qgenericunixfontdatabase_p.h" #include #include diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index b37bfbbb3b..6a6ffdffc0 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -1,14 +1,14 @@ TARGET = qwayland -load(qpa/plugin) +load(qt_plugin) -QT+=gui-private core-private opengl-private +CONFIG += qpa/genericunixfontdatabase DESTDIR = $$QT.gui.plugins/platforms DEFINES += Q_PLATFORM_WAYLAND DEFINES += $$QMAKE_DEFINES_WAYLAND -QT += core-private gui-private opengl-private +QT += core-private gui-private opengl-private platformsupport-private SOURCES = main.cpp \ qwaylandintegration.cpp \ @@ -37,19 +37,6 @@ INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND LIBS += $$QMAKE_LIBS_WAYLAND QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND -INCLUDEPATH += $$PWD - -QT += gui-private -QT += opengl-private -QT += core-private -QT += widgets-private - -include ($$PWD/gl_integration/gl_integration.pri) - -include ($$PWD/windowmanager_integration/windowmanager_integration.pri) - -load(qpa/fontdatabases/genericunix) - target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target -- cgit v1.2.3 From c84346ddff128daf6900860229aa99e4dc6763b2 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 16 Jun 2011 12:56:00 +0200 Subject: Make glx wayland backends working. --- .../wayland/gl_integration/gl_integration.pri | 6 +- .../gl_integration/qwaylandglwindowsurface.cpp | 192 --------------------- .../gl_integration/qwaylandglwindowsurface.h | 72 -------- .../readback_glx/qwaylandreadbackglxcontext.cpp | 3 +- .../readback_glx/qwaylandreadbackglxcontext.h | 2 +- .../readback_glx/qwaylandreadbackglxwindow.cpp | 5 + .../gl_integration/readback_glx/readback_glx.pri | 1 - .../qwaylandxcompositeglxcontext.cpp | 2 +- .../xcomposite_glx/qwaylandxcompositeglxcontext.h | 2 +- .../qwaylandxcompositeglxintegration.cpp | 14 +- .../xcomposite_glx/qwaylandxcompositeglxwindow.cpp | 5 + .../xcomposite_glx/xcomposite_glx.pri | 1 - src/plugins/platforms/wayland/main.cpp | 7 +- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 12 +- src/plugins/platforms/wayland/qwaylanddisplay.h | 5 +- .../platforms/wayland/qwaylandintegration.cpp | 37 +--- .../platforms/wayland/qwaylandintegration.h | 5 +- src/plugins/platforms/wayland/qwaylandwindow.cpp | 2 +- src/plugins/platforms/wayland/wayland.pro | 2 + 19 files changed, 41 insertions(+), 334 deletions(-) delete mode 100644 src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp delete mode 100644 src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index d9b5fa9bff..6652ff5fbb 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -3,12 +3,10 @@ contains(QT_CONFIG, opengl) { QT += opengl HEADERS += \ - $$PWD/qwaylandglintegration.h \ - $$PWD/qwaylandglwindowsurface.h + $$PWD/qwaylandglintegration.h SOURCES += \ - $$PWD/qwaylandglintegration.cpp \ - $$PWD/qwaylandglwindowsurface.cpp + $$PWD/qwaylandglintegration.cpp QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG) contains(QT_CONFIG, opengles2) { diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp deleted file mode 100644 index 1d6e79e94c..0000000000 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandglwindowsurface.h" - -#include "qwaylanddisplay.h" -#include "qwaylandwindow.h" -#include "qwaylandscreen.h" - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br) -{ -#if !defined(QT_OPENGL_ES_2) - QGLContext *ctx = const_cast(QGLContext::currentContext()); -#endif - const GLenum target = GL_TEXTURE_2D; - QRectF src = br.isEmpty() - ? QRectF(QPointF(), texSize) - : QRectF(QPointF(br.x(), texSize.height() - br.bottom()), br.size()); - - if (target == GL_TEXTURE_2D) { - qreal width = texSize.width(); - qreal height = texSize.height(); - - src.setLeft(src.left() / width); - src.setRight(src.right() / width); - src.setTop(src.top() / height); - src.setBottom(src.bottom() / height); - } - - const GLfloat tx1 = src.left(); - const GLfloat tx2 = src.right(); - const GLfloat ty1 = src.top(); - const GLfloat ty2 = src.bottom(); - - GLfloat texCoordArray[4*2] = { - tx1, ty2, tx2, ty2, tx2, ty1, tx1, ty1 - }; - - GLfloat vertexArray[4*2]; - vertexArray[0] = rect.left(); vertexArray[1] = rect.top(); - vertexArray[2] = rect.right(); vertexArray[3] = rect.top(); - vertexArray[4] = rect.right(); vertexArray[5] = rect.bottom(); - vertexArray[6] = rect.left(); vertexArray[7] = rect.bottom(); - - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexArray); - glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, texCoordArray); - - glBindTexture(target, tex_id); - - glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glEnableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glDisableVertexAttribArray(QT_TEXTURE_COORDS_ATTR); - - glBindTexture(target, 0); -} - -static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport, const QSize &texSize, const QRect &targetRect, const QRect &sourceRect) -{ - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_BLEND); - glViewport(0, 0, viewport.width(), viewport.height()); - - QGLShaderProgram *blitProgram = - QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram(); - blitProgram->bind(); - blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/); - - // The shader manager's blit program does not multiply the - // vertices by the pmv matrix, so we need to do the effect - // of the orthographic projection here ourselves. - QRectF r; - qreal w = viewport.width(); - qreal h = viewport.height(); - r.setLeft((targetRect.left() / w) * 2.0f - 1.0f); - if (targetRect.right() == (viewport.width() - 1)) - r.setRight(1.0f); - else - r.setRight((targetRect.right() / w) * 2.0f - 1.0f); - r.setBottom((targetRect.top() / h) * 2.0f - 1.0f); - if (targetRect.bottom() == (viewport.height() - 1)) - r.setTop(1.0f); - else - r.setTop((targetRect.bottom() / w) * 2.0f - 1.0f); - - drawTexture(r, texture, texSize, sourceRect); -} - -QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWindow *window) - : QWindowSurface(window) - , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) - , mPaintDevice(0) - , mContext(0) -{ -} - -QWaylandGLWindowSurface::~QWaylandGLWindowSurface() -{ - delete mPaintDevice; - delete mContext; -} - -QPaintDevice *QWaylandGLWindowSurface::paintDevice() -{ - return mPaintDevice; -} - -QGuiGLContext *QWaylandGLWindowSurface::context() const -{ - if (!mContext) - const_cast(mContext) = new QGuiGLContext(window()->glFormat()); - return mContext; -} - -void QWaylandGLWindowSurface::beginPaint(const QRegion &) -{ - context()->makeCurrent(window()->glSurface()); - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); -} - -void QWaylandGLWindowSurface::flush(QWindow *, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(offset); - Q_UNUSED(region); - - if (mPaintDevice->isBound()) - mPaintDevice->release(); - - QRect rect(0,0,size().width(),size().height()); - QGLContext *ctx = QGLContext::fromGuiGLContext(context()); - blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect); - context()->swapBuffers(window()->glSurface()); -} - -void QWaylandGLWindowSurface::resize(const QSize &size) -{ - QWindowSurface::resize(size); - context()->makeCurrent(window()->glSurface()); - delete mPaintDevice; - mPaintDevice = new QGLFramebufferObject(size); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h deleted file mode 100644 index 3703869a60..0000000000 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDDRMSURFACE_H -#define QWAYLANDDRMSURFACE_H - -#include "qwaylanddisplay.h" - -#include - -class QGLFramebufferObject; - -class QWaylandGLWindowSurface : public QWindowSurface -{ -public: - QWaylandGLWindowSurface(QWindow *window); - ~QWaylandGLWindowSurface(); - - void beginPaint(const QRegion &); - - QPaintDevice *paintDevice(); - void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); - - void resize(const QSize &size); - - QGuiGLContext *context() const; - -private: - QWaylandDisplay *mDisplay; - QGLFramebufferObject *mPaintDevice; - QGuiGLContext *mContext; -}; - -#endif // QWAYLANDDRMSURFACE_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp index 54b7d322f8..61fd26fe3a 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp @@ -113,7 +113,7 @@ void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface) { // #### makeCurrent() directly on the platform context doesn't update QGuiGLContext::currentContext() if (QGuiGLContext::currentContext()->handle() != this) - makeCurrent(surface, surface); + makeCurrent(surface); const QWaylandReadbackGlxSurface &s = static_cast(surface); @@ -135,6 +135,7 @@ void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface) memcpy(dstBits, constBits, (img.width() * 4) * img.height()); s.window()->damage(QRect(QPoint(), size)); + s.window()->waitForFrameSync(); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h index 27a7287b07..3008c295d3 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h @@ -47,7 +47,7 @@ #include "qwaylandreadbackglxintegration.h" -#include "qglxconvenience.h" +#include class QWaylandReadbackGlxWindow; class QWaylandShmBuffer; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp index f878bef0c4..5565e78ef4 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp @@ -86,6 +86,11 @@ uchar *QWaylandReadbackGlxWindow::buffer() return m_buffer->image()->bits(); } +QPlatformGLSurface *QWaylandReadbackGlxWindow::createGLSurface() const +{ + return new QWaylandReadbackGlxSurface(const_cast(this)); +} + void QWaylandReadbackGlxWindow::createSurface() { QSize size(geometry().size()); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri b/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri index dc84d1c9e9..746d594fa2 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri @@ -1,4 +1,3 @@ -load(qpa/glx/convenience) HEADERS += \ $$PWD/qwaylandreadbackglxintegration.h \ $$PWD/qwaylandreadbackglxwindow.h \ diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp index 5d4cf7a567..54d63a2bec 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -60,8 +60,8 @@ Window QWaylandXCompositeGLXSurface::xWindow() const QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen) : m_display(display) { + qDebug("creating XComposite-GLX context"); GLXContext shareContext = share ? static_cast(share)->m_context : 0; - GLXFBConfig config = qglx_findConfig(display, screen, format); XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config); m_context = glXCreateContext(display, visualInfo, shareContext, true); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h index e0de801a5e..39fe03032f 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -45,7 +45,7 @@ #include #include "qwaylandxcompositeglxintegration.h" -#include "qglxconvenience.h" +#include class QWaylandXCompositeGLXWindow; class QWaylandShmBuffer; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp index a80a595768..426c78e5e8 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -52,12 +52,15 @@ QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDispl return new QWaylandXCompositeGLXIntegration(waylandDisplay); } -QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay * waylandDispaly) - : QWaylandGLIntegration() - , mWaylandDisplay(waylandDispaly) +QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay *waylandDisplay) + : mWaylandDisplay(waylandDisplay) + , mWaylandComposite(0) + , mDisplay(0) + , mScreen(0) + , mRootWindow(0) { qDebug() << "Using XComposite-GLX"; - wl_display_add_global_listener(waylandDispaly->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal, + wl_display_add_global_listener(waylandDisplay->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal, this); } @@ -112,6 +115,7 @@ void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(wl_display *display { Q_UNUSED(version); if (strcmp(interface, "wl_xcomposite") == 0) { + qDebug("XComposite-GLX: got wl_xcomposite global"); QWaylandXCompositeGLXIntegration *integration = static_cast(data); integration->mWaylandComposite = wl_xcomposite_create(display,id,1); wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration); @@ -124,6 +128,8 @@ void QWaylandXCompositeGLXIntegration::rootInformation(void *data, wl_xcomposite Q_UNUSED(xcomposite); QWaylandXCompositeGLXIntegration *integration = static_cast(data); + qDebug("XComposite-GLX: xcomposite listener callback"); + integration->mDisplay = XOpenDisplay(display_name); integration->mRootWindow = (Window) root_window; integration->mScreen = XDefaultScreen(integration->mDisplay); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp index 41a14e3f66..797803f4cd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp @@ -112,6 +112,11 @@ void QWaylandXCompositeGLXWindow::createSurface() size = QSize(1,1); } + if (!m_glxIntegration->xDisplay()) { + qWarning("XCompositeGLXWindow: X display still null?!"); + return; + } + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(m_glxIntegration->xDisplay(), m_config); Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(), visualInfo->visual, AllocNone); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri index 9aae32c41b..bbd6c12e42 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri @@ -1,5 +1,4 @@ include (../xcomposite_share/xcomposite_share.pri) -load(qpa/glx/convenience) LIBS += -lXcomposite SOURCES += \ diff --git a/src/plugins/platforms/wayland/main.cpp b/src/plugins/platforms/wayland/main.cpp index ba365ca3a1..e4d420d68a 100644 --- a/src/plugins/platforms/wayland/main.cpp +++ b/src/plugins/platforms/wayland/main.cpp @@ -54,8 +54,7 @@ public: QStringList QWaylandIntegrationPlugin::keys() const { QStringList list; - list << "Wayland"; - list << "WaylandGL"; + list << "wayland"; return list; } @@ -63,9 +62,7 @@ QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, c { Q_UNUSED(paramList); if (system.toLower() == "wayland") - return new QWaylandIntegration; - if (system.toLower() == "waylandgl") - return new QWaylandIntegration(true); + return new QWaylandIntegration(); return 0; } diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index f1c9ccc18f..324f9dc632 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -47,9 +47,7 @@ #include "qwaylandinputdevice.h" #include "qwaylandclipboard.h" -#ifdef QT_WAYLAND_GL_SUPPORT #include "gl_integration/qwaylandglintegration.h" -#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT #include "windowmanager_integration/qwaylandwindowmanagerintegration.h" @@ -93,12 +91,10 @@ struct wl_visual *QWaylandDisplay::argbPremultipliedVisual() return premultiplied_argb_visual; } -#ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration * QWaylandDisplay::eglIntegration() { return mEglIntegration; } -#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration() @@ -136,9 +132,7 @@ QWaylandDisplay::QWaylandDisplay(void) wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this); -#ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration = QWaylandGLIntegration::createGLIntegration(this); -#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this); @@ -148,9 +142,7 @@ QWaylandDisplay::QWaylandDisplay(void) qRegisterMetaType("uint32_t"); -#ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration->initialize(); -#endif connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); @@ -165,9 +157,7 @@ QWaylandDisplay::QWaylandDisplay(void) QWaylandDisplay::~QWaylandDisplay(void) { close(mFd); -#ifdef QT_WAYLAND_GL_SUPPORT delete mEglIntegration; -#endif wl_display_destroy(mDisplay); } @@ -290,6 +280,8 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id, mInputDevices.append(inputDevice); } else if (interface == "wl_selection_offer") { QPlatformIntegration *plat = QGuiApplicationPrivate::platformIntegration(); + if (!plat) + return; QWaylandClipboard *clipboard = static_cast(plat->clipboard()); clipboard->createSelectionOffer(id); } diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 765be62eb4..2c31687518 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -73,9 +73,7 @@ public: struct wl_visual *argbVisual(); struct wl_visual *argbPremultipliedVisual(); -#ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration *eglIntegration(); -#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT QWaylandWindowManagerIntegration *windowManagerIntegration(); @@ -133,9 +131,8 @@ private: static void handleVisual(void *data, struct wl_compositor *compositor, uint32_t id, uint32_t token); -#ifdef QT_WAYLAND_GL_SUPPORT + QWaylandGLIntegration *mEglIntegration; -#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT QWaylandWindowManagerIntegration *mWindowManagerIntegration; diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 4c2eaa631c..4edcfc43f4 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -54,16 +54,12 @@ #include #include -#ifdef QT_WAYLAND_GL_SUPPORT + #include "gl_integration/qwaylandglintegration.h" -#include "gl_integration/qwaylandglwindowsurface.h" -#include -#endif -QWaylandIntegration::QWaylandIntegration(bool useOpenGL) +QWaylandIntegration::QWaylandIntegration() : mFontDb(new QGenericUnixFontDatabase()) , mDisplay(new QWaylandDisplay()) - , mUseOpenGL(useOpenGL) , mNativeInterface(new QWaylandNativeInterface) , mClipboard(0) { @@ -84,46 +80,32 @@ bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) co { switch (cap) { case ThreadedPixmaps: return true; - case OpenGL: return hasOpenGL(); + case OpenGL: return true; default: return QPlatformIntegration::hasCapability(cap); } } QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) const { -#ifdef QT_WAYLAND_GL_SUPPORT - if (mUseOpenGL) - return new QGLPixmapData(type); -#endif return new QRasterPixmapData(type); } QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const { -#ifdef QT_WAYLAND_GL_SUPPORT - bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface; - if (useOpenGL) + if (window->surfaceType() == QWindow::OpenGLSurface) return mDisplay->eglIntegration()->createEglWindow(window); -#endif + return new QWaylandShmWindow(window); } QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const { -#ifdef QT_WAYLAND_GL_SUPPORT return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share); -#endif - return 0; } QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const { Q_UNUSED(winId); -#ifdef QT_WAYLAND_GL_SUPPORT - bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface; - if (useOpenGL) - return new QWaylandGLWindowSurface(window); -#endif return new QWaylandShmWindowSurface(window); } @@ -132,15 +114,6 @@ QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const return mFontDb; } -bool QWaylandIntegration::hasOpenGL() const -{ -#ifdef QT_WAYLAND_GL_SUPPORT - return true; -#else - return false; -#endif -} - QPlatformClipboard *QWaylandIntegration::clipboard() const { if (!mClipboard) diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 2e05faf677..e55dec3229 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -52,7 +52,7 @@ class QWaylandDisplay; class QWaylandIntegration : public QPlatformIntegration { public: - QWaylandIntegration(bool useOpenGL = false); + QWaylandIntegration(); bool hasCapability(QPlatformIntegration::Capability cap) const; QPixmapData *createPixmapData(QPixmapData::PixelType type) const; @@ -69,11 +69,8 @@ public: QPlatformClipboard *clipboard() const; private: - bool hasOpenGL() const; - QPlatformFontDatabase *mFontDb; QWaylandDisplay *mDisplay; - bool mUseOpenGL; QPlatformNativeInterface *mNativeInterface; mutable QPlatformClipboard *mClipboard; }; diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 53f74e3ddf..ec62a3c799 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -116,8 +116,8 @@ void QWaylandWindow::configure(uint32_t time, uint32_t edges, { Q_UNUSED(time); Q_UNUSED(edges); - QRect geometry = QRect(x, y, width, height); + QRect geometry = QRect(x, y, width, height); setGeometry(geometry); QWindowSystemInterface::handleGeometryChange(window(), geometry); diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 6a6ffdffc0..0a2084df3b 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -40,3 +40,5 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND target.path += $$[QT_INSTALL_PLUGINS]/platforms INSTALLS += target +include ($$PWD/gl_integration/gl_integration.pri) +include ($$PWD/windowmanager_integration/windowmanager_integration.pri) -- cgit v1.2.3 From 672fe5d43cd256813acdda95e2cd9a4d22ad705a Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 20 Jun 2011 12:21:29 +0200 Subject: Restoring QT_WAYLAND_GL_SUPPORT ifdefs. --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 10 ++++++++++ src/plugins/platforms/wayland/qwaylanddisplay.h | 4 ++++ src/plugins/platforms/wayland/qwaylandintegration.cpp | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 324f9dc632..6f61cf1012 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -47,7 +47,9 @@ #include "qwaylandinputdevice.h" #include "qwaylandclipboard.h" +#ifdef QT_WAYLAND_GL_SUPPORT #include "gl_integration/qwaylandglintegration.h" +#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT #include "windowmanager_integration/qwaylandwindowmanagerintegration.h" @@ -91,10 +93,12 @@ struct wl_visual *QWaylandDisplay::argbPremultipliedVisual() return premultiplied_argb_visual; } +#ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration * QWaylandDisplay::eglIntegration() { return mEglIntegration; } +#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration() @@ -132,7 +136,9 @@ QWaylandDisplay::QWaylandDisplay(void) wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this); +#ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration = QWaylandGLIntegration::createGLIntegration(this); +#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT mWindowManagerIntegration = QWaylandWindowManagerIntegration::createIntegration(this); @@ -142,7 +148,9 @@ QWaylandDisplay::QWaylandDisplay(void) qRegisterMetaType("uint32_t"); +#ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration->initialize(); +#endif connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); @@ -157,7 +165,9 @@ QWaylandDisplay::QWaylandDisplay(void) QWaylandDisplay::~QWaylandDisplay(void) { close(mFd); +#ifdef QT_WAYLAND_GL_SUPPORT delete mEglIntegration; +#endif wl_display_destroy(mDisplay); } diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 2c31687518..5226f0d8e3 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -73,7 +73,9 @@ public: struct wl_visual *argbVisual(); struct wl_visual *argbPremultipliedVisual(); +#ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration *eglIntegration(); +#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT QWaylandWindowManagerIntegration *windowManagerIntegration(); @@ -132,7 +134,9 @@ private: struct wl_compositor *compositor, uint32_t id, uint32_t token); +#ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration *mEglIntegration; +#endif #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT QWaylandWindowManagerIntegration *mWindowManagerIntegration; diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 4edcfc43f4..090edfe324 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -55,7 +55,9 @@ #include +#ifdef QT_WAYLAND_GL_SUPPORT #include "gl_integration/qwaylandglintegration.h" +#endif QWaylandIntegration::QWaylandIntegration() : mFontDb(new QGenericUnixFontDatabase()) @@ -80,7 +82,12 @@ bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) co { switch (cap) { case ThreadedPixmaps: return true; - case OpenGL: return true; + case OpenGL: +#ifdef QT_WAYLAND_GL_SUPPORT + return true; +#else + return false; +#endif default: return QPlatformIntegration::hasCapability(cap); } } @@ -92,15 +99,21 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const { +#ifdef QT_WAYLAND_GL_SUPPORT if (window->surfaceType() == QWindow::OpenGLSurface) return mDisplay->eglIntegration()->createEglWindow(window); +#endif return new QWaylandShmWindow(window); } QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const { +#ifdef QT_WAYLAND_GL_SUPPORT return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share); +#else + return 0; +#endif } QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const -- cgit v1.2.3 From 891a86f0f3b0664162642ee1d6aa3078f16695d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 20 Jun 2011 12:32:49 +0200 Subject: Compile fixes. --- .../gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp | 2 +- .../gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp | 2 +- .../gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h | 2 +- .../gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp index 8769752d5f..cd6ab188f7 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp @@ -41,7 +41,7 @@ #include "qwaylandreadbackeglcontext.h" -#include "../../../eglconvenience/qeglconvenience.h" +#include #include #include diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index c5db44da4b..c43b675d44 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -46,7 +46,7 @@ #include #include -#include "QtPlatformSupport/private/qeglconvenience_p.h" +#include QWaylandXCompositeEGLSurface::QWaylandXCompositeEGLSurface(QWaylandXCompositeEGLWindow *window) : QEGLSurface(window->eglSurface(), window->window()->glFormat()) diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h index bd7039f284..e394ea1a04 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h @@ -46,7 +46,7 @@ #include "qwaylandxcompositeeglintegration.h" -#include "qeglplatformcontext.h" +#include class QWaylandXCompositeEGLWindow; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp index 5c6717eb0c..5e1bab2044 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp @@ -42,10 +42,10 @@ #include "qwaylandxcompositeeglwindow.h" #include "qwaylandxcompositebuffer.h" -#include "qeglconvenience.h" +#include +#include #include "wayland-xcomposite-client-protocol.h" -#include "qxlibeglintegration.h" #include -- cgit v1.2.3 From 6ce6b8a378b0d97ba950240ffb048a4b7e485235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 20 Jun 2011 13:29:26 +0200 Subject: Rename QWindowSurface -> QBackingStore and split into platform / public. Also get rid of GL window surface and related classes. --- src/plugins/platforms/wayland/qwaylandcursor.cpp | 2 +- .../platforms/wayland/qwaylandintegration.cpp | 7 +- .../platforms/wayland/qwaylandintegration.h | 2 +- .../platforms/wayland/qwaylandshmbackingstore.cpp | 143 ++++++++++++++++++++ .../platforms/wayland/qwaylandshmbackingstore.h | 83 ++++++++++++ .../platforms/wayland/qwaylandshmsurface.cpp | 144 --------------------- src/plugins/platforms/wayland/qwaylandshmsurface.h | 83 ------------ src/plugins/platforms/wayland/wayland.pro | 4 +- 8 files changed, 233 insertions(+), 235 deletions(-) create mode 100644 src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp create mode 100644 src/plugins/platforms/wayland/qwaylandshmbackingstore.h delete mode 100644 src/plugins/platforms/wayland/qwaylandshmsurface.cpp delete mode 100644 src/plugins/platforms/wayland/qwaylandshmsurface.h (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp index d69d618591..6612d67cb4 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp @@ -43,8 +43,8 @@ #include "qwaylanddisplay.h" #include "qwaylandinputdevice.h" -#include "qwaylandshmsurface.h" #include "qwaylandscreen.h" +#include "qwaylandshmbackingstore.h" #include diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 090edfe324..9cd79e2978 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -42,7 +42,7 @@ #include "qwaylandintegration.h" #include "qwaylanddisplay.h" -#include "qwaylandshmsurface.h" +#include "qwaylandshmbackingstore.h" #include "qwaylandshmwindow.h" #include "qwaylandnativeinterface.h" #include "qwaylandclipboard.h" @@ -116,10 +116,9 @@ QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QGuiGLFor #endif } -QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const +QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow *window) const { - Q_UNUSED(winId); - return new QWaylandShmWindowSurface(window); + return new QWaylandShmBackingStore(window); } QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index e55dec3229..1e22191ff7 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -58,7 +58,7 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; - QWindowSurface *createWindowSurface(QWindow *window, WId winId) const; + QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; QList screens() const; diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp new file mode 100644 index 0000000000..ccb50a73fb --- /dev/null +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qwaylandshmbackingstore.h" + +#include + +#include "qwaylanddisplay.h" +#include "qwaylandshmwindow.h" +#include "qwaylandscreen.h" + +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display, + const QSize &size, QImage::Format format) +{ + int stride = size.width() * 4; + int alloc = stride * size.height(); + char filename[] = "/tmp/wayland-shm-XXXXXX"; + int fd = mkstemp(filename); + if (fd < 0) + qWarning("open %s failed: %s", filename, strerror(errno)); + if (ftruncate(fd, alloc) < 0) { + qWarning("ftruncate failed: %s", strerror(errno)); + close(fd); + return; + } + uchar *data = (uchar *) + mmap(NULL, alloc, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + unlink(filename); + + if (data == (uchar *) MAP_FAILED) { + qWarning("mmap /dev/zero failed: %s", strerror(errno)); + close(fd); + return; + } + + mImage = QImage(data, size.width(), size.height(), stride, format); + mBuffer = display->createShmBuffer(fd, size.width(), size.height(), + stride, display->argbVisual()); + close(fd); +} + +QWaylandShmBuffer::~QWaylandShmBuffer(void) +{ + munmap((void *) mImage.constBits(), mImage.byteCount()); + wl_buffer_destroy(mBuffer); +} + +QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window) + : QPlatformBackingStore(window) + , mBuffer(0) + , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) +{ +} + +QWaylandShmBackingStore::~QWaylandShmBackingStore() +{ +} + +QPaintDevice *QWaylandShmBackingStore::paintDevice() +{ + return mBuffer->image(); +} + +void QWaylandShmBackingStore::beginPaint(const QRegion &) +{ + QWaylandShmWindow *waylandWindow = static_cast(window()->handle()); + Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); + waylandWindow->waitForFrameSync(); +} + +void QWaylandShmBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) +{ + Q_UNUSED(window); + Q_UNUSED(offset); + QWaylandShmWindow *waylandWindow = static_cast(window->handle()); + Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); + waylandWindow->damage(region); +} + +void QWaylandShmBackingStore::resize(const QSize &size, const QRegion &) +{ + QWaylandShmWindow *waylandWindow = static_cast(window()->handle()); + Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); + + QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format(); + + if (mBuffer != NULL && mBuffer->size() == size) + return; + + if (mBuffer != NULL) + delete mBuffer; + + mBuffer = new QWaylandShmBuffer(mDisplay, size, format); + + waylandWindow->attach(mBuffer); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.h b/src/plugins/platforms/wayland/qwaylandshmbackingstore.h new file mode 100644 index 0000000000..5e6959dc2f --- /dev/null +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDSHMBACKINGSTORE_H +#define QWAYLANDSHMBACKINGSTORE_H + +#include "qwaylandbuffer.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QWaylandDisplay; + +class QWaylandShmBuffer : public QWaylandBuffer { +public: + QWaylandShmBuffer(QWaylandDisplay *display, + const QSize &size, QImage::Format format); + ~QWaylandShmBuffer(); + QSize size() const { return mImage.size(); } + QImage *image() { return &mImage; } +private: + QImage mImage; +}; + +class QWaylandShmBackingStore : public QPlatformBackingStore +{ +public: + QWaylandShmBackingStore(QWindow *window); + ~QWaylandShmBackingStore(); + + QPaintDevice *paintDevice(); + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); + void resize(const QSize &size, const QRegion &staticContents); + void beginPaint(const QRegion &); + +private: + QWaylandShmBuffer *mBuffer; + QWaylandDisplay *mDisplay; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp deleted file mode 100644 index 520633811c..0000000000 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qwaylandshmsurface.h" - -#include - -#include "qwaylanddisplay.h" -#include "qwaylandshmwindow.h" -#include "qwaylandscreen.h" - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display, - const QSize &size, QImage::Format format) -{ - int stride = size.width() * 4; - int alloc = stride * size.height(); - char filename[] = "/tmp/wayland-shm-XXXXXX"; - int fd = mkstemp(filename); - if (fd < 0) - qWarning("open %s failed: %s", filename, strerror(errno)); - if (ftruncate(fd, alloc) < 0) { - qWarning("ftruncate failed: %s", strerror(errno)); - close(fd); - return; - } - uchar *data = (uchar *) - mmap(NULL, alloc, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - unlink(filename); - - if (data == (uchar *) MAP_FAILED) { - qWarning("mmap /dev/zero failed: %s", strerror(errno)); - close(fd); - return; - } - - mImage = QImage(data, size.width(), size.height(), stride, format); - mBuffer = display->createShmBuffer(fd, size.width(), size.height(), - stride, display->argbVisual()); - close(fd); -} - -QWaylandShmBuffer::~QWaylandShmBuffer(void) -{ - munmap((void *) mImage.constBits(), mImage.byteCount()); - wl_buffer_destroy(mBuffer); -} - -QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWindow *window) - : QWindowSurface(window) - , mBuffer(0) - , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) -{ -} - -QWaylandShmWindowSurface::~QWaylandShmWindowSurface() -{ -} - -QPaintDevice *QWaylandShmWindowSurface::paintDevice() -{ - return mBuffer->image(); -} - -void QWaylandShmWindowSurface::beginPaint(const QRegion &) -{ - QWaylandShmWindow *waylandWindow = static_cast(window()->handle()); - Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); - waylandWindow->waitForFrameSync(); -} - -void QWaylandShmWindowSurface::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(window); - Q_UNUSED(offset); - QWaylandShmWindow *waylandWindow = static_cast(window->handle()); - Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); - waylandWindow->damage(region); -} - -void QWaylandShmWindowSurface::resize(const QSize &size) -{ - QWaylandShmWindow *waylandWindow = static_cast(window()->handle()); - Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); - - QWindowSurface::resize(size); - QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format(); - - if (mBuffer != NULL && mBuffer->size() == size) - return; - - if (mBuffer != NULL) - delete mBuffer; - - mBuffer = new QWaylandShmBuffer(mDisplay, size, format); - - waylandWindow->attach(mBuffer); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmsurface.h deleted file mode 100644 index 1045709d7c..0000000000 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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, Nokia gives you certain additional -** rights. These rights are described in the Nokia 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSURFACE_WAYLAND_H -#define QWINDOWSURFACE_WAYLAND_H - -#include "qwaylandbuffer.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QWaylandDisplay; - -class QWaylandShmBuffer : public QWaylandBuffer { -public: - QWaylandShmBuffer(QWaylandDisplay *display, - const QSize &size, QImage::Format format); - ~QWaylandShmBuffer(); - QSize size() const { return mImage.size(); } - QImage *image() { return &mImage; } -private: - QImage mImage; -}; - -class QWaylandShmWindowSurface : public QWindowSurface -{ -public: - QWaylandShmWindowSurface(QWindow *window); - ~QWaylandShmWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); - void resize(const QSize &size); - void beginPaint(const QRegion &); - -private: - QWaylandShmBuffer *mBuffer; - QWaylandDisplay *mDisplay; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 0a2084df3b..9010439939 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -13,7 +13,7 @@ QT += core-private gui-private opengl-private platformsupport-private SOURCES = main.cpp \ qwaylandintegration.cpp \ qwaylandnativeinterface.cpp \ - qwaylandshmsurface.cpp \ + qwaylandshmbackingstore.cpp \ qwaylandinputdevice.cpp \ qwaylandcursor.cpp \ qwaylanddisplay.cpp \ @@ -28,7 +28,7 @@ HEADERS = qwaylandintegration.h \ qwaylanddisplay.h \ qwaylandwindow.h \ qwaylandscreen.h \ - qwaylandshmsurface.h \ + qwaylandshmbackingstore.h \ qwaylandbuffer.h \ qwaylandshmwindow.h \ qwaylandclipboard.h -- cgit v1.2.3 From 31b231181860b258aab7d142623221688f2445b8 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 21 Jun 2011 10:09:56 +0200 Subject: Compile fix for readbackglx after surface->backingstore renaming. --- .../wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp | 2 +- .../wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp index 61fd26fe3a..0ca04187d3 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp @@ -41,7 +41,7 @@ #include "qwaylandreadbackglxcontext.h" -#include "qwaylandshmsurface.h" +#include "qwaylandshmbackingstore.h" #include "qwaylandreadbackglxwindow.h" #include diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp index 5565e78ef4..df55caab76 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp @@ -42,8 +42,7 @@ #include #include "qwaylandreadbackglxwindow.h" - -#include "qwaylandshmsurface.h" +#include "qwaylandshmbackingstore.h" QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration) : QWaylandShmWindow(window) -- cgit v1.2.3 From 14a1d6d3c799baf934912a0d9003a2358820cd86 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 21 Jun 2011 10:21:46 +0200 Subject: Make readback-glx working again in wayland. --- .../gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp | 6 +++++- .../wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp index df55caab76..c7f00280a6 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp @@ -49,8 +49,9 @@ QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWindow *window, QWaylandRe , m_glxIntegration(glxIntegration) , m_buffer(0) , m_pixmap(0) - , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->glFormat())) + , m_config(0) , m_glxPixmap(0) + , m_window(window) { } @@ -107,6 +108,9 @@ void QWaylandReadbackGlxWindow::createSurface() m_pixmap = XCreatePixmap(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(), size.width(), size.height(), depth); XSync(m_glxIntegration->xDisplay(), False); + if (!m_config) + m_config = qglx_findConfig(m_glxIntegration->xDisplay(), m_glxIntegration->screen(), m_window->glFormat()); + m_glxPixmap = glXCreatePixmap(m_glxIntegration->xDisplay(), m_config, m_pixmap,0); if (!m_glxPixmap) diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h index 60b22a4408..4f753c660b 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h @@ -69,6 +69,7 @@ private: Pixmap m_pixmap; GLXFBConfig m_config; GLXPixmap m_glxPixmap; + QWindow *m_window; }; #endif // QWAYLANDREADBACKGLXWINDOW_H -- cgit v1.2.3 From 176f30b13739b352cbe453cba7796d9a9c808bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 21 Jun 2011 13:39:26 +0200 Subject: OpenGL API refactor. Rename QGuiGLFormat to QSurfaceFormat, and make QWindow sub-class of QSurface and QPlatformWindow sub-class of QPlatformSurface, instead of having QPlatformGLSurface accessor in QWindow. --- .../wayland/gl_integration/qwaylandglintegration.h | 4 +-- .../qwaylandreadbackeglintegration.cpp | 2 +- .../readback_egl/qwaylandreadbackeglintegration.h | 2 +- .../readback_glx/qwaylandreadbackglxcontext.cpp | 33 ++++++++-------------- .../readback_glx/qwaylandreadbackglxcontext.h | 24 ++++------------ .../qwaylandreadbackglxintegration.cpp | 2 +- .../readback_glx/qwaylandreadbackglxintegration.h | 2 +- .../readback_glx/qwaylandreadbackglxwindow.cpp | 5 ---- .../readback_glx/qwaylandreadbackglxwindow.h | 2 -- .../qwaylandxcompositeeglcontext.cpp | 30 ++++++++------------ .../xcomposite_egl/qwaylandxcompositeeglcontext.h | 18 ++++-------- .../qwaylandxcompositeeglintegration.cpp | 2 +- .../qwaylandxcompositeeglintegration.h | 2 +- .../xcomposite_egl/qwaylandxcompositeeglwindow.cpp | 7 +---- .../xcomposite_egl/qwaylandxcompositeeglwindow.h | 2 -- .../qwaylandxcompositeglxcontext.cpp | 33 ++++++++-------------- .../xcomposite_glx/qwaylandxcompositeglxcontext.h | 23 ++++----------- .../qwaylandxcompositeglxintegration.cpp | 2 +- .../qwaylandxcompositeglxintegration.h | 2 +- .../xcomposite_glx/qwaylandxcompositeglxwindow.cpp | 7 +---- .../xcomposite_glx/qwaylandxcompositeglxwindow.h | 2 -- .../platforms/wayland/qwaylandintegration.cpp | 13 +++++---- .../platforms/wayland/qwaylandintegration.h | 2 +- .../platforms/wayland/qwaylandshmwindow.cpp | 6 ---- src/plugins/platforms/wayland/qwaylandshmwindow.h | 2 +- 25 files changed, 71 insertions(+), 158 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h index 2960d64eea..2b4f9fe028 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h @@ -47,7 +47,7 @@ class QWaylandDisplay; class QWindow; class QPlatformGLContext; -class QGuiGLFormat; +class QSurfaceFormat; class QWaylandGLIntegration { @@ -58,7 +58,7 @@ public: virtual void initialize() = 0; virtual QWaylandWindow *createEglWindow(QWindow *window) = 0; - virtual QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const = 0; + virtual QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const = 0; static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay); }; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp index 7fbe5cc725..773087f513 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp @@ -86,7 +86,7 @@ QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWindow *window return new QWaylandReadbackEglWindow(window, this); } -QPlatformGLContext *QWaylandReadbackEglWindow::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +QPlatformGLContext *QWaylandReadbackEglWindow::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const { return new QWaylandReadbackEglContext(glFormat, share, this); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h index 8945cdab38..d96e6cface 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h @@ -63,7 +63,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; + QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; QWaylandDisplay *waylandDisplay() const; Display *xDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp index 0ca04187d3..dec2cdd428 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp @@ -47,16 +47,6 @@ #include #include -QWaylandReadbackGlxSurface::QWaylandReadbackGlxSurface(QWaylandReadbackGlxWindow *window) - : m_window(window) -{ -} - -GLXPixmap QWaylandReadbackGlxSurface::glxPixmap() const -{ - return m_window->glxPixmap(); -} - static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) { const int width = img.width(); @@ -79,7 +69,7 @@ static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) } } -QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QGuiGLFormat &format, +QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen) : m_display(display) { @@ -89,17 +79,17 @@ QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QGuiGLFormat &forma XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config); m_context = glXCreateContext(display, visualInfo, shareContext, TRUE); - m_format = qglx_guiGLFormatFromGLXFBConfig(display, config, m_context); + m_format = qglx_surfaceFormatFromGLXFBConfig(display, config, m_context); } -QGuiGLFormat QWaylandReadbackGlxContext::format() const +QSurfaceFormat QWaylandReadbackGlxContext::format() const { return m_format; } -bool QWaylandReadbackGlxContext::makeCurrent(const QPlatformGLSurface &surface) +bool QWaylandReadbackGlxContext::makeCurrent(QPlatformSurface *surface) { - GLXPixmap glxPixmap = static_cast(surface).glxPixmap(); + GLXPixmap glxPixmap = static_cast(surface)->glxPixmap(); return glXMakeCurrent(m_display, glxPixmap, m_context); } @@ -109,16 +99,15 @@ void QWaylandReadbackGlxContext::doneCurrent() glXMakeCurrent(m_display, 0, 0); } -void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface) +void QWaylandReadbackGlxContext::swapBuffers(QPlatformSurface *surface) { // #### makeCurrent() directly on the platform context doesn't update QGuiGLContext::currentContext() if (QGuiGLContext::currentContext()->handle() != this) makeCurrent(surface); - const QWaylandReadbackGlxSurface &s = - static_cast(surface); + QWaylandReadbackGlxWindow *w = static_cast(surface); - QSize size = s.window()->geometry().size(); + QSize size = w->geometry().size(); QImage img(size, QImage::Format_ARGB32); const uchar *constBits = img.bits(); @@ -130,13 +119,13 @@ void QWaylandReadbackGlxContext::swapBuffers(const QPlatformGLSurface &surface) qgl_byteSwapImage(img, GL_UNSIGNED_INT_8_8_8_8_REV); constBits = img.bits(); - const uchar *constDstBits = s.window()->buffer(); + const uchar *constDstBits = w->buffer(); uchar *dstBits = const_cast(constDstBits); memcpy(dstBits, constBits, (img.width() * 4) * img.height()); - s.window()->damage(QRect(QPoint(), size)); + w->damage(QRect(QPoint(), size)); - s.window()->waitForFrameSync(); + w->waitForFrameSync(); } void (*QWaylandReadbackGlxContext::getProcAddress(const QByteArray &procName)) () diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h index 3008c295d3..d3a028f51a 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h @@ -43,7 +43,7 @@ #define QWAYLANDREADBACKGLXCONTEXT_H #include -#include +#include #include "qwaylandreadbackglxintegration.h" @@ -52,28 +52,16 @@ class QWaylandReadbackGlxWindow; class QWaylandShmBuffer; -class QWaylandReadbackGlxSurface : public QPlatformGLSurface -{ -public: - QWaylandReadbackGlxSurface(QWaylandReadbackGlxWindow *window); - - QWaylandReadbackGlxWindow *window() const { return m_window; } - GLXPixmap glxPixmap() const; - -private: - QWaylandReadbackGlxWindow *m_window; -}; - class QWaylandReadbackGlxContext : public QPlatformGLContext { public: - QWaylandReadbackGlxContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen); + QWaylandReadbackGlxContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen); - QGuiGLFormat format() const; + QSurfaceFormat format() const; - void swapBuffers(const QPlatformGLSurface &surface); + void swapBuffers(QPlatformSurface *surface); - bool makeCurrent(const QPlatformGLSurface &surface); + bool makeCurrent(QPlatformSurface *surface); void doneCurrent(); void (*getProcAddress(const QByteArray &procName)) (); @@ -82,7 +70,7 @@ private: GLXContext m_context; Display *m_display; - QGuiGLFormat m_format; + QSurfaceFormat m_format; }; #endif // QWAYLANDREADBACKGLXCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp index 6fb2a178c8..22ff5dc0c6 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp @@ -71,7 +71,7 @@ QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWindow *window return new QWaylandReadbackGlxWindow(window,this); } -QPlatformGLContext *QWaylandReadbackGlxIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +QPlatformGLContext *QWaylandReadbackGlxIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const { return new QWaylandReadbackGlxContext(glFormat, share, mDisplay, mScreen); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h index 0b3d0cc2cc..05c224263b 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h @@ -61,7 +61,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; + QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; QWaylandDisplay *waylandDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp index c7f00280a6..41824b0efd 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp @@ -86,11 +86,6 @@ uchar *QWaylandReadbackGlxWindow::buffer() return m_buffer->image()->bits(); } -QPlatformGLSurface *QWaylandReadbackGlxWindow::createGLSurface() const -{ - return new QWaylandReadbackGlxSurface(const_cast(this)); -} - void QWaylandReadbackGlxWindow::createSurface() { QSize size(geometry().size()); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h index 4f753c660b..c92646c80d 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h @@ -52,8 +52,6 @@ public: QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration); WindowType windowType() const; - QPlatformGLSurface *createGLSurface() const; - void setGeometry(const QRect &rect); Pixmap glxPixmap() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index c43b675d44..6c1018d79a 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -48,31 +48,25 @@ #include -QWaylandXCompositeEGLSurface::QWaylandXCompositeEGLSurface(QWaylandXCompositeEGLWindow *window) - : QEGLSurface(window->eglSurface(), window->window()->glFormat()) - , m_window(window) -{ -} - -EGLSurface QWaylandXCompositeEGLSurface::eglSurface() const -{ - return m_window->eglSurface(); -} - -QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display) +QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display) : QEGLPlatformContext(format, share, display) { } -void QWaylandXCompositeEGLContext::swapBuffers(const QPlatformGLSurface &surface) +void QWaylandXCompositeEGLContext::swapBuffers(QPlatformSurface *surface) { QEGLPlatformContext::swapBuffers(surface); - const QWaylandXCompositeEGLSurface &s = - static_cast(surface); + QWaylandXCompositeEGLWindow *w = + static_cast(surface); + + QSize size = w->geometry().size(); - QSize size = s.window()->geometry().size(); + w->damage(QRect(QPoint(), size)); + w->waitForFrameSync(); +} - s.window()->damage(QRect(QPoint(), size)); - s.window()->waitForFrameSync(); +EGLSurface QWaylandXCompositeEGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) +{ + return static_cast(surface)->eglSurface(); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h index e394ea1a04..f0e96a19af 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h @@ -50,23 +50,15 @@ class QWaylandXCompositeEGLWindow; -class QWaylandXCompositeEGLSurface : public QEGLSurface -{ -public: - QWaylandXCompositeEGLSurface(QWaylandXCompositeEGLWindow *window); - - EGLSurface eglSurface() const; - QWaylandXCompositeEGLWindow *window() const { return m_window; } -private: - QWaylandXCompositeEGLWindow *m_window; -}; - class QWaylandXCompositeEGLContext : public QEGLPlatformContext { public: - QWaylandXCompositeEGLContext(const QGuiGLFormat &format, QPlatformGLContext *share, EGLDisplay display); + QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display); - void swapBuffers(const QPlatformGLSurface &surface); + void swapBuffers(QPlatformSurface *surface); + +private: + EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface); }; #endif // QWAYLANDXCOMPOSITEEGLCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp index 90d5bea770..47454dccab 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp @@ -75,7 +75,7 @@ QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWindow *wind return new QWaylandXCompositeEGLWindow(window,this); } -QPlatformGLContext *QWaylandXCompositeEGLIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +QPlatformGLContext *QWaylandXCompositeEGLIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const { return new QWaylandXCompositeEGLContext(glFormat, share, eglDisplay()); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h index ac302ef89f..1f67bf28e1 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h @@ -69,7 +69,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; + QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp index 5e1bab2044..9bf857d734 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp @@ -57,7 +57,7 @@ QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWayla , m_context(0) , m_buffer(0) , m_xWindow(0) - , m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->glFormat(), true)) + , m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->format(), true)) , m_surface(0) , m_waitingForSync(false) { @@ -69,11 +69,6 @@ QWaylandWindow::WindowType QWaylandXCompositeEGLWindow::windowType() const return QWaylandWindow::Egl; } -QPlatformGLSurface *QWaylandXCompositeEGLWindow::createGLSurface() const -{ - return new QWaylandXCompositeEGLSurface(const_cast(this)); -} - void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect) { QWaylandWindow::setGeometry(rect); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h index 16188ca3e0..535498a722 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h @@ -54,8 +54,6 @@ public: QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration); WindowType windowType() const; - QPlatformGLSurface *createGLSurface() const; - void setGeometry(const QRect &rect); EGLSurface eglSurface() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp index 54d63a2bec..20fb0396f8 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -47,17 +47,7 @@ #include -QWaylandXCompositeGLXSurface::QWaylandXCompositeGLXSurface(QWaylandXCompositeGLXWindow *window) - : m_window(window) -{ -} - -Window QWaylandXCompositeGLXSurface::xWindow() const -{ - return m_window->xWindow(); -} - -QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen) +QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen) : m_display(display) { qDebug("creating XComposite-GLX context"); @@ -65,12 +55,12 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QGuiGLFormat &f GLXFBConfig config = qglx_findConfig(display, screen, format); XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display, config); m_context = glXCreateContext(display, visualInfo, shareContext, true); - m_format = qglx_guiGLFormatFromGLXFBConfig(display, config, m_context); + m_format = qglx_surfaceFormatFromGLXFBConfig(display, config, m_context); } -bool QWaylandXCompositeGLXContext::makeCurrent(const QPlatformGLSurface &surface) +bool QWaylandXCompositeGLXContext::makeCurrent(QPlatformSurface *surface) { - Window xWindow = static_cast(surface).xWindow(); + Window xWindow = static_cast(surface)->xWindow(); return glXMakeCurrent(m_display, xWindow, m_context); } @@ -80,17 +70,16 @@ void QWaylandXCompositeGLXContext::doneCurrent() glXMakeCurrent(m_display, 0, 0); } -void QWaylandXCompositeGLXContext::swapBuffers(const QPlatformGLSurface &surface) +void QWaylandXCompositeGLXContext::swapBuffers(QPlatformSurface *surface) { - const QWaylandXCompositeGLXSurface &s = - static_cast(surface); + QWaylandXCompositeGLXWindow *w = static_cast(surface); - QSize size = s.window()->geometry().size(); + QSize size = w->geometry().size(); - glXSwapBuffers(m_display, s.xWindow()); + glXSwapBuffers(m_display, w->xWindow()); - s.window()->damage(QRect(QPoint(), size)); - s.window()->waitForFrameSync(); + w->damage(QRect(QPoint(), size)); + w->waitForFrameSync(); } void (*QWaylandXCompositeGLXContext::getProcAddress(const QByteArray &procName)) () @@ -98,7 +87,7 @@ void (*QWaylandXCompositeGLXContext::getProcAddress(const QByteArray &procName)) return glXGetProcAddress(reinterpret_cast(procName.constData())); } -QGuiGLFormat QWaylandXCompositeGLXContext::format() const +QSurfaceFormat QWaylandXCompositeGLXContext::format() const { return m_format; } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h index 39fe03032f..cabdbe1a82 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -50,29 +50,16 @@ class QWaylandXCompositeGLXWindow; class QWaylandShmBuffer; -class QWaylandXCompositeGLXSurface : public QPlatformGLSurface -{ -public: - QWaylandXCompositeGLXSurface(QWaylandXCompositeGLXWindow *window); - - QWaylandXCompositeGLXWindow *window() const { return m_window; } - Window xWindow() const; - -private: - QWaylandXCompositeGLXWindow *m_window; -}; - - class QWaylandXCompositeGLXContext : public QPlatformGLContext { public: - QWaylandXCompositeGLXContext(const QGuiGLFormat &format, QPlatformGLContext *share, Display *display, int screen); + QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen); - QGuiGLFormat format() const; + QSurfaceFormat format() const; - void swapBuffers(const QPlatformGLSurface &surface); + void swapBuffers(QPlatformSurface *surface); - bool makeCurrent(const QPlatformGLSurface &surface); + bool makeCurrent(QPlatformSurface *surface); void doneCurrent(); void (*getProcAddress(const QByteArray &procName)) (); @@ -81,7 +68,7 @@ private: GLXContext m_context; Display *m_display; - QGuiGLFormat m_format; + QSurfaceFormat m_format; }; #endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp index 426c78e5e8..8c27fa1cd8 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -78,7 +78,7 @@ QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *wind return new QWaylandXCompositeGLXWindow(window, this); } -QPlatformGLContext *QWaylandXCompositeGLXIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +QPlatformGLContext *QWaylandXCompositeGLXIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const { return new QWaylandXCompositeGLXContext(glFormat, share, mDisplay, mScreen); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h index c347b110c6..5a779bf58a 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h @@ -64,7 +64,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; + QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp index 797803f4cd..abaf3b16a9 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp @@ -54,7 +54,7 @@ QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWayla : QWaylandWindow(window) , m_glxIntegration(glxIntegration) , m_xWindow(0) - , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->glFormat())) + , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->format())) , m_buffer(0) , m_waitingForSync(false) { @@ -66,11 +66,6 @@ QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const return QWaylandWindow::Egl; } -QPlatformGLSurface *QWaylandXCompositeGLXWindow::createGLSurface() const -{ - return new QWaylandXCompositeGLXSurface(const_cast(this)); -} - void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect) { QWaylandWindow::setGeometry(rect); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h index 7a19c7175a..acf6c8e63e 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h @@ -56,8 +56,6 @@ public: QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration); WindowType windowType() const; - QPlatformGLSurface *createGLSurface() const; - void setGeometry(const QRect &rect); Window xWindow() const; diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 9cd79e2978..dc59d37f40 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -51,7 +51,7 @@ #include #include -#include +#include #include @@ -100,18 +100,19 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const { #ifdef QT_WAYLAND_GL_SUPPORT - if (window->surfaceType() == QWindow::OpenGLSurface) - return mDisplay->eglIntegration()->createEglWindow(window); -#endif - + return mDisplay->eglIntegration()->createEglWindow(window); +#else return new QWaylandShmWindow(window); +#endif } -QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const +QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const { #ifdef QT_WAYLAND_GL_SUPPORT return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share); #else + Q_UNUSED(glFormat); + Q_UNUSED(share); return 0; #endif } diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 1e22191ff7..adb8b81ca6 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -57,7 +57,7 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; - QPlatformGLContext *createPlatformGLContext(const QGuiGLFormat &glFormat, QPlatformGLContext *share) const; + QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; QList screens() const; diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp index bd1e61fa4c..ba5e46cab1 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp @@ -63,9 +63,3 @@ QWaylandWindow::WindowType QWaylandShmWindow::windowType() const return QWaylandWindow::Shm; } -QPlatformGLSurface * QWaylandShmWindow::glSurface() const -{ - qWarning("Raster window does not have a GL drawable"); - return 0; -} - diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h index db26c5c928..69d4228daa 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.h +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h @@ -52,7 +52,7 @@ public: ~QWaylandShmWindow(); WindowType windowType() const; - QPlatformGLSurface *glSurface() const; + QSurfaceFormat format() const { return window()->format(); } }; #endif // QWAYLANDSHMWINDOW_H -- cgit v1.2.3 From 4efaf305f51d09e214645a18a7bfa62bc36e2c61 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 21 Jun 2011 13:40:57 +0200 Subject: Add lighthouse event dispatcher API. Platform plugin creation is now moved forward in order to have a platform plugin instance at event dispatcher creation time. Plugins are now responsible for implementing PlatformIntegration::createEventDispatcher and returning an QAbstractEventDispatcher subclass. --- src/plugins/platforms/wayland/qwaylandintegration.cpp | 6 ++++++ src/plugins/platforms/wayland/qwaylandintegration.h | 2 ++ src/plugins/platforms/wayland/wayland.pro | 1 + 3 files changed, 9 insertions(+) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index dc59d37f40..bdd8235d5b 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -48,6 +48,7 @@ #include "qwaylandclipboard.h" #include "QtPlatformSupport/private/qgenericunixfontdatabase_p.h" +#include #include #include @@ -122,6 +123,11 @@ QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow * return new QWaylandShmBackingStore(window); } +QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const +{ + return createUnixEventDispatcher(); +} + QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const { return mFontDb; diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index adb8b81ca6..6a5e4d3b28 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -48,6 +48,7 @@ QT_BEGIN_NAMESPACE class QWaylandBuffer; class QWaylandDisplay; +class QAbstractEventDispatcher; class QWaylandIntegration : public QPlatformIntegration { @@ -59,6 +60,7 @@ public: QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; + QAbstractEventDispatcher *createEventDispatcher() const; QList screens() const; diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 9010439939..dc4485ca33 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -42,3 +42,4 @@ INSTALLS += target include ($$PWD/gl_integration/gl_integration.pri) include ($$PWD/windowmanager_integration/windowmanager_integration.pri) +load(qpa/eventdispatchers/eventdispatchers) -- cgit v1.2.3 From f3440ddf52de23711b00bb6a6097ce46c9cd3f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 22 Jun 2011 16:26:02 +0200 Subject: Get wayland plugin working again. --- .../gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp | 2 +- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 7 +++++-- src/plugins/platforms/wayland/qwaylanddisplay.h | 3 +++ src/plugins/platforms/wayland/qwaylandintegration.cpp | 10 ++++++---- src/plugins/platforms/wayland/qwaylandwindow.cpp | 1 + 5 files changed, 16 insertions(+), 7 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp index 41824b0efd..35c3ca3154 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp @@ -104,7 +104,7 @@ void QWaylandReadbackGlxWindow::createSurface() XSync(m_glxIntegration->xDisplay(), False); if (!m_config) - m_config = qglx_findConfig(m_glxIntegration->xDisplay(), m_glxIntegration->screen(), m_window->glFormat()); + m_config = qglx_findConfig(m_glxIntegration->xDisplay(), m_glxIntegration->screen(), m_window->format()); m_glxPixmap = glXCreatePixmap(m_glxIntegration->xDisplay(), m_config, m_pixmap,0); diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 6f61cf1012..d501659f51 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -152,9 +152,12 @@ QWaylandDisplay::QWaylandDisplay(void) mEglIntegration->initialize(); #endif - connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); - mFd = wl_display_get_fd(mDisplay, sourceUpdate, this); +} + +void QWaylandDisplay::eventDispatcherCreated(QAbstractEventDispatcher *dispatcher) +{ + connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this); connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(readEvents())); diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 5226f0d8e3..840f768964 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -49,6 +49,7 @@ #include +class QAbstractEventDispatcher; class QWaylandInputDevice; class QSocketNotifier; class QWaylandBuffer; @@ -91,6 +92,8 @@ public: QList inputDevices() const { return mInputDevices; } + void eventDispatcherCreated(QAbstractEventDispatcher *dispatcher); + public slots: void createNewScreen(struct wl_output *output, QRect geometry); void readEvents(); diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index bdd8235d5b..1f1ecda0e6 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -101,10 +101,10 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const { #ifdef QT_WAYLAND_GL_SUPPORT - return mDisplay->eglIntegration()->createEglWindow(window); -#else - return new QWaylandShmWindow(window); + if (window->surfaceType() == QWindow::OpenGLSurface) + return mDisplay->eglIntegration()->createEglWindow(window); #endif + return new QWaylandShmWindow(window); } QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const @@ -125,7 +125,9 @@ QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow * QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const { - return createUnixEventDispatcher(); + QAbstractEventDispatcher *dispatcher = createUnixEventDispatcher(); + mDisplay->eventDispatcherCreated(dispatcher); + return dispatcher; } QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index ec62a3c799..34fcdad23c 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -104,6 +104,7 @@ void QWaylandWindow::setVisible(bool visible) if (visible) { wl_surface_map_toplevel(mSurface); + QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); } else { wl_surface_destroy(mSurface); mSurface = NULL; -- cgit v1.2.3 From 6d6ac714ca63ba8d4bbe16cf332872939c29756c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 22 Jun 2011 16:28:45 +0200 Subject: Prevent endless loop when calling QWaylandShmWindow::format(). --- src/plugins/platforms/wayland/qwaylandshmwindow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h index 69d4228daa..36f9f225b7 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.h +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h @@ -52,7 +52,7 @@ public: ~QWaylandShmWindow(); WindowType windowType() const; - QSurfaceFormat format() const { return window()->format(); } + QSurfaceFormat format() const { return QSurfaceFormat(); } }; #endif // QWAYLANDSHMWINDOW_H -- cgit v1.2.3 From bbcc62efaae8addaa55281a8c9fab8877cb0d64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 22 Jun 2011 10:00:28 +0200 Subject: Update the wayland plugin to sha1 bfea3d6befdb688d5354e6f15a9400ea637febf9 --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 27 +++++++++++++++++++---- src/plugins/platforms/wayland/qwaylanddisplay.h | 11 ++++++++- src/plugins/platforms/wayland/qwaylandwindow.cpp | 12 +++++----- src/plugins/platforms/wayland/wayland_sha1.txt | 2 +- 4 files changed, 40 insertions(+), 12 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index d501659f51..9e8cfe3df6 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -234,17 +234,36 @@ int QWaylandDisplay::sourceUpdate(uint32_t mask, void *data) } void QWaylandDisplay::outputHandleGeometry(void *data, - struct wl_output *output, + wl_output *output, int32_t x, int32_t y, - int32_t width, int32_t height) + int32_t physicalWidth, + int32_t physicalHeight, + int subpixel, + const char *make, const char *model) { QWaylandDisplay *waylandDisplay = static_cast(data); - QRect outputRect = QRect(x, y, width, height); + QRect outputRect = QRect(x, y, physicalWidth, physicalHeight); waylandDisplay->createNewScreen(output,outputRect); } +void QWaylandDisplay::mode(void *data, + struct wl_output *wl_output, + uint32_t flags, + int width, + int height, + int refresh) +{ + Q_UNUSED(data); + Q_UNUSED(wl_output); + Q_UNUSED(flags); + Q_UNUSED(width); + Q_UNUSED(height); + Q_UNUSED(refresh); +} + const struct wl_output_listener QWaylandDisplay::outputListener = { - QWaylandDisplay::outputHandleGeometry + QWaylandDisplay::outputHandleGeometry, + QWaylandDisplay::mode }; const struct wl_compositor_listener QWaylandDisplay::compositorListener = { diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 840f768964..14812885a3 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -131,7 +131,16 @@ private: static void outputHandleGeometry(void *data, struct wl_output *output, int32_t x, int32_t y, - int32_t width, int32_t height); + int32_t width, int32_t height, + int subpixel, + const char *make, + const char *model); + static void mode(void *data, + struct wl_output *wl_output, + uint32_t flags, + int width, + int height, + int refresh); static void handleVisual(void *data, struct wl_compositor *compositor, diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 34fcdad23c..8fc8700d2f 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -59,6 +59,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window) : QPlatformWindow(window) + , mSurface(0) , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display()) , mBuffer(0) , mWaitingForFrameSync(false) @@ -70,8 +71,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window) mDisplay->windowManagerIntegration()->mapClientToProcess(qApp->applicationPid()); mDisplay->windowManagerIntegration()->authenticateWithToken(); #endif - - mSurface = mDisplay->createSurface(this); } QWaylandWindow::~QWaylandWindow() @@ -102,10 +101,7 @@ void QWaylandWindow::setVisible(bool visible) newSurfaceCreated(); } - if (visible) { - wl_surface_map_toplevel(mSurface); - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); - } else { + if (!visible) { wl_surface_destroy(mSurface); mSurface = NULL; } @@ -129,6 +125,7 @@ void QWaylandWindow::attach(QWaylandBuffer *buffer) mBuffer = buffer; if (mSurface) { wl_surface_attach(mSurface, buffer->buffer(),0,0); + QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); } } @@ -145,6 +142,8 @@ void QWaylandWindow::damage(const QRegion ®ion) wl_buffer_damage(mBuffer->buffer(), rect.x(), rect.y(), rect.width(), rect.height()); wl_surface_damage(mSurface, rect.x(), rect.y(), rect.width(), rect.height()); + wl_buffer_damage(mBuffer->buffer(), + rect.x(), rect.y(), rect.width(), rect.height()); } } @@ -152,6 +151,7 @@ void QWaylandWindow::newSurfaceCreated() { if (mBuffer) { wl_surface_attach(mSurface,mBuffer->buffer(),0,0); + QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); } } diff --git a/src/plugins/platforms/wayland/wayland_sha1.txt b/src/plugins/platforms/wayland/wayland_sha1.txt index d2624378e0..a696e760d5 100644 --- a/src/plugins/platforms/wayland/wayland_sha1.txt +++ b/src/plugins/platforms/wayland/wayland_sha1.txt @@ -1,3 +1,3 @@ This version of the Qt Wayland plugin is checked against the following sha1 from the Wayland repository: -eff7fc0d99be2e51eaa351785030c8d374ac71de +bfea3d6befdb688d5354e6f15a9400ea637febf9 -- cgit v1.2.3 From ce4d3435d75cf92d44b95522d24d0373a7aefb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 23 Jun 2011 14:30:04 +0200 Subject: Make sure to call damage on the buffer when we damage it --- .../gl_integration/xcomposite_egl/xcomposite_egl.pri | 3 --- .../platforms/wayland/qwaylandshmbackingstore.cpp | 7 ++++++- src/plugins/platforms/wayland/qwaylandwindow.cpp | 20 ++++++++------------ src/plugins/platforms/wayland/qwaylandwindow.h | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri index a61391b2d1..5f86bd9588 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri @@ -1,7 +1,4 @@ include (../xcomposite_share/xcomposite_share.pri) -load(qpa/egl/convenience) -load(qpa/egl/context) -load(qpa/egl/xlibintegration) LIBS += -lXcomposite -lEGL diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp index ccb50a73fb..25a1b466d4 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp @@ -119,7 +119,12 @@ void QWaylandShmBackingStore::flush(QWindow *window, const QRegion ®ion, cons Q_UNUSED(offset); QWaylandShmWindow *waylandWindow = static_cast(window->handle()); Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); - waylandWindow->damage(region); + QVector rects = region.rects(); + for (int i = 0; i < rects.size(); i++) { + const QRect rect = rects.at(i); + wl_buffer_damage(mBuffer->buffer(),rect.x(),rect.y(),rect.width(),rect.height()); + waylandWindow->damage(rect); + } } void QWaylandShmBackingStore::resize(const QSize &size, const QRegion &) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 8fc8700d2f..2376df55c9 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -129,22 +129,17 @@ void QWaylandWindow::attach(QWaylandBuffer *buffer) } } -void QWaylandWindow::damage(const QRegion ®ion) +void QWaylandWindow::damage(const QRect &rect) { //We have to do sync stuff before calling damage, or we might //get a frame callback before we get the timestamp - mDisplay->frameCallback(QWaylandWindow::frameCallback, mSurface, this); - mWaitingForFrameSync = true; - - QVector rects = region.rects(); - for (int i = 0; i < rects.size(); i++) { - const QRect rect = rects.at(i); - wl_buffer_damage(mBuffer->buffer(), rect.x(), rect.y(), rect.width(), rect.height()); - wl_surface_damage(mSurface, - rect.x(), rect.y(), rect.width(), rect.height()); - wl_buffer_damage(mBuffer->buffer(), - rect.x(), rect.y(), rect.width(), rect.height()); + if (!mWaitingForFrameSync) { + mDisplay->frameCallback(QWaylandWindow::frameCallback, mSurface, this); + mWaitingForFrameSync = true; } + + wl_surface_damage(mSurface, + rect.x(), rect.y(), rect.width(), rect.height()); } void QWaylandWindow::newSurfaceCreated() @@ -152,6 +147,7 @@ void QWaylandWindow::newSurfaceCreated() if (mBuffer) { wl_surface_attach(mSurface,mBuffer->buffer(),0,0); QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); + wl_surface_damage(mSurface,0,0,mBuffer->size().width(),mBuffer->size().height()); } } diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h index ca9f4b14d3..4f1e2c8183 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.h +++ b/src/plugins/platforms/wayland/qwaylandwindow.h @@ -71,7 +71,7 @@ public: int32_t x, int32_t y, int32_t width, int32_t height); void attach(QWaylandBuffer *buffer); - void damage(const QRegion ®ion); + void damage(const QRect &rect); void waitForFrameSync(); -- cgit v1.2.3 From 8ab2f3d9bdf1119cc13567c9dd2c74879c0b0ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 23 Jun 2011 15:37:37 +0200 Subject: Get declarative and wayland EGL backend working for Qt compositor. --- .../wayland_egl/qwaylandeglintegration.cpp | 18 +++-- .../wayland_egl/qwaylandeglintegration.h | 7 +- .../wayland_egl/qwaylandeglwindow.cpp | 76 ++++++++++++---------- .../gl_integration/wayland_egl/qwaylandeglwindow.h | 20 ++++-- .../wayland_egl/qwaylandglcontext.cpp | 57 ++++++---------- .../gl_integration/wayland_egl/qwaylandglcontext.h | 28 ++++---- 6 files changed, 106 insertions(+), 100 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp index d5c2f62e44..ab154017ec 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -44,11 +44,12 @@ #include "gl_integration/qwaylandglintegration.h" #include "qwaylandeglwindow.h" +#include "qwaylandglcontext.h" #include QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay) - : mWaylandDisplay(waylandDisplay) + : m_waylandDisplay(waylandDisplay) { qDebug() << "Using Wayland-EGL"; } @@ -56,17 +57,17 @@ QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay QWaylandEglIntegration::~QWaylandEglIntegration() { - eglTerminate(mEglDisplay); + eglTerminate(m_eglDisplay); } void QWaylandEglIntegration::initialize() { EGLint major,minor; - mEglDisplay = eglGetDisplay(mWaylandDisplay); - if (mEglDisplay == NULL) { + m_eglDisplay = eglGetDisplay(m_waylandDisplay); + if (m_eglDisplay == NULL) { qWarning("EGL not available"); } else { - if (!eglInitialize(mEglDisplay, &major, &minor)) { + if (!eglInitialize(m_eglDisplay, &major, &minor)) { qWarning("failed to initialize EGL display"); return; } @@ -78,9 +79,14 @@ QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWindow *window) return new QWaylandEglWindow(window); } +QPlatformGLContext *QWaylandEglIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const +{ + return new QWaylandGLContext(m_eglDisplay, glFormat, share); +} + EGLDisplay QWaylandEglIntegration::eglDisplay() const { - return mEglDisplay; + return m_eglDisplay; } QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h index bc20b2cdb3..5e39e39fe8 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h @@ -58,13 +58,14 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); + QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; EGLDisplay eglDisplay() const; - struct wl_egl_display *nativeDisplay() const; + private: - struct wl_display *mWaylandDisplay; + struct wl_display *m_waylandDisplay; - EGLDisplay mEglDisplay; + EGLDisplay m_eglDisplay; }; #endif // QWAYLANDEGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp index 4a085ae0bd..245097ef6c 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp @@ -44,21 +44,29 @@ #include "qwaylandscreen.h" #include "qwaylandglcontext.h" +#include + #include QWaylandEglWindow::QWaylandEglWindow(QWindow *window) : QWaylandWindow(window) - , mGLContext(0) - , mWaylandEglWindow(0) + , m_waylandEglWindow(0) + , m_eglSurface(0) + , m_eglConfig(0) + , m_format(window->format()) { - mEglIntegration = static_cast(mDisplay->eglIntegration()); + m_eglIntegration = static_cast(mDisplay->eglIntegration()); + //super creates a new surface newSurfaceCreated(); } QWaylandEglWindow::~QWaylandEglWindow() { - delete mGLContext; + if (m_eglSurface) { + eglDestroySurface(m_eglIntegration->eglDisplay(), m_eglSurface); + m_eglSurface = 0; + } } QWaylandWindow::WindowType QWaylandEglWindow::windowType() const @@ -69,46 +77,46 @@ QWaylandWindow::WindowType QWaylandEglWindow::windowType() const void QWaylandEglWindow::setGeometry(const QRect &rect) { QWaylandWindow::setGeometry(rect); - if (mWaylandEglWindow) { - wl_egl_window_resize(mWaylandEglWindow,rect.width(),rect.height(),0,0); - } + if (m_waylandEglWindow) + wl_egl_window_resize(m_waylandEglWindow, rect.width(), rect.height(), 0, 0); } -void QWaylandEglWindow::setParent(const QPlatformWindow *parent) +void QWaylandEglWindow::newSurfaceCreated() { - const QWaylandWindow *wParent = static_cast(parent); - - mParentWindow = wParent; -} + if (m_waylandEglWindow) + wl_egl_window_destroy(m_waylandEglWindow); -QPlatformGLContext * QWaylandEglWindow::glContext() const -{ - if (!mGLContext) { - QWaylandEglWindow *that = const_cast(this); - that->mGLContext = new QWaylandGLContext(mEglIntegration->eglDisplay(),this->window()->requestedWindowFormat()); + wl_visual *visual = QWaylandScreen::waylandScreenFromWindow(window())->visual(); + QSize size = geometry().size(); + if (!size.isValid()) + size = QSize(0,0); - EGLNativeWindowType window(reinterpret_cast(mWaylandEglWindow)); - EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL); - that->mGLContext->setEglSurface(surface); + if (m_eglSurface) { + eglDestroySurface(m_eglIntegration->eglDisplay(), m_eglSurface); + m_eglSurface = 0; } - return mGLContext; + m_waylandEglWindow = wl_egl_window_create(mSurface, size.width(), size.height(), visual); } -void QWaylandEglWindow::newSurfaceCreated() +QSurfaceFormat QWaylandEglWindow::format() const { - if (mWaylandEglWindow) { - wl_egl_window_destroy(mWaylandEglWindow); - } - wl_visual *visual = QWaylandScreen::waylandScreenFromWindow(window())->visual(); - QSize size = geometry().size(); - if (!size.isValid()) - size = QSize(0,0); + return m_format; +} + +EGLSurface QWaylandEglWindow::eglSurface() const +{ + if (!m_waylandEglWindow) + return 0; - mWaylandEglWindow = wl_egl_window_create(mSurface,size.width(),size.height(),visual); - if (mGLContext) { - EGLNativeWindowType window(reinterpret_cast(mWaylandEglWindow)); - EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL); - mGLContext->setEglSurface(surface); + if (!m_eglSurface) { + if (!m_eglConfig) + m_eglConfig = q_configFromGLFormat(m_eglIntegration->eglDisplay(), window()->format(), true); + + EGLNativeWindowType window = m_waylandEglWindow; + m_eglSurface = eglCreateWindowSurface(m_eglIntegration->eglDisplay(), m_eglConfig, window, 0); } + + return m_eglSurface; } + diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h index 343c50729b..d435a511c4 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h @@ -55,16 +55,24 @@ public: ~QWaylandEglWindow(); WindowType windowType() const; void setGeometry(const QRect &rect); - void setParent(const QPlatformWindow *parent); - QPlatformGLContext *glContext() const; + + EGLSurface eglSurface() const; + + QSurfaceFormat format() const; + protected: void newSurfaceCreated(); + private: - QWaylandEglIntegration *mEglIntegration; - QWaylandGLContext *mGLContext; - struct wl_egl_window *mWaylandEglWindow; + QWaylandEglIntegration *m_eglIntegration; + struct wl_egl_window *m_waylandEglWindow; + + const QWaylandWindow *m_parentWindow; + + mutable EGLSurface m_eglSurface; + mutable EGLConfig m_eglConfig; - const QWaylandWindow *mParentWindow; + QSurfaceFormat m_format; }; #endif // QWAYLANDEGLWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp index 0cff704ab1..d3ece7c7a9 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -43,21 +43,21 @@ #include "qwaylanddisplay.h" #include "qwaylandwindow.h" +#include "qwaylandeglwindow.h" -#include "../../../eglconvenience/qeglconvenience.h" +#include #include -#include +#include #include -QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QWindowFormat &format) +QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformGLContext *share) : QPlatformGLContext() - , mEglDisplay(eglDisplay) - , mSurface(EGL_NO_SURFACE) - , mConfig(q_configFromQWindowFormat(mEglDisplay,format,true)) - , mFormat(q_windowFormatFromConfig(mEglDisplay,mConfig)) + , m_eglDisplay(eglDisplay) + , m_config(q_configFromGLFormat(m_eglDisplay, format, true)) + , m_format(q_glFormatFromConfig(m_eglDisplay, m_config)) { - EGLContext shareEGLContext = EGL_NO_CONTEXT; + EGLContext shareEGLContext = share ? static_cast(share)->eglContext() : EGL_NO_CONTEXT; eglBindAPI(EGL_OPENGL_ES_API); @@ -66,55 +66,38 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QWindowFormat eglContextAttrs.append(2); eglContextAttrs.append(EGL_NONE); - mContext = eglCreateContext(mEglDisplay, mConfig, - shareEGLContext, eglContextAttrs.constData()); + m_context = eglCreateContext(m_eglDisplay, m_config, shareEGLContext, eglContextAttrs.constData()); } -QWaylandGLContext::QWaylandGLContext() - : QPlatformGLContext() - , mEglDisplay(0) - , mContext(EGL_NO_CONTEXT) - , mSurface(EGL_NO_SURFACE) - , mConfig(0) -{ } - QWaylandGLContext::~QWaylandGLContext() { - eglDestroyContext(mEglDisplay,mContext); + eglDestroyContext(m_eglDisplay, m_context); } -void QWaylandGLContext::makeCurrent() +bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface) { - if (mSurface == EGL_NO_SURFACE) { - qWarning("makeCurrent with EGL_NO_SURFACE"); - } - eglMakeCurrent(mEglDisplay, mSurface, mSurface, mContext); + EGLSurface eglSurface = static_cast(surface)->eglSurface(); + return eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_context); } void QWaylandGLContext::doneCurrent() { - QPlatformGLContext::doneCurrent(); - eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); -} - -void QWaylandGLContext::swapBuffers() -{ - eglSwapBuffers(mEglDisplay,mSurface); + eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); } -void *QWaylandGLContext::getProcAddress(const QString &string) +void QWaylandGLContext::swapBuffers(QPlatformSurface *surface) { - return (void *) eglGetProcAddress(string.toLatin1().data()); + EGLSurface eglSurface = static_cast(surface)->eglSurface(); + eglSwapBuffers(m_eglDisplay, eglSurface); } -void QWaylandGLContext::setEglSurface(EGLSurface surface) +void (*QWaylandGLContext::getProcAddress(const QByteArray &procName)) () { - doneCurrent(); - mSurface = surface; + return eglGetProcAddress(procName.constData()); } EGLConfig QWaylandGLContext::eglConfig() const { - return mConfig; + return m_config; } diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h index 47070f54b1..592f3d18f5 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h @@ -53,27 +53,27 @@ class QWaylandGLWindowSurface; class QWaylandGLContext : public QPlatformGLContext { public: - QWaylandGLContext(EGLDisplay eglDisplay, const QWindowFormat &format); + QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformGLContext *share); ~QWaylandGLContext(); - void makeCurrent(); + + void swapBuffers(QPlatformSurface *surface); + + bool makeCurrent(QPlatformSurface *surface); void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString&); - QWindowFormat windowFormat() const { return mFormat; } + void (*getProcAddress(const QByteArray &procName)) (); - void setEglSurface(EGLSurface surface); - EGLConfig eglConfig() const; -private: - EGLDisplay mEglDisplay; + QSurfaceFormat format() const { return m_format; } - EGLContext mContext; - EGLSurface mSurface; - EGLConfig mConfig; - QWindowFormat mFormat; + EGLConfig eglConfig() const; + EGLContext eglContext() const { return m_context; } - QWaylandGLContext(); +private: + EGLDisplay m_eglDisplay; + EGLContext m_context; + EGLConfig m_config; + QSurfaceFormat m_format; }; -- cgit v1.2.3 From 8e8ad987a2de2766da68d5b644a12e4363e74578 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 23 Jun 2011 11:10:05 +0200 Subject: Remove load(eventdispatchers). --- src/plugins/platforms/wayland/wayland.pro | 1 - 1 file changed, 1 deletion(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index dc4485ca33..9010439939 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -42,4 +42,3 @@ INSTALLS += target include ($$PWD/gl_integration/gl_integration.pri) include ($$PWD/windowmanager_integration/windowmanager_integration.pri) -load(qpa/eventdispatchers/eventdispatchers) -- cgit v1.2.3 From bebda38eaf18c282ba64a59033f2b611c1043d1f Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Mon, 6 Jun 2011 12:39:45 +0200 Subject: Add wayland mac readback implementation. --- .../readback_cgl/qwaylandreadbackcglcontext.cpp | 116 +++++++++++++++++++++ .../readback_cgl/qwaylandreadbackcglcontext.h | 72 +++++++++++++ .../qwaylandreadbackcglintegration.cpp | 82 +++++++++++++++ .../readback_cgl/qwaylandreadbackcglintegration.h | 71 +++++++++++++ .../readback_cgl/qwaylandreadbackcglwindow.cpp | 106 +++++++++++++++++++ .../readback_cgl/qwaylandreadbackcglwindow.h | 70 +++++++++++++ .../gl_integration/readback_cgl/readback_cgl.pri | 10 ++ 7 files changed, 527 insertions(+) create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.h create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_cgl/readback_cgl.pri (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp new file mode 100644 index 0000000000..7f21f2ebcc --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandreadbackcglcontext.h" + +#include "qwaylandshmbackingstore.h" +#include "qwaylandreadbackcglwindow.h" + +#include +#include + +#include +#include + +#include + +QWaylandReadbackCGLContext::QWaylandReadbackCGLContext(QPlatformGLContext *share) + : QPlatformGLContext() +{ + Q_UNUSED(share); + m_glContext = qcgl_createGlContext(); +} + +QSurfaceFormat QWaylandReadbackCGLContext::format() const +{ + return qcgl_surfaceFormat(); +} + +bool QWaylandReadbackCGLContext::makeCurrent(QPlatformSurface *surface) +{ + QWaylandReadbackCGLWindow *window = static_cast(surface); + CGLSetPBuffer(m_glContext, window->pixelBuffer(), 0, 0, 0); + CGLSetCurrentContext(m_glContext); + return true; +} + +void QWaylandReadbackCGLContext::doneCurrent() +{ + CGLSetCurrentContext(0); +} + +void QWaylandReadbackCGLContext::swapBuffers(QPlatformSurface *surface) +{ + Q_UNUSED(surface); + + if (QGuiGLContext::currentContext()->handle() != this) { + makeCurrent(surface); + } + CGLFlushDrawable(m_glContext); + + QWaylandReadbackCGLWindow *window = static_cast(surface); + + QSize size = window->geometry().size(); + + QImage img(size,QImage::Format_ARGB32); + img.fill(Qt::red); + const uchar *constBits = img.bits(); + void *pixels = const_cast(constBits); + +// glReadPixels(0,0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels); +// img = img.mirrored(); +// qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV); + + constBits = img.bits(); + + const uchar *constDstBits = window->buffer(); + uchar *dstBits = const_cast(constDstBits); + memcpy(dstBits,constBits,(img.width()*4) * img.height()); + + window->damage(QRect(QPoint(0,0),size)); + window->waitForFrameSync(); +} + +void (*QWaylandReadbackCGLContext::getProcAddress(const QByteArray &procName)) () +{ + return qcgl_getProcAddress(procName); +} + diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h new file mode 100644 index 0000000000..7f727ae8f9 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDREADBACKCGLCONTEXT_H +#define QWAYLANDREADBACKCGLCONTEXT_H + +#include + +#include "qwaylandreadbackcglintegration.h" + +#include + +class QWaylandReadbackCGLWindow; +class QWaylandShmBuffer; + +class QWaylandReadbackCGLContext : public QPlatformGLContext +{ +public: + QWaylandReadbackCGLContext(QPlatformGLContext *share); + + QSurfaceFormat format() const; + + bool makeCurrent(QPlatformSurface *surface); + void doneCurrent(); + void swapBuffers(QPlatformSurface *surface); + void (*getProcAddress(const QByteArray &procName)) (); + + void geometryChanged(); + +private: + CGLContextObj m_glContext; +}; + +#endif // QWAYLANDREADBACKCGLCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp new file mode 100644 index 0000000000..c9cc7b4fa1 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandreadbackcglintegration.h" +#include "qwaylandreadbackcglcontext.h" +#include "qwaylandreadbackcglwindow.h" + +#include + +QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandReadbackCGLIntegration(waylandDisplay); +} + +QWaylandReadbackCGLIntegration::QWaylandReadbackCGLIntegration(QWaylandDisplay * waylandDispaly) + : QWaylandGLIntegration() + , mWaylandDisplay(waylandDispaly) +{ + qDebug() << "Using Readback-CGL"; +} + +QWaylandReadbackCGLIntegration::~QWaylandReadbackCGLIntegration() +{ + +} + +void QWaylandReadbackCGLIntegration::initialize() +{ +} + +QWaylandWindow * QWaylandReadbackCGLIntegration::createEglWindow(QWindow *window) +{ + return new QWaylandReadbackCGLWindow(window,this); +} + +QPlatformGLContext *QWaylandReadbackCGLIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const +{ + return new QWaylandReadbackCGLContext(share); +} + +QWaylandDisplay * QWaylandReadbackCGLIntegration::waylandDisplay() const +{ + return mWaylandDisplay; +} diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h new file mode 100644 index 0000000000..63b95f5efa --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDREADBACKGLXINTEGRATION_H +#define QWAYLANDREADBACKGLXINTEGRATION_H + +#include "gl_integration/qwaylandglintegration.h" + +#include +#include +#include +#include +#include + +#include + +class QWaylandReadbackCGLIntegration : public QWaylandGLIntegration +{ +public: + QWaylandReadbackCGLIntegration(QWaylandDisplay * waylandDispaly); + ~QWaylandReadbackCGLIntegration(); + + void initialize(); + + QWaylandWindow *createEglWindow(QWindow *window); + QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; + QWaylandDisplay *waylandDisplay() const; + +private: + QWaylandDisplay *mWaylandDisplay; +}; + +#endif // QWAYLANDREADBACKGLXINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.cpp new file mode 100644 index 0000000000..9e7f8520c9 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandreadbackcglwindow.h" +#include "qwaylandshmbackingstore.h" + +#include +#include + +QWaylandReadbackCGLWindow::QWaylandReadbackCGLWindow(QWindow *window, QWaylandReadbackCGLIntegration *cglIntegration) + : QWaylandShmWindow(window) + , m_CglIntegration(cglIntegration) + , mContext(0) + , m_buffer(0) + , m_pixelBuffer(0) +{ +} + +QWaylandWindow::WindowType QWaylandReadbackCGLWindow::windowType() const +{ + //yeah. this type needs a new name + return QWaylandWindow::Egl; +} + + +void QWaylandReadbackCGLWindow::setGeometry(const QRect &rect) +{ + QWaylandShmWindow::setGeometry(rect); + + if (m_buffer) { + delete m_buffer; + m_buffer = 0; + + CGLDestroyPBuffer(m_pixelBuffer); + m_pixelBuffer = 0; + } +} + +CGLPBufferObj QWaylandReadbackCGLWindow::pixelBuffer() +{ + if (!m_pixelBuffer) + createSurface(); + + return m_pixelBuffer; +} + +uchar *QWaylandReadbackCGLWindow::buffer() +{ + return m_buffer->image()->bits(); +} + +void QWaylandReadbackCGLWindow::createSurface() +{ + QSize size(geometry().size()); + if (size.isEmpty()) { + //QGLWidget wants a context for a window without geometry + size = QSize(1,1); + } + + waitForFrameSync(); + + CGLCreatePBuffer(size.width(), size.height(), GL_TEXTURE_RECTANGLE_ARB, GL_BGRA, 0, &m_pixelBuffer); + + delete m_buffer; + m_buffer = new QWaylandShmBuffer(m_CglIntegration->waylandDisplay(),size,QImage::Format_ARGB32); + attach(m_buffer); +} + diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.h new file mode 100644 index 0000000000..0598cf9037 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglwindow.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDREADBACKGLXWINDOW_H +#define QWAYLANDREADBACKGLXWINDOW_H + +#include "qwaylandshmwindow.h" +#include "qwaylandreadbackcglintegration.h" +#include "qwaylandreadbackcglcontext.h" + +#include + +class QWaylandReadbackCGLWindow : public QWaylandShmWindow +{ +public: + QWaylandReadbackCGLWindow(QWindow *window, QWaylandReadbackCGLIntegration *cglIntegration); + WindowType windowType() const; + + void setGeometry(const QRect &rect); + CGLPBufferObj pixelBuffer(); + uchar *buffer(); +private: + void createSurface(); + + QWaylandReadbackCGLIntegration *m_CglIntegration; + QWaylandReadbackCGLContext *mContext; + + QWaylandShmBuffer *m_buffer; + CGLPBufferObj m_pixelBuffer; +}; + +#endif // QWAYLANDREADBACKGLXWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/readback_cgl.pri b/src/plugins/platforms/wayland/gl_integration/readback_cgl/readback_cgl.pri new file mode 100644 index 0000000000..91cb90a30c --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/readback_cgl.pri @@ -0,0 +1,10 @@ +HEADERS += \ + $$PWD/qwaylandreadbackcglintegration.h \ + $$PWD/qwaylandreadbackcglwindow.h \ + $$PWD/qwaylandreadbackcglcontext.h + +SOURCES += \ + $$PWD/qwaylandreadbackcglintegration.cpp \ + $$PWD/qwaylandreadbackcglwindow.cpp \ + $$PWD/qwaylandreadbackcglcontext.cpp + -- cgit v1.2.3 From b5b405ae72566b75038596188f18162ae28b3977 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 28 Jun 2011 10:36:06 +0200 Subject: Set mac wayland config. --- src/plugins/platforms/wayland/gl_integration/gl_integration.pri | 9 ++++++++- src/plugins/platforms/wayland/wayland.pro | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index 6652ff5fbb..98517730b6 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -20,7 +20,10 @@ SOURCES += \ QT_WAYLAND_GL_INTEGRATION = xcomposite_egl CONFIG += xcomposite_egl } - } else { + } mac { + QT_WAYLAND_GL_INTEGRATION = readback_cgl + CONFIG += readback_cgl + }else { isEqual(QT_WAYLAND_GL_CONFIG, readback) { QT_WAYLAND_GL_INTEGRATION = readback_glx CONFIG += readback_glx @@ -46,6 +49,10 @@ readback_glx { include ($$PWD/readback_glx/readback_glx.pri) } +readback_cgl { + include ($$PWD/readback_cgl/readback_cgl.pri) +} + xcomposite_glx { include ($$PWD/xcomposite_glx/xcomposite_glx.pri) } diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 9010439939..9f4563a88c 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -8,6 +8,10 @@ DESTDIR = $$QT.gui.plugins/platforms DEFINES += Q_PLATFORM_WAYLAND DEFINES += $$QMAKE_DEFINES_WAYLAND +mac { + DEFINES += QT_NO_WAYLAND_XKB +} + QT += core-private gui-private opengl-private platformsupport-private SOURCES = main.cpp \ @@ -35,6 +39,10 @@ HEADERS = qwaylandintegration.h \ INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND LIBS += $$QMAKE_LIBS_WAYLAND +mac { + LIBS += -lwayland-client +} + QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND target.path += $$[QT_INSTALL_PLUGINS]/platforms -- cgit v1.2.3 From 455d58e2cdc6833e389ab27dd028cc236dd5259b Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Wed, 29 Jun 2011 12:33:05 +0200 Subject: Clean up wayland-cgl-readback. Read directly into the window buffer - looks like we don't need to do any byte swapping. Disable the frame sync, since this causes a deadlock with the compositor. --- .../readback_cgl/qwaylandreadbackcglcontext.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp index 7f21f2ebcc..d0712a3989 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp @@ -49,6 +49,7 @@ #include #include +#include #include @@ -87,26 +88,15 @@ void QWaylandReadbackCGLContext::swapBuffers(QPlatformSurface *surface) CGLFlushDrawable(m_glContext); QWaylandReadbackCGLWindow *window = static_cast(surface); - QSize size = window->geometry().size(); - QImage img(size,QImage::Format_ARGB32); - img.fill(Qt::red); - const uchar *constBits = img.bits(); - void *pixels = const_cast(constBits); - -// glReadPixels(0,0, size.width(), size.height(), GL_RGBA,GL_UNSIGNED_BYTE, pixels); -// img = img.mirrored(); -// qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV); - - constBits = img.bits(); - - const uchar *constDstBits = window->buffer(); - uchar *dstBits = const_cast(constDstBits); - memcpy(dstBits,constBits,(img.width()*4) * img.height()); + uchar *dstBits = const_cast(window->buffer()); + glReadPixels(0,0, size.width(), size.height(), GL_BGRA,GL_UNSIGNED_BYTE, dstBits); window->damage(QRect(QPoint(0,0),size)); - window->waitForFrameSync(); + + // ### Should sync here but this call deadlocks with the server. + //window->waitForFrameSync(); } void (*QWaylandReadbackCGLContext::getProcAddress(const QByteArray &procName)) () -- cgit v1.2.3 From 1b95298d9d5d7f39e28c1bdb14afbf24ee8a64f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Jul 2011 12:51:50 +0200 Subject: Fixed gl_integration.pri on non-mac platforms. --- src/plugins/platforms/wayland/gl_integration/gl_integration.pri | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index 98517730b6..20c3aa0bd9 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -20,10 +20,10 @@ SOURCES += \ QT_WAYLAND_GL_INTEGRATION = xcomposite_egl CONFIG += xcomposite_egl } - } mac { + } else:mac { QT_WAYLAND_GL_INTEGRATION = readback_cgl CONFIG += readback_cgl - }else { + } else { isEqual(QT_WAYLAND_GL_CONFIG, readback) { QT_WAYLAND_GL_INTEGRATION = readback_glx CONFIG += readback_glx -- cgit v1.2.3 From 310519d6d11da546b23c1cba307f37c24e0a5c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 15 Jul 2011 14:07:12 +0200 Subject: Rename QPixmapData to QPlatformPixmap. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes the API symmetric with the other Lighthouse APIs. Change-Id: I8a399f3c968ea35d4624711b31f2ac5bb94b7893 Reviewed-on: http://codereview.qt.nokia.com/1735 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/plugins/platforms/wayland/qwaylandintegration.cpp | 4 ++-- src/plugins/platforms/wayland/qwaylandintegration.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 9a581c265f..800f1fc99c 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -92,9 +92,9 @@ bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) co } } -QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) const +QPlatformPixmap *QWaylandIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const { - return new QRasterPixmapData(type); + return new QRasterPlatformPixmap(type); } QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index c08c040261..b9a01dab8d 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -56,7 +56,7 @@ public: QWaylandIntegration(); bool hasCapability(QPlatformIntegration::Capability cap) const; - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; -- cgit v1.2.3 From c3da77798b876716ce038a30e9aa8517ec158c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 21 Jul 2011 13:50:28 +0200 Subject: Added workable QScreen API on top of QPlatformScreen. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QPlatformIntegration::screens() no longer has to be implemented, implementations should call QPlatformIntegration::screenAdded() for each screen instead. This is for being able to support adding screens at run-time later on, by connecting it to a signal in QGuiApplication. The QGuiGLContext API has changed a bit, by not sending in all the parameters in the constructor but instead having a create() function. The createPlatformGLContext() factory in QPlatformIntegration takes a QGuiGLContext * instead of a QSurfaceFormat and a share context, similar to how the window and backing store factory functions work. The XCB plugin has experimental support for connecting to multiple X displays simultaneously, creating one or more QScreen for each. Change-Id: I248a22a4fd3481280710110272c04a30a8021e8f Reviewed-on: http://codereview.qt.nokia.com/2103 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/plugins/platforms/wayland/qwaylandintegration.cpp | 7 ------- src/plugins/platforms/wayland/qwaylandintegration.h | 1 - src/plugins/platforms/wayland/qwaylandnativeinterface.cpp | 5 +++-- src/plugins/platforms/wayland/qwaylandscreen.cpp | 1 - 4 files changed, 3 insertions(+), 11 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 800f1fc99c..5405a8524e 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -54,8 +54,6 @@ #include #include -#include - #ifdef QT_WAYLAND_GL_SUPPORT #include "gl_integration/qwaylandglintegration.h" #endif @@ -92,11 +90,6 @@ bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) co } } -QPlatformPixmap *QWaylandIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const -{ - return new QRasterPlatformPixmap(type); -} - QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const { #ifdef QT_WAYLAND_GL_SUPPORT diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index b9a01dab8d..0dc3b61009 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -56,7 +56,6 @@ public: QWaylandIntegration(); bool hasCapability(QPlatformIntegration::Capability cap) const; - QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp index f6028f69b2..3158c73605 100644 --- a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp +++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp @@ -44,6 +44,7 @@ #include "qwaylanddisplay.h" #include "qwaylandwindow.h" #include +#include void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) { @@ -64,9 +65,9 @@ QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWindow(QWindow *wind QWaylandScreen *screen; if (window) { - screen = static_cast(QPlatformScreen::platformScreenForWindow(window)); + screen = static_cast(window->screen()->handle()); } else { - screen = static_cast(QGuiApplicationPrivate::platformIntegration()->screens()[0]); + screen = static_cast(QGuiApplication::primaryScreen()->handle()); } return screen; } diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index 3a63e78207..7b064bac40 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -53,7 +53,6 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output , mFormat(QImage::Format_ARGB32_Premultiplied) , mWaylandCursor(new QWaylandCursor(this)) { - moveToThread(waylandDisplay->thread()); } QWaylandScreen::~QWaylandScreen() -- cgit v1.2.3 From ec984bdd3e8e640606d420a68bcb00967d5f55fe Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 25 Jul 2011 12:57:57 +0300 Subject: Pixmap cursor support in QWaylandCursor. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7075229584e9705fae63679b5512c11fd8535797 Reviewed-on: http://codereview.qt.nokia.com/2100 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/plugins/platforms/wayland/qwaylandcursor.cpp | 67 +++++++++++++++++++----- src/plugins/platforms/wayland/qwaylandcursor.h | 12 ++++- 2 files changed, 64 insertions(+), 15 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp index 6612d67cb4..bbbab6dca7 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.cpp +++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp @@ -47,6 +47,7 @@ #include "qwaylandshmbackingstore.h" #include +#include #define DATADIR "/usr/share" @@ -116,6 +117,7 @@ void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window) return; p = NULL; + bool isBitmap = false; switch (cursor->shape()) { case Qt::ArrowCursor: @@ -152,32 +154,53 @@ void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window) p = &pointer_images[cursor->shape()]; break; - default: case Qt::BitmapCursor: + isBitmap = true; + break; + + default: break; } - if (!p) { + if (!p && !isBitmap) { p = &pointer_images[0]; qWarning("unhandled cursor %d", cursor->shape()); } - QImageReader reader(p->filename); - - if (!reader.canRead()) - return; - - if (mBuffer == NULL || mBuffer->size() != reader.size()) { - if (mBuffer) + if (isBitmap && !cursor->pixmap().isNull()) { + setupPixmapCursor(cursor); + } else if (isBitmap && cursor->bitmap()) { + qWarning("unsupported QBitmap cursor"); + } else { + QImageReader reader(p->filename); + if (!reader.canRead()) + return; + if (mBuffer == NULL || mBuffer->size() != reader.size()) { delete mBuffer; + mBuffer = new QWaylandShmBuffer(mDisplay, reader.size(), + QImage::Format_ARGB32); + } + reader.read(mBuffer->image()); + mDisplay->setCursor(mBuffer, p->hotspot_x, p->hotspot_y); + } +} - mBuffer = new QWaylandShmBuffer(mDisplay, reader.size(), +void QWaylandCursor::setupPixmapCursor(QCursor *cursor) +{ + if (!cursor) { + delete mBuffer; + mBuffer = 0; + return; + } + if (!mBuffer || mBuffer->size() != cursor->pixmap().size()) { + delete mBuffer; + mBuffer = new QWaylandShmBuffer(mDisplay, cursor->pixmap().size(), QImage::Format_ARGB32); } - - reader.read(mBuffer->image()); - - mDisplay->setCursor(mBuffer, p->hotspot_x, p->hotspot_y); + QImage src = cursor->pixmap().toImage().convertToFormat(QImage::Format_ARGB32); + for (int y = 0; y < src.height(); ++y) + qMemCopy(mBuffer->image()->scanLine(y), src.scanLine(y), src.bytesPerLine()); + mDisplay->setCursor(mBuffer, cursor->hotSpot().x(), cursor->hotSpot().y()); } void QWaylandDisplay::setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y) @@ -189,3 +212,19 @@ void QWaylandDisplay::setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y) inputDevice->attach(buffer, x, y); } } + +void QWaylandCursor::pointerEvent(const QMouseEvent &event) +{ + mLastPos = event.globalPos(); +} + +QPoint QWaylandCursor::pos() const +{ + return mLastPos; +} + +void QWaylandCursor::setPos(const QPoint &pos) +{ + Q_UNUSED(pos); + qWarning() << "QWaylandCursor::setPos: not implemented"; +} diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h index 4409eea828..8753aa5698 100644 --- a/src/plugins/platforms/wayland/qwaylandcursor.h +++ b/src/plugins/platforms/wayland/qwaylandcursor.h @@ -48,13 +48,23 @@ class QWaylandShmBuffer; class QWaylandDisplay; class QWaylandScreen; -class QWaylandCursor : QPlatformCursor { +class QWaylandCursor : public QPlatformCursor +{ public: QWaylandCursor(QWaylandScreen *screen); void changeCursor(QCursor *cursor, QWindow *window); + void pointerEvent(const QMouseEvent &event); + QPoint pos() const; + void setPos(const QPoint &pos); + + void setupPixmapCursor(QCursor *cursor); + QWaylandShmBuffer *mBuffer; QWaylandDisplay *mDisplay; + +private: + QPoint mLastPos; }; #endif // QWAYLANDCURSOR_H -- cgit v1.2.3 From f432927ffd73be2cf732d937da2faf43c3e767aa Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 25 Jul 2011 13:01:04 +0300 Subject: Drag and drop support in Wayland plug-in. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5e4448a9b3d3df9e3a12733386079031be340a42 Reviewed-on: http://codereview.qt.nokia.com/2101 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 3 + src/plugins/platforms/wayland/qwaylanddnd.cpp | 423 +++++++++++++++++++++ src/plugins/platforms/wayland/qwaylanddnd.h | 86 +++++ .../platforms/wayland/qwaylandinputdevice.h | 1 + .../platforms/wayland/qwaylandintegration.cpp | 6 + .../platforms/wayland/qwaylandintegration.h | 2 + src/plugins/platforms/wayland/wayland.pro | 6 +- 7 files changed, 525 insertions(+), 2 deletions(-) create mode 100644 src/plugins/platforms/wayland/qwaylanddnd.cpp create mode 100644 src/plugins/platforms/wayland/qwaylanddnd.h (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 1314eda012..ca0e6572cf 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -46,6 +46,7 @@ #include "qwaylandcursor.h" #include "qwaylandinputdevice.h" #include "qwaylandclipboard.h" +#include "qwaylanddnd.h" #ifdef QT_WAYLAND_GL_SUPPORT #include "gl_integration/qwaylandglintegration.h" @@ -315,6 +316,8 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id, mInputDevices.append(inputDevice); } else if (interface == "wl_selection_offer") { QWaylandClipboard::instance(display)->createSelectionOffer(id); + } else if (interface == "wl_drag_offer") { + QWaylandDrag::instance(display)->createDragOffer(id); } } diff --git a/src/plugins/platforms/wayland/qwaylanddnd.cpp b/src/plugins/platforms/wayland/qwaylanddnd.cpp new file mode 100644 index 0000000000..5368daaf63 --- /dev/null +++ b/src/plugins/platforms/wayland/qwaylanddnd.cpp @@ -0,0 +1,423 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylanddnd.h" +#include "qwaylandinputdevice.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "qwaylandcursor.h" + +class QWaylandDragWrapper +{ +public: + QWaylandDragWrapper(QWaylandDisplay *display, QMimeData *data); + ~QWaylandDragWrapper(); + QMimeData *mimeData() const { return mData; } + +private: + static void target(void *data, wl_drag *drag, const char *mimeType); + static void finish(void *data, wl_drag *drag, int fd); + static void reject(void *data, wl_drag *drag); + static const wl_drag_listener dragListener; + + QWaylandDisplay *mDisplay; + wl_drag *mDrag; + QMimeData *mData; + QString mAcceptedType; +}; + +class QWaylandDragOfferWrapper +{ +public: + QWaylandDragOfferWrapper(QWaylandDisplay *display, QMimeData *data, uint32_t id); + ~QWaylandDragOfferWrapper(); + +private: + static void offer(void *data, struct wl_drag_offer *offer, const char *mimeType); + static void pointerFocus(void *data, struct wl_drag_offer *offer, uint32_t time, + wl_surface *surface, + int32_t x, int32_t y, + int32_t surfaceX, int32_t surfaceY); + static void motion(void *data, struct wl_drag_offer *offer, uint32_t time, + int32_t x, int32_t y, + int32_t surfaceX, int32_t surfaceY); + static void drop(void *data, struct wl_drag_offer *offer); + static const wl_drag_offer_listener dragOfferListener; + + void sendEventToWindow(struct wl_drag_offer *offer, uint32_t time, + wl_surface *surface, const QPoint &pos); + + QWaylandDisplay *mDisplay; + QMimeData *mData; + struct wl_drag_offer *mOffer; + QMimeData mOfferedTypes; // no data in this one, just the formats + wl_surface *mFocusSurface; + bool mAccepted; + QPoint mLastEventPos; + friend class QWaylandDrag; +}; + +static QWaylandDrag *dnd = 0; + +QWaylandDrag *QWaylandDrag::instance(QWaylandDisplay *display) +{ + if (!dnd) + dnd = new QWaylandDrag(display); + return dnd; +} + +QWaylandDrag::QWaylandDrag(QWaylandDisplay *display) + : mDisplay(display), mDropData(0), mCurrentDrag(0), mCurrentOffer(0) +{ + mDropData = new QMimeData; +} + +QWaylandDrag::~QWaylandDrag() +{ + delete mCurrentDrag; + delete mCurrentOffer; + delete mDropData; +} + +QMimeData *QWaylandDrag::platformDropData() +{ + return mDropData; +} + +static void showDragPixmap(bool show) +{ + QCursor c(QDragManager::self()->object->pixmap()); + QList > cursors = QPlatformCursorPrivate::getInstances(); + foreach (QWeakPointer cursor, cursors) + if (cursor) + static_cast(cursor.data())->setupPixmapCursor(show ? &c : 0); +} + + +QWaylandDragWrapper::QWaylandDragWrapper(QWaylandDisplay *display, QMimeData *data) + : mDisplay(display), mDrag(0), mData(data) +{ + QWaylandWindow *w = mDisplay->inputDevices().at(0)->pointerFocus(); + if (!w) { + qWarning("QWaylandDragWrapper: No window with pointer focus?!"); + return; + } + qDebug() << "QWaylandDragWrapper" << data->formats(); + struct wl_shell *shell = display->wl_shell(); + mDrag = wl_shell_create_drag(shell); + wl_drag_add_listener(mDrag, &dragListener, this); + foreach (const QString &format, data->formats()) + wl_drag_offer(mDrag, format.toLatin1().constData()); + struct timeval tv; + gettimeofday(&tv, 0); + wl_drag_activate(mDrag, + w->wl_surface(), + display->inputDevices().at(0)->wl_input_device(), + tv.tv_sec * 1000 + tv.tv_usec / 1000); + showDragPixmap(true); +} + +QWaylandDragWrapper::~QWaylandDragWrapper() +{ + QWaylandDrag *dragHandler = QWaylandDrag::instance(mDisplay); + if (dragHandler->mCurrentDrag == this) + dragHandler->mCurrentDrag = 0; + wl_drag_destroy(mDrag); +} + +const wl_drag_listener QWaylandDragWrapper::dragListener = { + QWaylandDragWrapper::target, + QWaylandDragWrapper::finish, + QWaylandDragWrapper::reject +}; + +void QWaylandDragWrapper::target(void *data, wl_drag *drag, const char *mimeType) +{ + Q_UNUSED(drag); + QWaylandDragWrapper *self = static_cast(data); + self->mAcceptedType = mimeType ? QString::fromLatin1(mimeType) : QString(); + qDebug() << "target" << self->mAcceptedType; + QDragManager *manager = QDragManager::self(); + if (mimeType) + manager->global_accepted_action = manager->defaultAction(manager->possible_actions, + QGuiApplication::keyboardModifiers()); + else + manager->global_accepted_action = Qt::IgnoreAction; +} + +void QWaylandDragWrapper::finish(void *data, wl_drag *drag, int fd) +{ + Q_UNUSED(drag); + QWaylandDragWrapper *self = static_cast(data); + qDebug() << "finish" << self->mAcceptedType; + if (self->mAcceptedType.isEmpty()) + return; // no drag target was valid when the drag finished + QByteArray content = self->mData->data(self->mAcceptedType); + if (!content.isEmpty()) { + QFile f; + if (f.open(fd, QIODevice::WriteOnly)) + f.write(content); + } + close(fd); + // Drag finished on source side with drop. + + QDragManager::self()->stopDrag(); + showDragPixmap(false); + delete self; + qDebug() << " *** DRAG OVER WITH DROP"; +} + +void QWaylandDragWrapper::reject(void *data, wl_drag *drag) +{ + Q_UNUSED(drag); + QWaylandDragWrapper *self = static_cast(data); + self->mAcceptedType = QString(); + qDebug() << "reject"; + QDragManager::self()->global_accepted_action = Qt::IgnoreAction; +} + + +QWaylandDragOfferWrapper::QWaylandDragOfferWrapper(QWaylandDisplay *display, + QMimeData *data, + uint32_t id) + : mDisplay(display), mData(data), mOffer(0), mFocusSurface(0), + mAccepted(false) +{ + mOffer = wl_drag_offer_create(mDisplay->wl_display(), id, 1); + wl_drag_offer_add_listener(mOffer, &dragOfferListener, this); +} + +QWaylandDragOfferWrapper::~QWaylandDragOfferWrapper() +{ + QWaylandDrag *dragHandler = QWaylandDrag::instance(mDisplay); + if (dragHandler->mCurrentOffer == this) + dragHandler->mCurrentOffer = 0; + wl_drag_offer_destroy(mOffer); +} + +const wl_drag_offer_listener QWaylandDragOfferWrapper::dragOfferListener = { + QWaylandDragOfferWrapper::offer, + QWaylandDragOfferWrapper::pointerFocus, + QWaylandDragOfferWrapper::motion, + QWaylandDragOfferWrapper::drop +}; + +void QWaylandDragOfferWrapper::offer(void *data, struct wl_drag_offer *offer, const char *mimeType) +{ + // Called for each type before pointerFocus. + Q_UNUSED(offer); + QWaylandDragOfferWrapper *self = static_cast(data); + self->mOfferedTypes.setData(QString::fromLatin1(mimeType), QByteArray()); +} + +void QWaylandDragOfferWrapper::pointerFocus(void *data, struct wl_drag_offer *offer, uint32_t time, + wl_surface *surface, + int32_t x, int32_t y, + int32_t surfaceX, int32_t surfaceY) +{ + qDebug() << "pointerFocus" << surface << x << y << surfaceX << surfaceY; + QWaylandDragOfferWrapper *self = static_cast(data); + QWaylandDrag *mgr = QWaylandDrag::instance(self->mDisplay); + + if (!surface) { + if (self->mFocusSurface) { + // This is a DragLeave. + QWindow *window = static_cast( + wl_surface_get_user_data(self->mFocusSurface))->window(); + QWindowSystemInterface::handleDrag(window, 0, QPoint()); + if (self->mAccepted) { + wl_drag_offer_reject(offer); + self->mAccepted = false; + } + if (!mgr->mCurrentDrag) // no drag -> this is not the source side -> offer can be destroyed + delete mgr->mCurrentOffer; + } else { + // Drag finished on source side without drop. + QDragManager::self()->stopDrag(); + showDragPixmap(false); + delete mgr->mCurrentDrag; + qDebug() << " *** DRAG OVER WITHOUT DROP"; + } + } + + self->mFocusSurface = surface; + + // This is a DragMove or DragEnter+DragMove. + if (surface) + self->sendEventToWindow(offer, time, surface, QPoint(surfaceX, surfaceY)); +} + +void QWaylandDragOfferWrapper::motion(void *data, struct wl_drag_offer *offer, uint32_t time, + int32_t x, int32_t y, + int32_t surfaceX, int32_t surfaceY) +{ + Q_UNUSED(x); + Q_UNUSED(y); + QWaylandDragOfferWrapper *self = static_cast(data); + if (!self->mFocusSurface) + return; +// qDebug() << "motion" << self->mFocusSurface << x << y << surfaceX << surfaceY; + self->sendEventToWindow(offer, time, self->mFocusSurface, QPoint(surfaceX, surfaceY)); +} + +void QWaylandDragOfferWrapper::sendEventToWindow(struct wl_drag_offer *offer, uint32_t time, + wl_surface *surface, const QPoint &pos) +{ + QWindow *window = static_cast(wl_surface_get_user_data(surface))->window(); + Qt::DropAction action = QWindowSystemInterface::handleDrag(window, &mOfferedTypes, pos); + bool accepted = (action != Qt::IgnoreAction && !mOfferedTypes.formats().isEmpty()); + if (accepted != mAccepted) { + mAccepted = accepted; + if (mAccepted) { + // What can we do, just accept the first type... + QByteArray ba = mOfferedTypes.formats().first().toLatin1(); + qDebug() << "wl_drag_offer_accept" << ba; + wl_drag_offer_accept(offer, time, ba.constData()); + } else { + qDebug() << "wl_drag_offer_reject"; + wl_drag_offer_reject(offer); + } + } + mLastEventPos = pos; +} + +void QWaylandDragOfferWrapper::drop(void *data, struct wl_drag_offer *offer) +{ + QWaylandDragOfferWrapper *self = static_cast(data); + if (!self->mAccepted) { + wl_drag_offer_reject(offer); + return; + } + + QWaylandDrag *mgr = QWaylandDrag::instance(self->mDisplay); + QMimeData *mimeData = QWaylandDrag::instance(self->mDisplay)->platformDropData(); + mimeData->clear(); + if (mgr->mCurrentDrag) { // means this offer is the client's own + QMimeData *localData = mgr->mCurrentDrag->mimeData(); + foreach (const QString &format, localData->formats()) + mimeData->setData(format, localData->data(format)); + QWindow *window = static_cast( + wl_surface_get_user_data(self->mFocusSurface))->window(); + QWindowSystemInterface::handleDrop(window, mimeData, self->mLastEventPos); + // Drag finished with drop (source == target). + QDragManager::self()->stopDrag(); + showDragPixmap(false); + delete mgr->mCurrentOffer; + qDebug() << " *** DRAG OVER WITH DROP, SOURCE == TARGET"; + } else { + // ### TODO + // This is a bit broken: The QMimeData will only contain the data for + // the first type. The Wayland protocol and QDropEvents/QMimeData do not + // match perfectly at the moment. + QString format = self->mOfferedTypes.formats().first(); + QByteArray mimeTypeBa = format.toLatin1(); + int pipefd[2]; + if (pipe(pipefd) == -1) { + qWarning("QWaylandDragOfferWrapper: pipe() failed"); + return; + } + fcntl(pipefd[0], F_SETFL, fcntl(pipefd[0], F_GETFL, 0) | O_NONBLOCK); + wl_drag_offer_receive(offer, pipefd[1]); + mgr->mPipeData.clear(); + mgr->mMimeFormat = format; + mgr->mPipeWriteEnd = pipefd[1]; + mgr->mPipeWatcher = new QSocketNotifier(pipefd[0], QSocketNotifier::Read); + QObject::connect(mgr->mPipeWatcher, SIGNAL(activated(int)), mgr, SLOT(pipeReadable(int))); + } +} + + +void QWaylandDrag::pipeReadable(int fd) +{ + if (mPipeWriteEnd) { + close(mPipeWriteEnd); + mPipeWriteEnd = 0; + } + char buf[256]; + int n; + while ((n = read(fd, &buf, sizeof buf)) > 0 || errno == EINTR) + if (n > 0) + mPipeData.append(buf, n); + if (n == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) + return; + delete mPipeWatcher; + close(fd); + + QMimeData *mimeData = platformDropData(); + mimeData->setData(mMimeFormat, mPipeData); + foreach (const QString &format, mimeData->formats()) + qDebug() << " got type" << format << "with data" << mimeData->data(format); + + QWindow *window = static_cast( + wl_surface_get_user_data(mCurrentOffer->mFocusSurface))->window(); + QWindowSystemInterface::handleDrop(window, mimeData, mCurrentOffer->mLastEventPos); + + // Drag finished on target side with drop. + delete mCurrentOffer; + qDebug() << " *** DRAG OVER ON TARGET WITH DROP"; +} + +void QWaylandDrag::createDragOffer(uint32_t id) +{ + delete mCurrentOffer; + mCurrentOffer = new QWaylandDragOfferWrapper(mDisplay, mDropData, id); +} + +void QWaylandDrag::startDrag() +{ + QDragManager *manager = QDragManager::self(); + + // No need for the traditional desktop-oriented event handling in QDragManager. + manager->unmanageEvents(); + + delete mCurrentDrag; + mCurrentDrag = new QWaylandDragWrapper(mDisplay, manager->dropData()); +} diff --git a/src/plugins/platforms/wayland/qwaylanddnd.h b/src/plugins/platforms/wayland/qwaylanddnd.h new file mode 100644 index 0000000000..ebafd960ec --- /dev/null +++ b/src/plugins/platforms/wayland/qwaylanddnd.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDDND_H +#define QWAYLANDDND_H + +#include +#include +#include "qwaylanddisplay.h" + +class QWaylandDragWrapper; +class QWaylandDragOfferWrapper; +class QSocketNotifier; + +class QWaylandDrag : public QObject, public QPlatformDrag +{ + Q_OBJECT + +public: + static QWaylandDrag *instance(QWaylandDisplay *display); + ~QWaylandDrag(); + void createDragOffer(uint32_t id); + + QMimeData *platformDropData(); + void startDrag(); + void move(const QMouseEvent *) { } + void drop(const QMouseEvent *) { } + void cancel() { } + +private slots: + void pipeReadable(int fd); + +private: + QWaylandDrag(QWaylandDisplay *display); + + QWaylandDisplay *mDisplay; + QMimeData *mDropData; + QWaylandDragWrapper *mCurrentDrag; + QWaylandDragOfferWrapper *mCurrentOffer; + int mPipeWriteEnd; + QSocketNotifier *mPipeWatcher; + QByteArray mPipeData; + QString mMimeFormat; + friend class QWaylandDragWrapper; + friend class QWaylandDragOfferWrapper; +}; + +#endif // QWAYLANDDND_H diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h index 008ecf144d..05ebe05969 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h @@ -63,6 +63,7 @@ public: void attach(QWaylandBuffer *buffer, int x, int y); void handleWindowDestroyed(QWaylandWindow *window); struct wl_input_device *wl_input_device() const { return mInputDevice; } + QWaylandWindow *pointerFocus() const { return mPointerFocus; } private: QWaylandDisplay *mQDisplay; diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 5405a8524e..d3d7edf0f6 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -46,6 +46,7 @@ #include "qwaylandshmwindow.h" #include "qwaylandnativeinterface.h" #include "qwaylandclipboard.h" +#include "qwaylanddnd.h" #include "QtPlatformSupport/private/qgenericunixfontdatabase_p.h" #include @@ -131,3 +132,8 @@ QPlatformClipboard *QWaylandIntegration::clipboard() const { return QWaylandClipboard::instance(mDisplay); } + +QPlatformDrag *QWaylandIntegration::drag() const +{ + return QWaylandDrag::instance(mDisplay); +} diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 0dc3b61009..3c8b996f14 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -69,6 +69,8 @@ public: QPlatformClipboard *clipboard() const; + QPlatformDrag *drag() const; + private: QPlatformFontDatabase *mFontDb; QWaylandDisplay *mDisplay; diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 9f4563a88c..a46f508417 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -24,7 +24,8 @@ SOURCES = main.cpp \ qwaylandwindow.cpp \ qwaylandscreen.cpp \ qwaylandshmwindow.cpp \ - qwaylandclipboard.cpp + qwaylandclipboard.cpp \ + qwaylanddnd.cpp HEADERS = qwaylandintegration.h \ qwaylandnativeinterface.h \ @@ -35,7 +36,8 @@ HEADERS = qwaylandintegration.h \ qwaylandshmbackingstore.h \ qwaylandbuffer.h \ qwaylandshmwindow.h \ - qwaylandclipboard.h + qwaylandclipboard.h \ + qwaylanddnd.h INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND LIBS += $$QMAKE_LIBS_WAYLAND -- cgit v1.2.3 From dfd72c6e6c5aab58bd56c8f7854e94df2230bd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 27 Jul 2011 16:54:53 +0200 Subject: Make QPlatformIntegration not have a factory for eventdispatcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit but rather an accessor for the guiThreadEventDispatcher Change-Id: I1b9ba14efc9f338c5a67e3e24ddb0caf76c07413 Reviewed-on: http://codereview.qt.nokia.com/2321 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 17 +++++++---------- src/plugins/platforms/wayland/qwaylanddisplay.h | 2 -- src/plugins/platforms/wayland/qwaylandintegration.cpp | 12 +++++++----- src/plugins/platforms/wayland/qwaylandintegration.h | 4 +++- 4 files changed, 17 insertions(+), 18 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index ca0e6572cf..588096933c 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -142,6 +142,13 @@ QWaylandDisplay::QWaylandDisplay(void) wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this); + mFd = wl_display_get_fd(mDisplay, sourceUpdate, this); + QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher; + connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); + + mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this); + connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(readEvents())); + #ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration = QWaylandGLIntegration::createGLIntegration(this); #endif @@ -156,16 +163,6 @@ QWaylandDisplay::QWaylandDisplay(void) mEglIntegration->initialize(); #endif - mFd = wl_display_get_fd(mDisplay, sourceUpdate, this); -} - -void QWaylandDisplay::eventDispatcherCreated(QAbstractEventDispatcher *dispatcher) -{ - connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); - - mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this); - connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(readEvents())); - waitForScreens(); } diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 14812885a3..2b7f33f4f6 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -92,8 +92,6 @@ public: QList inputDevices() const { return mInputDevices; } - void eventDispatcherCreated(QAbstractEventDispatcher *dispatcher); - public slots: void createNewScreen(struct wl_output *output, QRect geometry); void readEvents(); diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index d3d7edf0f6..eb4503c829 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -51,6 +51,8 @@ #include "QtPlatformSupport/private/qgenericunixfontdatabase_p.h" #include +#include + #include #include #include @@ -61,9 +63,11 @@ QWaylandIntegration::QWaylandIntegration() : mFontDb(new QGenericUnixFontDatabase()) - , mDisplay(new QWaylandDisplay()) + , mEventDispatcher(createUnixEventDispatcher()) , mNativeInterface(new QWaylandNativeInterface) { + QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher); + mDisplay = new QWaylandDisplay(); } QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const @@ -116,11 +120,9 @@ QPlatformBackingStore *QWaylandIntegration::createPlatformBackingStore(QWindow * return new QWaylandShmBackingStore(window); } -QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const +QAbstractEventDispatcher *QWaylandIntegration::guiThreadEventDispatcher() const { - QAbstractEventDispatcher *dispatcher = createUnixEventDispatcher(); - mDisplay->eventDispatcherCreated(dispatcher); - return dispatcher; + return mEventDispatcher; } QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 3c8b996f14..209d5da0da 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -59,7 +59,8 @@ public: QPlatformWindow *createPlatformWindow(QWindow *window) const; QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; - QAbstractEventDispatcher *createEventDispatcher() const; + + QAbstractEventDispatcher *guiThreadEventDispatcher() const; QList screens() const; @@ -73,6 +74,7 @@ public: private: QPlatformFontDatabase *mFontDb; + QAbstractEventDispatcher *mEventDispatcher; QWaylandDisplay *mDisplay; QPlatformNativeInterface *mNativeInterface; }; -- cgit v1.2.3 From 6b728caee4c53643e7ee2f60ffa8329719ad9e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 5 Aug 2011 09:21:34 +0200 Subject: Get rid of missing qmake warning. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I470e89cb5b2042cda1811ef327e0703c7510fd08 Reviewed-on: http://codereview.qt.nokia.com/2683 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- .../platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri index 6f4edb08a6..8b4b163b03 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri @@ -1,5 +1,3 @@ -load(qpa/egl/convenience) - LIBS += -lwayland-egl -lEGL INCLUDEPATH += $$PWD SOURCES += $$PWD/qwaylandeglintegration.cpp \ -- cgit v1.2.3 From ca1ad7e9a56959ee8946eef1ade30d00755eac67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 5 Aug 2011 12:11:40 +0200 Subject: Get wayland plugin working after latest QPA API changes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If54e7068aaed84fe765b887250bca79c787bd8a3 Reviewed-on: http://codereview.qt.nokia.com/2684 Reviewed-by: Qt Sanity Bot Reviewed-by: Jørgen Lind --- src/plugins/platforms/wayland/qwaylandintegration.cpp | 14 ++++++-------- src/plugins/platforms/wayland/qwaylandintegration.h | 4 +--- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index eb4503c829..eefd86dbf1 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #ifdef QT_WAYLAND_GL_SUPPORT #include "gl_integration/qwaylandglintegration.h" @@ -68,6 +69,9 @@ QWaylandIntegration::QWaylandIntegration() { QGuiApplicationPrivate::instance()->setEventDispatcher(mEventDispatcher); mDisplay = new QWaylandDisplay(); + + foreach (QPlatformScreen *screen, mDisplay->screens()) + screenAdded(screen); } QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const @@ -75,12 +79,6 @@ QPlatformNativeInterface * QWaylandIntegration::nativeInterface() const return mNativeInterface; } -QList -QWaylandIntegration::screens() const -{ - return mDisplay->screens(); -} - bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { @@ -104,10 +102,10 @@ QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) cons return new QWaylandShmWindow(window); } -QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const +QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(QGuiGLContext *context) const { #ifdef QT_WAYLAND_GL_SUPPORT - return mDisplay->eglIntegration()->createPlatformGLContext(glFormat, share); + return mDisplay->eglIntegration()->createPlatformGLContext(context->format(), context->shareHandle()); #else Q_UNUSED(glFormat); Q_UNUSED(share); diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 209d5da0da..69b8863ebc 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -57,13 +57,11 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; - QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; + QPlatformGLContext *createPlatformGLContext(QGuiGLContext *context) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; QAbstractEventDispatcher *guiThreadEventDispatcher() const; - QList screens() const; - QPlatformFontDatabase *fontDatabase() const; QPlatformNativeInterface *nativeInterface() const; -- cgit v1.2.3 From f5777742126d5fb025522d1528d7e12d7239a03f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 24 Aug 2011 10:38:31 +0200 Subject: If the EGL_PLATFORM is not set, then set it Change-Id: I6c1b0ba757c64fc42faacd69d4e5d1df28faf7d1 Reviewed-on: http://codereview.qt.nokia.com/3472 Reviewed-by: Qt Sanity Bot Reviewed-by: Paul Olav Tvete --- .../wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp index ab154017ec..6e72a45bcd 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -62,6 +62,11 @@ QWaylandEglIntegration::~QWaylandEglIntegration() void QWaylandEglIntegration::initialize() { + QByteArray eglPlatform = qgetenv("EGL_PLATFORM"); + if (eglPlatform.isEmpty()) { + setenv("EGL_PLATFORM","wayland",true); + } + EGLint major,minor; m_eglDisplay = eglGetDisplay(m_waylandDisplay); if (m_eglDisplay == NULL) { -- cgit v1.2.3 From 5a23825f017ddebea698f6f81a36bd7ff7edadc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 25 Aug 2011 20:19:44 +0200 Subject: Introduce new platform capability ThreadedOpenGL. Lets the platform plugin advertise whether it's safe to use OpenGL from a different thread. With XCB we only advertise this if we have a reasonably new XCB libary, as older versions suffer from the xcb_wait_for_reply() blocking bug, which cause GL rendering in a separate to stall when using Mesa drivers. Change-Id: I4829df7e583a1c8aed218ae13a159d21266cc594 Reviewed-on: http://codereview.qt.nokia.com/3613 Reviewed-by: Qt Sanity Bot Reviewed-by: Lars Knoll --- src/plugins/platforms/wayland/qwaylandintegration.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index eefd86dbf1..3ed5f163ff 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -89,6 +89,8 @@ bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) co #else return false; #endif + case ThreadedOpenGL: + return hasCapability(OpenGL); default: return QPlatformIntegration::hasCapability(cap); } } -- cgit v1.2.3 From 6e28e8441b698c3397c2c78125c877f2e9867cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 22 Aug 2011 10:49:28 +0200 Subject: Copy core GL functionality to QtGui with QGL -> QOpenGL naming. Change-Id: Ibc989afa4a30dd184d41d1a1cd89f97196e48855 Reviewed-on: http://codereview.qt.nokia.com/3710 Reviewed-by: Gunnar Sletta --- .../platforms/wayland/gl_integration/qwaylandglintegration.h | 4 ++-- .../gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp | 8 ++++---- .../gl_integration/readback_cgl/qwaylandreadbackcglcontext.h | 6 +++--- .../readback_cgl/qwaylandreadbackcglintegration.cpp | 2 +- .../gl_integration/readback_cgl/qwaylandreadbackcglintegration.h | 2 +- .../gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp | 2 +- .../gl_integration/readback_egl/qwaylandreadbackeglcontext.h | 4 ++-- .../readback_egl/qwaylandreadbackeglintegration.cpp | 2 +- .../gl_integration/readback_egl/qwaylandreadbackeglintegration.h | 2 +- .../gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp | 2 +- .../gl_integration/readback_egl/qwaylandreadbackeglwindow.h | 2 +- .../gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp | 8 ++++---- .../gl_integration/readback_glx/qwaylandreadbackglxcontext.h | 6 +++--- .../readback_glx/qwaylandreadbackglxintegration.cpp | 2 +- .../gl_integration/readback_glx/qwaylandreadbackglxintegration.h | 2 +- .../wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp | 2 +- .../wayland/gl_integration/wayland_egl/qwaylandeglintegration.h | 2 +- .../wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp | 6 +++--- .../wayland/gl_integration/wayland_egl/qwaylandglcontext.h | 6 +++--- .../xcomposite_egl/qwaylandxcompositeeglcontext.cpp | 2 +- .../gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h | 4 ++-- .../xcomposite_egl/qwaylandxcompositeeglintegration.cpp | 2 +- .../xcomposite_egl/qwaylandxcompositeeglintegration.h | 4 ++-- .../xcomposite_glx/qwaylandxcompositeglxcontext.cpp | 2 +- .../gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h | 6 +++--- .../xcomposite_glx/qwaylandxcompositeglxintegration.cpp | 2 +- .../xcomposite_glx/qwaylandxcompositeglxintegration.h | 2 +- src/plugins/platforms/wayland/qwaylandintegration.cpp | 6 +++--- src/plugins/platforms/wayland/qwaylandintegration.h | 2 +- 29 files changed, 51 insertions(+), 51 deletions(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h index 2b4f9fe028..4f688e41d8 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h @@ -46,7 +46,7 @@ class QWaylandWindow; class QWaylandDisplay; class QWindow; -class QPlatformGLContext; +class QPlatformOpenGLContext; class QSurfaceFormat; class QWaylandGLIntegration @@ -58,7 +58,7 @@ public: virtual void initialize() = 0; virtual QWaylandWindow *createEglWindow(QWindow *window) = 0; - virtual QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const = 0; + virtual QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const = 0; static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay); }; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp index d0712a3989..5f7663ef55 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.cpp @@ -44,7 +44,7 @@ #include "qwaylandshmbackingstore.h" #include "qwaylandreadbackcglwindow.h" -#include +#include #include #include @@ -53,8 +53,8 @@ #include -QWaylandReadbackCGLContext::QWaylandReadbackCGLContext(QPlatformGLContext *share) - : QPlatformGLContext() +QWaylandReadbackCGLContext::QWaylandReadbackCGLContext(QPlatformOpenGLContext *share) + : QPlatformOpenGLContext() { Q_UNUSED(share); m_glContext = qcgl_createGlContext(); @@ -82,7 +82,7 @@ void QWaylandReadbackCGLContext::swapBuffers(QPlatformSurface *surface) { Q_UNUSED(surface); - if (QGuiGLContext::currentContext()->handle() != this) { + if (QOpenGLContext::currentContext()->handle() != this) { makeCurrent(surface); } CGLFlushDrawable(m_glContext); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h index 7f727ae8f9..eb065c3f69 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglcontext.h @@ -42,7 +42,7 @@ #ifndef QWAYLANDREADBACKCGLCONTEXT_H #define QWAYLANDREADBACKCGLCONTEXT_H -#include +#include #include "qwaylandreadbackcglintegration.h" @@ -51,10 +51,10 @@ class QWaylandReadbackCGLWindow; class QWaylandShmBuffer; -class QWaylandReadbackCGLContext : public QPlatformGLContext +class QWaylandReadbackCGLContext : public QPlatformOpenGLContext { public: - QWaylandReadbackCGLContext(QPlatformGLContext *share); + QWaylandReadbackCGLContext(QPlatformOpenGLContext *share); QSurfaceFormat format() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp index c9cc7b4fa1..2878f9e292 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.cpp @@ -71,7 +71,7 @@ QWaylandWindow * QWaylandReadbackCGLIntegration::createEglWindow(QWindow *window return new QWaylandReadbackCGLWindow(window,this); } -QPlatformGLContext *QWaylandReadbackCGLIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const +QPlatformOpenGLContext *QWaylandReadbackCGLIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const { return new QWaylandReadbackCGLContext(share); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h index 63b95f5efa..34c8d00a7c 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_cgl/qwaylandreadbackcglintegration.h @@ -61,7 +61,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; + QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; QWaylandDisplay *waylandDisplay() const; private: diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp index cd6ab188f7..c03e8a9444 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp @@ -106,7 +106,7 @@ void QWaylandReadbackEglContext::makeCurrent() void QWaylandReadbackEglContext::doneCurrent() { - QPlatformGLContext::doneCurrent(); + QPlatformOpenGLContext::doneCurrent(); eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h index f57ac46667..75755fbd1a 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h @@ -42,14 +42,14 @@ #ifndef QWAYLANDREADBACKEGLGLCONTEXT_H #define QWAYLANDREADBACKEGLGLCONTEXT_H -#include +#include #include "qwaylandreadbackeglintegration.h" #include "qwaylandreadbackeglwindow.h" class QWaylandShmBuffer; -class QWaylandReadbackEglContext : public QPlatformGLContext +class QWaylandReadbackEglContext : public QPlatformOpenGLContext { public: QWaylandReadbackEglContext(QWaylandReadbackEglIntegration *eglIntegration, QWaylandReadbackEglWindow *window); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp index 773087f513..39fa3d589c 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp @@ -86,7 +86,7 @@ QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWindow *window return new QWaylandReadbackEglWindow(window, this); } -QPlatformGLContext *QWaylandReadbackEglWindow::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const +QPlatformOpenGLContext *QWaylandReadbackEglWindow::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const { return new QWaylandReadbackEglContext(glFormat, share, this); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h index d96e6cface..0d6aa55e4e 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h @@ -63,7 +63,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; + QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; QWaylandDisplay *waylandDisplay() const; Display *xDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp index 39ccafec5c..f4bc6379d6 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp @@ -57,7 +57,7 @@ QWaylandWindow::WindowType QWaylandReadbackEglWindow::windowType() const return QWaylandWindow::Egl; } -QPlatformGLContext *QWaylandReadbackEglWindow::glContext() const +QPlatformOpenGLContext *QWaylandReadbackEglWindow::glContext() const { if (!mContext) { QWaylandReadbackEglWindow *that = const_cast(this); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h index 63ab7a55ae..0852a8ee66 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h @@ -54,7 +54,7 @@ public: WindowType windowType() const; - QPlatformGLContext *glContext() const; + QPlatformOpenGLContext *glContext() const; void setGeometry(const QRect &rect); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp index dec2cdd428..850e7bb0ac 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp @@ -44,7 +44,7 @@ #include "qwaylandshmbackingstore.h" #include "qwaylandreadbackglxwindow.h" -#include +#include #include static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) @@ -70,7 +70,7 @@ static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) } QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(const QSurfaceFormat &format, - QPlatformGLContext *share, Display *display, int screen) + QPlatformOpenGLContext *share, Display *display, int screen) : m_display(display) { GLXFBConfig config = qglx_findConfig(display, screen, format, GLX_PIXMAP_BIT); @@ -101,8 +101,8 @@ void QWaylandReadbackGlxContext::doneCurrent() void QWaylandReadbackGlxContext::swapBuffers(QPlatformSurface *surface) { - // #### makeCurrent() directly on the platform context doesn't update QGuiGLContext::currentContext() - if (QGuiGLContext::currentContext()->handle() != this) + // #### makeCurrent() directly on the platform context doesn't update QOpenGLContext::currentContext() + if (QOpenGLContext::currentContext()->handle() != this) makeCurrent(surface); QWaylandReadbackGlxWindow *w = static_cast(surface); diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h index d3a028f51a..7b5eeece93 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h @@ -42,7 +42,7 @@ #ifndef QWAYLANDREADBACKGLXCONTEXT_H #define QWAYLANDREADBACKGLXCONTEXT_H -#include +#include #include #include "qwaylandreadbackglxintegration.h" @@ -52,10 +52,10 @@ class QWaylandReadbackGlxWindow; class QWaylandShmBuffer; -class QWaylandReadbackGlxContext : public QPlatformGLContext +class QWaylandReadbackGlxContext : public QPlatformOpenGLContext { public: - QWaylandReadbackGlxContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen); + QWaylandReadbackGlxContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, Display *display, int screen); QSurfaceFormat format() const; diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp index 22ff5dc0c6..752bb06a43 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp @@ -71,7 +71,7 @@ QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWindow *window return new QWaylandReadbackGlxWindow(window,this); } -QPlatformGLContext *QWaylandReadbackGlxIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const +QPlatformOpenGLContext *QWaylandReadbackGlxIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const { return new QWaylandReadbackGlxContext(glFormat, share, mDisplay, mScreen); } diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h index 05c224263b..ee50d74ebd 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h @@ -61,7 +61,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; + QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; QWaylandDisplay *waylandDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp index 6e72a45bcd..27f17a6153 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -84,7 +84,7 @@ QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWindow *window) return new QWaylandEglWindow(window); } -QPlatformGLContext *QWaylandEglIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const +QPlatformOpenGLContext *QWaylandEglIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const { return new QWaylandGLContext(m_eglDisplay, glFormat, share); } diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h index 5e39e39fe8..7a26c57658 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h @@ -58,7 +58,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; + QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; EGLDisplay eglDisplay() const; diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp index d3ece7c7a9..aa61405eb6 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -47,12 +47,12 @@ #include -#include +#include #include #include -QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformGLContext *share) - : QPlatformGLContext() +QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share) + : QPlatformOpenGLContext() , m_eglDisplay(eglDisplay) , m_config(q_configFromGLFormat(m_eglDisplay, format, true)) , m_format(q_glFormatFromConfig(m_eglDisplay, m_config)) diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h index 592f3d18f5..16d9fa4ada 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h @@ -44,16 +44,16 @@ #include "qwaylanddisplay.h" -#include +#include #include "qwaylandeglinclude.h" class QWaylandWindow; class QWaylandGLWindowSurface; -class QWaylandGLContext : public QPlatformGLContext { +class QWaylandGLContext : public QPlatformOpenGLContext { public: - QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformGLContext *share); + QWaylandGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share); ~QWaylandGLContext(); void swapBuffers(QPlatformSurface *surface); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp index 6c1018d79a..f2f9d1ceb6 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -48,7 +48,7 @@ #include -QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display) +QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display) : QEGLPlatformContext(format, share, display) { } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h index f0e96a19af..8420f2be13 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h @@ -42,7 +42,7 @@ #ifndef QWAYLANDXCOMPOSITEEGLCONTEXT_H #define QWAYLANDXCOMPOSITEEGLCONTEXT_H -#include +#include #include "qwaylandxcompositeeglintegration.h" @@ -53,7 +53,7 @@ class QWaylandXCompositeEGLWindow; class QWaylandXCompositeEGLContext : public QEGLPlatformContext { public: - QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformGLContext *share, EGLDisplay display); + QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display); void swapBuffers(QPlatformSurface *surface); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp index 47454dccab..d7e37f8e70 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp @@ -75,7 +75,7 @@ QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWindow *wind return new QWaylandXCompositeEGLWindow(window,this); } -QPlatformGLContext *QWaylandXCompositeEGLIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const +QPlatformOpenGLContext *QWaylandXCompositeEGLIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const { return new QWaylandXCompositeEGLContext(glFormat, share, eglDisplay()); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h index 1f67bf28e1..74ea930e9a 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h @@ -51,7 +51,7 @@ #include #include -#include +#include #include @@ -69,7 +69,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; + QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp index 20fb0396f8..75881a7fdd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -47,7 +47,7 @@ #include -QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen) +QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, Display *display, int screen) : m_display(display) { qDebug("creating XComposite-GLX context"); diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h index cabdbe1a82..3364d88ec4 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -42,7 +42,7 @@ #ifndef QWAYLANDXCOMPOSITEGLXCONTEXT_H #define QWAYLANDXCOMPOSITEGLXCONTEXT_H -#include +#include #include "qwaylandxcompositeglxintegration.h" #include @@ -50,10 +50,10 @@ class QWaylandXCompositeGLXWindow; class QWaylandShmBuffer; -class QWaylandXCompositeGLXContext : public QPlatformGLContext +class QWaylandXCompositeGLXContext : public QPlatformOpenGLContext { public: - QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformGLContext *share, Display *display, int screen); + QWaylandXCompositeGLXContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, Display *display, int screen); QSurfaceFormat format() const; diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp index 8c27fa1cd8..e1eb2e635a 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -78,7 +78,7 @@ QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *wind return new QWaylandXCompositeGLXWindow(window, this); } -QPlatformGLContext *QWaylandXCompositeGLXIntegration::createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const +QPlatformOpenGLContext *QWaylandXCompositeGLXIntegration::createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const { return new QWaylandXCompositeGLXContext(glFormat, share, mDisplay, mScreen); } diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h index 5a779bf58a..b028067d8e 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h @@ -64,7 +64,7 @@ public: void initialize(); QWaylandWindow *createEglWindow(QWindow *window); - QPlatformGLContext *createPlatformGLContext(const QSurfaceFormat &glFormat, QPlatformGLContext *share) const; + QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; QWaylandDisplay *waylandDisplay() const; struct wl_xcomposite *waylandXComposite() const; diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 3ed5f163ff..e17c2f8d95 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -56,7 +56,7 @@ #include #include #include -#include +#include #ifdef QT_WAYLAND_GL_SUPPORT #include "gl_integration/qwaylandglintegration.h" @@ -104,10 +104,10 @@ QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) cons return new QWaylandShmWindow(window); } -QPlatformGLContext *QWaylandIntegration::createPlatformGLContext(QGuiGLContext *context) const +QPlatformOpenGLContext *QWaylandIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { #ifdef QT_WAYLAND_GL_SUPPORT - return mDisplay->eglIntegration()->createPlatformGLContext(context->format(), context->shareHandle()); + return mDisplay->eglIntegration()->createPlatformOpenGLContext(context->format(), context->shareHandle()); #else Q_UNUSED(glFormat); Q_UNUSED(share); diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 69b8863ebc..61e8559a7d 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -57,7 +57,7 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; - QPlatformGLContext *createPlatformGLContext(QGuiGLContext *context) const; + QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; QAbstractEventDispatcher *guiThreadEventDispatcher() const; -- cgit v1.2.3 From 071914232189735ae6475d44d07f11f90b4729a1 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Tue, 23 Aug 2011 12:51:11 +0200 Subject: Cocoa: Fix qmlscene flicker on startup. The SG render thread was racing window creation in the GUI thread, which would cause flicker if the window won the race and was shown before the SG thread had a frame ready. Send a synchronous expose event before showing the window - this will wait for the SG render thread. In addition, don't defer NSwindow creation. The GL context setup is done before the window is shown and needs a fully created window. New API: QWindowSystemInterface::handleSynchronousExposeEvent Retire: QWindowSystemInterface::handleExposeEvent Change-Id: I0bb46089d16ec4882aaac8db67b57d15e0f51531 Reviewed-on: http://codereview.qt.nokia.com/3399 Reviewed-by: Qt Sanity Bot Reviewed-by: Gunnar Sletta Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index f685dae729..48da7b537e 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -125,7 +125,7 @@ void QWaylandWindow::attach(QWaylandBuffer *buffer) mBuffer = buffer; if (mSurface) { wl_surface_attach(mSurface, buffer->buffer(),0,0); - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size())); + QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size())); } } -- cgit v1.2.3 From 8d9266ca642d6b59089640e24363ea15e709d0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 2 Sep 2011 16:39:06 +0200 Subject: Propogate that the size has changed Change-Id: I73dde157e38933d39992cb4393297c0849ee1ae2 Reviewed-on: http://codereview.qt.nokia.com/4149 Reviewed-by: Qt Sanity Bot Reviewed-by: Paul Olav Tvete --- .../wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/wayland') diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp index 245097ef6c..e0e1f772b9 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp @@ -47,6 +47,7 @@ #include #include +#include QWaylandEglWindow::QWaylandEglWindow(QWindow *window) : QWaylandWindow(window) @@ -77,8 +78,10 @@ QWaylandWindow::WindowType QWaylandEglWindow::windowType() const void QWaylandEglWindow::setGeometry(const QRect &rect) { QWaylandWindow::setGeometry(rect); - if (m_waylandEglWindow) + if (m_waylandEglWindow){ wl_egl_window_resize(m_waylandEglWindow, rect.width(), rect.height(), 0, 0); + QWindowSystemInterface::handleGeometryChange(window(), rect); + } } void QWaylandEglWindow::newSurfaceCreated() -- cgit v1.2.3