From: Laszlo Agocs Date: Thu, 16 Jun 2011 10:56:00 +0000 (+0200) Subject: Make glx wayland backends working. X-Git-Tag: qt-v5.0.0-alpha1~3626^2~350 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c84346ddff128daf6900860229aa99e4dc6763b2;p=profile%2Fivi%2Fqtbase.git Make glx wayland backends working. --- diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp index 50cf8b0..a88fcf1 100644 --- a/examples/opengl/hellowindow/hellowindow.cpp +++ b/examples/opengl/hellowindow/hellowindow.cpp @@ -34,9 +34,8 @@ HelloWindow::HelloWindow(Renderer *renderer) create(); QTimer *timer = new QTimer(this); - timer->start(10); - connect(timer, SIGNAL(timeout()), this, SLOT(render())); + timer->start(10); updateColor(); } diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 9ba8af2..2996c00 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -101,6 +101,7 @@ void QWindow::create() d->platformWindow->setWindowTitle(d->windowTitle); if (d->windowState != Qt::WindowNoState) d->windowState = d->platformWindow->setWindowState(d->windowState); + d->platformWindow->setGeometry(geometry()); QObjectList childObjects = children(); for (int i = 0; i < childObjects.size(); i ++) { diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index d9b5fa9..6652ff5 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 1d6e79e..0000000 --- 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 3703869..0000000 --- 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 54b7d32..61fd26f 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 27a7287..3008c29 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 f878bef..5565e78 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 dc84d1c..746d594 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 5d4cf7a..54d63a2 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 e0de801..39fe030 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 a80a595..426c78e 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 41a14e3..797803f 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 9aae32c..bbd6c12 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 ba365ca..e4d420d 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 f1c9ccc..324f9dc 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 765be62..2c31687 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 4c2eaa6..4edcfc4 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 2e05faf..e55dec3 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 53f74e3..ec62a3c 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 6a6ffdf..0a2084d 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)