From 42aa4968f6badb8940f5eee6f662ba649c7b4790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 17 Mar 2011 18:55:01 +0100 Subject: Fixed compilation of QtOpenGL with Q_WS_QPA. --- src/opengl/qwindowsurface_gl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 93e720c..f5edce8 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -405,10 +405,12 @@ QGLWindowSurface::~QGLWindowSurface() delete d_ptr->fbo; delete d_ptr; +#ifndef Q_WS_QPA if (QGLGlobalShareWidget::cleanedUp) return; --(_qt_gl_share_widget()->widgetRefCount); +#endif #ifdef QGL_USE_TEXTURE_POOL if (_qt_gl_share_widget()->widgetRefCount <= 0) { @@ -474,8 +476,10 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) ctx->create(qt_gl_share_context()); +#ifndef Q_WS_QPA if (widget != qt_gl_share_widget()) ++(_qt_gl_share_widget()->widgetRefCount); +#endif #ifndef QT_NO_EGL static bool checkedForNOKSwapRegion = false; -- cgit v0.12 From 7b0d9bbbe766e5f2aa7408b35707592d369acb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 18 Mar 2011 10:08:16 +0100 Subject: Correctly set QMAKE_CFLAGS_WAYLAND and QMAKE_LIBS_WAYLAND in configure. --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index e88373e..9ea68c2 100755 --- a/configure +++ b/configure @@ -6190,8 +6190,8 @@ if [ "$PLATFORM_QPA" = "yes" ]; then QMAKE_LIBDIR_WAYLAND=`$PKG_CONFIG --variable=libdir wayland-client 2>/dev/null` if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists xkbcommon 2>/dev/null; then - QMAKE_CFLAGS_WAYLAND=$QMAKE_CFLAGS_WAYLAND `$PKG_CONFIG --cflags xkbcommon 2>/dev/null` - QMAKE_LIBS_WAYLAND=$QMAKE_LIBS_WAYLAND `$PKG_CONFIG --libs xkbcommon 2>/dev/null` + QMAKE_CFLAGS_WAYLAND="$QMAKE_CFLAGS_WAYLAND `$PKG_CONFIG --cflags xkbcommon 2>/dev/null`" + QMAKE_LIBS_WAYLAND="$QMAKE_LIBS_WAYLAND `$PKG_CONFIG --libs xkbcommon 2>/dev/null`" else QMAKE_DEFINES_WAYLAND=QT_NO_WAYLAND_XKB fi -- cgit v0.12 From 4234ea4479ca858d058840eec01760a387e4afb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 18 Mar 2011 10:42:14 +0100 Subject: Lighthouse: Make it possible to compile in default platform plugin --- src/gui/kernel/qapplication_qpa.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index cb5439c..1d4400a 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -514,7 +514,14 @@ void qt_init(QApplicationPrivate *priv, int type) QList pluginList; QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH")); - QString platformName = QLatin1String(qgetenv("QT_QPA_PLATFORM")); + QByteArray platformName; +#ifdef QT_QPA_DEFAULT_PLATFORM_NAME + platformName = QT_QPA_DEFAULT_PLATFORM_NAME; +#endif + QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM"); + if (!platformNameEnv.isEmpty()) { + platformName = platformNameEnv; + } // Get command line params @@ -533,7 +540,7 @@ void qt_init(QApplicationPrivate *priv, int type) platformPluginPath = QLatin1String(argv[i]); } else if (arg == "-platform") { if (++i < argc) - platformName = QLatin1String(argv[i]); + platformName = argv[i]; } else if (arg == "-plugin") { if (++i < argc) pluginList << argv[i]; @@ -554,7 +561,7 @@ void qt_init(QApplicationPrivate *priv, int type) } #endif - init_platform(platformName, platformPluginPath); + init_platform(QLatin1String(platformName), platformPluginPath); init_plugins(pluginList); QColormap::initialize(); -- cgit v0.12 From 105a4d6d2e7fda3bf0753e78af470b16fa9f0485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 21 Mar 2011 09:25:23 +0100 Subject: Lighthouse: compile fix for dri2 contexts --- src/plugins/platforms/xcb/qdri2context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qdri2context.cpp b/src/plugins/platforms/xcb/qdri2context.cpp index 0079f91..dbbfa67 100644 --- a/src/plugins/platforms/xcb/qdri2context.cpp +++ b/src/plugins/platforms/xcb/qdri2context.cpp @@ -266,6 +266,6 @@ xcb_dri2_dri2_buffer_t * QDri2Context::backBuffer() void * QDri2Context::eglContext() const { - Q_D(QDri2Context); + Q_D(const QDri2Context); return d->eglContext; } -- cgit v0.12 From 792305ed03bdff6d2aa5d7bf31a139d9ae453f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 21 Mar 2011 09:33:19 +0100 Subject: Lighthouse: Fixing broken pattern in configure script --- configure | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 9ea68c2..83c836c 100755 --- a/configure +++ b/configure @@ -6140,12 +6140,13 @@ if [ "$PLATFORM_QPA" = "yes" ]; then QMAKE_INCDIR_OPENGL_ES2=`$PKG_CONFIG --variable=includedir glesv2 2>/dev/null` QMAKE_LIBDIR_OPENGL_ES2=`$PKG_CONFIG --variable=libdir glesv2 2>/dev/null` QMAKE_LIBS_OPENGL_ES2=`$PKG_CONFIG --libs glesv2 2>/dev/null` + QMAKE_CFLAGS_OPENGL_ES2=`$PKG_CONFIG --cflags glesv2 2>/dev/null` QMakeVar set QMAKE_INCDIR_OPENGL_ES2 "$QMAKE_INCDIR_OPENGL_ES2" QMakeVar set QMAKE_LIBDIR_OPENGL_ES2 "$QMAKE_LIBDIR_OPENGL_ES2" QMakeVar set QMAKE_LIBS_OPENGL_ES2 "$QMAKE_LIBS_OPENGL_ES2" fi - "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS -I$QMAKE_INCDIR_OPENGL_ES2 $QMAKE_LIBS_OPENGL_ES2 -L$QMAKE_LIBDIR_OPENGL_ES2 + "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/opengles2 "OpenGL ES 2.x" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_LIBS_OPENGL_ES2 $QMAKE_CFLAGS_OPENGL_ES2 if [ $? != "0" ]; then echo "The OpenGL ES 2.0 functionality test failed!" echo " You might need to modify the include and library search paths by editing" @@ -6206,7 +6207,7 @@ if [ "$PLATFORM_QPA" = "yes" ]; then QMakeVar set QMAKE_DEFINES_WAYLAND " $QMAKE_DEFINES_WAYLAND" fi - if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qpa/wayland "Wayland" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_CFLAGS_WAYLAND -I$QMAKE_INCDIR_WAYLAND $QMAKE_LIBS_WAYLAND; then + if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/qpa/wayland "Wayland" $L_FLAGS $I_FLAGS $l_FLAGS $QMAKE_CFLAGS_WAYLAND $QMAKE_LIBS_WAYLAND; then QT_CONFIG="$QT_CONFIG wayland" fi -- cgit v0.12 From a9b5cc1b3d6d5fb9569ad3bca9b5584b6415bfd6 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 21 Mar 2011 10:07:49 +0100 Subject: Compile fix for QPA --- src/opengl/qwindowsurface_gl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index f5edce8..cfccda5 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -426,7 +426,8 @@ QGLWindowSurface::~QGLWindowSurface() if (!qt_gl_share_widget()->context()->isSharing()) qt_destroy_gl_share_widget(); } -#endif +#endif // QGL_USE_TEXTURE_POOL +#endif // Q_WS_QPA } void QGLWindowSurface::deleted(QObject *object) -- cgit v0.12 From d8aef5788774f5450b48354fe8d436ee0f8f5417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 21 Mar 2011 10:33:23 +0100 Subject: Lighthouse: fixup from cherry-pick a9b5cc1b3d6d5fb9569ad3bca9b5584b6415bfd6 --- src/opengl/qwindowsurface_gl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index cfccda5..681ab69 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -410,7 +410,6 @@ QGLWindowSurface::~QGLWindowSurface() return; --(_qt_gl_share_widget()->widgetRefCount); -#endif #ifdef QGL_USE_TEXTURE_POOL if (_qt_gl_share_widget()->widgetRefCount <= 0) { -- cgit v0.12 From 4f19dc5b35ded10cb1ed74b91c47c1bc6a744845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 22 Mar 2011 08:41:49 +0100 Subject: Lighthouse: Remove drm hack in pro file --- src/plugins/platforms/wayland/wayland.pro | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index face860..f78e4b3 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -47,11 +47,6 @@ contains(QT_CONFIG, opengles2) { DEFINES += QT_WAYLAND_GL_SUPPORT } -unix:isEmpty(QMAKE_INCDIR_WAYLAND) { - CONFIG += link_pkgconfig - PKGCONFIG += libdrm -} - include (../fontdatabases/genericunix/genericunix.pri) target.path += $$[QT_INSTALL_PLUGINS]/platforms -- cgit v0.12 From dc1f979b7d2d13efd852fd3fa41930f115a9edd1 Mon Sep 17 00:00:00 2001 From: con Date: Tue, 22 Mar 2011 09:58:11 +0100 Subject: Fix QT_NO_NETWORKPROXY. Reviewed-by: Peter Hartmann --- src/network/access/qhttpthreaddelegate.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 81410a4..0b4459a 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -131,6 +131,8 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy) result = key.toEncoded(); } } +#else + Q_UNUSED(proxy) #endif return "http-connection:" + result; @@ -226,11 +228,13 @@ void QHttpThreadDelegate::startRequest() QUrl urlCopy = httpRequest.url(); urlCopy.setPort(urlCopy.port(ssl ? 443 : 80)); +#ifndef QT_NO_NETWORKPROXY if (transparentProxy.type() != QNetworkProxy::NoProxy) cacheKey = makeCacheKey(urlCopy, &transparentProxy); else if (cacheProxy.type() != QNetworkProxy::NoProxy) cacheKey = makeCacheKey(urlCopy, &cacheProxy); else +#endif cacheKey = makeCacheKey(urlCopy, 0); -- cgit v0.12 From 07b5eac8a85088a928d04b84be9cc082e4500978 Mon Sep 17 00:00:00 2001 From: con Date: Tue, 22 Mar 2011 11:07:00 +0100 Subject: Use the new QT_QPA_DEFAULT_PLATFORM_NAME define. --- mkspecs/qws/macx-iphonedevice-g++/qplatformdefs.h | 2 ++ mkspecs/qws/macx-iphonesimulator-g++/qplatformdefs.h | 2 ++ src/plugins/platforms/uikit/examples/qmltest/main.mm | 16 +++------------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/mkspecs/qws/macx-iphonedevice-g++/qplatformdefs.h b/mkspecs/qws/macx-iphonedevice-g++/qplatformdefs.h index 425fda3..0468935 100644 --- a/mkspecs/qws/macx-iphonedevice-g++/qplatformdefs.h +++ b/mkspecs/qws/macx-iphonedevice-g++/qplatformdefs.h @@ -94,4 +94,6 @@ #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf +#define QT_QPA_DEFAULT_PLATFORM_NAME "uikit" + #endif // QPLATFORMDEFS_H diff --git a/mkspecs/qws/macx-iphonesimulator-g++/qplatformdefs.h b/mkspecs/qws/macx-iphonesimulator-g++/qplatformdefs.h index 425fda3..0468935 100644 --- a/mkspecs/qws/macx-iphonesimulator-g++/qplatformdefs.h +++ b/mkspecs/qws/macx-iphonesimulator-g++/qplatformdefs.h @@ -94,4 +94,6 @@ #define QT_SNPRINTF ::snprintf #define QT_VSNPRINTF ::vsnprintf +#define QT_QPA_DEFAULT_PLATFORM_NAME "uikit" + #endif // QPLATFORMDEFS_H diff --git a/src/plugins/platforms/uikit/examples/qmltest/main.mm b/src/plugins/platforms/uikit/examples/qmltest/main.mm index 6fd5629..2b5f024 100644 --- a/src/plugins/platforms/uikit/examples/qmltest/main.mm +++ b/src/plugins/platforms/uikit/examples/qmltest/main.mm @@ -39,14 +39,6 @@ ** ****************************************************************************/ -// -// main.m -// qmltest -// -// Created by Eike Troll on 18.02.11. -// Copyright 2011 __MyCompanyName__. All rights reserved. -// - #import #include "qmlapplicationviewer/qmlapplicationviewer.h" @@ -60,15 +52,13 @@ int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - setenv("QT_QPA_PLATFORM","uikit",1); - - QApplication app(argc, argv); + QApplication app(argc, argv); QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); - NSString *resourcePath = [[NSBundle mainBundle] resourcePath]; + NSString *resourcePath = [[NSBundle mainBundle] resourcePath]; viewer.setMainQmlFile(QString::fromUtf8([[resourcePath stringByAppendingPathComponent:@"qml/main.qml"] UTF8String])); viewer.showMaximized(); - int retVal = app.exec(); + int retVal = app.exec(); [pool release]; return retVal; } -- cgit v0.12 From 9f6eb99448d3ee8cbdd1c5b41903176759b1664f Mon Sep 17 00:00:00 2001 From: con Date: Tue, 22 Mar 2011 11:45:05 +0100 Subject: We need the xml libs for QML also for the simulator. --- .../uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj index fc4f1df..84f0d3a 100755 --- a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj +++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj @@ -10,6 +10,8 @@ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; + D316594E1338B29E00760B02 /* libQtXml_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D31659431338B21000760B02 /* libQtXml_debug.a */; }; + D316594F1338B29E00760B02 /* libQtXmlPatterns_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D31659441338B21000760B02 /* libQtXmlPatterns_debug.a */; }; D3CAA7C813264AAD008BB877 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7C713264AAD008BB877 /* main.mm */; }; D3CAA7E613264EA6008BB877 /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */; }; D3CAA7E713264EA6008BB877 /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */; }; @@ -50,6 +52,8 @@ 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 32CA4F630368D1EE00C91783 /* qmltest_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = qmltest_Prefix.pch; sourceTree = ""; }; 8D1107310486CEB800E47090 /* qmltest-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "qmltest-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; + D31659431338B21000760B02 /* libQtXml_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXml_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtXml_debug.a"; sourceTree = SOURCE_ROOT; }; + D31659441338B21000760B02 /* libQtXmlPatterns_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXmlPatterns_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtXmlPatterns_debug.a"; sourceTree = SOURCE_ROOT; }; D3CAA7C713264AAD008BB877 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_qmlapplicationviewer.cpp; path = qmlapplicationviewer/moc_qmlapplicationviewer.cpp; sourceTree = ""; }; D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = qmlapplicationviewer.cpp; path = qmlapplicationviewer/qmlapplicationviewer.cpp; sourceTree = ""; }; @@ -92,6 +96,8 @@ D3CAA81F13265056008BB877 /* libQtSql_debug.a in Frameworks */, D3CAA8211326507D008BB877 /* libquikit_debug.a in Frameworks */, D3CAA82813265220008BB877 /* libQtNetwork_debug.a in Frameworks */, + D316594E1338B29E00760B02 /* libQtXml_debug.a in Frameworks */, + D316594F1338B29E00760B02 /* libQtXmlPatterns_debug.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -207,6 +213,8 @@ D3CAA82713265220008BB877 /* libQtNetwork_debug.a */, D3CAA81913265056008BB877 /* libQtScript_debug.a */, D3CAA81A13265056008BB877 /* libQtSql_debug.a */, + D31659431338B21000760B02 /* libQtXml_debug.a */, + D31659441338B21000760B02 /* libQtXmlPatterns_debug.a */, ); name = Simulator; sourceTree = ""; -- cgit v0.12 From 2905f11e8e8fe7e05d61cec9fcc1d78ff91f0f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 23 Mar 2011 13:41:28 +0100 Subject: Avoid duplicate calls to eglGetDisplay() in XCB / Xlib platforms. Just call eglGetDisplay() once, as we also need to call eglInitialize() before the display can be used validly. --- src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp | 4 +--- src/plugins/platforms/eglconvenience/qxlibeglintegration.h | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 7 +++---- src/plugins/platforms/xlib/qxlibintegration.cpp | 3 ++- src/plugins/platforms/xlib/qxlibscreen.cpp | 5 ++++- src/plugins/platforms/xlib/qxlibscreen.h | 8 ++++++++ src/plugins/platforms/xlib/qxlibwindow.cpp | 6 +++--- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp b/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp index 7f296c5..45746e9 100644 --- a/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp +++ b/src/plugins/platforms/eglconvenience/qxlibeglintegration.cpp @@ -52,13 +52,11 @@ static int countBits(unsigned long mask) return count; } -VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLConfig config) +VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config) { VisualID visualId = 0; EGLint eglValue = 0; - EGLDisplay eglDisplay = eglGetDisplay(display); - EGLint configRedSize = 0; eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &configRedSize); diff --git a/src/plugins/platforms/eglconvenience/qxlibeglintegration.h b/src/plugins/platforms/eglconvenience/qxlibeglintegration.h index 51996da..6c2e266 100644 --- a/src/plugins/platforms/eglconvenience/qxlibeglintegration.h +++ b/src/plugins/platforms/eglconvenience/qxlibeglintegration.h @@ -47,7 +47,7 @@ class QXlibEglIntegration { public: - static VisualID getCompatibleVisualId(Display *display, EGLConfig config); + static VisualID getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config); }; #endif // QTESTLITEEGLINTEGRATION_H diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index cbf50f7..017a902 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -114,9 +114,9 @@ QXcbWindow::QXcbWindow(QWidget *tlw) #if defined(XCB_USE_GLX) XVisualInfo *visualInfo = QGLXContext::findVisualInfo(m_screen, tlw->platformWindowFormat()); #elif defined(XCB_USE_EGL) - EGLDisplay eglDisplay = eglGetDisplay(DISPLAY_FROM_XCB(this)); + EGLDisplay eglDisplay = connection()->egl_display(); EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true); - VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this),eglConfig); + VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig); XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); @@ -430,8 +430,7 @@ QPlatformGLContext *QXcbWindow::glContext() const } #elif defined(XCB_USE_EGL) if (!m_context) { - EGLDisplay display = eglGetDisplay(DISPLAY_FROM_XCB(this)); - + EGLDisplay display = connection()->egl_display(); EGLConfig config = q_configFromQPlatformWindowFormat(display,widget()->platformWindowFormat(),true); QVector eglContextAttrs; eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp index 6733ed1..63197b0 100644 --- a/src/plugins/platforms/xlib/qxlibintegration.cpp +++ b/src/plugins/platforms/xlib/qxlibintegration.cpp @@ -141,11 +141,12 @@ bool QXlibIntegration::hasOpenGL() const static bool wasEglInitialized = false; if (!eglHasbeenInitialized) { eglHasbeenInitialized = true; - const QXlibScreen *screen = static_cast(mScreens.at(0)); + QXlibScreen *screen = static_cast(mScreens.at(0)); EGLint major, minor; eglBindAPI(EGL_OPENGL_ES_API); EGLDisplay disp = eglGetDisplay(screen->display()->nativeDisplay()); wasEglInitialized = eglInitialize(disp,&major,&minor); + screen->setEglDisplay(disp); } return wasEglInitialized; #endif diff --git a/src/plugins/platforms/xlib/qxlibscreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp index 23a2d07..7c8a367 100644 --- a/src/plugins/platforms/xlib/qxlibscreen.cpp +++ b/src/plugins/platforms/xlib/qxlibscreen.cpp @@ -191,6 +191,9 @@ qDebug() << "qt_x_errhandler" << err->error_code; QXlibScreen::QXlibScreen() : mFormat(QImage::Format_RGB32) +#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) + , mEGLDisplay(0) +#endif { char *display_name = getenv("DISPLAY"); Display *display = XOpenDisplay(display_name); @@ -467,7 +470,7 @@ int QXlibScreen::xScreenNumber() const Visual * QXlibScreen::defaultVisual() const { - DefaultVisual(display()->nativeDisplay(), xScreenNumber()); + return DefaultVisual(display()->nativeDisplay(), xScreenNumber()); } QXlibKeyboard * QXlibScreen::keyboard() const diff --git a/src/plugins/platforms/xlib/qxlibscreen.h b/src/plugins/platforms/xlib/qxlibscreen.h index 35c0141..8c04c0f 100644 --- a/src/plugins/platforms/xlib/qxlibscreen.h +++ b/src/plugins/platforms/xlib/qxlibscreen.h @@ -82,6 +82,11 @@ public: QXlibKeyboard *keyboard() const; +#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) + void *eglDisplay() const { return mEGLDisplay; } + void setEglDisplay(void *display) { mEGLDisplay = display; } +#endif + public slots: void eventDispatcher(); @@ -96,6 +101,9 @@ private: QXlibKeyboard *mKeyboard; QXlibDisplay * mDisplay; +#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) + void *mEGLDisplay; +#endif int mScreen; }; diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index a7bc53c..01d4b8e 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -87,9 +87,9 @@ QXlibWindow::QXlibWindow(QWidget *window) #else QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat()); - EGLDisplay eglDisplay = eglGetDisplay(mScreen->display()->nativeDisplay()); + EGLDisplay eglDisplay = mScreen->eglDisplay(); EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat); - VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(),eglConfig); + VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(), eglDisplay, eglConfig); XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); @@ -663,7 +663,7 @@ QPlatformGLContext *QXlibWindow::glContext() const #if !defined(QT_OPENGL_ES_2) that->mGLContext = new QGLXContext(x_window, mScreen,widget()->platformWindowFormat()); #else - EGLDisplay display = eglGetDisplay(mScreen->display()->nativeDisplay()); + EGLDisplay display = mScreen->eglDisplay(); QPlatformWindowFormat windowFormat = correctColorBuffers(widget()->platformWindowFormat()); -- cgit v0.12 From 9ca3f9c6b6ae50c6b8a19d5e4b26bff15d5421e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 23 Mar 2011 07:01:56 +0100 Subject: Lighthouse: Wayland, implement gl_integration --- .../platforms/eglconvenience/qeglconvenience.h | 4 - .../wayland/gl_integration/gl_integration.pri | 13 ++ .../gl_integration/qwaylandglintegration.cpp | 11 ++ .../wayland/gl_integration/qwaylandglintegration.h | 20 +++ .../gl_integration/qwaylandglwindowsurface.cpp | 181 ++++++++++++++++++++ .../gl_integration/qwaylandglwindowsurface.h | 69 ++++++++ .../wayland_egl/qwaylandeglinclude.h | 16 ++ .../wayland_egl/qwaylandeglintegration.cpp | 48 ++++++ .../wayland_egl/qwaylandeglintegration.h | 32 ++++ .../wayland_egl/qwaylandeglwindow.cpp | 112 +++++++++++++ .../gl_integration/wayland_egl/qwaylandeglwindow.h | 71 ++++++++ .../wayland_egl/qwaylandglcontext.cpp | 155 +++++++++++++++++ .../gl_integration/wayland_egl/qwaylandglcontext.h | 81 +++++++++ .../gl_integration/wayland_egl/wayland_egl.pri | 12 ++ src/plugins/platforms/wayland/qwaylanddisplay.cpp | 30 ++-- src/plugins/platforms/wayland/qwaylanddisplay.h | 17 +- .../platforms/wayland/qwaylanddrmsurface.cpp | 183 --------------------- src/plugins/platforms/wayland/qwaylanddrmsurface.h | 70 -------- .../platforms/wayland/qwaylandeglwindow.cpp | 113 ------------- src/plugins/platforms/wayland/qwaylandeglwindow.h | 68 -------- .../platforms/wayland/qwaylandglcontext.cpp | 155 ----------------- src/plugins/platforms/wayland/qwaylandglcontext.h | 81 --------- src/plugins/platforms/wayland/qwaylandinclude.h | 63 ------- .../platforms/wayland/qwaylandintegration.cpp | 14 +- src/plugins/platforms/wayland/qwaylandwindow.h | 1 - src/plugins/platforms/wayland/wayland.pro | 18 +- 26 files changed, 852 insertions(+), 786 deletions(-) create mode 100644 src/plugins/platforms/wayland/gl_integration/gl_integration.pri create mode 100644 src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h create mode 100644 src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h create mode 100644 src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h create mode 100644 src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h create mode 100644 src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri delete mode 100644 src/plugins/platforms/wayland/qwaylanddrmsurface.cpp delete mode 100644 src/plugins/platforms/wayland/qwaylanddrmsurface.h delete mode 100644 src/plugins/platforms/wayland/qwaylandeglwindow.cpp delete mode 100644 src/plugins/platforms/wayland/qwaylandeglwindow.h delete mode 100644 src/plugins/platforms/wayland/qwaylandglcontext.cpp delete mode 100644 src/plugins/platforms/wayland/qwaylandglcontext.h delete mode 100644 src/plugins/platforms/wayland/qwaylandinclude.h diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h index 8668095..fab1cb0 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.h +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h @@ -46,11 +46,7 @@ #include #include -#ifdef Q_PLATFORM_WAYLAND -#include "qwaylandinclude.h" -#else #include -#endif QT_BEGIN_NAMESPACE QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format); diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri new file mode 100644 index 0000000..8a792a5 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -0,0 +1,13 @@ +HEADERS += \ + $$PWD/qwaylandglintegration.h \ + $$PWD/qwaylandglwindowsurface.h + +SOURCES += \ + $$PWD/qwaylandglintegration.cpp \ + $$PWD/qwaylandglwindowsurface.cpp + +wayland_egl { + include ($$PWD/wayland_egl/wayland_egl.pri) +} + + diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp new file mode 100644 index 0000000..9a0a824 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp @@ -0,0 +1,11 @@ +#include "qwaylandglintegration.h" + +QWaylandGLIntegration::QWaylandGLIntegration() +{ + +} + +QWaylandGLIntegration::~QWaylandGLIntegration() +{ + +} diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h new file mode 100644 index 0000000..a1f6b2c --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h @@ -0,0 +1,20 @@ +#ifndef QWAYLANDGLINTEGRATION_H +#define QWAYLANDGLINTEGRATION_H + +class QWaylandWindow; +class QWidget; + +class QWaylandGLIntegration +{ +public: + QWaylandGLIntegration(); + virtual ~QWaylandGLIntegration(); + + virtual void initialize() = 0; + + virtual QWaylandWindow *createEglWindow(QWidget *widget) = 0; + + static QWaylandGLIntegration *createEglIntegration(struct wl_display *waylandDisplay); +}; + +#endif // QWAYLANDGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp new file mode 100644 index 0000000..ca9fb97 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandglwindowsurface.h" + +#include "qwaylanddisplay.h" +#include "qwaylandwindow.h" +#include "qwaylandscreen.h" + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br) +{ + 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(QWidget *window) + : QWindowSurface(window) + , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) + , mPaintDevice(0) +{ + +} + +QWaylandGLWindowSurface::~QWaylandGLWindowSurface() +{ + delete mPaintDevice; +} + +QPaintDevice *QWaylandGLWindowSurface::paintDevice() +{ + return mPaintDevice; +} + +void QWaylandGLWindowSurface::beginPaint(const QRegion &) +{ + window()->platformWindow()->glContext()->makeCurrent(); + glClearColor(0,0,0,0xff); + glClear(GL_COLOR_BUFFER_BIT); +} + +void QWaylandGLWindowSurface::flush(QWidget *widget, 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()); + blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect); + ww->glContext()->swapBuffers(); +} + +void QWaylandGLWindowSurface::resize(const QSize &size) +{ + QWindowSurface::resize(size); + window()->platformWindow()->glContext()->makeCurrent(); + delete mPaintDevice; + mPaintDevice = new QGLFramebufferObject(size,QGLFramebufferObject::CombinedDepthStencil,GL_TEXTURE_2D,GL_RGBA); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h new file mode 100644 index 0000000..faff872 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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 config.tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDDRMSURFACE_H +#define QWAYLANDDRMSURFACE_H + +#include "qwaylanddisplay.h" + +#include + +class QGLFramebufferObject; + +class QWaylandGLWindowSurface : public QWindowSurface +{ +public: + QWaylandGLWindowSurface(QWidget *window); + ~QWaylandGLWindowSurface(); + + void beginPaint(const QRegion &); + + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + + void resize(const QSize &size); + +private: + QWaylandDisplay *mDisplay; + QGLFramebufferObject *mPaintDevice; +}; + +#endif // QWAYLANDDRMSURFACE_H diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h new file mode 100644 index 0000000..778c3db --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h @@ -0,0 +1,16 @@ +#ifndef QWAYLANDEGLINCLUDE_H +#define QWAYLANDEGLINCLUDE_H + +#include + +#include + +#define GL_GLEXT_PROTOTYPES +#include +#include + +#define EGL_EGLEXT_PROTOTYPES +#include +#include + +#endif // QWAYLANDEGLINCLUDE_H diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp new file mode 100644 index 0000000..eb46bc7 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -0,0 +1,48 @@ +#include "qwaylandeglintegration.h" + +#include "qwaylandeglwindow.h" + +QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay) + : mWaylandDisplay(waylandDisplay) + , mNativeEglDisplay(wl_egl_display_create(mWaylandDisplay)) +{ +} + +QWaylandEglIntegration::~QWaylandEglIntegration() +{ + eglTerminate(mEglDisplay); +} + +void QWaylandEglIntegration::initialize() +{ + EGLint major,minor; + mEglDisplay = eglGetDisplay((EGLNativeDisplayType)mNativeEglDisplay); + if (mEglDisplay == NULL) { + qWarning("EGL not available"); + } else { + if (!eglInitialize(mEglDisplay, &major, &minor)) { + qWarning("failed to initialize EGL display"); + return; + } + } +} + +QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWidget *window) +{ + return new QWaylandEglWindow(window); +} + +EGLDisplay QWaylandEglIntegration::eglDisplay() const +{ + return mEglDisplay; +} + +wl_egl_display * QWaylandEglIntegration::nativeDisplay() const +{ + return mNativeEglDisplay; +} + +QWaylandGLIntegration *QWaylandGLIntegration::createEglIntegration(wl_display *waylandDisplay) +{ + return new QWaylandEglIntegration(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 new file mode 100644 index 0000000..8b166ce --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h @@ -0,0 +1,32 @@ +#ifndef QWAYLANDEGLINTEGRATION_H +#define QWAYLANDEGLINTEGRATION_H + +#include "gl_integration/qwaylandglintegration.h" + +#include "qwaylandeglinclude.h" + +class QWaylandWindow; +class QWidget; + +class QWaylandEglIntegration : public QWaylandGLIntegration +{ +public: + QWaylandEglIntegration(struct wl_display *waylandDisplay); + ~QWaylandEglIntegration(); + + void initialize(); + + QWaylandWindow *createEglWindow(QWidget *window); + + EGLDisplay eglDisplay() const; + struct wl_egl_display *nativeDisplay() const; +private: + struct wl_display *mWaylandDisplay; + + EGLDisplay mEglDisplay; + struct wl_egl_display *mNativeEglDisplay; + + +}; + +#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 new file mode 100644 index 0000000..a9aa46f --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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 config.tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandeglwindow.h" + +#include "qwaylandscreen.h" +#include "qwaylandglcontext.h" + +QWaylandEglWindow::QWaylandEglWindow(QWidget *window) + : QWaylandWindow(window) + , mGLContext(0) + , mWaylandEglWindow(0) +{ + mEglIntegration = static_cast(mDisplay->eglIntegration()); + //super creates a new surface + newSurfaceCreated(); +} + +QWaylandEglWindow::~QWaylandEglWindow() +{ + delete mGLContext; +} + +QWaylandWindow::WindowType QWaylandEglWindow::windowType() const +{ + return QWaylandWindow::Egl; +} + +void QWaylandEglWindow::setGeometry(const QRect &rect) +{ + QWaylandWindow::setGeometry(rect); + if (mWaylandEglWindow) { + wl_egl_window_resize(mWaylandEglWindow,rect.width(),rect.height(),0,0); + } +} + +void QWaylandEglWindow::setParent(const QPlatformWindow *parent) +{ + const QWaylandWindow *wParent = static_cast(parent); + + mParentWindow = wParent; +} + +QPlatformGLContext * QWaylandEglWindow::glContext() const +{ + if (!mGLContext) { + QWaylandEglWindow *that = const_cast(this); + that->mGLContext = new QWaylandGLContext(mEglIntegration->eglDisplay(),widget()->platformWindowFormat()); + + EGLNativeWindowType window(reinterpret_cast(mWaylandEglWindow)); + EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL); + that->mGLContext->setEglSurface(surface); + } + + return mGLContext; +} + +void QWaylandEglWindow::newSurfaceCreated() +{ + if (mWaylandEglWindow) { + wl_egl_window_destroy(mWaylandEglWindow); + } + wl_visual *visual = QWaylandScreen::waylandScreenFromWidget(widget())->visual(); + QSize size = geometry().size(); + if (!size.isValid()) + size = QSize(0,0); + + mWaylandEglWindow = wl_egl_window_create(mEglIntegration->nativeDisplay(),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); + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h new file mode 100644 index 0000000..ef1e02a --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.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 config.tests of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDEGLWINDOW_H +#define QWAYLANDEGLWINDOW_H + +#include "qwaylandwindow.h" +#include "qwaylandeglinclude.h" +#include "qwaylandeglintegration.h" + +class QWaylandGLContext; + +class QWaylandEglWindow : public QWaylandWindow +{ +public: + QWaylandEglWindow(QWidget *window); + ~QWaylandEglWindow(); + WindowType windowType() const; + void setGeometry(const QRect &rect); + void setParent(const QPlatformWindow *parent); + QPlatformGLContext *glContext() const; +protected: + void newSurfaceCreated(); +private: + QWaylandEglIntegration *mEglIntegration; + QWaylandGLContext *mGLContext; + struct wl_egl_window *mWaylandEglWindow; + EGLConfig mConfig; + + const QWaylandWindow *mParentWindow; +}; + +#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 new file mode 100644 index 0000000..4444229 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandglcontext.h" + +#include "qwaylanddisplay.h" +#include "qwaylandwindow.h" + +#include "../../../eglconvenience/qeglconvenience.h" + +#include +#include +#include + +Q_GLOBAL_STATIC(QMutex,qt_defaultSharedContextMutex) + +QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format) + : QPlatformGLContext() + , mEglDisplay(eglDisplay) + , mSurface(EGL_NO_SURFACE) + , mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true)) + , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig)) +{ + QPlatformGLContext *sharePlatformContext = 0; + if (format.useDefaultSharedContext()) { + if (!QPlatformGLContext::defaultSharedContext()) { + if (qt_defaultSharedContextMutex()->tryLock()){ + createDefaultSharedContex(eglDisplay); + qt_defaultSharedContextMutex()->unlock(); + } else { + qt_defaultSharedContextMutex()->lock(); //wait to the the shared context is created + qt_defaultSharedContextMutex()->unlock(); + } + } + sharePlatformContext = QPlatformGLContext::defaultSharedContext(); + } else { + sharePlatformContext = format.sharedGLContext(); + } + mFormat.setSharedContext(sharePlatformContext); + EGLContext shareEGLContext = EGL_NO_CONTEXT; + if (sharePlatformContext) + shareEGLContext = static_cast(sharePlatformContext)->mContext; + + eglBindAPI(EGL_OPENGL_ES_API); + + QVector eglContextAttrs; + eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); + eglContextAttrs.append(2); + eglContextAttrs.append(EGL_NONE); + + mContext = eglCreateContext(mEglDisplay, mConfig, + shareEGLContext, eglContextAttrs.constData()); +} + +QWaylandGLContext::QWaylandGLContext() + : QPlatformGLContext() + , mEglDisplay(0) + , mContext(EGL_NO_CONTEXT) + , mSurface(EGL_NO_SURFACE) + , mConfig(0) +{ } + +QWaylandGLContext::~QWaylandGLContext() +{ + eglDestroyContext(mEglDisplay,mContext); +} + +void QWaylandGLContext::makeCurrent() +{ + QPlatformGLContext::makeCurrent(); + if (mSurface == EGL_NO_SURFACE) { + qWarning("makeCurrent with EGL_NO_SURFACE"); + } + eglMakeCurrent(mEglDisplay, mSurface, mSurface, mContext); +} + +void QWaylandGLContext::doneCurrent() +{ + QPlatformGLContext::doneCurrent(); + eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); +} + +void QWaylandGLContext::swapBuffers() +{ + eglSwapBuffers(mEglDisplay,mSurface); +} + +void *QWaylandGLContext::getProcAddress(const QString &string) +{ + return (void *) eglGetProcAddress(string.toLatin1().data()); +} + +void QWaylandGLContext::createDefaultSharedContex(EGLDisplay display) +{ + QVector eglContextAttrs; + eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); + eglContextAttrs.append(2); + eglContextAttrs.append(EGL_NONE); + + QWaylandGLContext *defaultSharedContext = new QWaylandGLContext; + defaultSharedContext->mEglDisplay = display; + defaultSharedContext->mContext = eglCreateContext(mEglDisplay,mConfig, + EGL_NO_CONTEXT, eglContextAttrs.constData()); + QPlatformGLContext::setDefaultSharedContext(defaultSharedContext); +} + +void QWaylandGLContext::setEglSurface(EGLSurface surface) +{ + doneCurrent(); + mSurface = surface; +} + +EGLConfig QWaylandGLContext::eglConfig() const +{ + return mConfig; +} + diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h new file mode 100644 index 0000000..d530b1c --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDGLCONTEXT_H +#define QWAYLANDGLCONTEXT_H + +#include "qwaylanddisplay.h" + +#include + +#include "qwaylandeglinclude.h" + +class QWaylandWindow; +class QWaylandGLWindowSurface; + +class QWaylandGLContext : public QPlatformGLContext { +public: + QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format); + ~QWaylandGLContext(); + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString&); + + QPlatformWindowFormat platformWindowFormat() const { return mFormat; } + + void setEglSurface(EGLSurface surface); + EGLConfig eglConfig() const; +private: + EGLDisplay mEglDisplay; + + EGLContext mContext; + EGLSurface mSurface; + EGLConfig mConfig; + QPlatformWindowFormat mFormat; + + void createDefaultSharedContex(EGLDisplay eglDisplay); + QWaylandGLContext(); + +}; + + +#endif // QWAYLANDGLCONTEXT_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 new file mode 100644 index 0000000..bc97864 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/wayland_egl.pri @@ -0,0 +1,12 @@ +LIBS += -lwayland-egl -lEGL +INCLUDEPATH += $$PWD +SOURCES += $$PWD/qwaylandeglintegration.cpp \ + $$PWD/qwaylandglcontext.cpp \ + $$PWD/qwaylandeglwindow.cpp \ + $$PWD/../../../eglconvenience/qeglconvenience.cpp + +HEADERS += $$PWD/qwaylandeglintegration.h \ + $$PWD/qwaylandglcontext.h \ + $$PWD/qwaylandeglwindow.h \ + $$PWD/../../../eglconvenience/qeglconvenience.h \ + gl_integration/wayland_egl/qwaylandeglinclude.h diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 27f4334..eebc9de 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -46,6 +46,10 @@ #include "qwaylandcursor.h" #include "qwaylandinputdevice.h" +#ifdef QT_WAYLAND_GL_SUPPORT +#include "gl_integration/qwaylandglintegration.h" +#endif + #include #include #include @@ -78,9 +82,9 @@ struct wl_visual *QWaylandDisplay::argbPremultipliedVisual() return wl_display_get_premultiplied_argb_visual(mDisplay); } -struct wl_egl_display *QWaylandDisplay::nativeDisplay() +QWaylandGLIntegration * QWaylandDisplay::eglIntegration() { - return mNativeEglDisplay; + return mEglIntegration; } void QWaylandDisplay::shellHandleConfigure(void *data, struct wl_shell *shell, @@ -176,9 +180,6 @@ void QWaylandDisplay::flushRequests(void) QWaylandDisplay::QWaylandDisplay(void) : mWriteNotifier(0) { -#ifdef QT_WAYLAND_GL_SUPPORT - EGLint major, minor; -#endif mDisplay = wl_display_connect(NULL); if (mDisplay == NULL) { fprintf(stderr, "failed to create display: %m\n"); @@ -189,25 +190,13 @@ QWaylandDisplay::QWaylandDisplay(void) QWaylandDisplay::displayHandleGlobal, this); #ifdef QT_WAYLAND_GL_SUPPORT - mNativeEglDisplay = wl_egl_display_create(mDisplay); -#else - mNativeEglDisplay = 0; + mEglIntegration = QWaylandGLIntegration::createEglIntegration(mDisplay); #endif readEvents(); #ifdef QT_WAYLAND_GL_SUPPORT - mEglDisplay = eglGetDisplay((EGLNativeDisplayType)mNativeEglDisplay); - if (mEglDisplay == NULL) { - qWarning("EGL not available"); - } else { - if (!eglInitialize(mEglDisplay, &major, &minor)) { - qWarning("failed to initialize EGL display"); - return; - } - } -#else - mEglDisplay = 0; + mEglIntegration->initialize(); #endif int fd = wl_display_get_fd(mDisplay, sourceUpdate, this); @@ -225,7 +214,7 @@ QWaylandDisplay::~QWaylandDisplay(void) { close(mFd); #ifdef QT_WAYLAND_GL_SUPPORT - eglTerminate(mEglDisplay); + delete mEglIntegration; #endif wl_display_destroy(mDisplay); } @@ -245,3 +234,4 @@ void QWaylandDisplay::frameCallback(wl_display_frame_func_t func, void *data) { wl_display_frame_callback(mDisplay, func, data); } + diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index d994ffe..535dcd6 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -44,18 +44,15 @@ #include #include -#include -#include -#include -#include -#include "qwaylandinclude.h" +#include class QWaylandInputDevice; class QSocketNotifier; class QWaylandBuffer; class QPlatformScreen; class QWaylandScreen; +class QWaylandGLIntegration; class QWaylandDisplay : public QObject { Q_OBJECT @@ -73,9 +70,10 @@ public: struct wl_visual *rgbVisual(); struct wl_visual *argbVisual(); struct wl_visual *argbPremultipliedVisual(); - struct wl_egl_display *nativeDisplay(); - EGLDisplay eglDisplay() { return mEglDisplay; } +#ifdef QT_WAYLAND_GL_SUPPORT + QWaylandGLIntegration *eglIntegration(); +#endif void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y); void syncCallback(wl_display_sync_func_t func, void *data); @@ -98,8 +96,9 @@ private: QList mInputDevices; QSocketNotifier *mReadNotifier; QSocketNotifier *mWriteNotifier; - EGLDisplay mEglDisplay; - struct wl_egl_display *mNativeEglDisplay; +#ifdef QT_WAYLAND_GL_SUPPORT + QWaylandGLIntegration *mEglIntegration; +#endif static void displayHandleGlobal(struct wl_display *display, uint32_t id, diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp b/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp deleted file mode 100644 index a8bc352..0000000 --- a/src/plugins/platforms/wayland/qwaylanddrmsurface.cpp +++ /dev/null @@ -1,183 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylanddrmsurface.h" - -#include "qwaylanddisplay.h" -#include "qwaylandwindow.h" -#include "qwaylandscreen.h" - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize, const QRectF &br) -{ - 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); -} - -QWaylandDrmWindowSurface::QWaylandDrmWindowSurface(QWidget *window) - : QWindowSurface(window) - , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) - , mPaintDevice(0) -{ - -} - -QWaylandDrmWindowSurface::~QWaylandDrmWindowSurface() -{ - delete mPaintDevice; -} - -QPaintDevice *QWaylandDrmWindowSurface::paintDevice() -{ - return mPaintDevice; -} - -void QWaylandDrmWindowSurface::beginPaint(const QRegion &) -{ - window()->platformWindow()->glContext()->makeCurrent(); - glClearColor(0,0,0,0xff); - glClear(GL_COLOR_BUFFER_BIT); -} - -void QWaylandDrmWindowSurface::flush(QWidget *widget, 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()); - blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect); - ww->glContext()->swapBuffers(); -} - -void QWaylandDrmWindowSurface::resize(const QSize &size) -{ - QWindowSurface::resize(size); - window()->platformWindow()->glContext()->makeCurrent(); - delete mPaintDevice; - mPaintDevice = new QGLFramebufferObject(size,QGLFramebufferObject::CombinedDepthStencil,GL_TEXTURE_2D,GL_RGBA); -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylanddrmsurface.h b/src/plugins/platforms/wayland/qwaylanddrmsurface.h deleted file mode 100644 index 78418ee..0000000 --- a/src/plugins/platforms/wayland/qwaylanddrmsurface.h +++ /dev/null @@ -1,70 +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 config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDDRMSURFACE_H -#define QWAYLANDDRMSURFACE_H - -#include "qwaylanddisplay.h" - -#include - -class QGLFramebufferObject; - -class QWaylandDrmWindowSurface : public QWindowSurface -{ -public: - QWaylandDrmWindowSurface(QWidget *window); - ~QWaylandDrmWindowSurface(); - - void beginPaint(const QRegion &); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - - void resize(const QSize &size); - -private: - - QWaylandDisplay *mDisplay; - QGLFramebufferObject *mPaintDevice; -}; - -#endif // QWAYLANDDRMSURFACE_H diff --git a/src/plugins/platforms/wayland/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/qwaylandeglwindow.cpp deleted file mode 100644 index ed54bb9..0000000 --- a/src/plugins/platforms/wayland/qwaylandeglwindow.cpp +++ /dev/null @@ -1,113 +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 config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandeglwindow.h" - -#include "qwaylandscreen.h" -#include "qwaylandglcontext.h" -#include "qwaylandinclude.h" - -QWaylandEglWindow::QWaylandEglWindow(QWidget *window) - : QWaylandWindow(window) - , mGLContext(0) - , mWaylandEglWindow(0) -{ - //super creates a new surface - newSurfaceCreated(); -} - -QWaylandEglWindow::~QWaylandEglWindow() -{ - if (mGLContext) - delete mGLContext; -} - -QWaylandWindow::WindowType QWaylandEglWindow::windowType() const -{ - return QWaylandWindow::Egl; -} - -void QWaylandEglWindow::setGeometry(const QRect &rect) -{ - QWaylandWindow::setGeometry(rect); - if (mWaylandEglWindow) { - wl_egl_window_resize(mWaylandEglWindow,rect.width(),rect.height(),0,0); - } -} - -void QWaylandEglWindow::setParent(const QPlatformWindow *parent) -{ - const QWaylandWindow *wParent = static_cast(parent); - - mParentWindow = wParent; -} - -QPlatformGLContext * QWaylandEglWindow::glContext() const -{ - if (!mGLContext) { - QWaylandEglWindow *that = const_cast(this); - that->mGLContext = new QWaylandGLContext(that->mDisplay,widget()->platformWindowFormat()); - - EGLNativeWindowType window(reinterpret_cast(mWaylandEglWindow)); - EGLSurface surface = eglCreateWindowSurface(mDisplay->eglDisplay(),mGLContext->eglConfig(),window,NULL); - that->mGLContext->setEglSurface(surface); - } - - return mGLContext; -} - -void QWaylandEglWindow::newSurfaceCreated() -{ - if (mWaylandEglWindow) { - wl_egl_window_destroy(mWaylandEglWindow); - } - wl_visual *visual = QWaylandScreen::waylandScreenFromWidget(widget())->visual(); - QSize size = geometry().size(); - if (!size.isValid()) - size = QSize(0,0); - - mWaylandEglWindow = wl_egl_window_create(mDisplay->nativeDisplay(),mSurface,size.width(),size.height(),visual); - if (mGLContext) { - EGLNativeWindowType window(reinterpret_cast(mWaylandEglWindow)); - EGLSurface surface = eglCreateWindowSurface(mDisplay->eglDisplay(),mGLContext->eglConfig(),window,NULL); - mGLContext->setEglSurface(surface); - } -} diff --git a/src/plugins/platforms/wayland/qwaylandeglwindow.h b/src/plugins/platforms/wayland/qwaylandeglwindow.h deleted file mode 100644 index 4b3bb5b..0000000 --- a/src/plugins/platforms/wayland/qwaylandeglwindow.h +++ /dev/null @@ -1,68 +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 config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDEGLWINDOW_H -#define QWAYLANDEGLWINDOW_H - -#include "qwaylandwindow.h" - -class QWaylandGLContext; - -class QWaylandEglWindow : public QWaylandWindow -{ -public: - QWaylandEglWindow(QWidget *window); - ~QWaylandEglWindow(); - WindowType windowType() const; - void setGeometry(const QRect &rect); - void setParent(const QPlatformWindow *parent); - QPlatformGLContext *glContext() const; -protected: - void newSurfaceCreated(); -private: - QWaylandGLContext *mGLContext; - struct wl_egl_window *mWaylandEglWindow; - EGLConfig mConfig; - - const QWaylandWindow *mParentWindow; -}; - -#endif // QWAYLANDEGLWINDOW_H diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/qwaylandglcontext.cpp deleted file mode 100644 index 3720567..0000000 --- a/src/plugins/platforms/wayland/qwaylandglcontext.cpp +++ /dev/null @@ -1,155 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandglcontext.h" - -#include "qwaylanddisplay.h" -#include "qwaylandwindow.h" -#include "qwaylanddrmsurface.h" - -#include "../eglconvenience/qeglconvenience.h" - -#include -#include - -Q_GLOBAL_STATIC(QMutex,qt_defaultSharedContextMutex) - -QWaylandGLContext::QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowFormat &format) - : QPlatformGLContext() - , mDisplay(wd) - , mSurface(EGL_NO_SURFACE) - , mConfig(q_configFromQPlatformWindowFormat(mDisplay->eglDisplay(),format,true)) - , mFormat(qt_qPlatformWindowFormatFromConfig(mDisplay->eglDisplay(),mConfig)) -{ - QPlatformGLContext *sharePlatformContext = 0; - if (format.useDefaultSharedContext()) { - if (!QPlatformGLContext::defaultSharedContext()) { - if (qt_defaultSharedContextMutex()->tryLock()){ - createDefaultSharedContex(wd); - qt_defaultSharedContextMutex()->unlock(); - } else { - qt_defaultSharedContextMutex()->lock(); //wait to the the shared context is created - qt_defaultSharedContextMutex()->unlock(); - } - } - sharePlatformContext = QPlatformGLContext::defaultSharedContext(); - } else { - sharePlatformContext = format.sharedGLContext(); - } - mFormat.setSharedContext(sharePlatformContext); - EGLContext shareEGLContext = EGL_NO_CONTEXT; - if (sharePlatformContext) - shareEGLContext = static_cast(sharePlatformContext)->mContext; - - eglBindAPI(EGL_OPENGL_ES_API); - - QVector eglContextAttrs; - eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); - eglContextAttrs.append(2); - eglContextAttrs.append(EGL_NONE); - - mContext = eglCreateContext(mDisplay->eglDisplay(), mConfig, - shareEGLContext, eglContextAttrs.constData()); -} - -QWaylandGLContext::QWaylandGLContext() - : QPlatformGLContext() - , mDisplay(0) - , mContext(EGL_NO_CONTEXT) - , mSurface(EGL_NO_SURFACE) - , mConfig(0) -{ } - -QWaylandGLContext::~QWaylandGLContext() -{ - eglDestroyContext(mDisplay->eglDisplay(),mContext); -} - -void QWaylandGLContext::makeCurrent() -{ - QPlatformGLContext::makeCurrent(); - if (mSurface == EGL_NO_SURFACE) { - qWarning("makeCurrent with EGL_NO_SURFACE"); - } - eglMakeCurrent(mDisplay->eglDisplay(), mSurface, mSurface, mContext); -} - -void QWaylandGLContext::doneCurrent() -{ - QPlatformGLContext::doneCurrent(); - eglMakeCurrent(mDisplay->eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); -} - -void QWaylandGLContext::swapBuffers() -{ - eglSwapBuffers(mDisplay->eglDisplay(),mSurface); -} - -void *QWaylandGLContext::getProcAddress(const QString &string) -{ - return (void *) eglGetProcAddress(string.toLatin1().data()); -} - -void QWaylandGLContext::createDefaultSharedContex(QWaylandDisplay *display) -{ - QVector eglContextAttrs; - eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); - eglContextAttrs.append(2); - eglContextAttrs.append(EGL_NONE); - - QWaylandGLContext *defaultSharedContext = new QWaylandGLContext; - defaultSharedContext->mDisplay = display; - defaultSharedContext->mContext = eglCreateContext(mDisplay->eglDisplay(),mConfig, - EGL_NO_CONTEXT, eglContextAttrs.constData()); - QPlatformGLContext::setDefaultSharedContext(defaultSharedContext); -} - -void QWaylandGLContext::setEglSurface(EGLSurface surface) -{ - doneCurrent(); - mSurface = surface; -} - -EGLConfig QWaylandGLContext::eglConfig() const -{ - return mConfig; -} - diff --git a/src/plugins/platforms/wayland/qwaylandglcontext.h b/src/plugins/platforms/wayland/qwaylandglcontext.h deleted file mode 100644 index dd319fd..0000000 --- a/src/plugins/platforms/wayland/qwaylandglcontext.h +++ /dev/null @@ -1,81 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDGLCONTEXT_H -#define QWAYLANDGLCONTEXT_H - -#include "qwaylanddisplay.h" - -#include - -class QWaylandWindow; -class QWaylandDrmWindowSurface; - -#include "qwaylandinclude.h" - -class QWaylandGLContext : public QPlatformGLContext { -public: - QWaylandGLContext(QWaylandDisplay *wd, const QPlatformWindowFormat &format); - ~QWaylandGLContext(); - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString&); - - QPlatformWindowFormat platformWindowFormat() const { return mFormat; } - - void setEglSurface(EGLSurface surface); - EGLConfig eglConfig() const; -private: - QWaylandDisplay *mDisplay; - - EGLContext mContext; - EGLSurface mSurface; - EGLConfig mConfig; - QPlatformWindowFormat mFormat; - - void createDefaultSharedContex(QWaylandDisplay *display); - QWaylandGLContext(); - -}; - - -#endif // QWAYLANDGLCONTEXT_H diff --git a/src/plugins/platforms/wayland/qwaylandinclude.h b/src/plugins/platforms/wayland/qwaylandinclude.h deleted file mode 100644 index 0135251..0000000 --- a/src/plugins/platforms/wayland/qwaylandinclude.h +++ /dev/null @@ -1,63 +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 config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDINCLUDE_H -#define QWAYLANDINCLUDE_H - -#include - -#ifdef QT_WAYLAND_GL_SUPPORT -#include - -#define GL_GLEXT_PROTOTYPES -#include -#include - -#define EGL_EGLEXT_PROTOTYPES - #include - #include - -#else -typedef void* EGLDisplay; -typedef void* EGLConfig; -#endif - -#endif // QWAYLANDINCLUDE_H diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 267a037..be78b82 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -43,9 +43,7 @@ #include "qwaylanddisplay.h" #include "qwaylandshmsurface.h" -#include "qwaylanddrmsurface.h" #include "qwaylandshmwindow.h" -#include "qwaylandeglwindow.h" #include "qgenericunixfontdatabase.h" @@ -55,6 +53,8 @@ #include #ifdef QT_WAYLAND_GL_SUPPORT +#include "gl_integration/qwaylandglintegration.h" +#include "gl_integration/qwaylandglwindowsurface.h" #include #endif @@ -91,10 +91,11 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type) QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const { Q_UNUSED(winId); +#ifdef QT_WAYLAND_GL_SUPPORT bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL); if (useOpenGL) - return new QWaylandEglWindow(widget); - + return mDisplay->eglIntegration()->createEglWindow(widget); +#endif return new QWaylandShmWindow(widget); } @@ -102,10 +103,11 @@ QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId wi { Q_UNUSED(winId); Q_UNUSED(winId); +#ifdef QT_WAYLAND_GL_SUPPORT bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL); if (useOpenGL) - return new QWaylandDrmWindowSurface(widget); - + return new QWaylandGLWindowSurface(widget); +#endif return new QWaylandShmWindowSurface(widget); } diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h index 3b51ee7..afc214e 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.h +++ b/src/plugins/platforms/wayland/qwaylandwindow.h @@ -44,7 +44,6 @@ #include -#include #include "qwaylanddisplay.h" class QWaylandDisplay; diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index f78e4b3..b44857b 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -22,29 +22,21 @@ HEADERS = qwaylandintegration.h \ qwaylandwindow.h \ qwaylandscreen.h \ qwaylandshmsurface.h \ - qwaylanddrmsurface.h \ qwaylandbuffer.h \ - qwaylandinclude.h \ - qwaylandeglwindow.h \ qwaylandshmwindow.h INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND LIBS += $$QMAKE_LIBS_WAYLAND QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND +INCLUDEPATH += $$PWD + contains(QT_CONFIG, opengles2) { + DEFINES += QT_WAYLAND_GL_SUPPORT QT += opengl - LIBS += -lwayland-egl -lEGL - - SOURCES += qwaylanddrmsurface.cpp \ - qwaylandglcontext.cpp \ - ../eglconvenience/qeglconvenience.cpp \ - qwaylandeglwindow.cpp - HEADERS += qwaylandglcontext.h \ - ../eglconvenience/qeglconvenience.h \ - - DEFINES += QT_WAYLAND_GL_SUPPORT + CONFIG += wayland_egl + include ($$PWD/gl_integration/gl_integration.pri) } include (../fontdatabases/genericunix/genericunix.pri) -- cgit v0.12 From 11d327e3d2b90a8f1f68675cf1c93a67e26b273b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 23 Mar 2011 09:04:40 +0100 Subject: Lighthouse: Wayland: Move the frame throttling into the platform window This is only for the shm case --- src/plugins/platforms/wayland/qwaylandshmsurface.cpp | 19 ++++--------------- src/plugins/platforms/wayland/qwaylandshmwindow.cpp | 19 ++++++++++++++++--- src/plugins/platforms/wayland/qwaylandshmwindow.h | 5 ++++- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp index 54da9a1..cc6b2a1 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp @@ -95,7 +95,6 @@ QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window) : QWindowSurface(window) , mBuffer(0) , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) - , mWaitingForFrameSync(false) { } @@ -110,30 +109,20 @@ QPaintDevice *QWaylandShmWindowSurface::paintDevice() void QWaylandShmWindowSurface::beginPaint(const QRegion &) { - while (mWaitingForFrameSync) { + QWaylandShmWindow *waylandWindow = static_cast(window()->platformWindow()); + Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); + while (waylandWindow->waitingForFrameSync()) { mDisplay->iterate(); } } -void QWaylandShmWindowSurface::frameCallback(void *data, uint32_t time) -{ - QWaylandShmWindowSurface *self = static_cast(data); - self->mWaitingForFrameSync = false; -} - void QWaylandShmWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); Q_UNUSED(offset); QWaylandShmWindow *waylandWindow = static_cast(window()->platformWindow()); Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); - - QVector rects = region.rects(); - for (int i = 0; i < rects.size(); i++) { - waylandWindow->damage(rects.at(i)); - } - mWaitingForFrameSync = true; - mDisplay->frameCallback(QWaylandShmWindowSurface::frameCallback, this); + waylandWindow->damage(region); } void QWaylandShmWindowSurface::resize(const QSize &size) diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp index cafd2d0..d7c44a4 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp @@ -46,6 +46,7 @@ QWaylandShmWindow::QWaylandShmWindow(QWidget *widget) : QWaylandWindow(widget) , mBuffer(0) + , mWaitingForFrameSync(false) { newSurfaceCreated(); } @@ -75,10 +76,16 @@ void QWaylandShmWindow::attach(QWaylandBuffer *buffer) } -void QWaylandShmWindow::damage(const QRect &rect) +void QWaylandShmWindow::damage(const QRegion ®ion) { - wl_surface_damage(mSurface, - rect.x(), rect.y(), rect.width(), rect.height()); + QVector rects = region.rects(); + for (int i = 0; i < rects.size(); i++) { + const QRect rect = rects.at(i); + wl_surface_damage(mSurface, + rect.x(), rect.y(), rect.width(), rect.height()); + } + mWaitingForFrameSync = true; + mDisplay->frameCallback(QWaylandShmWindow::frameCallback, this); } void QWaylandShmWindow::newSurfaceCreated() @@ -87,3 +94,9 @@ void QWaylandShmWindow::newSurfaceCreated() wl_surface_attach(mSurface,mBuffer->buffer(),0,0); } } + +void QWaylandShmWindow::frameCallback(void *data, uint32_t time) +{ + QWaylandShmWindow *self = static_cast(data); + self->mWaitingForFrameSync = false; +} diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h index 14a29d2..669533c 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.h +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h @@ -53,11 +53,14 @@ public: WindowType windowType() const; QPlatformGLContext *glContext() const; void attach(QWaylandBuffer *buffer); - void damage(const QRect &rect); + void damage(const QRegion ®ion); + bool waitingForFrameSync() const { return mWaitingForFrameSync; } protected: void newSurfaceCreated(); private: + static void frameCallback(void *data, uint32_t time); QWaylandBuffer *mBuffer; + bool mWaitingForFrameSync; }; #endif // QWAYLANDSHMWINDOW_H -- cgit v0.12 From 60941f8fccca4406cbfee826df738bea3d5695d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 23 Mar 2011 16:57:11 +0100 Subject: Lighthouse: Wayland: Added a xpixmap readback glcontext It uses a x11 pixmap to render all gl content into, then reads it back using glReadPixels. Then it sends it over the wire like any other shm surface. --- .../platforms/eglconvenience/qeglconvenience.cpp | 4 +- .../platforms/eglconvenience/qeglconvenience.h | 2 +- .../wayland/gl_integration/gl_integration.pri | 4 + .../wayland/gl_integration/qwaylandglintegration.h | 3 +- .../gl_integration/qwaylandglwindowsurface.cpp | 2 +- .../wayland_egl/qwaylandeglintegration.cpp | 6 +- .../xpixmap_egl/qwaylandxpixmapeglcontext.cpp | 109 +++++++++++++++++++++ .../xpixmap_egl/qwaylandxpixmapeglcontext.h | 39 ++++++++ .../xpixmap_egl/qwaylandxpixmapeglintegration.cpp | 70 +++++++++++++ .../xpixmap_egl/qwaylandxpixmapeglintegration.h | 42 ++++++++ .../xpixmap_egl/qwaylandxpixmapwindow.cpp | 38 +++++++ .../xpixmap_egl/qwaylandxpixmapwindow.h | 27 +++++ .../gl_integration/xpixmap_egl/xpixmap_egl.pri | 14 +++ src/plugins/platforms/wayland/qwaylanddisplay.cpp | 2 +- src/plugins/platforms/wayland/qwaylanddisplay.h | 1 + src/plugins/platforms/wayland/qwaylandshmsurface.h | 3 - .../platforms/wayland/qwaylandshmwindow.cpp | 2 + src/plugins/platforms/wayland/qwaylandshmwindow.h | 1 + src/plugins/platforms/wayland/wayland.pro | 1 + 19 files changed, 359 insertions(+), 11 deletions(-) create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/xpixmap_egl.pri diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp index ec4577a..df7abc1 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp @@ -206,12 +206,12 @@ bool q_reduceConfigAttributes(QVector *configAttributes) return false; } -EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat) +EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType) { EGLConfig cfg = 0; QVector configureAttributes = q_createConfigAttributesFromFormat(format); configureAttributes.append(EGL_SURFACE_TYPE); //we only support eglconfigs for windows for now - configureAttributes.append(EGL_WINDOW_BIT); + configureAttributes.append(surfaceType); configureAttributes.append(EGL_RENDERABLE_TYPE); if (format.windowApi() == QPlatformWindowFormat::OpenVG) { diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h index fab1cb0..c7d3d61 100644 --- a/src/plugins/platforms/eglconvenience/qeglconvenience.h +++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE QVector q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format); bool q_reduceConfigAttributes(QVector *configAttributes); -EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat = false); +EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT); QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config); bool q_hasEglExtension(EGLDisplay display,const char* extensionName); diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index 8a792a5..ed2b021 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -10,4 +10,8 @@ wayland_egl { include ($$PWD/wayland_egl/wayland_egl.pri) } +xpixmap_egl { + include ($$PWD/xpixmap_egl/xpixmap_egl.pri) +} + diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h index a1f6b2c..52a663f 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h @@ -2,6 +2,7 @@ #define QWAYLANDGLINTEGRATION_H class QWaylandWindow; +class QWaylandDisplay; class QWidget; class QWaylandGLIntegration @@ -14,7 +15,7 @@ public: virtual QWaylandWindow *createEglWindow(QWidget *widget) = 0; - static QWaylandGLIntegration *createEglIntegration(struct wl_display *waylandDisplay); + static QWaylandGLIntegration *createEglIntegration(QWaylandDisplay *waylandDisplay); }; #endif // QWAYLANDGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp index ca9fb97..8c83128 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp @@ -175,7 +175,7 @@ void QWaylandGLWindowSurface::resize(const QSize &size) QWindowSurface::resize(size); window()->platformWindow()->glContext()->makeCurrent(); delete mPaintDevice; - mPaintDevice = new QGLFramebufferObject(size,QGLFramebufferObject::CombinedDepthStencil,GL_TEXTURE_2D,GL_RGBA); + mPaintDevice = new QGLFramebufferObject(size); } QT_END_NAMESPACE 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 eb46bc7..255fbfe 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -1,5 +1,7 @@ #include "qwaylandeglintegration.h" +#include "gl_integration/qwaylandglintegration.h" + #include "qwaylandeglwindow.h" QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay) @@ -42,7 +44,7 @@ wl_egl_display * QWaylandEglIntegration::nativeDisplay() const return mNativeEglDisplay; } -QWaylandGLIntegration *QWaylandGLIntegration::createEglIntegration(wl_display *waylandDisplay) +QWaylandGLIntegration *QWaylandGLIntegration::createEglIntegration(QWaylandDisplay *waylandDisplay) { - return new QWaylandEglIntegration(waylandDisplay); + return new QWaylandEglIntegration(waylandDisplay->wl_display()); } diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp new file mode 100644 index 0000000..e29ad97 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp @@ -0,0 +1,109 @@ +#include "qwaylandxpixmapeglcontext.h" + +#include "../../../eglconvenience/qeglconvenience.h" + +#include + +#include "qwaylandshmsurface.h" + +#include + +QXPixmapReadbackGLContext::QXPixmapReadbackGLContext(QWaylandXPixmapEglIntegration *eglIntegration, QWaylandXPixmapWindow *window) + : mEglIntegration(eglIntegration) + , mWindow(window) + , mBuffer(0) + , mPixmap(0) + , mConfig(q_configFromQPlatformWindowFormat(eglIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_PIXMAP_BIT)) + , mPixmapSurface(EGL_NO_SURFACE) +{ + QVector eglContextAttrs; + eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); + eglContextAttrs.append(2); + eglContextAttrs.append(EGL_NONE); + + mContext = eglCreateContext(eglIntegration->eglDisplay(),mConfig,0,eglContextAttrs.constData()); + + geometryChanged(); +} + +QXPixmapReadbackGLContext::~QXPixmapReadbackGLContext() +{ + eglDestroyContext(mEglIntegration->eglDisplay(),mContext); +} + +void QXPixmapReadbackGLContext::makeCurrent() +{ + QPlatformGLContext::makeCurrent(); + + while(mWindow->waitingForFrameSync()) { + mEglIntegration->waylandDisplay()->iterate(); + } + + eglMakeCurrent(mEglIntegration->eglDisplay(),mPixmapSurface,mPixmapSurface,mContext); +} + +void QXPixmapReadbackGLContext::doneCurrent() +{ + QPlatformGLContext::doneCurrent(); + eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT); +} + +void QXPixmapReadbackGLContext::swapBuffers() +{ + eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface); + + if (QPlatformGLContext::currentContext() != this) { + makeCurrent(); + } + + QSize size = mWindow->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); + + img = img.mirrored(); + constBits = img.bits(); + + const uchar *constDstBits = mBuffer->image()->bits(); + uchar *dstBits = const_cast(constDstBits); + memcpy(dstBits,constBits,(img.width()*4) * img.height()); + + + mWindow->damage(QRegion(QRect(QPoint(0,0),size))); +} + +void * QXPixmapReadbackGLContext::getProcAddress(const QString &procName) +{ + return (void *) eglGetProcAddress(procName.toLatin1().data()); +} + +QPlatformWindowFormat QXPixmapReadbackGLContext::platformWindowFormat() const +{ + return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); +} + +void QXPixmapReadbackGLContext::geometryChanged() +{ + while (mWindow->waitingForFrameSync()) + mEglIntegration->waylandDisplay()->iterate(); + + QSize size(mWindow->geometry().size()); + delete mBuffer; + if (mPixmap) + XFreePixmap(mEglIntegration->xDisplay(),mPixmap); + if (mPixmapSurface != EGL_NO_SURFACE) + eglDestroySurface(mEglIntegration->eglDisplay(),mPixmapSurface); + + mBuffer = new QWaylandShmBuffer(mEglIntegration->waylandDisplay(),size,QImage::Format_ARGB32); + mWindow->attach(mBuffer); + mPixmap = XCreatePixmap(mEglIntegration->xDisplay(),mEglIntegration->rootWindow(),size.width(),size.height(),mEglIntegration->depth()); + XSync(mEglIntegration->xDisplay(),False); + + mPixmapSurface = eglCreatePixmapSurface(mEglIntegration->eglDisplay(),mConfig,mPixmap,0); + if (mPixmapSurface == EGL_NO_SURFACE) { + qDebug() << "Could not make egl surface out of pixmap :("; + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h new file mode 100644 index 0000000..e6c6e8d --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h @@ -0,0 +1,39 @@ +#ifndef QXPIXMAPREADBACKGLCONTEXT_H +#define QXPIXMAPREADBACKGLCONTEXT_H + +#include +#include + +#include "qwaylandxpixmapeglintegration.h" +#include "qwaylandxpixmapwindow.h" + +class QWaylandShmBuffer; + +class QXPixmapReadbackGLContext : public QPlatformGLContext +{ +public: + QXPixmapReadbackGLContext(QWaylandXPixmapEglIntegration *eglIntegration, QWaylandXPixmapWindow *window); + ~QXPixmapReadbackGLContext(); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + + virtual QPlatformWindowFormat platformWindowFormat() const; + + void geometryChanged(); + +private: + QWaylandXPixmapEglIntegration *mEglIntegration; + QWaylandXPixmapWindow *mWindow; + QWaylandShmBuffer *mBuffer; + + Pixmap mPixmap; + + EGLConfig mConfig; + EGLContext mContext; + EGLSurface mPixmapSurface; +}; + +#endif // QXPIXMAPREADBACKGLCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp new file mode 100644 index 0000000..c9f244c --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp @@ -0,0 +1,70 @@ +#include "qwaylandxpixmapeglintegration.h" + +#include + +#include "qwaylandxpixmapwindow.h" + +QWaylandXPixmapEglIntegration::QWaylandXPixmapEglIntegration(QWaylandDisplay *display) + : QWaylandGLIntegration() + , mWaylandDisplay(display) +{ + char *display_name = getenv("DISPLAY"); + mDisplay = XOpenDisplay(display_name); + mScreen = XDefaultScreen(mDisplay); + mRootWindow = XDefaultRootWindow(mDisplay); + XSync(mDisplay, False); +} + +QWaylandXPixmapEglIntegration::~QWaylandXPixmapEglIntegration() +{ + XCloseDisplay(mDisplay); +} + + +QWaylandGLIntegration *QWaylandGLIntegration::createEglIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandXPixmapEglIntegration(waylandDisplay); +} + +void QWaylandXPixmapEglIntegration::initialize() +{ + eglBindAPI(EGL_OPENGL_ES_API); + mEglDisplay = eglGetDisplay(mDisplay); + EGLint major, minor; + EGLBoolean initialized = eglInitialize(mEglDisplay,&major,&minor); + if (initialized) { + qDebug() << "EGL initialized successfully" << major << "," << minor; + } else { + qDebug() << "EGL could not initialized. All EGL and GL operations will fail"; + } +} + +QWaylandWindow * QWaylandXPixmapEglIntegration::createEglWindow(QWidget *widget) +{ + return new QWaylandXPixmapWindow(widget,this); +} + +EGLDisplay QWaylandXPixmapEglIntegration::eglDisplay() +{ + return mEglDisplay; +} + +Window QWaylandXPixmapEglIntegration::rootWindow() const +{ + return mRootWindow; +} + +int QWaylandXPixmapEglIntegration::depth() const +{ + return XDefaultDepth(mDisplay,mScreen); +} + +Display * QWaylandXPixmapEglIntegration::xDisplay() const +{ + return mDisplay; +} + +QWaylandDisplay * QWaylandXPixmapEglIntegration::waylandDisplay() const +{ + return mWaylandDisplay; +} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h new file mode 100644 index 0000000..534494b --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h @@ -0,0 +1,42 @@ +#ifndef QWAYLANDXPIXMAPEGLINTEGRATION_H +#define QWAYLANDXPIXMAPEGLINTEGRATION_H + +#include "gl_integration/qwaylandglintegration.h" + +#include +#include +#include +#include +#include + +#include + +#include +//#include (this); + that->mContext = new QXPixmapReadbackGLContext(mEglIntegration,that); + } + return mContext; +} + +void QWaylandXPixmapWindow::newSurfaceCreated() +{ +} + +void QWaylandXPixmapWindow::setGeometry(const QRect &rect) +{ + QPlatformWindow::setGeometry(rect); + + if (mContext) + mContext->geometryChanged(); +} + diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h new file mode 100644 index 0000000..919e29d --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h @@ -0,0 +1,27 @@ +#ifndef QWAYLANDXPIXMAPWINDOW_H +#define QWAYLANDXPIXMAPWINDOW_H + +#include "qwaylandshmwindow.h" +#include "qwaylandxpixmapeglintegration.h" + +class QXPixmapReadbackGLContext; + +class QWaylandXPixmapWindow : public QWaylandShmWindow +{ +public: + QWaylandXPixmapWindow(QWidget *window, QWaylandXPixmapEglIntegration *eglIntegration); + + WindowType windowType() const; + + QPlatformGLContext *glContext() const; + + void setGeometry(const QRect &rect); +protected: + void newSurfaceCreated(); + +private: + QWaylandXPixmapEglIntegration *mEglIntegration; + QXPixmapReadbackGLContext *mContext; +}; + +#endif // QWAYLANDXPIXMAPWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/xpixmap_egl.pri b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/xpixmap_egl.pri new file mode 100644 index 0000000..87e2d28 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/xpixmap_egl.pri @@ -0,0 +1,14 @@ + +LIBS += -lX11 -lXext -lEGL + +HEADERS += \ + gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h \ + gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h \ + gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h \ + $$PWD/../../../eglconvenience/qeglconvenience.h + +SOURCES += \ + gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp \ + gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp \ + gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp \ + $$PWD/../../../eglconvenience/qeglconvenience.cpp diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index eebc9de..22e38eb 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -190,7 +190,7 @@ QWaylandDisplay::QWaylandDisplay(void) QWaylandDisplay::displayHandleGlobal, this); #ifdef QT_WAYLAND_GL_SUPPORT - mEglIntegration = QWaylandGLIntegration::createEglIntegration(mDisplay); + mEglIntegration = QWaylandGLIntegration::createEglIntegration(this); #endif readEvents(); diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 535dcd6..fc26ad2 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -81,6 +81,7 @@ public: void iterate(); + struct wl_display *wl_display() const { return mDisplay; } public slots: void readEvents(void); void flushRequests(void); diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmsurface.h index 02b324a..b29ceaf 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.h +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.h @@ -74,11 +74,8 @@ public: void beginPaint(const QRegion &); private: - static void frameCallback(void *data, uint32_t time);\ - QWaylandShmBuffer *mBuffer; QWaylandDisplay *mDisplay; - bool mWaitingForFrameSync; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp index d7c44a4..2808ed6 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp @@ -43,6 +43,8 @@ #include "qwaylandbuffer.h" +#include + QWaylandShmWindow::QWaylandShmWindow(QWidget *widget) : QWaylandWindow(widget) , mBuffer(0) diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h index 669533c..3876c52 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.h +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h @@ -43,6 +43,7 @@ #define QWAYLANDSHMWINDOW_H #include "qwaylandwindow.h" +#include class QWaylandShmWindow : public QWaylandWindow { diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index b44857b..f2d9d6b 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -36,6 +36,7 @@ contains(QT_CONFIG, opengles2) { QT += opengl CONFIG += wayland_egl +# CONFIG += xpixmap_egl include ($$PWD/gl_integration/gl_integration.pri) } -- cgit v0.12 From 0579b6f43686b6dca17e2bf2b49bb39e81527a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 24 Mar 2011 09:54:26 +0100 Subject: Don't say we support _NET_WM_PING when we don't (xcb platform). Fixes graying out of windows on Compiz. --- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 017a902..30b700c 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -167,7 +167,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw) int propertyCount = 0; properties[propertyCount++] = atom(QXcbAtom::WM_DELETE_WINDOW); properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS); - properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); +// properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); -- cgit v0.12 From 8debf8fb8bc18dc4b125aa7ac1ee4980f5ac146c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 23 Mar 2011 17:11:28 +0100 Subject: Lighthouse: Wayland Fix naming bug in the glintegration --- src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h | 2 +- .../wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp | 2 +- .../gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp | 2 +- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h index 52a663f..16115d5 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h @@ -15,7 +15,7 @@ public: virtual QWaylandWindow *createEglWindow(QWidget *widget) = 0; - static QWaylandGLIntegration *createEglIntegration(QWaylandDisplay *waylandDisplay); + static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay); }; #endif // QWAYLANDGLINTEGRATION_H 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 255fbfe..1f77064 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -44,7 +44,7 @@ wl_egl_display * QWaylandEglIntegration::nativeDisplay() const return mNativeEglDisplay; } -QWaylandGLIntegration *QWaylandGLIntegration::createEglIntegration(QWaylandDisplay *waylandDisplay) +QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) { return new QWaylandEglIntegration(waylandDisplay->wl_display()); } diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp index c9f244c..a121900 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp @@ -21,7 +21,7 @@ QWaylandXPixmapEglIntegration::~QWaylandXPixmapEglIntegration() } -QWaylandGLIntegration *QWaylandGLIntegration::createEglIntegration(QWaylandDisplay *waylandDisplay) +QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) { return new QWaylandXPixmapEglIntegration(waylandDisplay); } diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 22e38eb..d54a0fe 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -190,7 +190,7 @@ QWaylandDisplay::QWaylandDisplay(void) QWaylandDisplay::displayHandleGlobal, this); #ifdef QT_WAYLAND_GL_SUPPORT - mEglIntegration = QWaylandGLIntegration::createEglIntegration(this); + mEglIntegration = QWaylandGLIntegration::createGLIntegration(this); #endif readEvents(); -- cgit v0.12 From bbdc68b95bcec6e1a369df6b99df8ea499284d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Mar 2011 09:57:38 +0100 Subject: Lighthouse: Wayland. Added glx backend for gl integration --- .../platforms/glxconvenience/glxconvenience.pri | 7 + .../platforms/glxconvenience/qglxconvenience.cpp | 202 +++++++++++++++++++++ .../platforms/glxconvenience/qglxconvenience.h | 15 ++ .../wayland/gl_integration/gl_integration.pri | 4 +- .../gl_integration/qwaylandglwindowsurface.cpp | 3 + .../xpixmap_egl/qwaylandxpixmapwindow.cpp | 4 - .../xpixmap_egl/qwaylandxpixmapwindow.h | 2 - .../xpixmap_glx/qwaylandxpixmapglxcontext.cpp | 98 ++++++++++ .../xpixmap_glx/qwaylandxpixmapglxcontext.h | 38 ++++ .../xpixmap_glx/qwaylandxpixmapglxintegration.cpp | 53 ++++++ .../xpixmap_glx/qwaylandxpixmapglxintegration.h | 39 ++++ .../xpixmap_glx/qwaylandxpixmapglxwindow.cpp | 32 ++++ .../xpixmap_glx/qwaylandxpixmapglxwindow.h | 24 +++ .../gl_integration/xpixmap_glx/xpixmap_glx.pri | 10 + src/plugins/platforms/wayland/wayland.pro | 12 +- 15 files changed, 533 insertions(+), 10 deletions(-) create mode 100644 src/plugins/platforms/glxconvenience/glxconvenience.pri create mode 100644 src/plugins/platforms/glxconvenience/qglxconvenience.cpp create mode 100644 src/plugins/platforms/glxconvenience/qglxconvenience.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri diff --git a/src/plugins/platforms/glxconvenience/glxconvenience.pri b/src/plugins/platforms/glxconvenience/glxconvenience.pri new file mode 100644 index 0000000..5734ff7 --- /dev/null +++ b/src/plugins/platforms/glxconvenience/glxconvenience.pri @@ -0,0 +1,7 @@ +INCLUDEPATH = $$PWD + +HEADERS += \ + $$PWD/qglxconvenience.h + +SOURCES += \ + $$PWD/qglxconvenience.cpp diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp new file mode 100644 index 0000000..5088691 --- /dev/null +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp @@ -0,0 +1,202 @@ +#include "qglxconvenience.h" + +#include + +enum { + XFocusOut = FocusOut, + XFocusIn = FocusIn, + XKeyPress = KeyPress, + XKeyRelease = KeyRelease, + XNone = None, + XRevertToParent = RevertToParent, + XGrayScale = GrayScale, + XCursorShape = CursorShape +}; +#undef FocusOut +#undef FocusIn +#undef KeyPress +#undef KeyRelease +#undef None +#undef RevertToParent +#undef GrayScale +#undef CursorShape + +#ifdef FontChange +#undef FontChange +#endif + +QVector buildSpec(const QPlatformWindowFormat &format) +{ + QVector spec(48); + int i = 0; + + spec[i++] = GLX_LEVEL; + spec[i++] = 0; + spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT; + + if (format.rgba()) { + spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; + spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize(); + spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(); + spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(); + if (format.alpha()) { + spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); + } + + spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + + if (format.alpha()) { + spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); + } + + } else { + spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works.... + spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8; + } + + spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False; + spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False; + + if (format.depth()) { + spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); + } + + if (format.stencil()) { + spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); + } + if (format.sampleBuffers()) { + spec[i++] = GLX_SAMPLE_BUFFERS_ARB; + spec[i++] = 1; + spec[i++] = GLX_SAMPLES_ARB; + spec[i++] = format.samples() == -1 ? 4 : format.samples(); + } + + spec[i++] = XNone; + return spec; +} + +GLXFBConfig findConfig(Display *display, int screen , const QPlatformWindowFormat &format) +{ + bool reduced = true; + GLXFBConfig chosenConfig = 0; + QPlatformWindowFormat reducedFormat = format; + while (!chosenConfig && reduced) { + QVector spec = buildSpec(reducedFormat); + int confcount = 0; + GLXFBConfig *configs; + configs = glXChooseFBConfig(display, screen,spec.constData(),&confcount); + if (confcount) + { + for (int i = 0; i < confcount; i++) { + chosenConfig = configs[i]; + // Make sure we try to get an ARGB visual if the format asked for an alpha: + if (reducedFormat.alpha()) { + int alphaSize; + glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize); + if (alphaSize > 0) + break; + } else { + break; // Just choose the first in the list if there's no alpha requested + } + } + + XFree(configs); + } + reducedFormat = reducePlatformWindowFormat(reducedFormat,&reduced); + } + + if (!chosenConfig) + qWarning("Warning no context created"); + + return chosenConfig; +} + +XVisualInfo *findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format) +{ + GLXFBConfig config = findConfig(display,screen,format); + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display,config); + return visualInfo; +} + +QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) +{ + QPlatformWindowFormat format; + int redSize = 0; + int greenSize = 0; + int blueSize = 0; + int alphaSize = 0; + int depthSize = 0; + int stencilSize = 0; + int sampleBuffers = 0; + int sampleCount = 0; + int level = 0; + int rgba = 0; + int stereo = 0; + int accumSizeA = 0; + int accumSizeR = 0; + int accumSizeG = 0; + int accumSizeB = 0; + + XVisualInfo *vi = glXGetVisualFromFBConfig(display,config); + glXGetConfig(display,vi,GLX_RGBA,&rgba); + XFree(vi); + glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); + glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); + glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize); + glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize); + glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); + glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); + glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers); + glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level); + glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); + glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA); + glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR); + glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG); + glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB); + + format.setRedBufferSize(redSize); + format.setGreenBufferSize(greenSize); + format.setBlueBufferSize(blueSize); + format.setAlphaBufferSize(alphaSize); + format.setDepthBufferSize(depthSize); + format.setStencilBufferSize(stencilSize); + format.setSampleBuffers(sampleBuffers); + if (format.sampleBuffers()) { + glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); + format.setSamples(sampleCount); + } + + format.setDirectRendering(glXIsDirect(display, ctx)); + format.setRgba(rgba); + format.setStereo(stereo); + format.setAccumBufferSize(accumSizeB); + + return format; +} + +QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) +{ + QPlatformWindowFormat retFormat = format; + *reduced = true; + + if (retFormat.sampleBuffers()) { + retFormat.setSampleBuffers(false); + } else if (retFormat.stereo()) { + retFormat.setStereo(false); + } else if (retFormat.accum()) { + retFormat.setAccum(false); + }else if (retFormat.stencil()) { + retFormat.setStencil(false); + }else if (retFormat.alpha()) { + retFormat.setAlpha(false); + }else if (retFormat.depth()) { + retFormat.setDepth(false); + }else if (retFormat.doubleBuffer()) { + retFormat.setDoubleBuffer(false); + }else{ + *reduced = false; + } + return retFormat; +} diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.h b/src/plugins/platforms/glxconvenience/qglxconvenience.h new file mode 100644 index 0000000..b2a775e --- /dev/null +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.h @@ -0,0 +1,15 @@ +#ifndef QGLXCONVENIENCE_H +#define QGLXCONVENIENCE_H + +#include + +#include +#include + +XVisualInfo *findVisualInfo(const Display *display, int screen, const QPlatformWindowFormat &format); +GLXFBConfig findConfig(Display *display, int screen, const QPlatformWindowFormat &format); +QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); +QVector buildSpec(const QPlatformWindowFormat &format); +QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); + +#endif // QGLXCONVENIENCE_H diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index ed2b021..10567cd 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -14,4 +14,6 @@ xpixmap_egl { include ($$PWD/xpixmap_egl/xpixmap_egl.pri) } - +xpixmap_glx { + include ($$PWD/xpixmap_glx/xpixmap_glx.pri) +} diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp index 8c83128..ebe4c7b 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp @@ -54,6 +54,9 @@ 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) diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp index add30d8..35ce41a 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp @@ -24,10 +24,6 @@ QPlatformGLContext *QWaylandXPixmapWindow::glContext() const return mContext; } -void QWaylandXPixmapWindow::newSurfaceCreated() -{ -} - void QWaylandXPixmapWindow::setGeometry(const QRect &rect) { QPlatformWindow::setGeometry(rect); diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h index 919e29d..1f10112 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h @@ -16,8 +16,6 @@ public: QPlatformGLContext *glContext() const; void setGeometry(const QRect &rect); -protected: - void newSurfaceCreated(); private: QWaylandXPixmapEglIntegration *mEglIntegration; diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp new file mode 100644 index 0000000..c8b5fba --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp @@ -0,0 +1,98 @@ +#include "qwaylandxpixmapglxcontext.h" + +#include "qwaylandshmsurface.h" +#include "qwaylandxpixmapglxwindow.h" + +#include + +QWaylandXPixmapGLXContext::QWaylandXPixmapGLXContext(QWaylandXPixmapGLXIntegration *glxIntegration, QWaylandXPixmapGLXWindow *window) + : QPlatformGLContext() + , mGlxIntegration(glxIntegration) + , mWindow(window) + , mBuffer(0) + , mPixmap(0) + , mConfig(findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat())) + , mGlxPixmap(0) +{ + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); + mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE); + + geometryChanged(); +} + +void QWaylandXPixmapGLXContext::makeCurrent() +{ + QPlatformGLContext::makeCurrent(); + + while(mWindow->waitingForFrameSync()) { + mGlxIntegration->waylandDisplay()->iterate(); + } + + glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext); +} + +void QWaylandXPixmapGLXContext::doneCurrent() +{ + QPlatformGLContext::doneCurrent(); +} + +void QWaylandXPixmapGLXContext::swapBuffers() +{ + if (QPlatformGLContext::currentContext() != this) { + makeCurrent(); + } + + QSize size = mWindow->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); + + img = img.mirrored(); + constBits = img.bits(); + + const uchar *constDstBits = mBuffer->image()->bits(); + uchar *dstBits = const_cast(constDstBits); + memcpy(dstBits,constBits,(img.width()*4) * img.height()); + + + mWindow->damage(QRegion(QRect(QPoint(0,0),size))); + +} + +void * QWaylandXPixmapGLXContext::getProcAddress(const QString &procName) +{ + return (void *) glXGetProcAddress(reinterpret_cast(procName.toLatin1().data())); +} + +QPlatformWindowFormat QWaylandXPixmapGLXContext::platformWindowFormat() const +{ + return platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); +} + +void QWaylandXPixmapGLXContext::geometryChanged() +{ + while (mWindow->waitingForFrameSync()) + mGlxIntegration->waylandDisplay()->iterate(); + + QSize size(mWindow->geometry().size()); + delete mBuffer; + if (mPixmap) + XFreePixmap(mGlxIntegration->xDisplay(),mPixmap); + if (mGlxPixmap) + glXDestroyPixmap(mGlxIntegration->xDisplay(),mGlxPixmap); + + 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 :("; + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h new file mode 100644 index 0000000..c4c3796 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h @@ -0,0 +1,38 @@ +#ifndef QWAYLANDXPIXMAPGLXCONTEXT_H +#define QWAYLANDXPIXMAPGLXCONTEXT_H + +#include + +#include "qwaylandxpixmapglxintegration.h" + +#include "qglxconvenience.h" + +class QWaylandXPixmapGLXWindow; +class QWaylandShmBuffer; + +class QWaylandXPixmapGLXContext : public QPlatformGLContext +{ +public: + QWaylandXPixmapGLXContext(QWaylandXPixmapGLXIntegration *glxIntegration, QWaylandXPixmapGLXWindow *window); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + + QPlatformWindowFormat platformWindowFormat() const; + + void geometryChanged(); + +private: + QWaylandXPixmapGLXIntegration *mGlxIntegration; + QWaylandXPixmapGLXWindow *mWindow; + QWaylandShmBuffer *mBuffer; + + Pixmap mPixmap; + GLXFBConfig mConfig; + GLXContext mContext; + GLXPixmap mGlxPixmap; +}; + +#endif // QWAYLANDXPIXMAPGLXCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp new file mode 100644 index 0000000..17593d7 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp @@ -0,0 +1,53 @@ +#include "qwaylandxpixmapglxintegration.h" + +#include "qwaylandxpixmapglxwindow.h" + +QWaylandXPixmapGLXIntegration::QWaylandXPixmapGLXIntegration(QWaylandDisplay * waylandDispaly) + : QWaylandGLIntegration() + , mWaylandDisplay(waylandDispaly) +{ + char *display_name = getenv("DISPLAY"); + mDisplay = XOpenDisplay(display_name); + mScreen = XDefaultScreen(mDisplay); + mRootWindow = XDefaultRootWindow(mDisplay); + XSync(mDisplay, False); +} + +QWaylandXPixmapGLXIntegration::~QWaylandXPixmapGLXIntegration() +{ + XCloseDisplay(mDisplay); +} + +void QWaylandXPixmapGLXIntegration::initialize() +{ +} + +QWaylandWindow * QWaylandXPixmapGLXIntegration::createEglWindow(QWidget *widget) +{ + return new QWaylandXPixmapGLXWindow(widget,this); +} + +QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandXPixmapGLXIntegration(waylandDisplay); +} + +Display * QWaylandXPixmapGLXIntegration::xDisplay() const +{ + return mDisplay; +} + +int QWaylandXPixmapGLXIntegration::screen() const +{ + return mScreen; +} + +Window QWaylandXPixmapGLXIntegration::rootWindow() const +{ + return mRootWindow; +} + +QWaylandDisplay * QWaylandXPixmapGLXIntegration::waylandDisplay() const +{ + return mWaylandDisplay; +} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h new file mode 100644 index 0000000..c48abb4 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h @@ -0,0 +1,39 @@ +#ifndef QWAYLANDXPIXMAPGLXINTEGRATION_H +#define QWAYLANDXPIXMAPGLXINTEGRATION_H + +#include "gl_integration/qwaylandglintegration.h" + +#include +#include +#include +#include +#include + +#include + +class QWaylandXPixmapGLXIntegration : public QWaylandGLIntegration +{ +public: + QWaylandXPixmapGLXIntegration(QWaylandDisplay * waylandDispaly); + ~QWaylandXPixmapGLXIntegration(); + + void initialize(); + + QWaylandWindow *createEglWindow(QWidget *widget); + + QWaylandDisplay *waylandDisplay() const; + + Display *xDisplay() const; + int screen() const; + Window rootWindow() const; + +private: + QWaylandDisplay *mWaylandDisplay; + + Display *mDisplay; + int mScreen; + Window mRootWindow; + +}; + +#endif // QWAYLANDXPIXMAPGLXINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp new file mode 100644 index 0000000..a191320 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp @@ -0,0 +1,32 @@ +#include "qwaylandxpixmapglxwindow.h" + +QWaylandXPixmapGLXWindow::QWaylandXPixmapGLXWindow(QWidget *window, QWaylandXPixmapGLXIntegration *glxIntegration) + : QWaylandShmWindow(window) + , mGlxIntegration(glxIntegration) + , mContext(0) +{ +} + +QWaylandWindow::WindowType QWaylandXPixmapGLXWindow::windowType() const +{ + //yeah. this type needs a new name + return QWaylandWindow::Egl; +} + +QPlatformGLContext * QWaylandXPixmapGLXWindow::glContext() const +{ + if (!mContext) { + QWaylandXPixmapGLXWindow *that = const_cast(this); + that->mContext = new QWaylandXPixmapGLXContext(mGlxIntegration,that); + } + return mContext; +} + +void QWaylandXPixmapGLXWindow::setGeometry(const QRect &rect) +{ + QWaylandShmWindow::setGeometry(rect); + + if (mContext) { + mContext->geometryChanged(); + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h new file mode 100644 index 0000000..6aba21c --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h @@ -0,0 +1,24 @@ +#ifndef QWAYLANDXPIXMAPGLXWINDOW_H +#define QWAYLANDXPIXMAPGLXWINDOW_H + +#include "qwaylandshmwindow.h" +#include "qwaylandxpixmapglxintegration.h" +#include "qwaylandxpixmapglxcontext.h" + +class QWaylandXPixmapGLXWindow : public QWaylandShmWindow +{ +public: + QWaylandXPixmapGLXWindow(QWidget *window, QWaylandXPixmapGLXIntegration *glxIntegration); + WindowType windowType() const; + + QPlatformGLContext *glContext() const; + + void setGeometry(const QRect &rect); + +private: + QWaylandXPixmapGLXIntegration *mGlxIntegration; + QWaylandXPixmapGLXContext *mContext; + +}; + +#endif // QWAYLANDXPIXMAPGLXWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri new file mode 100644 index 0000000..07654df --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri @@ -0,0 +1,10 @@ +include (../../../glxconvenience/glxconvenience.pri) +HEADERS += \ + $$PWD/qwaylandxpixmapglxintegration.h \ + gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h \ + gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h + +SOURCES += \ + $$PWD/qwaylandxpixmapglxintegration.cpp \ + gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp \ + gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index f2d9d6b..45457fc 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -31,12 +31,18 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND INCLUDEPATH += $$PWD -contains(QT_CONFIG, opengles2) { +contains(QT_CONFIG, opengl) { DEFINES += QT_WAYLAND_GL_SUPPORT QT += opengl - CONFIG += wayland_egl -# CONFIG += xpixmap_egl + contains(QT_CONFIG, opengles2) { + CONFIG += wayland_egl + #CONFIG += xpixmap_egl + } else { + message("HELLO") + CONFIG += xpixmap_glx + } + include ($$PWD/gl_integration/gl_integration.pri) } -- cgit v0.12 From d7594cbb83f223ec4a56ba3d999412a1c0185937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 24 Mar 2011 10:35:24 +0100 Subject: Added missing -lX11 to xpixmap_glx wayland integration. --- .../platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri | 2 ++ src/plugins/platforms/wayland/wayland.pro | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri index 07654df..2b6ae0d 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri @@ -8,3 +8,5 @@ SOURCES += \ $$PWD/qwaylandxpixmapglxintegration.cpp \ gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp \ gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp + +LIBS += -lX11 diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 45457fc..e5c866b 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -39,7 +39,6 @@ contains(QT_CONFIG, opengl) { CONFIG += wayland_egl #CONFIG += xpixmap_egl } else { - message("HELLO") CONFIG += xpixmap_glx } -- cgit v0.12 From cfd32d1f590fff2545932347d0ff6081a4a4477a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Mar 2011 11:19:44 +0100 Subject: Lighthouse: Wayland: Make QGLWidget work with the glx integration Still missing same code for egl integration --- .../xpixmap_glx/qwaylandxpixmapglxcontext.cpp | 36 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp index c8b5fba..50bf4ee 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp @@ -5,6 +5,28 @@ #include +static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) +{ + const int width = img.width(); + const int height = img.height(); + + if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV + || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) + { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); + } + } else { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff); + } + } +} + QWaylandXPixmapGLXContext::QWaylandXPixmapGLXContext(QWaylandXPixmapGLXIntegration *glxIntegration, QWaylandXPixmapGLXWindow *window) : QPlatformGLContext() , mGlxIntegration(glxIntegration) @@ -51,6 +73,7 @@ void QWaylandXPixmapGLXContext::swapBuffers() 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 = mBuffer->image()->bits(); @@ -74,15 +97,20 @@ QPlatformWindowFormat QWaylandXPixmapGLXContext::platformWindowFormat() const void QWaylandXPixmapGLXContext::geometryChanged() { + QSize size(mWindow->geometry().size()); + if (size.isEmpty()) { + //QGLWidget wants a context for a window without geometry + size = QSize(1,1); + } + while (mWindow->waitingForFrameSync()) mGlxIntegration->waylandDisplay()->iterate(); - QSize size(mWindow->geometry().size()); delete mBuffer; - if (mPixmap) + //XFreePixmap deletes the glxPixmap as well + if (mPixmap) { XFreePixmap(mGlxIntegration->xDisplay(),mPixmap); - if (mGlxPixmap) - glXDestroyPixmap(mGlxIntegration->xDisplay(),mGlxPixmap); + } mBuffer = new QWaylandShmBuffer(mGlxIntegration->waylandDisplay(),size,QImage::Format_ARGB32); mWindow->attach(mBuffer); -- cgit v0.12 From 39ede7e7914b486d5971491dd742da3712a1d7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 24 Mar 2011 15:25:15 +0100 Subject: Lighthouse: Move glx common code into shared files --- .../fontdatabases/genericunix/genericunix.pri | 5 +- .../platforms/glxconvenience/glxconvenience.pri | 2 +- .../platforms/glxconvenience/qglxconvenience.cpp | 16 +- .../platforms/glxconvenience/qglxconvenience.h | 10 +- .../xpixmap_glx/qwaylandxpixmapglxcontext.cpp | 4 +- src/plugins/platforms/xcb/qglxintegration.cpp | 183 +-------------------- src/plugins/platforms/xcb/qglxintegration.h | 7 - src/plugins/platforms/xcb/qxcbwindow.cpp | 3 +- src/plugins/platforms/xcb/xcb.pro | 1 + src/plugins/platforms/xlib/qglxintegration.cpp | 183 +-------------------- src/plugins/platforms/xlib/qglxintegration.h | 7 - src/plugins/platforms/xlib/qxlibwindow.cpp | 3 +- src/plugins/platforms/xlib/xlib.pro | 1 + 13 files changed, 33 insertions(+), 392 deletions(-) diff --git a/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri b/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri index dbcfbce..7b0db41 100644 --- a/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri +++ b/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri @@ -5,6 +5,7 @@ contains(QT_CONFIG, fontconfig) { include(../basicunix/basicunix.pri) } -INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/genericunix +message("GENERIC UNIX") +INCLUDEPATH += $$PWD HEADERS += \ - $$QT_SOURCE_TREE/src/plugins/platforms/fontdatabases/genericunix/qgenericunixfontdatabase.h + $$PWD/qgenericunixfontdatabase.h diff --git a/src/plugins/platforms/glxconvenience/glxconvenience.pri b/src/plugins/platforms/glxconvenience/glxconvenience.pri index 5734ff7..d6c9922 100644 --- a/src/plugins/platforms/glxconvenience/glxconvenience.pri +++ b/src/plugins/platforms/glxconvenience/glxconvenience.pri @@ -1,4 +1,4 @@ -INCLUDEPATH = $$PWD +INCLUDEPATH += $$PWD HEADERS += \ $$PWD/qglxconvenience.h diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp index 5088691..08972f7 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp @@ -25,7 +25,7 @@ enum { #undef FontChange #endif -QVector buildSpec(const QPlatformWindowFormat &format) +QVector qglx_buildSpec(const QPlatformWindowFormat &format) { QVector spec(48); int i = 0; @@ -77,13 +77,13 @@ QVector buildSpec(const QPlatformWindowFormat &format) return spec; } -GLXFBConfig findConfig(Display *display, int screen , const QPlatformWindowFormat &format) +GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format) { bool reduced = true; GLXFBConfig chosenConfig = 0; QPlatformWindowFormat reducedFormat = format; while (!chosenConfig && reduced) { - QVector spec = buildSpec(reducedFormat); + QVector spec = qglx_buildSpec(reducedFormat); int confcount = 0; GLXFBConfig *configs; configs = glXChooseFBConfig(display, screen,spec.constData(),&confcount); @@ -104,7 +104,7 @@ GLXFBConfig findConfig(Display *display, int screen , const QPlatformWindowForma XFree(configs); } - reducedFormat = reducePlatformWindowFormat(reducedFormat,&reduced); + reducedFormat = qglx_reducePlatformWindowFormat(reducedFormat,&reduced); } if (!chosenConfig) @@ -113,14 +113,14 @@ GLXFBConfig findConfig(Display *display, int screen , const QPlatformWindowForma return chosenConfig; } -XVisualInfo *findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format) +XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format) { - GLXFBConfig config = findConfig(display,screen,format); + GLXFBConfig config = qglx_findConfig(display,screen,format); XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display,config); return visualInfo; } -QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) +QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) { QPlatformWindowFormat format; int redSize = 0; @@ -176,7 +176,7 @@ QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfi return format; } -QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) +QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) { QPlatformWindowFormat retFormat = format; *reduced = true; diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.h b/src/plugins/platforms/glxconvenience/qglxconvenience.h index b2a775e..a3cfd9a 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.h +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.h @@ -6,10 +6,10 @@ #include #include -XVisualInfo *findVisualInfo(const Display *display, int screen, const QPlatformWindowFormat &format); -GLXFBConfig findConfig(Display *display, int screen, const QPlatformWindowFormat &format); -QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); -QVector buildSpec(const QPlatformWindowFormat &format); -QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); +XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format); +GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format); +QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); +QVector qglx_buildSpec(const QPlatformWindowFormat &format); +QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); #endif // QGLXCONVENIENCE_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp index 50bf4ee..d5806bb 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp @@ -33,7 +33,7 @@ QWaylandXPixmapGLXContext::QWaylandXPixmapGLXContext(QWaylandXPixmapGLXIntegrati , mWindow(window) , mBuffer(0) , mPixmap(0) - , mConfig(findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat())) + , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat())) , mGlxPixmap(0) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); @@ -92,7 +92,7 @@ void * QWaylandXPixmapGLXContext::getProcAddress(const QString &procName) QPlatformWindowFormat QWaylandXPixmapGLXContext::platformWindowFormat() const { - return platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); + return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); } void QWaylandXPixmapGLXContext::geometryChanged() diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index e94b6a6..e086f91 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -51,6 +51,7 @@ #include #include "qglxintegration.h" +#include "qglxconvenience.h" #if defined(Q_OS_LINUX) || defined(Q_OS_BSD4) #include @@ -58,182 +59,6 @@ QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive); -QVector QGLXContext::buildSpec(const QPlatformWindowFormat &format) -{ - QVector spec(48); - int i = 0; - - spec[i++] = GLX_LEVEL; - spec[i++] = 0; - spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT; - - if (format.rgba()) { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; - spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize(); - spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(); - spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(); - if (format.alpha()) { - spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); - } - - spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - - if (format.alpha()) { - spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - } - - } else { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works.... - spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8; - } - - spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False; - spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False; - - if (format.depth()) { - spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); - } - - if (format.stencil()) { - spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); - } - if (format.sampleBuffers()) { - spec[i++] = GLX_SAMPLE_BUFFERS_ARB; - spec[i++] = 1; - spec[i++] = GLX_SAMPLES_ARB; - spec[i++] = format.samples() == -1 ? 4 : format.samples(); - } - - spec[i++] = None; - return spec; -} - -GLXFBConfig QGLXContext::findConfig(const QXcbScreen *screen, const QPlatformWindowFormat &format) -{ - bool reduced = true; - GLXFBConfig chosenConfig = 0; - QPlatformWindowFormat reducedFormat = format; - while (!chosenConfig && reduced) { - QVector spec = buildSpec(reducedFormat); - int confcount = 0; - GLXFBConfig *configs; - configs = glXChooseFBConfig(DISPLAY_FROM_XCB(screen), screen->screenNumber(), spec.constData(), &confcount); - if (confcount) - { - for (int i = 0; i < confcount; i++) { - chosenConfig = configs[i]; - // Make sure we try to get an ARGB visual if the format asked for an alpha: - if (reducedFormat.alpha()) { - int alphaSize; - glXGetFBConfigAttrib(DISPLAY_FROM_XCB(screen), configs[i], GLX_ALPHA_SIZE, &alphaSize); - if (alphaSize > 0) - break; - } else { - break; // Just choose the first in the list if there's no alpha requested - } - } - - XFree(configs); - } - reducedFormat = reducePlatformWindowFormat(reducedFormat,&reduced); - } - - if (!chosenConfig) - qWarning("Warning no context created"); - - return chosenConfig; -} - -XVisualInfo *QGLXContext::findVisualInfo(const QXcbScreen *screen, const QPlatformWindowFormat &format) -{ - GLXFBConfig config = QGLXContext::findConfig(screen,format); - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(DISPLAY_FROM_XCB(screen), config); - return visualInfo; -} - -QPlatformWindowFormat QGLXContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) -{ - QPlatformWindowFormat format; - int redSize = 0; - int greenSize = 0; - int blueSize = 0; - int alphaSize = 0; - int depthSize = 0; - int stencilSize = 0; - int sampleBuffers = 0; - int sampleCount = 0; - int level = 0; - int rgba = 0; - int stereo = 0; - int accumSizeA = 0; - int accumSizeR = 0; - int accumSizeG = 0; - int accumSizeB = 0; - - XVisualInfo *vi = glXGetVisualFromFBConfig(display,config); - glXGetConfig(display,vi,GLX_RGBA,&rgba); - XFree(vi); - glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); - glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); - glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize); - glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize); - glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); - glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); - glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers); - glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level); - glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB); - - format.setRedBufferSize(redSize); - format.setGreenBufferSize(greenSize); - format.setBlueBufferSize(blueSize); - format.setAlphaBufferSize(alphaSize); - format.setDepthBufferSize(depthSize); - format.setStencilBufferSize(stencilSize); - format.setSampleBuffers(sampleBuffers); - if (format.sampleBuffers()) { - glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); - format.setSamples(sampleCount); - } - - format.setDirectRendering(glXIsDirect(display, ctx)); - format.setRgba(rgba); - format.setStereo(stereo); - format.setAccumBufferSize(accumSizeB); - - return format; -} - -QPlatformWindowFormat QGLXContext::reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) -{ - QPlatformWindowFormat retFormat = format; - *reduced = true; - - if (retFormat.sampleBuffers()) { - retFormat.setSampleBuffers(false); - } else if (retFormat.stereo()) { - retFormat.setStereo(false); - } else if (retFormat.accum()) { - retFormat.setAccum(false); - }else if (retFormat.stencil()) { - retFormat.setStencil(false); - }else if (retFormat.alpha()) { - retFormat.setAlpha(false); - }else if (retFormat.depth()) { - retFormat.setDepth(false); - }else if (retFormat.doubleBuffer()) { - retFormat.setDoubleBuffer(false); - }else{ - *reduced = false; - } - return retFormat; -} - QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_screen(screen) @@ -260,9 +85,9 @@ QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindo if (sharePlatformContext) shareGlxContext = static_cast(sharePlatformContext)->glxContext(); - GLXFBConfig config = findConfig(screen,format); + GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format); m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE); - m_windowFormat = QGLXContext::platformWindowFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context); + m_windowFormat = qglx_platformWindowFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context); } QGLXContext::QGLXContext(QXcbScreen *screen, Drawable drawable, GLXContext context) @@ -286,7 +111,7 @@ void QGLXContext::createDefaultSharedContex(QXcbScreen *screen) QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat(); GLXContext context; - GLXFBConfig config = findConfig(screen,format); + GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format); if (config) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(DISPLAY_FROM_XCB(screen), config); Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(screen), screen->root(), visualInfo->visual, AllocNone); diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h index f2e20c4..c65a00a 100644 --- a/src/plugins/platforms/xcb/qglxintegration.h +++ b/src/plugins/platforms/xcb/qglxintegration.h @@ -66,14 +66,7 @@ public: QPlatformWindowFormat platformWindowFormat() const; - static XVisualInfo *findVisualInfo(const QXcbScreen *xd, const QPlatformWindowFormat &format); - private: - static GLXFBConfig findConfig(const QXcbScreen *xd,const QPlatformWindowFormat &format); - static QVector buildSpec(const QPlatformWindowFormat &format); - static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); - static QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); - QXcbScreen *m_screen; Drawable m_drawable; GLXContext m_context; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 30b700c..a016ccd 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -63,6 +63,7 @@ #if defined(XCB_USE_GLX) #include "qglxintegration.h" +#include "qglxconvenience.h" #elif defined(XCB_USE_EGL) #include "../eglconvenience/qeglplatformcontext.h" #include "../eglconvenience/qeglconvenience.h" @@ -112,7 +113,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw) if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL && QApplicationPrivate::platformIntegration()->hasOpenGL() ) { #if defined(XCB_USE_GLX) - XVisualInfo *visualInfo = QGLXContext::findVisualInfo(m_screen, tlw->platformWindowFormat()); + XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat()); #elif defined(XCB_USE_EGL) EGLDisplay eglDisplay = connection()->egl_display(); EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true); diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index fdbe2cd..122cb40 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -55,6 +55,7 @@ contains(QT_CONFIG, opengl) { LIBS += -lEGL } else { DEFINES += XCB_USE_GLX + include (../glxconvenience/glxconvenience.pri) HEADERS += qglxintegration.h SOURCES += qglxintegration.cpp } diff --git a/src/plugins/platforms/xlib/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp index 80011d9..9995f87 100644 --- a/src/plugins/platforms/xlib/qglxintegration.cpp +++ b/src/plugins/platforms/xlib/qglxintegration.cpp @@ -51,6 +51,7 @@ #include #include #include +#include "qglxconvenience.h" #include "qglxintegration.h" @@ -62,182 +63,6 @@ QT_BEGIN_NAMESPACE QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive); -QVector QGLXContext::buildSpec(const QPlatformWindowFormat &format) -{ - QVector spec(48); - int i = 0; - - spec[i++] = GLX_LEVEL; - spec[i++] = 0; - spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT; - - if (format.rgba()) { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; - spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize(); - spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(); - spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(); - if (format.alpha()) { - spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); - } - - spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - - if (format.alpha()) { - spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - } - - } else { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works.... - spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8; - } - - spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False; - spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False; - - if (format.depth()) { - spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); - } - - if (format.stencil()) { - spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); - } - if (format.sampleBuffers()) { - spec[i++] = GLX_SAMPLE_BUFFERS_ARB; - spec[i++] = 1; - spec[i++] = GLX_SAMPLES_ARB; - spec[i++] = format.samples() == -1 ? 4 : format.samples(); - } - - spec[i++] = XNone; - return spec; -} - -GLXFBConfig QGLXContext::findConfig(const QXlibScreen *screen, const QPlatformWindowFormat &format) -{ - bool reduced = true; - GLXFBConfig chosenConfig = 0; - QPlatformWindowFormat reducedFormat = format; - while (!chosenConfig && reduced) { - QVector spec = buildSpec(reducedFormat); - int confcount = 0; - GLXFBConfig *configs; - configs = glXChooseFBConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),spec.constData(),&confcount); - if (confcount) - { - for (int i = 0; i < confcount; i++) { - chosenConfig = configs[i]; - // Make sure we try to get an ARGB visual if the format asked for an alpha: - if (reducedFormat.alpha()) { - int alphaSize; - glXGetFBConfigAttrib(screen->display()->nativeDisplay(),configs[i],GLX_ALPHA_SIZE,&alphaSize); - if (alphaSize > 0) - break; - } else { - break; // Just choose the first in the list if there's no alpha requested - } - } - - XFree(configs); - } - reducedFormat = reducePlatformWindowFormat(reducedFormat,&reduced); - } - - if (!chosenConfig) - qWarning("Warning no context created"); - - return chosenConfig; -} - -XVisualInfo *QGLXContext::findVisualInfo(const QXlibScreen *screen, const QPlatformWindowFormat &format) -{ - GLXFBConfig config = QGLXContext::findConfig(screen,format); - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config); - return visualInfo; -} - -QPlatformWindowFormat QGLXContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) -{ - QPlatformWindowFormat format; - int redSize = 0; - int greenSize = 0; - int blueSize = 0; - int alphaSize = 0; - int depthSize = 0; - int stencilSize = 0; - int sampleBuffers = 0; - int sampleCount = 0; - int level = 0; - int rgba = 0; - int stereo = 0; - int accumSizeA = 0; - int accumSizeR = 0; - int accumSizeG = 0; - int accumSizeB = 0; - - XVisualInfo *vi = glXGetVisualFromFBConfig(display,config); - glXGetConfig(display,vi,GLX_RGBA,&rgba); - XFree(vi); - glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); - glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); - glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize); - glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize); - glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); - glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); - glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers); - glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level); - glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB); - - format.setRedBufferSize(redSize); - format.setGreenBufferSize(greenSize); - format.setBlueBufferSize(blueSize); - format.setAlphaBufferSize(alphaSize); - format.setDepthBufferSize(depthSize); - format.setStencilBufferSize(stencilSize); - format.setSampleBuffers(sampleBuffers); - if (format.sampleBuffers()) { - glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); - format.setSamples(sampleCount); - } - - format.setDirectRendering(glXIsDirect(display, ctx)); - format.setRgba(rgba); - format.setStereo(stereo); - format.setAccumBufferSize(accumSizeB); - - return format; -} - -QPlatformWindowFormat QGLXContext::reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) -{ - QPlatformWindowFormat retFormat = format; - *reduced = true; - - if (retFormat.sampleBuffers()) { - retFormat.setSampleBuffers(false); - } else if (retFormat.stereo()) { - retFormat.setStereo(false); - } else if (retFormat.accum()) { - retFormat.setAccum(false); - }else if (retFormat.stencil()) { - retFormat.setStencil(false); - }else if (retFormat.alpha()) { - retFormat.setAlpha(false); - }else if (retFormat.depth()) { - retFormat.setDepth(false); - }else if (retFormat.doubleBuffer()) { - retFormat.setDoubleBuffer(false); - }else{ - *reduced = false; - } - return retFormat; -} - QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_screen(screen) @@ -264,9 +89,9 @@ QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWind if (sharePlatformContext) shareGlxContext = static_cast(sharePlatformContext)->glxContext(); - GLXFBConfig config = findConfig(screen,format); + GLXFBConfig config = qglx_findConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),format); m_context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,shareGlxContext,TRUE); - m_windowFormat = QGLXContext::platformWindowFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context); + m_windowFormat = qglx_platformWindowFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context); #ifdef MYX11_DEBUG qDebug() << "QGLXGLContext::create context" << m_context; @@ -296,7 +121,7 @@ void QGLXContext::createDefaultSharedContex(QXlibScreen *screen) QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat(); GLXContext context; - GLXFBConfig config = findConfig(screen,format); + GLXFBConfig config = qglx_findConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),format); if (config) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config); Colormap cmap = XCreateColormap(screen->display()->nativeDisplay(),screen->rootWindow(),visualInfo->visual,AllocNone); diff --git a/src/plugins/platforms/xlib/qglxintegration.h b/src/plugins/platforms/xlib/qglxintegration.h index dbb5c2e..8a40527 100644 --- a/src/plugins/platforms/xlib/qglxintegration.h +++ b/src/plugins/platforms/xlib/qglxintegration.h @@ -69,14 +69,7 @@ public: QPlatformWindowFormat platformWindowFormat() const; - static XVisualInfo *findVisualInfo(const QXlibScreen *xd, const QPlatformWindowFormat &format); private: - static GLXFBConfig findConfig(const QXlibScreen *xd,const QPlatformWindowFormat &format); - static QVector buildSpec(const QPlatformWindowFormat &format); - static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); - static QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); - - QXlibScreen *m_screen; Drawable m_drawable; GLXContext m_context; diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index 01d4b8e..e9bcbf5 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -58,6 +58,7 @@ #if !defined(QT_NO_OPENGL) #if !defined(QT_OPENGL_ES_2) #include "qglxintegration.h" +#include "qglxconvenience.h" #else #include "../eglconvenience/qeglconvenience.h" #include "../eglconvenience/qeglplatformcontext.h" @@ -83,7 +84,7 @@ QXlibWindow::QXlibWindow(QWidget *window) && QApplicationPrivate::platformIntegration()->hasOpenGL() ) { #if !defined(QT_NO_OPENGL) #if !defined(QT_OPENGL_ES_2) - XVisualInfo *visualInfo = QGLXContext::findVisualInfo(mScreen,window->platformWindowFormat()); + XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(),mScreen->xScreenNumber(),window->platformWindowFormat()); #else QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat()); diff --git a/src/plugins/platforms/xlib/xlib.pro b/src/plugins/platforms/xlib/xlib.pro index 159fdbe..4cda1a7 100644 --- a/src/plugins/platforms/xlib/xlib.pro +++ b/src/plugins/platforms/xlib/xlib.pro @@ -39,6 +39,7 @@ include (../fontdatabases/genericunix/genericunix.pri) contains(QT_CONFIG, opengl) { QT += opengl !contains(QT_CONFIG, opengles2) { + include (../glxconvenience/glxconvenience.pri) HEADERS += qglxintegration.h SOURCES += qglxintegration.cpp } else { # There is no easy way to detect if we'r suppose to use glx or not -- cgit v0.12 From 31ca1ee427cce4dadb98e3091504db707346b0bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 24 Mar 2011 18:55:18 +0100 Subject: Prevent crash on exit by deleting QXcbWindow's GL context integration. --- src/plugins/platforms/xcb/qxcbwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index a016ccd..e33a661 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -195,6 +195,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw) QXcbWindow::~QXcbWindow() { + delete m_context; xcb_destroy_window(xcb_connection(), m_window); } -- cgit v0.12 From f55e9ff471a29eb4c8f0e1558bc5b0592686ddf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 25 Mar 2011 08:23:53 +0100 Subject: Lighthouse: Wayland: Print out what platformbackend we are using --- .../wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp | 4 ++++ .../gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp | 1 + .../gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h | 1 - .../gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) 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 1f77064..942e591 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -4,12 +4,16 @@ #include "qwaylandeglwindow.h" +#include + QWaylandEglIntegration::QWaylandEglIntegration(struct wl_display *waylandDisplay) : mWaylandDisplay(waylandDisplay) , mNativeEglDisplay(wl_egl_display_create(mWaylandDisplay)) { + qDebug() << "Using Wayland-EGL"; } + QWaylandEglIntegration::~QWaylandEglIntegration() { eglTerminate(mEglDisplay); diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp index a121900..8ccfc67 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp @@ -8,6 +8,7 @@ QWaylandXPixmapEglIntegration::QWaylandXPixmapEglIntegration(QWaylandDisplay *di : QWaylandGLIntegration() , mWaylandDisplay(display) { + qDebug() << "Using Wayland XPixmap-EGL"; char *display_name = getenv("DISPLAY"); mDisplay = XOpenDisplay(display_name); mScreen = XDefaultScreen(mDisplay); diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h index 534494b..9e7cb66 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h @@ -12,7 +12,6 @@ #include #include -//#include + QWaylandXPixmapGLXIntegration::QWaylandXPixmapGLXIntegration(QWaylandDisplay * waylandDispaly) : QWaylandGLIntegration() , mWaylandDisplay(waylandDispaly) { + qDebug() << "Using Wayland XPixmap-GLX"; char *display_name = getenv("DISPLAY"); mDisplay = XOpenDisplay(display_name); mScreen = XDefaultScreen(mDisplay); -- cgit v0.12 From 372539b350b8c48863d04e46438267210569768e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Fri, 25 Mar 2011 08:32:57 +0100 Subject: Lighthouse: Wayland: Fix the readback for the glContext in the egl backend --- .../xpixmap_egl/qwaylandxpixmapeglcontext.cpp | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp index e29ad97..32ba6de 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp @@ -3,11 +3,34 @@ #include "../../../eglconvenience/qeglconvenience.h" #include +#include #include "qwaylandshmsurface.h" #include +static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) +{ + const int width = img.width(); + const int height = img.height(); + + if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV + || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) + { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); + } + } else { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff); + } + } +} + QXPixmapReadbackGLContext::QXPixmapReadbackGLContext(QWaylandXPixmapEglIntegration *eglIntegration, QWaylandXPixmapWindow *window) : mEglIntegration(eglIntegration) , mWindow(window) @@ -65,6 +88,7 @@ void QXPixmapReadbackGLContext::swapBuffers() 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 = mBuffer->image()->bits(); @@ -87,15 +111,18 @@ QPlatformWindowFormat QXPixmapReadbackGLContext::platformWindowFormat() const void QXPixmapReadbackGLContext::geometryChanged() { + QSize size(mWindow->geometry().size()); + if (size.isEmpty()) { + //QGLWidget wants a context for a window without geometry + size = QSize(1,1); + } + while (mWindow->waitingForFrameSync()) mEglIntegration->waylandDisplay()->iterate(); - QSize size(mWindow->geometry().size()); delete mBuffer; if (mPixmap) XFreePixmap(mEglIntegration->xDisplay(),mPixmap); - if (mPixmapSurface != EGL_NO_SURFACE) - eglDestroySurface(mEglIntegration->eglDisplay(),mPixmapSurface); mBuffer = new QWaylandShmBuffer(mEglIntegration->waylandDisplay(),size,QImage::Format_ARGB32); mWindow->attach(mBuffer); -- cgit v0.12 From 3b37a79cd94bb0c03d7d8af0f20036ed60a7056f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 25 Mar 2011 10:59:50 +0100 Subject: Fixed GLX on Nvidia for XCB backend. We probably need to make sure the window is mapped before we start issuing GL commands. --- src/plugins/platforms/xcb/qxcbwindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index e33a661..b6c133f 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -219,6 +219,9 @@ void QXcbWindow::setVisible(bool visible) xcb_wm_hints_set_normal(&hints); xcb_set_wm_hints(xcb_connection(), m_window, &hints); xcb_map_window(xcb_connection(), m_window); +#if defined(XCB_USE_GLX) + glXWaitX(); +#endif } else { xcb_unmap_window(xcb_connection(), m_window); -- cgit v0.12 From c648418f82450f12de14b93d007c7564cd77a791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 25 Mar 2011 12:49:40 +0100 Subject: Fixed typo. --- .../wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp | 4 ++-- .../platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h | 2 +- src/plugins/platforms/xcb/qglxintegration.cpp | 4 ++-- src/plugins/platforms/xcb/qglxintegration.h | 2 +- src/plugins/platforms/xlib/qglxintegration.cpp | 4 ++-- src/plugins/platforms/xlib/qglxintegration.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) 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 4444229..89ba12b 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -63,7 +63,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindo if (format.useDefaultSharedContext()) { if (!QPlatformGLContext::defaultSharedContext()) { if (qt_defaultSharedContextMutex()->tryLock()){ - createDefaultSharedContex(eglDisplay); + createDefaultSharedContext(eglDisplay); qt_defaultSharedContextMutex()->unlock(); } else { qt_defaultSharedContextMutex()->lock(); //wait to the the shared context is created @@ -128,7 +128,7 @@ void *QWaylandGLContext::getProcAddress(const QString &string) return (void *) eglGetProcAddress(string.toLatin1().data()); } -void QWaylandGLContext::createDefaultSharedContex(EGLDisplay display) +void QWaylandGLContext::createDefaultSharedContext(EGLDisplay display) { QVector eglContextAttrs; eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); 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 d530b1c..a3befdc 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h @@ -72,7 +72,7 @@ private: EGLConfig mConfig; QPlatformWindowFormat mFormat; - void createDefaultSharedContex(EGLDisplay eglDisplay); + void createDefaultSharedContext(EGLDisplay eglDisplay); QWaylandGLContext(); }; diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index e086f91..bce3dfc 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -70,7 +70,7 @@ QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindo if (format.useDefaultSharedContext()) { if (!QPlatformGLContext::defaultSharedContext()) { if (m_defaultSharedContextMutex.tryLock()){ - createDefaultSharedContex(screen); + createDefaultSharedContext(screen); m_defaultSharedContextMutex.unlock(); } else { m_defaultSharedContextMutex.lock(); //wait to the the shared context is created @@ -102,7 +102,7 @@ QGLXContext::~QGLXContext() glXDestroyContext(DISPLAY_FROM_XCB(m_screen), m_context); } -void QGLXContext::createDefaultSharedContex(QXcbScreen *screen) +void QGLXContext::createDefaultSharedContext(QXcbScreen *screen) { int x = 0; int y = 0; diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h index c65a00a..2e19cf2 100644 --- a/src/plugins/platforms/xcb/qglxintegration.h +++ b/src/plugins/platforms/xcb/qglxintegration.h @@ -74,7 +74,7 @@ private: QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context); static QMutex m_defaultSharedContextMutex; - static void createDefaultSharedContex(QXcbScreen *xd); + static void createDefaultSharedContext(QXcbScreen *xd); }; #endif diff --git a/src/plugins/platforms/xlib/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp index 9995f87..6746e22 100644 --- a/src/plugins/platforms/xlib/qglxintegration.cpp +++ b/src/plugins/platforms/xlib/qglxintegration.cpp @@ -74,7 +74,7 @@ QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWind if (format.useDefaultSharedContext()) { if (!QPlatformGLContext::defaultSharedContext()) { if (m_defaultSharedContextMutex.tryLock()){ - createDefaultSharedContex(screen); + createDefaultSharedContext(screen); m_defaultSharedContextMutex.unlock(); } else { m_defaultSharedContextMutex.lock(); //wait to the the shared context is created @@ -112,7 +112,7 @@ QGLXContext::~QGLXContext() } } -void QGLXContext::createDefaultSharedContex(QXlibScreen *screen) +void QGLXContext::createDefaultSharedContext(QXlibScreen *screen) { int x = 0; int y = 0; diff --git a/src/plugins/platforms/xlib/qglxintegration.h b/src/plugins/platforms/xlib/qglxintegration.h index 8a40527..cf6b006 100644 --- a/src/plugins/platforms/xlib/qglxintegration.h +++ b/src/plugins/platforms/xlib/qglxintegration.h @@ -77,7 +77,7 @@ private: QGLXContext (QXlibScreen *screen, Drawable drawable, GLXContext context); static QMutex m_defaultSharedContextMutex; - static void createDefaultSharedContex(QXlibScreen *xd); + static void createDefaultSharedContext(QXlibScreen *xd); }; QT_END_NAMESPACE -- cgit v0.12 From d3fb49f36f1a3f3ecf8ffac0824ea70d8792a8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 28 Mar 2011 15:06:41 +0200 Subject: Xlib platform plugin also doesn't support PING protocol. --- src/plugins/platforms/xlib/qxlibwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index e9bcbf5..82e377c 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -137,7 +137,7 @@ QXlibWindow::QXlibWindow(QWidget *window) int n = 0; protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW); // support del window protocol protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_TAKE_FOCUS); // support take focus window protocol - protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_PING); // support _NET_WM_PING protocol +// protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_PING); // support _NET_WM_PING protocol #ifndef QT_NO_XSYNC protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_SYNC_REQUEST); // support _NET_WM_SYNC_REQUEST protocol #endif // QT_NO_XSYNC -- cgit v0.12 From 26012845b8b12b2e4d3b6138124f8647a6144d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 29 Mar 2011 14:32:48 +0200 Subject: Don't break on the first unhandled event in XCB plugin. Prevent the XCB event queue from growing indefinitely. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 191699b..2bdd6d4 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -247,7 +247,7 @@ void QXcbConnection::eventDispatcher() break; default: handled = false; - return; + break; } if (handled) printXcbEvent("Handled XCB event", event); -- cgit v0.12 From 2ac622fae920ac038e6d5afb4db9df2e3b896514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 29 Mar 2011 18:25:11 +0200 Subject: Threaded event handling and improved error reporting in XCB plugin. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 233 +++++++++++++++++++++++- src/plugins/platforms/xcb/qxcbconnection.h | 20 +- src/plugins/platforms/xcb/qxcbscreen.cpp | 3 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 44 ++--- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 18 ++ src/plugins/platforms/xcb/qxcbwindowsurface.h | 1 + 6 files changed, 284 insertions(+), 35 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 2bdd6d4..1ac73c9 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -76,6 +76,7 @@ extern "C" { QXcbConnection::QXcbConnection(const char *displayName) : m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY")) + , m_enabled(true) #ifdef XCB_USE_DRI2 , m_dri2_major(0) , m_dri2_minor(0) @@ -112,8 +113,11 @@ QXcbConnection::QXcbConnection(const char *displayName) xcb_screen_next(&it); } - QSocketNotifier *socket = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this); - connect(socket, SIGNAL(activated(int)), this, SLOT(eventDispatcher())); + m_connectionEventListener = xcb_generate_id(xcb_connection()); + xcb_create_window(xcb_connection(), XCB_COPY_FROM_PARENT, + m_connectionEventListener, m_screens.at(0)->root(), + 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY, + m_screens.at(0)->screen()->root_visual, 0, 0); m_keyboard = new QXcbKeyboard(this); @@ -122,10 +126,47 @@ QXcbConnection::QXcbConnection(const char *displayName) #ifdef XCB_USE_DRI2 initializeDri2(); #endif + + start(); +} + +void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom atom) +{ + xcb_client_message_event_t event; + memset(&event, 0, sizeof(event)); + + event.response_type = XCB_CLIENT_MESSAGE; + event.format = 32; + event.sequence = 0; + event.window = m_connectionEventListener; + event.type = atom; + + xcb_send_event(xcb_connection(), false, m_connectionEventListener, XCB_EVENT_MASK_NO_EVENT, (const char *)&event); + + xcb_flush(xcb_connection()); +} + +void QXcbConnection::setEventProcessingEnabled(bool enabled) +{ + if (enabled == m_enabled) + return; + + if (!enabled) { + m_connectionLock.lock(); + sendConnectionEvent(QXcbAtom::_QT_PAUSE_CONNECTION); + } else { + m_connectionLock.unlock(); + } + + m_enabled = enabled; } QXcbConnection::~QXcbConnection() { + sendConnectionEvent(QXcbAtom::_QT_CLOSE_CONNECTION); + wait(); + + xcb_destroy_window(xcb_connection(), m_connectionEventListener); qDeleteAll(m_screens); #ifdef XCB_USE_XLIB @@ -168,7 +209,7 @@ void printXcbEvent(const char *message, xcb_generic_event_t *event) #ifdef XCB_EVENT_DEBUG #define PRINT_XCB_EVENT(event) \ case event: \ - printf("%s: %d - %s\n", message, event, #event); \ + printf("%s: %d - %s\n", message, int(event), #event); \ break; switch (event->response_type & ~0x80) { @@ -205,7 +246,7 @@ void printXcbEvent(const char *message, xcb_generic_event_t *event) PRINT_XCB_EVENT(XCB_CLIENT_MESSAGE); PRINT_XCB_EVENT(XCB_MAPPING_NOTIFY); default: - printf("%s: %d - %s\n", message, event->response_type, "unknown"); + printf("%s: unknown event - response_type: %d - sequence: %d\n", message, int(event->response_type & ~0x80), int(event->sequence)); } #else Q_UNUSED(message); @@ -213,11 +254,185 @@ void printXcbEvent(const char *message, xcb_generic_event_t *event) #endif } -void QXcbConnection::eventDispatcher() +const char *xcb_errors[] = { - while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection())) { + "Success", + "BadRequest", + "BadValue", + "BadWindow", + "BadPixmap", + "BadAtom", + "BadCursor", + "BadFont", + "BadMatch", + "BadDrawable", + "BadAccess", + "BadAlloc", + "BadColor", + "BadGC", + "BadIDChoice", + "BadName", + "BadLength", + "BadImplementation", + "Unknown" +}; + +const char *xcb_protocol_request_codes[] = +{ + "CreateWindow", + "ChangeWindowAttributes", + "GetWindowAttributes", + "DestroyWindow", + "DestroySubwindows", + "ChangeSaveSet", + "ReparentWindow", + "MapWindow", + "MapSubwindows", + "UnmapWindow", + "UnmapSubwindows", + "ConfigureWindow", + "CirculateWindow", + "GetGeometry", + "QueryTree", + "InternAtom", + "GetAtomName", + "ChangeProperty", + "DeleteProperty", + "GetProperty", + "ListProperties", + "SetSelectionOwner", + "GetSelectionOwner", + "ConvertSelection", + "SendEvent", + "GrabPointer", + "UngrabPointer", + "GrabButton", + "UngrabButton", + "ChangeActivePointerGrab", + "GrabKeyboard", + "UngrabKeyboard", + "GrabKey", + "UngrabKey", + "AllowEvents", + "GrabServer", + "UngrabServer", + "QueryPointer", + "GetMotionEvents", + "TranslateCoords", + "WarpPointer", + "SetInputFocus", + "GetInputFocus", + "QueryKeymap", + "OpenFont", + "CloseFont", + "QueryFont", + "QueryTextExtents", + "ListFonts", + "ListFontsWithInfo", + "SetFontPath", + "GetFontPath", + "CreatePixmap", + "FreePixmap", + "CreateGC", + "ChangeGC", + "CopyGC", + "SetDashes", + "SetClipRectangles", + "FreeGC", + "ClearArea", + "CopyArea", + "CopyPlane", + "PolyPoint", + "PolyLine", + "PolySegment", + "PolyRectangle", + "PolyArc", + "FillPoly", + "PolyFillRectangle", + "PolyFillArc", + "PutImage", + "GetImage", + "PolyText8", + "PolyText16", + "ImageText8", + "ImageText16", + "CreateColormap", + "FreeColormap", + "CopyColormapAndFree", + "InstallColormap", + "UninstallColormap", + "ListInstalledColormaps", + "AllocColor", + "AllocNamedColor", + "AllocColorCells", + "AllocColorPlanes", + "FreeColors", + "StoreColors", + "StoreNamedColor", + "QueryColors", + "LookupColor", + "CreateCursor", + "CreateGlyphCursor", + "FreeCursor", + "RecolorCursor", + "QueryBestSize", + "QueryExtension", + "ListExtensions", + "ChangeKeyboardMapping", + "GetKeyboardMapping", + "ChangeKeyboardControl", + "GetKeyboardControl", + "Bell", + "ChangePointerControl", + "GetPointerControl", + "SetScreenSaver", + "GetScreenSaver", + "ChangeHosts", + "ListHosts", + "SetAccessControl", + "SetCloseDownMode", + "KillClient", + "RotateProperties", + "ForceScreenSaver", + "SetPointerMapping", + "GetPointerMapping", + "SetModifierMapping", + "GetModifierMapping", + "NoOperation", + "Unknown" +}; + +void QXcbConnection::run() +{ + while (xcb_generic_event_t *event = xcb_wait_for_event(xcb_connection())) { bool handled = true; - switch (event->response_type & ~0x80) { + + uint response_type = event->response_type & ~0x80; + + if (!response_type) { + xcb_generic_error_t *error = (xcb_generic_error_t *)event; + + uint clamped_error_code = qMin(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1); + uint clamped_major_code = qMin(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1); + + printf("XCB error: %d (%s), resource id: %d, major code: %d (%s), minor code: %d\n", + int(error->error_code), xcb_errors[clamped_error_code], int(error->resource_id), + int(error->major_code), xcb_protocol_request_codes[clamped_major_code], + int(error->minor_code)); + continue; + } + + if (response_type == XCB_CLIENT_MESSAGE + && ((xcb_client_message_event_t *)event)->type == QXcbAtom::_QT_CLOSE_CONNECTION) + return; + + if (response_type == XCB_CLIENT_MESSAGE + && ((xcb_client_message_event_t *)event)->type == QXcbAtom::_QT_PAUSE_CONNECTION) + { + QMutexLocker locker(&m_connectionLock); + } + + switch (response_type) { case XCB_EXPOSE: HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent); case XCB_BUTTON_PRESS: @@ -254,6 +469,7 @@ void QXcbConnection::eventDispatcher() else printXcbEvent("Unhandled XCB event", event); } + fprintf(stderr, "I/O error in xcb_wait_for_event\n"); } static const char * xcb_atomnames = { @@ -295,6 +511,9 @@ static const char * xcb_atomnames = { "_QT_SCROLL_DONE\0" "_QT_INPUT_ENCODING\0" + "_QT_CLOSE_CONNECTION\0" + "_QT_PAUSE_CONNECTION\0" + "_MOTIF_WM_HINTS\0" "DTWM_IS_RUNNING\0" diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index e00fbb1..a36694d 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -45,7 +45,8 @@ #include #include -#include +#include +#include class QXcbScreen; @@ -89,6 +90,10 @@ namespace QXcbAtom { _QT_SCROLL_DONE, _QT_INPUT_ENCODING, + // Qt/XCB specific + _QT_CLOSE_CONNECTION, + _QT_PAUSE_CONNECTION, + _MOTIF_WM_HINTS, DTWM_IS_RUNNING, @@ -214,7 +219,7 @@ namespace QXcbAtom { class QXcbKeyboard; -class QXcbConnection : public QObject +class QXcbConnection : public QThread { Q_OBJECT public: @@ -232,6 +237,8 @@ public: QXcbKeyboard *keyboard() const { return m_keyboard; } + void setEventProcessingEnabled(bool enabled); + #ifdef XCB_USE_XLIB void *xlib_display() const { return m_xlib_display; } #endif @@ -247,11 +254,12 @@ public: void *egl_display() const { return m_egl_display; } #endif -private slots: - void eventDispatcher(); +protected: + void run(); private: void initializeAllAtoms(); + void sendConnectionEvent(QXcbAtom::Atom atom); #ifdef XCB_USE_DRI2 void initializeDri2(); #endif @@ -266,6 +274,10 @@ private: QByteArray m_displayName; + xcb_window_t m_connectionEventListener; + QMutex m_connectionLock; + bool m_enabled; + QXcbKeyboard *m_keyboard; #if defined(XCB_USE_XLIB) diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index fffeb2e..49ed44c 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -60,8 +60,7 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int num const quint32 mask = XCB_CW_EVENT_MASK; const quint32 values[] = { // XCB_CW_EVENT_MASK - XCB_EVENT_MASK_KEYMAP_STATE - | XCB_EVENT_MASK_ENTER_WINDOW + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_PROPERTY_CHANGE }; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index b6c133f..54a4d7f 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -111,9 +111,11 @@ QXcbWindow::QXcbWindow(QWidget *tlw) #if defined(XCB_USE_GLX) || defined(XCB_USE_EGL) if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL - && QApplicationPrivate::platformIntegration()->hasOpenGL() ) { + && QApplicationPrivate::platformIntegration()->hasOpenGL()) + { + connection()->setEventProcessingEnabled(false); #if defined(XCB_USE_GLX) - XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat()); + XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat()); #elif defined(XCB_USE_EGL) EGLDisplay eglDisplay = connection()->egl_display(); EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true); @@ -127,19 +129,20 @@ QXcbWindow::QXcbWindow(QWidget *tlw) int matchingCount = 0; visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount); #endif //XCB_USE_GLX - if (visualInfo) { - Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone); - - XSetWindowAttributes a; - a.colormap = cmap; - m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(), - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); - - printf("created GL window: %d\n", m_window); - } else { - qFatal("no window!"); - } + if (visualInfo) { + Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone); + + XSetWindowAttributes a; + a.colormap = cmap; + m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(), + 0, visualInfo->depth, InputOutput, visualInfo->visual, + CWColormap, &a); + + printf("created GL window: %d\n", m_window); + } else { + qFatal("no window!"); + } + connection()->setEventProcessingEnabled(true); } else #endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL) { @@ -428,13 +431,12 @@ QPlatformGLContext *QXcbWindow::glContext() const printf("no opengl\n"); return 0; } -#if defined(XCB_USE_GLX) if (!m_context) { + connection()->setEventProcessingEnabled(false); +#if defined(XCB_USE_GLX) QXcbWindow *that = const_cast(this); that->m_context = new QGLXContext(m_window, m_screen, widget()->platformWindowFormat()); - } #elif defined(XCB_USE_EGL) - if (!m_context) { EGLDisplay display = connection()->egl_display(); EGLConfig config = q_configFromQPlatformWindowFormat(display,widget()->platformWindowFormat(),true); QVector eglContextAttrs; @@ -445,14 +447,12 @@ QPlatformGLContext *QXcbWindow::glContext() const EGLSurface eglSurface = eglCreateWindowSurface(display,config,(EGLNativeWindowType)m_window,0); QXcbWindow *that = const_cast(this); that->m_context = new QEGLPlatformContext(display, config, eglContextAttrs.data(), eglSurface, EGL_OPENGL_ES_API); - } #elif defined(XCB_USE_DRI2) - if (!m_context) { QXcbWindow *that = const_cast(this); that->m_context = new QDri2Context(that); - } - #endif + connection()->setEventProcessingEnabled(true); + } return m_context; } diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 7fed230..6bacf3d 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -44,6 +44,7 @@ #include "qxcbconnection.h" #include "qxcbscreen.h" #include "qxcbwindow.h" +#include "qmutex.h" #include #include @@ -64,6 +65,9 @@ public: void put(xcb_window_t window, const QPoint &dst, const QRect &source); void preparePaint(const QRegion ®ion); + void lock() { m_surfaceLock.lock(); } + void unlock() { m_surfaceLock.unlock(); } + private: void destroy(); @@ -77,6 +81,7 @@ private: xcb_window_t m_gc_window; QRegion m_dirty; + QMutex m_surfaceLock; }; QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size) @@ -174,9 +179,15 @@ QPaintDevice *QXcbWindowSurface::paintDevice() void QXcbWindowSurface::beginPaint(const QRegion ®ion) { + m_image->lock(); m_image->preparePaint(region); } +void QXcbWindowSurface::endPaint(const QRegion &) +{ + m_image->unlock(); +} + void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(region); @@ -187,9 +198,13 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi extern QWidgetData* qt_widget_data(QWidget *); QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft(); + m_image->lock(); + QVector rects = region.rects(); for (int i = 0; i < rects.size(); ++i) m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset)); + + m_image->unlock(); } void QXcbWindowSurface::resize(const QSize &size) @@ -198,6 +213,9 @@ void QXcbWindowSurface::resize(const QSize &size) QXcbScreen *screen = static_cast(QPlatformScreen::platformScreenForWidget(window())); + if (m_image) + m_image->lock(); + delete m_image; m_image = new QXcbShmImage(screen, size); } diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbwindowsurface.h index 61689b1..f87e122 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.h +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.h @@ -62,6 +62,7 @@ public: bool scroll(const QRegion &area, int dx, int dy); void beginPaint(const QRegion &); + void endPaint(const QRegion &); private: QXcbShmImage *m_image; -- cgit v0.12 From c25609217e99f890431c0170fea585b3e86822ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 09:53:55 +0200 Subject: Remove unnecessary setters in XCB plugin. These are the default settings in qwindowsurface.cpp anyway, and the explicit setters are about to be replaced by a features() function. --- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 6bacf3d..e1ebce2 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -161,9 +161,6 @@ QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface) : QWindowSurface(widget, setDefaultSurface) , m_image(0) { - setStaticContentsSupport(false); - setPartialUpdateSupport(true); - QXcbScreen *screen = static_cast(QPlatformScreen::platformScreenForWidget(widget)); setConnection(screen->connection()); } -- cgit v0.12 From b35988fe3299b2f76fb29507ca46298c2bef47df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 12:29:27 +0200 Subject: Added X error tracking to XCB platform. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 37 +++++++-- src/plugins/platforms/xcb/qxcbconnection.h | 32 ++++++- src/plugins/platforms/xcb/qxcbwindow.cpp | 106 ++++++++++++------------ src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 14 ++-- 4 files changed, 122 insertions(+), 67 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 1ac73c9..9924b1e 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -207,9 +207,9 @@ break; void printXcbEvent(const char *message, xcb_generic_event_t *event) { #ifdef XCB_EVENT_DEBUG -#define PRINT_XCB_EVENT(event) \ - case event: \ - printf("%s: %d - %s\n", message, int(event), #event); \ +#define PRINT_XCB_EVENT(ev) \ + case ev: \ + printf("%s: %d - %s - sequence: %d\n", message, int(ev), #ev, event->sequence); \ break; switch (event->response_type & ~0x80) { @@ -402,6 +402,16 @@ const char *xcb_protocol_request_codes[] = "Unknown" }; +void QXcbConnection::log(const char *file, int line, int sequence) +{ + CallInfo info; + info.sequence = sequence; + info.file = file; + info.line = line; + + m_callLog << info; +} + void QXcbConnection::run() { while (xcb_generic_event_t *event = xcb_wait_for_event(xcb_connection())) { @@ -415,13 +425,30 @@ void QXcbConnection::run() uint clamped_error_code = qMin(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1); uint clamped_major_code = qMin(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1); - printf("XCB error: %d (%s), resource id: %d, major code: %d (%s), minor code: %d\n", - int(error->error_code), xcb_errors[clamped_error_code], int(error->resource_id), + printf("XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d\n", + int(error->error_code), xcb_errors[clamped_error_code], + int(error->sequence), int(error->resource_id), int(error->major_code), xcb_protocol_request_codes[clamped_major_code], int(error->minor_code)); +#ifdef Q_XCB_DEBUG + for (int i = 0; i < m_callLog.size(); ++i) { + if (m_callLog.at(i).sequence == error->sequence) { + printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + break; + } + } +#endif continue; } +#ifdef Q_XCB_DEBUG + int i = 0; + for (; i < m_callLog.size(); ++i) + if (m_callLog.at(i).sequence >= event->sequence) + break; + m_callLog.remove(0, i); +#endif + if (response_type == XCB_CLIENT_MESSAGE && ((xcb_client_message_event_t *)event)->type == QXcbAtom::_QT_CLOSE_CONNECTION) return; diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index a36694d..0a7efd5 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -1,5 +1,4 @@ -/**************************************************************************** -** +/**************************************************************************** ** ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -46,8 +45,11 @@ #include #include +#include #include +#define Q_XCB_DEBUG + class QXcbScreen; namespace QXcbAtom { @@ -295,10 +297,36 @@ private: void *m_egl_display; bool m_has_egl; #endif +#ifdef Q_XCB_DEBUG + struct CallInfo { + int sequence; + QByteArray file; + int line; + }; + QVector m_callLog; + void log(const char *file, int line, int sequence); + template + friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); +#endif }; #define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display())) +#ifdef Q_XCB_DEBUG +template +cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line) +{ + connection->log(file, line, cookie.sequence); + return cookie; +} +#define Q_XCB_CALL(x) q_xcb_call_template(x, connection(), __FILE__, __LINE__) +#define Q_XCB_CALL2(x, connection) q_xcb_call_template(x, connection, __FILE__, __LINE__) +#else +#define Q_XCB_CALL(x) x +#define Q_XCB_CALL2(x, connection) x +#endif + + #if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL) #define EGL_DISPLAY_FROM_XCB(object) ((EGLDisplay)(object->connection()->egl_display())) #endif //endifXCB_USE_DRI2 diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 54a4d7f..710d531 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -148,24 +148,24 @@ QXcbWindow::QXcbWindow(QWidget *tlw) { m_window = xcb_generate_id(xcb_connection()); - xcb_create_window(xcb_connection(), - XCB_COPY_FROM_PARENT, // depth -- same as root - m_window, // window id - m_screen->root(), // parent window id - tlw->x(), - tlw->y(), - tlw->width(), - tlw->height(), - 0, // border width - XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class - m_screen->screen()->root_visual, // visual - 0, // value mask - 0); // value list + Q_XCB_CALL(xcb_create_window(xcb_connection(), + XCB_COPY_FROM_PARENT, // depth -- same as root + m_window, // window id + m_screen->root(), // parent window id + tlw->x(), + tlw->y(), + tlw->width(), + tlw->height(), + 0, // border width + XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class + m_screen->screen()->root_visual, // visual + 0, // value mask + 0)); // value list printf("created regular window: %d\n", m_window); } - xcb_change_window_attributes(xcb_connection(), m_window, mask, values); + Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values)); xcb_atom_t properties[4]; int propertyCount = 0; @@ -176,22 +176,22 @@ QXcbWindow::QXcbWindow(QWidget *tlw) if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); - xcb_change_property(xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_window, - atom(QXcbAtom::WM_PROTOCOLS), - 4, - 32, - propertyCount, - properties); + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_window, + atom(QXcbAtom::WM_PROTOCOLS), + 4, + 32, + propertyCount, + properties)); if (isTransient(tlw) && tlw->parentWidget()) { // ICCCM 4.1.2.6 QWidget *p = tlw->parentWidget()->window(); xcb_window_t parentWindow = p->winId(); - xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, - XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, - 1, &parentWindow); + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, + 1, &parentWindow)); } } @@ -199,7 +199,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw) QXcbWindow::~QXcbWindow() { delete m_context; - xcb_destroy_window(xcb_connection(), m_window); + Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); } void QXcbWindow::setGeometry(const QRect &rect) @@ -209,7 +209,7 @@ void QXcbWindow::setGeometry(const QRect &rect) const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; const quint32 values[] = { rect.x(), rect.y(), rect.width(), rect.height() }; - xcb_configure_window(xcb_connection(), m_window, mask, values); + Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); } void QXcbWindow::setVisible(bool visible) @@ -221,12 +221,12 @@ void QXcbWindow::setVisible(bool visible) else xcb_wm_hints_set_normal(&hints); xcb_set_wm_hints(xcb_connection(), m_window, &hints); - xcb_map_window(xcb_connection(), m_window); + Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); #if defined(XCB_USE_GLX) glXWaitX(); #endif } else { - xcb_unmap_window(xcb_connection(), m_window); + Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window)); // send synthetic UnmapNotify event according to icccm 4.1.4 xcb_unmap_notify_event_t event; @@ -235,8 +235,8 @@ void QXcbWindow::setVisible(bool visible) event.event = m_screen->root(); event.window = m_window; event.from_configure = false; - xcb_send_event(xcb_connection(), false, m_screen->root(), - XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event); + Q_XCB_CALL(xcb_send_event(xcb_connection(), false, m_screen->root(), + XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); xcb_flush(xcb_connection()); } @@ -360,23 +360,23 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags) } if (mwmhints.flags != 0l) { - xcb_change_property(xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_window, - atom(QXcbAtom::_MOTIF_WM_HINTS), - atom(QXcbAtom::_MOTIF_WM_HINTS), - 32, - 5, - &mwmhints); + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_window, + atom(QXcbAtom::_MOTIF_WM_HINTS), + atom(QXcbAtom::_MOTIF_WM_HINTS), + 32, + 5, + &mwmhints)); } else { - xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_MOTIF_WM_HINTS)); + Q_XCB_CALL(xcb_delete_property(xcb_connection(), m_window, atom(QXcbAtom::_MOTIF_WM_HINTS))); } if (popup || tooltip) { const quint32 mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER; const quint32 values[] = { true, true }; - xcb_change_window_attributes(xcb_connection(), m_window, mask, values); + Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values)); } return QPlatformWindow::setWindowFlags(flags); @@ -390,39 +390,39 @@ WId QXcbWindow::winId() const void QXcbWindow::setParent(const QPlatformWindow *parent) { QPoint topLeft = geometry().topLeft(); - xcb_reparent_window(xcb_connection(), window(), static_cast(parent)->window(), topLeft.x(), topLeft.y()); + Q_XCB_CALL(xcb_reparent_window(xcb_connection(), window(), static_cast(parent)->window(), topLeft.x(), topLeft.y())); } void QXcbWindow::setWindowTitle(const QString &title) { QByteArray ba = title.toUtf8(); - xcb_change_property (xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_window, - atom(QXcbAtom::_NET_WM_NAME), - atom(QXcbAtom::UTF8_STRING), - 8, - ba.length(), - ba.constData()); + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_window, + atom(QXcbAtom::_NET_WM_NAME), + atom(QXcbAtom::UTF8_STRING), + 8, + ba.length(), + ba.constData())); } void QXcbWindow::raise() { const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE; const quint32 values[] = { XCB_STACK_MODE_ABOVE }; - xcb_configure_window(xcb_connection(), m_window, mask, values); + Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); } void QXcbWindow::lower() { const quint32 mask = XCB_CONFIG_WINDOW_STACK_MODE; const quint32 values[] = { XCB_STACK_MODE_BELOW }; - xcb_configure_window(xcb_connection(), m_window, mask, values); + Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); } void QXcbWindow::requestActivateWindow() { - xcb_set_input_focus(xcb_connection(), m_window, XCB_INPUT_FOCUS_PARENT, XCB_TIME_CURRENT_TIME); + Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), m_window, XCB_INPUT_FOCUS_PARENT, XCB_TIME_CURRENT_TIME)); } QPlatformGLContext *QXcbWindow::glContext() const diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index e1ebce2..61239af 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -103,28 +103,27 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size) m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat (m_shm_info.shmid, 0, 0); m_shm_info.shmseg = xcb_generate_id(xcb_connection()); - xcb_shm_attach(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false); + Q_XCB_CALL(xcb_shm_attach(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false)); m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, screen->format()); } void QXcbShmImage::destroy() { - xcb_shm_detach(xcb_connection(), m_shm_info.shmseg); + Q_XCB_CALL(xcb_shm_detach(xcb_connection(), m_shm_info.shmseg)); xcb_image_destroy(m_xcb_image); shmdt(m_shm_info.shmaddr); shmctl(m_shm_info.shmid, IPC_RMID, 0); - - xcb_free_gc(xcb_connection(), m_gc); + Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); } void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &source) { if (m_gc_window != window) { - xcb_free_gc(xcb_connection(), m_gc); + Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); m_gc = xcb_generate_id(xcb_connection()); - xcb_create_gc(xcb_connection(), m_gc, window, 0, 0); + Q_XCB_CALL(xcb_create_gc(xcb_connection(), m_gc, window, 0, 0)); m_gc_window = window; } @@ -152,7 +151,8 @@ void QXcbShmImage::preparePaint(const QRegion ®ion) // to prevent X from reading from the image region while we're writing to it if (m_dirty.intersects(region)) { // from xcb_aux_sync - free(xcb_get_input_focus_reply(xcb_connection(), xcb_get_input_focus(xcb_connection()), 0)); + xcb_get_input_focus_cookie_t cookie = Q_XCB_CALL(xcb_get_input_focus(xcb_connection())); + free(xcb_get_input_focus_reply(xcb_connection(), cookie, 0)); m_dirty = QRegion(); } } -- cgit v0.12 From 725ed9f1c192e9c72ddfb2f34c28355ea2d0b769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 12:52:09 +0200 Subject: Protect access to the call log with a mutex. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 17 ++++++++++++----- src/plugins/platforms/xcb/qxcbconnection.h | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 9924b1e..794c0ef 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -402,6 +402,7 @@ const char *xcb_protocol_request_codes[] = "Unknown" }; +#ifdef Q_XCB_DEBUG void QXcbConnection::log(const char *file, int line, int sequence) { CallInfo info; @@ -409,8 +410,10 @@ void QXcbConnection::log(const char *file, int line, int sequence) info.file = file; info.line = line; + QMutexLocker locker(&m_callLogMutex); m_callLog << info; } +#endif void QXcbConnection::run() { @@ -431,6 +434,7 @@ void QXcbConnection::run() int(error->major_code), xcb_protocol_request_codes[clamped_major_code], int(error->minor_code)); #ifdef Q_XCB_DEBUG + QMutexLocker locker(&m_callLogMutex); for (int i = 0; i < m_callLog.size(); ++i) { if (m_callLog.at(i).sequence == error->sequence) { printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); @@ -442,11 +446,14 @@ void QXcbConnection::run() } #ifdef Q_XCB_DEBUG - int i = 0; - for (; i < m_callLog.size(); ++i) - if (m_callLog.at(i).sequence >= event->sequence) - break; - m_callLog.remove(0, i); + { + QMutexLocker locker(&m_callLogMutex); + int i = 0; + for (; i < m_callLog.size(); ++i) + if (m_callLog.at(i).sequence >= event->sequence) + break; + m_callLog.remove(0, i); + } #endif if (response_type == XCB_CLIENT_MESSAGE diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 0a7efd5..036670a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -304,6 +304,7 @@ private: int line; }; QVector m_callLog; + QMutex m_callLogMutex; void log(const char *file, int line, int sequence); template friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); -- cgit v0.12 From 9566b696026402f4c4b84ca0cd86126c84f89fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 12:54:49 +0200 Subject: Fixed off-by-one error in request name error logging in XCB platform. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 794c0ef..5b7d6d5 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -279,6 +279,7 @@ const char *xcb_errors[] = const char *xcb_protocol_request_codes[] = { + "Null", "CreateWindow", "ChangeWindowAttributes", "GetWindowAttributes", -- cgit v0.12 From 8af8a969ea7266ecdce4cbbc89c3e505074b5286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 12:57:21 +0200 Subject: Fixed X error in qxcbwindowsurface.cpp Don't free null GC. --- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 61239af..110aa10 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -120,7 +120,8 @@ void QXcbShmImage::destroy() void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &source) { if (m_gc_window != window) { - Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); + if (m_gc) + Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); m_gc = xcb_generate_id(xcb_connection()); Q_XCB_CALL(xcb_create_gc(xcb_connection(), m_gc, window, 0, 0)); -- cgit v0.12 From 5c0605f617aa3dd727853b92b7d1b1d46208646f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 14:04:40 +0200 Subject: Fixed synchronization issue in QXcbWindow. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 7 +++++++ src/plugins/platforms/xcb/qxcbconnection.h | 4 ++++ src/plugins/platforms/xcb/qxcbwindow.cpp | 1 + src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 4 +--- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 5b7d6d5..ffa6537 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -701,6 +701,13 @@ void QXcbConnection::initializeAllAtoms() { m_allAtoms[i] = xcb_intern_atom_reply(xcb_connection(), cookies[i], 0)->atom; } +void QXcbConnection::sync() +{ + // from xcb_aux_sync + xcb_get_input_focus_cookie_t cookie = Q_XCB_CALL(xcb_get_input_focus(xcb_connection())); + free(xcb_get_input_focus_reply(xcb_connection(), cookie, 0)); +} + #if defined(XCB_USE_EGL) bool QXcbConnection::hasEgl() const { diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 036670a..2723f26 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -228,6 +228,8 @@ public: QXcbConnection(const char *displayName = 0); ~QXcbConnection(); + QXcbConnection *connection() const { return const_cast(this); } + QList screens() const { return m_screens; } int primaryScreen() const { return m_primaryScreen; } @@ -256,6 +258,8 @@ public: void *egl_display() const { return m_egl_display; } #endif + void sync(); + protected: void run(); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 710d531..508755a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -423,6 +423,7 @@ void QXcbWindow::lower() void QXcbWindow::requestActivateWindow() { Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), m_window, XCB_INPUT_FOCUS_PARENT, XCB_TIME_CURRENT_TIME)); + connection()->sync(); } QPlatformGLContext *QXcbWindow::glContext() const diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 110aa10..8ab0140 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -151,9 +151,7 @@ void QXcbShmImage::preparePaint(const QRegion ®ion) { // to prevent X from reading from the image region while we're writing to it if (m_dirty.intersects(region)) { - // from xcb_aux_sync - xcb_get_input_focus_cookie_t cookie = Q_XCB_CALL(xcb_get_input_focus(xcb_connection())); - free(xcb_get_input_focus_reply(xcb_connection(), cookie, 0)); + connection()->sync(); m_dirty = QRegion(); } } -- cgit v0.12 From f64bd45a1595bd012dcaa6c3b7ffa778c084b5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 14:42:17 +0200 Subject: Unswapped arguments to xcb_set_input_focus. --- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 508755a..e997824 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -422,7 +422,7 @@ void QXcbWindow::lower() void QXcbWindow::requestActivateWindow() { - Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), m_window, XCB_INPUT_FOCUS_PARENT, XCB_TIME_CURRENT_TIME)); + Q_XCB_CALL(xcb_set_input_focus(xcb_connection(), XCB_INPUT_FOCUS_PARENT, m_window, XCB_TIME_CURRENT_TIME)); connection()->sync(); } -- cgit v0.12 From 98687d47cc64133856de187cfc2acace3f42652e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 15:37:12 +0200 Subject: Better error reporting in XCB platform. Try to report the interval of known calls between which the X error was generated, if we can't find a sequence match. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index ffa6537..22149f0 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -399,7 +399,6 @@ const char *xcb_protocol_request_codes[] = "GetPointerMapping", "SetModifierMapping", "GetModifierMapping", - "NoOperation", "Unknown" }; @@ -436,12 +435,20 @@ void QXcbConnection::run() int(error->minor_code)); #ifdef Q_XCB_DEBUG QMutexLocker locker(&m_callLogMutex); - for (int i = 0; i < m_callLog.size(); ++i) { + int i = 0; + for (; i < m_callLog.size(); ++i) { if (m_callLog.at(i).sequence == error->sequence) { printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); break; + } else if (m_callLog.at(i).sequence > error->sequence) { + printf("Caused some time before: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + if (i > 0) + printf("and after: %s:%d\n", qPrintable(m_callLog.at(i-1).file), m_callLog.at(i-1).line); + break; } } + if (i == m_callLog.size() && !m_callLog.isEmpty()) + printf("Caused some time after: %s:%d\n", qPrintable(m_callLog.first().file), m_callLog.first().line); #endif continue; } @@ -465,6 +472,7 @@ void QXcbConnection::run() && ((xcb_client_message_event_t *)event)->type == QXcbAtom::_QT_PAUSE_CONNECTION) { QMutexLocker locker(&m_connectionLock); + continue; } switch (response_type) { -- cgit v0.12 From b69d64dfe615bbbfbaf317debbab5b9933895b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 15:37:56 +0200 Subject: Prevent deadlock in XCB due to GLX calling XCB functions. --- src/plugins/platforms/xcb/qglxintegration.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index bce3dfc..d42cfeb 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -65,7 +65,6 @@ QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindo , m_drawable((Drawable)window) , m_context(0) { - const QPlatformGLContext *sharePlatformContext; if (format.useDefaultSharedContext()) { if (!QPlatformGLContext::defaultSharedContext()) { @@ -131,6 +130,7 @@ void QGLXContext::createDefaultSharedContext(QXcbScreen *screen) void QGLXContext::makeCurrent() { + m_screen->connection()->setEventProcessingEnabled(false); QPlatformGLContext::makeCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context); } @@ -139,11 +139,13 @@ void QGLXContext::doneCurrent() { QPlatformGLContext::doneCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0); + m_screen->connection()->setEventProcessingEnabled(true); } void QGLXContext::swapBuffers() { glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), m_drawable); + doneCurrent(); } void* QGLXContext::getProcAddress(const QString& procName) -- cgit v0.12 From a3524950a04329b7f37f0d1107902a59f86b2c3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 15:39:09 +0200 Subject: Fixed dead-locks in XCB window surface. Move the mutex lock into the window surface instead of belonging to the QXcbShmImage, which will be destroyed and recreated in resize(). --- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 21 ++++++++------------- src/plugins/platforms/xcb/qxcbwindowsurface.h | 3 +++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 8ab0140..c90ebb5 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -44,7 +44,6 @@ #include "qxcbconnection.h" #include "qxcbscreen.h" #include "qxcbwindow.h" -#include "qmutex.h" #include #include @@ -65,9 +64,6 @@ public: void put(xcb_window_t window, const QPoint &dst, const QRect &source); void preparePaint(const QRegion ®ion); - void lock() { m_surfaceLock.lock(); } - void unlock() { m_surfaceLock.unlock(); } - private: void destroy(); @@ -81,7 +77,6 @@ private: xcb_window_t m_gc_window; QRegion m_dirty; - QMutex m_surfaceLock; }; QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size) @@ -114,7 +109,8 @@ void QXcbShmImage::destroy() xcb_image_destroy(m_xcb_image); shmdt(m_shm_info.shmaddr); shmctl(m_shm_info.shmid, IPC_RMID, 0); - Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); + if (m_gc) + Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); } void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &source) @@ -175,13 +171,13 @@ QPaintDevice *QXcbWindowSurface::paintDevice() void QXcbWindowSurface::beginPaint(const QRegion ®ion) { - m_image->lock(); + m_surfaceLock.lock(); m_image->preparePaint(region); } void QXcbWindowSurface::endPaint(const QRegion &) { - m_image->unlock(); + m_surfaceLock.unlock(); } void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) @@ -189,18 +185,18 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi Q_UNUSED(region); Q_UNUSED(offset); + connection()->sync(); + QXcbWindow *window = static_cast(widget->window()->platformWindow()); extern QWidgetData* qt_widget_data(QWidget *); QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft(); - m_image->lock(); + QMutexLocker(&m_surfaceLock); QVector rects = region.rects(); for (int i = 0; i < rects.size(); ++i) m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset)); - - m_image->unlock(); } void QXcbWindowSurface::resize(const QSize &size) @@ -209,8 +205,7 @@ void QXcbWindowSurface::resize(const QSize &size) QXcbScreen *screen = static_cast(QPlatformScreen::platformScreenForWidget(window())); - if (m_image) - m_image->lock(); + QMutexLocker(&m_surfaceLock); delete m_image; m_image = new QXcbShmImage(screen, size); diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbwindowsurface.h index f87e122..e508fe6 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.h +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.h @@ -48,6 +48,8 @@ #include "qxcbobject.h" +#include + class QXcbShmImage; class QXcbWindowSurface : public QXcbObject, public QWindowSurface @@ -66,6 +68,7 @@ public: private: QXcbShmImage *m_image; + QMutex m_surfaceLock; }; #endif -- cgit v0.12 From 973cd5be8a980a6cb57dc719b05e4b99f8e6d3e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 15:59:34 +0200 Subject: Compile fix. --- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index c90ebb5..50be2c7 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -192,7 +192,7 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi extern QWidgetData* qt_widget_data(QWidget *); QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft(); - QMutexLocker(&m_surfaceLock); + QMutexLocker locker(&m_surfaceLock); QVector rects = region.rects(); for (int i = 0; i < rects.size(); ++i) @@ -205,7 +205,7 @@ void QXcbWindowSurface::resize(const QSize &size) QXcbScreen *screen = static_cast(QPlatformScreen::platformScreenForWidget(window())); - QMutexLocker(&m_surfaceLock); + QMutexLocker locker(&m_surfaceLock); delete m_image; m_image = new QXcbShmImage(screen, size); -- cgit v0.12 From 3cad0744477da31ab59ffb6d3baa498a369d5089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 16:05:10 +0200 Subject: Prevent dead-lock when quitting XCB application. Make sure event processing is enabled when we close the connection. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 22149f0..f1d3d2b 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -163,6 +163,8 @@ void QXcbConnection::setEventProcessingEnabled(bool enabled) QXcbConnection::~QXcbConnection() { + setEventProcessingEnabled(true); + sendConnectionEvent(QXcbAtom::_QT_CLOSE_CONNECTION); wait(); -- cgit v0.12 From ee481481bbd1d910c8a0191aa517f96186130d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 17:07:00 +0200 Subject: Removed superfluous sync in QXcbWindowSurface. --- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 50be2c7..dd28c31 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -185,8 +185,6 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi Q_UNUSED(region); Q_UNUSED(offset); - connection()->sync(); - QXcbWindow *window = static_cast(widget->window()->platformWindow()); extern QWidgetData* qt_widget_data(QWidget *); -- cgit v0.12 From faeabd9d202b1af002cd73da148ca4c27715470d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 31 Mar 2011 12:08:14 +0200 Subject: Fixed synchronizations issues in XCB platform plugin. Use select() and xcb_poll_for_event() instead of xcb_wait_for_event(), ad xcb_wait_for_event() will lock the XCB connection mutex, preventing the other thread from posting events etc. --- src/plugins/platforms/xcb/qglxintegration.cpp | 13 ++ src/plugins/platforms/xcb/qxcbconnection.cpp | 205 ++++++++++++++---------- src/plugins/platforms/xcb/qxcbconnection.h | 7 +- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 6 + src/plugins/platforms/xcb/qxcbwindow.cpp | 4 +- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 33 +++- 6 files changed, 170 insertions(+), 98 deletions(-) diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index d42cfeb..d1171b8 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -65,6 +65,7 @@ QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindo , m_drawable((Drawable)window) , m_context(0) { + Q_XCB_NOOP(m_screen->connection()); const QPlatformGLContext *sharePlatformContext; if (format.useDefaultSharedContext()) { if (!QPlatformGLContext::defaultSharedContext()) { @@ -87,6 +88,7 @@ QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindo GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format); m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE); m_windowFormat = qglx_platformWindowFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context); + Q_XCB_NOOP(m_screen->connection()); } QGLXContext::QGLXContext(QXcbScreen *screen, Drawable drawable, GLXContext context) @@ -97,12 +99,15 @@ QGLXContext::QGLXContext(QXcbScreen *screen, Drawable drawable, GLXContext conte QGLXContext::~QGLXContext() { + Q_XCB_NOOP(m_screen->connection()); if (m_context) glXDestroyContext(DISPLAY_FROM_XCB(m_screen), m_context); + Q_XCB_NOOP(m_screen->connection()); } void QGLXContext::createDefaultSharedContext(QXcbScreen *screen) { + Q_XCB_NOOP(screen->connection()); int x = 0; int y = 0; int w = 3; @@ -126,30 +131,38 @@ void QGLXContext::createDefaultSharedContext(QXcbScreen *screen) } else { qWarning("Warning no shared context created"); } + Q_XCB_NOOP(screen->connection()); } void QGLXContext::makeCurrent() { + Q_XCB_NOOP(m_screen->connection()); m_screen->connection()->setEventProcessingEnabled(false); QPlatformGLContext::makeCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context); + Q_XCB_NOOP(m_screen->connection()); } void QGLXContext::doneCurrent() { + Q_XCB_NOOP(m_screen->connection()); QPlatformGLContext::doneCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0); m_screen->connection()->setEventProcessingEnabled(true); + Q_XCB_NOOP(m_screen->connection()); } void QGLXContext::swapBuffers() { + Q_XCB_NOOP(m_screen->connection()); glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), m_drawable); doneCurrent(); + Q_XCB_NOOP(m_screen->connection()); } void* QGLXContext::getProcAddress(const QString& procName) { + Q_XCB_NOOP(m_screen->connection()); typedef void *(*qt_glXGetProcAddressARB)(const GLubyte *); static qt_glXGetProcAddressARB glXGetProcAddressARB = 0; static bool resolved = false; diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index f1d3d2b..05d3440 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -76,6 +76,7 @@ extern "C" { QXcbConnection::QXcbConnection(const char *displayName) : m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY")) + , m_pauseId(0) , m_enabled(true) #ifdef XCB_USE_DRI2 , m_dri2_major(0) @@ -130,7 +131,7 @@ QXcbConnection::QXcbConnection(const char *displayName) start(); } -void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom atom) +void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom atom, uint id) { xcb_client_message_event_t event; memset(&event, 0, sizeof(event)); @@ -140,9 +141,9 @@ void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom atom) event.sequence = 0; event.window = m_connectionEventListener; event.type = atom; + event.data.data32[0] = id; - xcb_send_event(xcb_connection(), false, m_connectionEventListener, XCB_EVENT_MASK_NO_EVENT, (const char *)&event); - + Q_XCB_CALL(xcb_send_event(xcb_connection(), false, m_connectionEventListener, XCB_EVENT_MASK_NO_EVENT, (const char *)&event)); xcb_flush(xcb_connection()); } @@ -152,10 +153,12 @@ void QXcbConnection::setEventProcessingEnabled(bool enabled) return; if (!enabled) { + sendConnectionEvent(QXcbAtom::_QT_PAUSE_CONNECTION, uint(m_pauseId)); m_connectionLock.lock(); - sendConnectionEvent(QXcbAtom::_QT_PAUSE_CONNECTION); + m_pauseId.fetchAndAddOrdered(1); } else { m_connectionLock.unlock(); + m_connectionWaitCondition.wakeAll(); } m_enabled = enabled; @@ -191,8 +194,11 @@ QXcbWindow *platformWindowFromId(xcb_window_t id) #define HANDLE_PLATFORM_WINDOW_EVENT(event_t, window, handler) \ { \ event_t *e = (event_t *)event; \ - if (QXcbWindow *platformWindow = platformWindowFromId(e->window)) \ - platformWindow->handler(e); \ + if (QXcbWindow *platformWindow = platformWindowFromId(e->window)) { \ + QObjectPrivate *d = QObjectPrivate::get(platformWindow->widget()); \ + if (!d->wasDeleted) \ + platformWindow->handler(e); \ + } \ } \ break; @@ -419,100 +425,118 @@ void QXcbConnection::log(const char *file, int line, int sequence) void QXcbConnection::run() { - while (xcb_generic_event_t *event = xcb_wait_for_event(xcb_connection())) { - bool handled = true; + QMutexLocker locker(&m_connectionLock); + fd_set readset; + int xcb_fd = xcb_get_file_descriptor(xcb_connection()); + FD_ZERO(&readset); + FD_SET(xcb_fd, &readset); + int result; + while (true) { + while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection())) { + bool handled = true; + + uint response_type = event->response_type & ~0x80; + + if (!response_type) { + xcb_generic_error_t *error = (xcb_generic_error_t *)event; + + uint clamped_error_code = qMin(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1); + uint clamped_major_code = qMin(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1); + + printf("XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d\n", + int(error->error_code), xcb_errors[clamped_error_code], + int(error->sequence), int(error->resource_id), + int(error->major_code), xcb_protocol_request_codes[clamped_major_code], + int(error->minor_code)); +#ifdef Q_XCB_DEBUG + QMutexLocker locker(&m_callLogMutex); + int i = 0; + for (; i < m_callLog.size(); ++i) { + if (m_callLog.at(i).sequence == error->sequence) { + printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + break; + } else if (m_callLog.at(i).sequence > error->sequence) { + printf("Caused some time before: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + if (i > 0) + printf("and after: %s:%d\n", qPrintable(m_callLog.at(i-1).file), m_callLog.at(i-1).line); + break; + } + } + if (i == m_callLog.size() && !m_callLog.isEmpty()) + printf("Caused some time after: %s:%d\n", qPrintable(m_callLog.first().file), m_callLog.first().line); +#endif + continue; + } - uint response_type = event->response_type & ~0x80; +#ifdef Q_XCB_DEBUG + { + QMutexLocker locker(&m_callLogMutex); + int i = 0; + for (; i < m_callLog.size(); ++i) + if (m_callLog.at(i).sequence >= event->sequence) + break; + m_callLog.remove(0, i); + } +#endif - if (!response_type) { - xcb_generic_error_t *error = (xcb_generic_error_t *)event; + if (response_type == XCB_CLIENT_MESSAGE) { + xcb_client_message_event_t *ev = (xcb_client_message_event_t *)event; - uint clamped_error_code = qMin(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1); - uint clamped_major_code = qMin(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1); + if (ev->type == QXcbAtom::_QT_CLOSE_CONNECTION) + return; - printf("XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d\n", - int(error->error_code), xcb_errors[clamped_error_code], - int(error->sequence), int(error->resource_id), - int(error->major_code), xcb_protocol_request_codes[clamped_major_code], - int(error->minor_code)); -#ifdef Q_XCB_DEBUG - QMutexLocker locker(&m_callLogMutex); - int i = 0; - for (; i < m_callLog.size(); ++i) { - if (m_callLog.at(i).sequence == error->sequence) { - printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); - break; - } else if (m_callLog.at(i).sequence > error->sequence) { - printf("Caused some time before: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); - if (i > 0) - printf("and after: %s:%d\n", qPrintable(m_callLog.at(i-1).file), m_callLog.at(i-1).line); - break; + if (ev->type == QXcbAtom::_QT_PAUSE_CONNECTION) { + if (ev->data.data32[0] == uint(m_pauseId)) + m_connectionWaitCondition.wait(&m_connectionLock); + continue; } } - if (i == m_callLog.size() && !m_callLog.isEmpty()) - printf("Caused some time after: %s:%d\n", qPrintable(m_callLog.first().file), m_callLog.first().line); -#endif - continue; - } -#ifdef Q_XCB_DEBUG - { - QMutexLocker locker(&m_callLogMutex); - int i = 0; - for (; i < m_callLog.size(); ++i) - if (m_callLog.at(i).sequence >= event->sequence) - break; - m_callLog.remove(0, i); + switch (response_type) { + case XCB_EXPOSE: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent); + case XCB_BUTTON_PRESS: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent); + case XCB_BUTTON_RELEASE: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent); + case XCB_MOTION_NOTIFY: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent); + case XCB_CONFIGURE_NOTIFY: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent); + case XCB_CLIENT_MESSAGE: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_client_message_event_t, window, handleClientMessageEvent); + case XCB_ENTER_NOTIFY: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent); + case XCB_LEAVE_NOTIFY: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent); + case XCB_FOCUS_IN: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent); + case XCB_FOCUS_OUT: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_out_event_t, event, handleFocusOutEvent); + case XCB_KEY_PRESS: + HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent); + case XCB_KEY_RELEASE: + HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent); + case XCB_MAPPING_NOTIFY: + m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event); + break; + default: + handled = false; + break; + } + if (handled) + printXcbEvent("Handled XCB event", event); + else + printXcbEvent("Unhandled XCB event", event); } -#endif - if (response_type == XCB_CLIENT_MESSAGE - && ((xcb_client_message_event_t *)event)->type == QXcbAtom::_QT_CLOSE_CONNECTION) - return; + do { + result = select(xcb_fd + 1, &readset, 0, 0, 0); + } while (result == -1 && errno == EINTR); - if (response_type == XCB_CLIENT_MESSAGE - && ((xcb_client_message_event_t *)event)->type == QXcbAtom::_QT_PAUSE_CONNECTION) - { - QMutexLocker locker(&m_connectionLock); + if (result <= 0 || !FD_ISSET(xcb_fd, &readset)) continue; - } - switch (response_type) { - case XCB_EXPOSE: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent); - case XCB_BUTTON_PRESS: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent); - case XCB_BUTTON_RELEASE: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent); - case XCB_MOTION_NOTIFY: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent); - case XCB_CONFIGURE_NOTIFY: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent); - case XCB_CLIENT_MESSAGE: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_client_message_event_t, window, handleClientMessageEvent); - case XCB_ENTER_NOTIFY: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent); - case XCB_LEAVE_NOTIFY: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent); - case XCB_FOCUS_IN: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent); - case XCB_FOCUS_OUT: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_out_event_t, event, handleFocusOutEvent); - case XCB_KEY_PRESS: - HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent); - case XCB_KEY_RELEASE: - HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent); - case XCB_MAPPING_NOTIFY: - m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event); - break; - default: - handled = false; - break; - } - if (handled) - printXcbEvent("Handled XCB event", event); - else - printXcbEvent("Unhandled XCB event", event); } fprintf(stderr, "I/O error in xcb_wait_for_event\n"); } @@ -714,8 +738,13 @@ void QXcbConnection::initializeAllAtoms() { void QXcbConnection::sync() { // from xcb_aux_sync + bool wasEnabled = m_enabled; + setEventProcessingEnabled(false); xcb_get_input_focus_cookie_t cookie = Q_XCB_CALL(xcb_get_input_focus(xcb_connection())); free(xcb_get_input_focus_reply(xcb_connection(), cookie, 0)); + + if (wasEnabled) + setEventProcessingEnabled(true); } #if defined(XCB_USE_EGL) diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 2723f26..7088184 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #define Q_XCB_DEBUG @@ -265,7 +266,7 @@ protected: private: void initializeAllAtoms(); - void sendConnectionEvent(QXcbAtom::Atom atom); + void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0); #ifdef XCB_USE_DRI2 void initializeDri2(); #endif @@ -282,6 +283,8 @@ private: xcb_window_t m_connectionEventListener; QMutex m_connectionLock; + QWaitCondition m_connectionWaitCondition; + QAtomicInt m_pauseId; bool m_enabled; QXcbKeyboard *m_keyboard; @@ -326,9 +329,11 @@ cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, } #define Q_XCB_CALL(x) q_xcb_call_template(x, connection(), __FILE__, __LINE__) #define Q_XCB_CALL2(x, connection) q_xcb_call_template(x, connection, __FILE__, __LINE__) +#define Q_XCB_NOOP(c) q_xcb_call_template(xcb_no_operation(c->xcb_connection()), c, __FILE__, __LINE__); #else #define Q_XCB_CALL(x) x #define Q_XCB_CALL2(x, connection) x +#define Q_XCB_NOOP(c) #endif diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index ec9a009..f501c00 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -921,6 +921,8 @@ void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycod if (state & 128) col += altGrOffset; + Q_XCB_NOOP(connection()); + #ifdef XCB_KEYBOARD_DEBUG printf("key code: %d, state: %d, syms: ", code, state); for (int i = 0; i <= 5; ++i) { @@ -929,6 +931,8 @@ void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycod printf("\n"); #endif + Q_XCB_NOOP(connection()); + xcb_keysym_t sym = xcb_key_symbols_get_keysym(m_key_symbols, code, col); if (sym == XCB_NO_SYMBOL) sym = xcb_key_symbols_get_keysym(m_key_symbols, code, col ^ 0x1); @@ -940,6 +944,8 @@ void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycod sym = toupper(sym); } + Q_XCB_NOOP(connection()); + QByteArray chars; Qt::KeyboardModifiers modifiers; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index e997824..7aeb557 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -222,9 +222,7 @@ void QXcbWindow::setVisible(bool visible) xcb_wm_hints_set_normal(&hints); xcb_set_wm_hints(xcb_connection(), m_window, &hints); Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); -#if defined(XCB_USE_GLX) - glXWaitX(); -#endif + connection()->sync(); } else { Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window)); diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index dd28c31..4c0d862 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -62,7 +62,7 @@ public: QImage *image() { return &m_qimage; } void put(xcb_window_t window, const QPoint &dst, const QRect &source); - void preparePaint(const QRegion ®ion); + void preparePaint(const QRegion ®ion, QMutex *mutex); private: void destroy(); @@ -84,6 +84,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size) , m_gc(0) , m_gc_window(0) { + Q_XCB_NOOP(connection()); m_xcb_image = xcb_image_create_native(xcb_connection(), size.width(), size.height(), @@ -115,6 +116,7 @@ void QXcbShmImage::destroy() void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &source) { + Q_XCB_NOOP(connection()); if (m_gc_window != window) { if (m_gc) Q_XCB_CALL(xcb_free_gc(xcb_connection(), m_gc)); @@ -125,6 +127,7 @@ void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &s m_gc_window = window; } + Q_XCB_NOOP(connection()); xcb_image_shm_put(xcb_connection(), window, m_gc, @@ -137,18 +140,23 @@ void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &s source.width(), source.height(), false); + Q_XCB_NOOP(connection()); m_dirty = m_dirty | source; xcb_flush(xcb_connection()); + Q_XCB_NOOP(connection()); } -void QXcbShmImage::preparePaint(const QRegion ®ion) +void QXcbShmImage::preparePaint(const QRegion ®ion, QMutex *mutex) { // to prevent X from reading from the image region while we're writing to it if (m_dirty.intersects(region)) { connection()->sync(); + mutex->lock(); m_dirty = QRegion(); + } else { + mutex->lock(); } } @@ -162,6 +170,8 @@ QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface) QXcbWindowSurface::~QXcbWindowSurface() { + QMutexLocker locker(&m_surfaceLock); + delete m_image; } QPaintDevice *QXcbWindowSurface::paintDevice() @@ -171,8 +181,7 @@ QPaintDevice *QXcbWindowSurface::paintDevice() void QXcbWindowSurface::beginPaint(const QRegion ®ion) { - m_surfaceLock.lock(); - m_image->preparePaint(region); + m_image->preparePaint(region, &m_surfaceLock); } void QXcbWindowSurface::endPaint(const QRegion &) @@ -185,6 +194,8 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi Q_UNUSED(region); Q_UNUSED(offset); + Q_XCB_NOOP(connection()); + QXcbWindow *window = static_cast(widget->window()->platformWindow()); extern QWidgetData* qt_widget_data(QWidget *); @@ -195,18 +206,26 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi QVector rects = region.rects(); for (int i = 0; i < rects.size(); ++i) m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset)); + + Q_XCB_NOOP(connection()); } void QXcbWindowSurface::resize(const QSize &size) { + Q_XCB_NOOP(connection()); QWindowSurface::resize(size); QXcbScreen *screen = static_cast(QPlatformScreen::platformScreenForWidget(window())); - QMutexLocker locker(&m_surfaceLock); + connection()->setEventProcessingEnabled(false); + m_surfaceLock.lock(); delete m_image; m_image = new QXcbShmImage(screen, size); + Q_XCB_NOOP(connection()); + + m_surfaceLock.unlock(); + connection()->setEventProcessingEnabled(true); } extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset); @@ -216,12 +235,14 @@ bool QXcbWindowSurface::scroll(const QRegion &area, int dx, int dy) if (m_image->image()->isNull()) return false; - m_image->preparePaint(area); + m_image->preparePaint(area, &m_surfaceLock); const QVector rects = area.rects(); for (int i = 0; i < rects.size(); ++i) qt_scrollRectInImage(*m_image->image(), rects.at(i), QPoint(dx, dy)); + m_surfaceLock.unlock(); + return true; } -- cgit v0.12 From 33ca59cd1827195cb7ef91a18c0775568471d4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 1 Apr 2011 14:26:42 +0200 Subject: Fixed compilation of wayland plugin when there's no GL support. --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index d54a0fe..e3b2d46 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -82,10 +82,12 @@ struct wl_visual *QWaylandDisplay::argbPremultipliedVisual() return wl_display_get_premultiplied_argb_visual(mDisplay); } +#ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration * QWaylandDisplay::eglIntegration() { return mEglIntegration; } +#endif void QWaylandDisplay::shellHandleConfigure(void *data, struct wl_shell *shell, uint32_t time, uint32_t edges, -- cgit v0.12 From 991f59a295e7678165b1db7befc9beac8bdbe503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 1 Apr 2011 17:36:26 +0200 Subject: Moved all XCB event handling back into the main thread. There are to many synchronization problems if any GL call can lead the event processing thread to stall. --- src/plugins/platforms/xcb/qglxintegration.cpp | 2 - src/plugins/platforms/xcb/qxcbconnection.cpp | 241 ++++++++---------------- src/plugins/platforms/xcb/qxcbconnection.h | 23 +-- src/plugins/platforms/xcb/qxcbwindow.cpp | 4 - src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 23 +-- src/plugins/platforms/xcb/qxcbwindowsurface.h | 3 - 6 files changed, 86 insertions(+), 210 deletions(-) diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index d1171b8..19a9503 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -137,7 +137,6 @@ void QGLXContext::createDefaultSharedContext(QXcbScreen *screen) void QGLXContext::makeCurrent() { Q_XCB_NOOP(m_screen->connection()); - m_screen->connection()->setEventProcessingEnabled(false); QPlatformGLContext::makeCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context); Q_XCB_NOOP(m_screen->connection()); @@ -148,7 +147,6 @@ void QGLXContext::doneCurrent() Q_XCB_NOOP(m_screen->connection()); QPlatformGLContext::doneCurrent(); glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0); - m_screen->connection()->setEventProcessingEnabled(true); Q_XCB_NOOP(m_screen->connection()); } diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 05d3440..ec1fc1b 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -76,8 +77,6 @@ extern "C" { QXcbConnection::QXcbConnection(const char *displayName) : m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY")) - , m_pauseId(0) - , m_enabled(true) #ifdef XCB_USE_DRI2 , m_dri2_major(0) , m_dri2_minor(0) @@ -114,12 +113,6 @@ QXcbConnection::QXcbConnection(const char *displayName) xcb_screen_next(&it); } - m_connectionEventListener = xcb_generate_id(xcb_connection()); - xcb_create_window(xcb_connection(), XCB_COPY_FROM_PARENT, - m_connectionEventListener, m_screens.at(0)->root(), - 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY, - m_screens.at(0)->screen()->root_visual, 0, 0); - m_keyboard = new QXcbKeyboard(this); initializeAllAtoms(); @@ -128,50 +121,15 @@ QXcbConnection::QXcbConnection(const char *displayName) initializeDri2(); #endif - start(); -} + QSocketNotifier *notifier = new QSocketNotifier(xcb_get_file_descriptor(xcb_connection()), QSocketNotifier::Read, this); + connect(notifier, SIGNAL(activated(int)), this, SLOT(processXcbEvents())); -void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom atom, uint id) -{ - xcb_client_message_event_t event; - memset(&event, 0, sizeof(event)); - - event.response_type = XCB_CLIENT_MESSAGE; - event.format = 32; - event.sequence = 0; - event.window = m_connectionEventListener; - event.type = atom; - event.data.data32[0] = id; - - Q_XCB_CALL(xcb_send_event(xcb_connection(), false, m_connectionEventListener, XCB_EVENT_MASK_NO_EVENT, (const char *)&event)); - xcb_flush(xcb_connection()); -} - -void QXcbConnection::setEventProcessingEnabled(bool enabled) -{ - if (enabled == m_enabled) - return; - - if (!enabled) { - sendConnectionEvent(QXcbAtom::_QT_PAUSE_CONNECTION, uint(m_pauseId)); - m_connectionLock.lock(); - m_pauseId.fetchAndAddOrdered(1); - } else { - m_connectionLock.unlock(); - m_connectionWaitCondition.wakeAll(); - } - - m_enabled = enabled; + QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance(qApp->thread()); + connect(dispatcher, SIGNAL(awake()), this, SLOT(processXcbEvents())); } QXcbConnection::~QXcbConnection() { - setEventProcessingEnabled(true); - - sendConnectionEvent(QXcbAtom::_QT_CLOSE_CONNECTION); - wait(); - - xcb_destroy_window(xcb_connection(), m_connectionEventListener); qDeleteAll(m_screens); #ifdef XCB_USE_XLIB @@ -417,128 +375,93 @@ void QXcbConnection::log(const char *file, int line, int sequence) info.sequence = sequence; info.file = file; info.line = line; - - QMutexLocker locker(&m_callLogMutex); - m_callLog << info; } #endif -void QXcbConnection::run() +void QXcbConnection::processXcbEvents() { - QMutexLocker locker(&m_connectionLock); - fd_set readset; - int xcb_fd = xcb_get_file_descriptor(xcb_connection()); - FD_ZERO(&readset); - FD_SET(xcb_fd, &readset); - int result; - while (true) { - while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection())) { - bool handled = true; - - uint response_type = event->response_type & ~0x80; - - if (!response_type) { - xcb_generic_error_t *error = (xcb_generic_error_t *)event; - - uint clamped_error_code = qMin(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1); - uint clamped_major_code = qMin(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1); - - printf("XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d\n", - int(error->error_code), xcb_errors[clamped_error_code], - int(error->sequence), int(error->resource_id), - int(error->major_code), xcb_protocol_request_codes[clamped_major_code], - int(error->minor_code)); -#ifdef Q_XCB_DEBUG - QMutexLocker locker(&m_callLogMutex); - int i = 0; - for (; i < m_callLog.size(); ++i) { - if (m_callLog.at(i).sequence == error->sequence) { - printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); - break; - } else if (m_callLog.at(i).sequence > error->sequence) { - printf("Caused some time before: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); - if (i > 0) - printf("and after: %s:%d\n", qPrintable(m_callLog.at(i-1).file), m_callLog.at(i-1).line); - break; - } - } - if (i == m_callLog.size() && !m_callLog.isEmpty()) - printf("Caused some time after: %s:%d\n", qPrintable(m_callLog.first().file), m_callLog.first().line); -#endif - continue; - } + while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection())) { + bool handled = true; -#ifdef Q_XCB_DEBUG - { - QMutexLocker locker(&m_callLogMutex); - int i = 0; - for (; i < m_callLog.size(); ++i) - if (m_callLog.at(i).sequence >= event->sequence) - break; - m_callLog.remove(0, i); - } -#endif + uint response_type = event->response_type & ~0x80; - if (response_type == XCB_CLIENT_MESSAGE) { - xcb_client_message_event_t *ev = (xcb_client_message_event_t *)event; + if (!response_type) { + xcb_generic_error_t *error = (xcb_generic_error_t *)event; - if (ev->type == QXcbAtom::_QT_CLOSE_CONNECTION) - return; + uint clamped_error_code = qMin(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1); + uint clamped_major_code = qMin(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1); - if (ev->type == QXcbAtom::_QT_PAUSE_CONNECTION) { - if (ev->data.data32[0] == uint(m_pauseId)) - m_connectionWaitCondition.wait(&m_connectionLock); - continue; + printf("XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d\n", + int(error->error_code), xcb_errors[clamped_error_code], + int(error->sequence), int(error->resource_id), + int(error->major_code), xcb_protocol_request_codes[clamped_major_code], + int(error->minor_code)); +#ifdef Q_XCB_DEBUG + int i = 0; + for (; i < m_callLog.size(); ++i) { + if (m_callLog.at(i).sequence == error->sequence) { + printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + break; + } else if (m_callLog.at(i).sequence > error->sequence) { + printf("Caused some time before: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + if (i > 0) + printf("and after: %s:%d\n", qPrintable(m_callLog.at(i-1).file), m_callLog.at(i-1).line); + break; } } - - switch (response_type) { - case XCB_EXPOSE: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent); - case XCB_BUTTON_PRESS: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent); - case XCB_BUTTON_RELEASE: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent); - case XCB_MOTION_NOTIFY: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent); - case XCB_CONFIGURE_NOTIFY: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent); - case XCB_CLIENT_MESSAGE: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_client_message_event_t, window, handleClientMessageEvent); - case XCB_ENTER_NOTIFY: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent); - case XCB_LEAVE_NOTIFY: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent); - case XCB_FOCUS_IN: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent); - case XCB_FOCUS_OUT: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_out_event_t, event, handleFocusOutEvent); - case XCB_KEY_PRESS: - HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent); - case XCB_KEY_RELEASE: - HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent); - case XCB_MAPPING_NOTIFY: - m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event); - break; - default: - handled = false; - break; - } - if (handled) - printXcbEvent("Handled XCB event", event); - else - printXcbEvent("Unhandled XCB event", event); + if (i == m_callLog.size() && !m_callLog.isEmpty()) + printf("Caused some time after: %s:%d\n", qPrintable(m_callLog.first().file), m_callLog.first().line); +#endif + continue; } - do { - result = select(xcb_fd + 1, &readset, 0, 0, 0); - } while (result == -1 && errno == EINTR); - - if (result <= 0 || !FD_ISSET(xcb_fd, &readset)) - continue; +#ifdef Q_XCB_DEBUG + { + int i = 0; + for (; i < m_callLog.size(); ++i) + if (m_callLog.at(i).sequence >= event->sequence) + break; + m_callLog.remove(0, i); + } +#endif + switch (response_type) { + case XCB_EXPOSE: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent); + case XCB_BUTTON_PRESS: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent); + case XCB_BUTTON_RELEASE: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent); + case XCB_MOTION_NOTIFY: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent); + case XCB_CONFIGURE_NOTIFY: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent); + case XCB_CLIENT_MESSAGE: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_client_message_event_t, window, handleClientMessageEvent); + case XCB_ENTER_NOTIFY: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent); + case XCB_LEAVE_NOTIFY: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent); + case XCB_FOCUS_IN: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent); + case XCB_FOCUS_OUT: + HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_out_event_t, event, handleFocusOutEvent); + case XCB_KEY_PRESS: + HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent); + case XCB_KEY_RELEASE: + HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent); + case XCB_MAPPING_NOTIFY: + m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event); + break; + default: + handled = false; + break; + } + if (handled) + printXcbEvent("Handled XCB event", event); + else + printXcbEvent("Unhandled XCB event", event); } - fprintf(stderr, "I/O error in xcb_wait_for_event\n"); } static const char * xcb_atomnames = { @@ -580,9 +503,6 @@ static const char * xcb_atomnames = { "_QT_SCROLL_DONE\0" "_QT_INPUT_ENCODING\0" - "_QT_CLOSE_CONNECTION\0" - "_QT_PAUSE_CONNECTION\0" - "_MOTIF_WM_HINTS\0" "DTWM_IS_RUNNING\0" @@ -738,13 +658,8 @@ void QXcbConnection::initializeAllAtoms() { void QXcbConnection::sync() { // from xcb_aux_sync - bool wasEnabled = m_enabled; - setEventProcessingEnabled(false); xcb_get_input_focus_cookie_t cookie = Q_XCB_CALL(xcb_get_input_focus(xcb_connection())); free(xcb_get_input_focus_reply(xcb_connection(), cookie, 0)); - - if (wasEnabled) - setEventProcessingEnabled(true); } #if defined(XCB_USE_EGL) diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 7088184..53846f1 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -44,10 +44,8 @@ #include #include -#include +#include #include -#include -#include #define Q_XCB_DEBUG @@ -93,10 +91,6 @@ namespace QXcbAtom { _QT_SCROLL_DONE, _QT_INPUT_ENCODING, - // Qt/XCB specific - _QT_CLOSE_CONNECTION, - _QT_PAUSE_CONNECTION, - _MOTIF_WM_HINTS, DTWM_IS_RUNNING, @@ -222,7 +216,7 @@ namespace QXcbAtom { class QXcbKeyboard; -class QXcbConnection : public QThread +class QXcbConnection : public QObject { Q_OBJECT public: @@ -242,8 +236,6 @@ public: QXcbKeyboard *keyboard() const { return m_keyboard; } - void setEventProcessingEnabled(bool enabled); - #ifdef XCB_USE_XLIB void *xlib_display() const { return m_xlib_display; } #endif @@ -261,8 +253,8 @@ public: void sync(); -protected: - void run(); +private slots: + void processXcbEvents(); private: void initializeAllAtoms(); @@ -281,12 +273,6 @@ private: QByteArray m_displayName; - xcb_window_t m_connectionEventListener; - QMutex m_connectionLock; - QWaitCondition m_connectionWaitCondition; - QAtomicInt m_pauseId; - bool m_enabled; - QXcbKeyboard *m_keyboard; #if defined(XCB_USE_XLIB) @@ -311,7 +297,6 @@ private: int line; }; QVector m_callLog; - QMutex m_callLogMutex; void log(const char *file, int line, int sequence); template friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 7aeb557..1f4a13c 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -113,7 +113,6 @@ QXcbWindow::QXcbWindow(QWidget *tlw) if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL && QApplicationPrivate::platformIntegration()->hasOpenGL()) { - connection()->setEventProcessingEnabled(false); #if defined(XCB_USE_GLX) XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat()); #elif defined(XCB_USE_EGL) @@ -142,7 +141,6 @@ QXcbWindow::QXcbWindow(QWidget *tlw) } else { qFatal("no window!"); } - connection()->setEventProcessingEnabled(true); } else #endif //defined(XCB_USE_GLX) || defined(XCB_USE_EGL) { @@ -431,7 +429,6 @@ QPlatformGLContext *QXcbWindow::glContext() const return 0; } if (!m_context) { - connection()->setEventProcessingEnabled(false); #if defined(XCB_USE_GLX) QXcbWindow *that = const_cast(this); that->m_context = new QGLXContext(m_window, m_screen, widget()->platformWindowFormat()); @@ -450,7 +447,6 @@ QPlatformGLContext *QXcbWindow::glContext() const QXcbWindow *that = const_cast(this); that->m_context = new QDri2Context(that); #endif - connection()->setEventProcessingEnabled(true); } return m_context; } diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 4c0d862..a4607dc 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -62,7 +62,7 @@ public: QImage *image() { return &m_qimage; } void put(xcb_window_t window, const QPoint &dst, const QRect &source); - void preparePaint(const QRegion ®ion, QMutex *mutex); + void preparePaint(const QRegion ®ion); private: void destroy(); @@ -148,15 +148,12 @@ void QXcbShmImage::put(xcb_window_t window, const QPoint &target, const QRect &s Q_XCB_NOOP(connection()); } -void QXcbShmImage::preparePaint(const QRegion ®ion, QMutex *mutex) +void QXcbShmImage::preparePaint(const QRegion ®ion) { // to prevent X from reading from the image region while we're writing to it if (m_dirty.intersects(region)) { connection()->sync(); - mutex->lock(); m_dirty = QRegion(); - } else { - mutex->lock(); } } @@ -170,7 +167,6 @@ QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface) QXcbWindowSurface::~QXcbWindowSurface() { - QMutexLocker locker(&m_surfaceLock); delete m_image; } @@ -181,12 +177,11 @@ QPaintDevice *QXcbWindowSurface::paintDevice() void QXcbWindowSurface::beginPaint(const QRegion ®ion) { - m_image->preparePaint(region, &m_surfaceLock); + m_image->preparePaint(region); } void QXcbWindowSurface::endPaint(const QRegion &) { - m_surfaceLock.unlock(); } void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) @@ -201,8 +196,6 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi extern QWidgetData* qt_widget_data(QWidget *); QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft(); - QMutexLocker locker(&m_surfaceLock); - QVector rects = region.rects(); for (int i = 0; i < rects.size(); ++i) m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset)); @@ -217,15 +210,9 @@ void QXcbWindowSurface::resize(const QSize &size) QXcbScreen *screen = static_cast(QPlatformScreen::platformScreenForWidget(window())); - connection()->setEventProcessingEnabled(false); - m_surfaceLock.lock(); - delete m_image; m_image = new QXcbShmImage(screen, size); Q_XCB_NOOP(connection()); - - m_surfaceLock.unlock(); - connection()->setEventProcessingEnabled(true); } extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset); @@ -235,14 +222,12 @@ bool QXcbWindowSurface::scroll(const QRegion &area, int dx, int dy) if (m_image->image()->isNull()) return false; - m_image->preparePaint(area, &m_surfaceLock); + m_image->preparePaint(area); const QVector rects = area.rects(); for (int i = 0; i < rects.size(); ++i) qt_scrollRectInImage(*m_image->image(), rects.at(i), QPoint(dx, dy)); - m_surfaceLock.unlock(); - return true; } diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbwindowsurface.h index e508fe6..f87e122 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.h +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.h @@ -48,8 +48,6 @@ #include "qxcbobject.h" -#include - class QXcbShmImage; class QXcbWindowSurface : public QXcbObject, public QWindowSurface @@ -68,7 +66,6 @@ public: private: QXcbShmImage *m_image; - QMutex m_surfaceLock; }; #endif -- cgit v0.12 From cc46428d5b421b3ebc3a2ff3171b5197af008022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 4 Apr 2011 12:13:48 +0200 Subject: Wayland: Allways have a userPtr for QWaylandWindow So that we can use it without having to check for 0 in input handling Conflicts: src/plugins/platforms/wayland/qwaylandinputdevice.cpp --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 6 ++++-- src/plugins/platforms/wayland/qwaylanddisplay.h | 2 +- src/plugins/platforms/wayland/qwaylandwindow.cpp | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index e3b2d46..b79f355 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -54,9 +54,11 @@ #include #include -struct wl_surface *QWaylandDisplay::createSurface() +struct wl_surface *QWaylandDisplay::createSurface(void *handle) { - return wl_compositor_create_surface(mCompositor); + struct wl_surface * surface = wl_compositor_create_surface(mCompositor); + wl_surface_set_user_data(surface, handle); + return surface; } struct wl_buffer *QWaylandDisplay::createShmBuffer(int fd, diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index fc26ad2..481f829 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -63,7 +63,7 @@ public: void createNewScreen(struct wl_output *output, QRect geometry); QList screens() const { return mScreens; } - struct wl_surface *createSurface(); + struct wl_surface *createSurface(void *handle); struct wl_buffer *createShmBuffer(int fd, int width, int height, uint32_t stride, struct wl_visual *visual); diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index a912a83..9e851b3 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -56,7 +56,7 @@ QWaylandWindow::QWaylandWindow(QWidget *window) static WId id = 1; mWindowId = id++; - mSurface = mDisplay->createSurface(); + mSurface = mDisplay->createSurface(this); } QWaylandWindow::~QWaylandWindow() @@ -76,13 +76,12 @@ void QWaylandWindow::setParent(const QPlatformWindow *parent) void QWaylandWindow::setVisible(bool visible) { - if (!mSurface) { - mSurface = mDisplay->createSurface(); + if (!mSurface && visible) { + mSurface = mDisplay->createSurface(this); newSurfaceCreated(); } if (visible) { - wl_surface_set_user_data(mSurface, this); wl_surface_map_toplevel(mSurface); } else { wl_surface_destroy(mSurface); -- cgit v0.12 From 05f2b1c912e09be9cb9f1128494d315c53698d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 4 Apr 2011 12:19:57 +0200 Subject: Lighthouse: Add drawable bit to the glx config selection rutine So that we can use the same thing when creating glx pixmaps --- src/plugins/platforms/glxconvenience/qglxconvenience.cpp | 8 ++++---- src/plugins/platforms/glxconvenience/qglxconvenience.h | 4 ++-- .../gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp index 08972f7..f548ad9 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp @@ -25,14 +25,14 @@ enum { #undef FontChange #endif -QVector qglx_buildSpec(const QPlatformWindowFormat &format) +QVector qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit) { QVector spec(48); int i = 0; spec[i++] = GLX_LEVEL; spec[i++] = 0; - spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT; + spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = drawableBit; if (format.rgba()) { spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; @@ -77,13 +77,13 @@ QVector qglx_buildSpec(const QPlatformWindowFormat &format) return spec; } -GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format) +GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format, int drawableBit) { bool reduced = true; GLXFBConfig chosenConfig = 0; QPlatformWindowFormat reducedFormat = format; while (!chosenConfig && reduced) { - QVector spec = qglx_buildSpec(reducedFormat); + QVector spec = qglx_buildSpec(reducedFormat, drawableBit); int confcount = 0; GLXFBConfig *configs; configs = glXChooseFBConfig(display, screen,spec.constData(),&confcount); diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.h b/src/plugins/platforms/glxconvenience/qglxconvenience.h index a3cfd9a..6b65e08 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.h +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.h @@ -7,9 +7,9 @@ #include XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format); -GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format); +GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); -QVector qglx_buildSpec(const QPlatformWindowFormat &format); +QVector qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); #endif // QGLXCONVENIENCE_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp index d5806bb..f98e026 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp @@ -33,7 +33,7 @@ QWaylandXPixmapGLXContext::QWaylandXPixmapGLXContext(QWaylandXPixmapGLXIntegrati , mWindow(window) , mBuffer(0) , mPixmap(0) - , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat())) + , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat(),GLX_PIXMAP_BIT)) , mGlxPixmap(0) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); -- cgit v0.12 From e8d31fa99352c18d469394d65c80541b7788440c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 4 Apr 2011 12:35:25 +0200 Subject: Process XCB events on aboutToBlock() instead of awake(). We want the XCB events to be processed right before calling select(), to make sure any remaining events in the queue are flushed. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index ec1fc1b..2a220af 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -125,7 +125,7 @@ QXcbConnection::QXcbConnection(const char *displayName) connect(notifier, SIGNAL(activated(int)), this, SLOT(processXcbEvents())); QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance(qApp->thread()); - connect(dispatcher, SIGNAL(awake()), this, SLOT(processXcbEvents())); + connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processXcbEvents())); } QXcbConnection::~QXcbConnection() -- cgit v0.12 From a715d1fe5e9a9781218701afe9c10f2ba54448ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 4 Apr 2011 15:33:02 +0200 Subject: Made Qt applications get the correct GLES2 include path. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the same as the one used when building QtOpenGL + examples/demos. Reviewed-by: Jørgen Lind --- configure | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure b/configure index 83c836c..167ae1b 100755 --- a/configure +++ b/configure @@ -8330,6 +8330,11 @@ if [ -n "$QT_CFLAGS_FPU" ]; then echo "MMP_RULES += \"ARMFPU $QT_CFLAGS_FPU\"" >> "$QTCONFIG.tmp" fi +if [ -n "$QMAKE_INCDIR_OPENGL_ES2" ]; then + echo "\n#Qt opengl include path" >> "$QTCONFIG.tmp" + echo "QMAKE_INCDIR_OPENGL_ES2 = \"$QMAKE_INCDIR_OPENGL_ES2\"" >> "$QTCONFIG.tmp" +fi + # replace qconfig.pri if it differs from the newly created temp file if cmp -s "$QTCONFIG.tmp" "$QTCONFIG"; then rm -f "$QTCONFIG.tmp" -- cgit v0.12 From 5def7de22269906cc304c70534cef724b6127505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 5 Apr 2011 09:38:46 +0200 Subject: Implement QWaylandIntegration::hasOpenGL(). --- src/plugins/platforms/wayland/qwaylandintegration.cpp | 9 +++++++++ src/plugins/platforms/wayland/qwaylandintegration.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index be78b82..04f3d9a 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -115,3 +115,12 @@ QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const { return mFontDb; } + +bool QWaylandIntegration::hasOpenGL() const +{ +#ifdef QT_WAYLAND_GL_SUPPORT + return true; +#else + return false; +#endif +} diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h index 067b6e4..20f8c5c 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.h +++ b/src/plugins/platforms/wayland/qwaylandintegration.h @@ -63,6 +63,8 @@ public: QPlatformFontDatabase *fontDatabase() const; + bool hasOpenGL() const; + private: QPlatformFontDatabase *mFontDb; QWaylandDisplay *mDisplay; -- cgit v0.12 From 1513c28ac391741fc7d18dd79374a6c59f7e4dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 5 Apr 2011 10:12:45 +0200 Subject: Make sure to delete wayland surface when QWaylandWindow is destroyed. --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 9e851b3..e994616 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -61,6 +61,8 @@ QWaylandWindow::QWaylandWindow(QWidget *window) QWaylandWindow::~QWaylandWindow() { + if (mSurface) + wl_surface_destroy(mSurface); } WId QWaylandWindow::winId() const -- cgit v0.12 From 25054c7a20a6ebd15603ac1060e09ee244afa054 Mon Sep 17 00:00:00 2001 From: con Date: Tue, 29 Mar 2011 12:22:40 +0200 Subject: uikit: Set the offline storage path for QML --- src/plugins/platforms/uikit/examples/qmltest/main.mm | 16 +++++++++++++++- src/plugins/platforms/uikit/quikitwindowsurface.h | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/uikit/examples/qmltest/main.mm b/src/plugins/platforms/uikit/examples/qmltest/main.mm index 2b5f024..ea4e90c 100644 --- a/src/plugins/platforms/uikit/examples/qmltest/main.mm +++ b/src/plugins/platforms/uikit/examples/qmltest/main.mm @@ -45,9 +45,22 @@ #include #include +#include Q_IMPORT_PLUGIN(UIKit) +static QString qStringFromNSString(NSString *nsstring) +{ + return QString::fromUtf8([nsstring UTF8String]); +} + +static QString documentsDirectory() +{ + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + return qStringFromNSString(documentsDirectory); +} + int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; @@ -55,8 +68,9 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer.engine()->setOfflineStoragePath(documentsDirectory()); NSString *resourcePath = [[NSBundle mainBundle] resourcePath]; - viewer.setMainQmlFile(QString::fromUtf8([[resourcePath stringByAppendingPathComponent:@"qml/main.qml"] UTF8String])); + viewer.setMainQmlFile(qStringFromNSString([resourcePath stringByAppendingPathComponent:@"qml/main.qml"])); viewer.showMaximized(); int retVal = app.exec(); [pool release]; diff --git a/src/plugins/platforms/uikit/quikitwindowsurface.h b/src/plugins/platforms/uikit/quikitwindowsurface.h index 50d02b4..81f60f5 100644 --- a/src/plugins/platforms/uikit/quikitwindowsurface.h +++ b/src/plugins/platforms/uikit/quikitwindowsurface.h @@ -72,7 +72,7 @@ public: void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); void resize (const QSize &size); - QImageView *nativeView() const { return mView; } + UIView *nativeView() const { return mView; } private: QImage *mImage; QImageView *mView; -- cgit v0.12 From f3d82a8903b14bb35b0b5f0eb69168b2ca59c31b Mon Sep 17 00:00:00 2001 From: con Date: Thu, 31 Mar 2011 17:53:10 +0200 Subject: Compile fixes for GL ES and Mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For QPA the unix tests are used to determine the availability of OpenGL ES, so they need to compile even on Mac. Similarly the includes in the OpenGL module have to be adapted on Mac. Acked-by: Jørgen Lind --- config.tests/unix/opengles1/opengles1.cpp | 6 ++++- config.tests/unix/opengles1/opengles1.pro | 4 ++++ config.tests/unix/opengles2/opengles2.cpp | 6 ++++- config.tests/unix/opengles2/opengles2.pro | 4 ++++ mkspecs/qws/macx-iphonedevice-g++/qmake.conf | 5 +++- mkspecs/qws/macx-iphonesimulator-g++/qmake.conf | 3 +++ src/opengl/opengl.pro | 2 +- src/opengl/qgl.h | 32 +++++++++++++++---------- src/plugins/platforms/uikit/README | 4 ++-- 9 files changed, 48 insertions(+), 18 deletions(-) diff --git a/config.tests/unix/opengles1/opengles1.cpp b/config.tests/unix/opengles1/opengles1.cpp index caef9a9..ec16fc0 100644 --- a/config.tests/unix/opengles1/opengles1.cpp +++ b/config.tests/unix/opengles1/opengles1.cpp @@ -39,7 +39,11 @@ ** ****************************************************************************/ -#include +#ifdef BUILD_ON_MAC + #include +#else + #include +#endif int main(int, char **) { diff --git a/config.tests/unix/opengles1/opengles1.pro b/config.tests/unix/opengles1/opengles1.pro index 1469aa9..9e60124 100644 --- a/config.tests/unix/opengles1/opengles1.pro +++ b/config.tests/unix/opengles1/opengles1.pro @@ -7,3 +7,7 @@ for(p, QMAKE_LIBDIR_OPENGL_ES1) { CONFIG -= qt LIBS += $$QMAKE_LIBS_OPENGL_ES1 +mac { + DEFINES += BUILD_ON_MAC + CONFIG -= app_bundle +} diff --git a/config.tests/unix/opengles2/opengles2.cpp b/config.tests/unix/opengles2/opengles2.cpp index caf02e6..39c6fa7 100644 --- a/config.tests/unix/opengles2/opengles2.cpp +++ b/config.tests/unix/opengles2/opengles2.cpp @@ -39,7 +39,11 @@ ** ****************************************************************************/ -#include +#ifdef BUILD_ON_MAC + #include +#else + #include +#endif int main(int, char **) { diff --git a/config.tests/unix/opengles2/opengles2.pro b/config.tests/unix/opengles2/opengles2.pro index c383fd0..34d7737 100644 --- a/config.tests/unix/opengles2/opengles2.pro +++ b/config.tests/unix/opengles2/opengles2.pro @@ -7,3 +7,7 @@ for(p, QMAKE_LIBDIR_OPENGL_ES2) { CONFIG -= qt LIBS += $$QMAKE_LIBS_OPENGL_ES2 +mac { + DEFINES += BUILD_ON_MAC + CONFIG -= app_bundle +} diff --git a/mkspecs/qws/macx-iphonedevice-g++/qmake.conf b/mkspecs/qws/macx-iphonedevice-g++/qmake.conf index 36b9496..227d24e 100644 --- a/mkspecs/qws/macx-iphonedevice-g++/qmake.conf +++ b/mkspecs/qws/macx-iphonedevice-g++/qmake.conf @@ -16,12 +16,15 @@ DEFINES += QT_NO_AUDIO_BACKEND QT_NO_NETWORKPROXY QT_NO_FILESYSTEMWATCHER # You may need to change this to point to the iOS SDK you want to use. QMAKE_IOS_DEV_PATH = /Developer/Platforms/iPhoneOS.platform/Developer -QMAKE_IOS_SDK = $$QMAKE_IOS_DEV_PATH/SDKs/iPhoneOS4.2.sdk +QMAKE_IOS_SDK = $$QMAKE_IOS_DEV_PATH/SDKs/iPhoneOS4.3.sdk DEFINES += __IPHONE_OS_VERSION_MIN_REQUIRED=40200 #clear QMAKE_MACOSX_DEPLOYMENT_TARGET = +QMAKE_LIBS_OPENGL_ES1 += -framework OpenGLES +QMAKE_LIBS_OPENGL_ES2 += -framework OpenGLES + # TARGET_PLATFORM = ios QMAKE_CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 QMAKE_CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2 diff --git a/mkspecs/qws/macx-iphonesimulator-g++/qmake.conf b/mkspecs/qws/macx-iphonesimulator-g++/qmake.conf index dccab70..93c4786 100644 --- a/mkspecs/qws/macx-iphonesimulator-g++/qmake.conf +++ b/mkspecs/qws/macx-iphonesimulator-g++/qmake.conf @@ -21,6 +21,9 @@ DEFINES += __IPHONE_OS_VERSION_MIN_REQUIRED=40200 #clear QMAKE_MACOSX_DEPLOYMENT_TARGET = +QMAKE_LIBS_OPENGL_ES1 += -framework OpenGLES +QMAKE_LIBS_OPENGL_ES2 += -framework OpenGLES + # TARGET_PLATFORM = ios QMAKE_CC = /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 QMAKE_CXX = /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index b512146..0d65b25 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -120,7 +120,7 @@ x11 { LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD } -mac { +mac:!qpa { OBJECTIVE_SOURCES += qgl_mac.mm \ qglpixelbuffer_mac.mm LIBS_PRIVATE += -framework AppKit -framework Carbon diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index ff73d88..c57995d 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -61,21 +61,29 @@ QT_BEGIN_HEADER #if defined(Q_WS_MAC) # include #elif defined(QT_OPENGL_ES_1) -# include -#ifndef GL_DOUBLE -# define GL_DOUBLE GL_FLOAT -#endif -#ifndef GLdouble +# if defined(Q_OS_MAC) +# include +# else +# include +# endif +# ifndef GL_DOUBLE +# define GL_DOUBLE GL_FLOAT +# endif +# ifndef GLdouble typedef GLfloat GLdouble; -#endif +# endif #elif defined(QT_OPENGL_ES_2) -# include -#ifndef GL_DOUBLE -# define GL_DOUBLE GL_FLOAT -#endif -#ifndef GLdouble +# if defined(Q_OS_MAC) +# include +# else +# include +# endif +# ifndef GL_DOUBLE +# define GL_DOUBLE GL_FLOAT +# endif +# ifndef GLdouble typedef GLfloat GLdouble; -#endif +# endif #else # include #endif diff --git a/src/plugins/platforms/uikit/README b/src/plugins/platforms/uikit/README index b2984fc..a101a3a 100644 --- a/src/plugins/platforms/uikit/README +++ b/src/plugins/platforms/uikit/README @@ -18,11 +18,11 @@ After configuring and building Qt you need to also build src/plugins/platforms/u Simulator: ---------- -configure -qpa -xplatform qws/macx-iphonesimulator-g++ -arch i386 -developer-build -no-accessibility -no-qt3support -no-multimedia -no-phonon -no-phonon-backend -no-svg -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -no-opengl -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations +configure -qpa -xplatform qws/macx-iphonesimulator-g++ -arch i386 -developer-build -opengl es1 -no-accessibility -no-qt3support -no-multimedia -no-phonon -no-phonon-backend -no-svg -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations Device: ------- -configure -qpa -xplatform qws/macx-iphonedevice-g++ -arch armv7 -developer-build -release -no-accessibility -no-qt3support -no-multimedia -no-phonon -no-phonon-backend -no-svg -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -no-opengl -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations +configure -qpa -xplatform qws/macx-iphonedevice-g++ -arch armv7 -developer-build -release -opengl es1 -no-accessibility -no-qt3support -no-multimedia -no-phonon -no-phonon-backend -no-svg -no-webkit -no-scripttools -no-openssl -no-sql-mysql -no-sql-odbc -no-cups -no-iconv -no-dbus -static -nomake tools -nomake demos -nomake docs -nomake examples -nomake translations 2) XCode setup: - there are examples in the examples subdirectory of the platform plugin -- cgit v0.12 From f4d1db4ddb2339fdbf9d4c15a4eebcc1c55ad33a Mon Sep 17 00:00:00 2001 From: con Date: Tue, 5 Apr 2011 10:54:31 +0200 Subject: Fix QPA prerendered fonts in combination with GL paint engine. QPA uses the Indexed8 image format but stores 8 bit gray values in it. The OpenVG and Raster paint engines handle that, but the OpenGL engine didn't. Reviewed-by: Paul Olav Tvete --- src/opengl/qpaintengine_opengl.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 2c01ac4..9da811a 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -4736,7 +4736,7 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine, // qDebug() << "new context" << context << font_cache; qt_context_cache.insert(context, font_cache); if (context->isValid()) { - if (context->device()->devType() == QInternal::Widget) { + if (context->device() && context->device()->devType() == QInternal::Widget) { QWidget *widget = static_cast(context->device()); connect(widget, SIGNAL(destroyed(QObject*)), SLOT(widgetDestroyed(QObject*))); } @@ -4832,7 +4832,6 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine, } QImage glyph_im(fontEngine->alphaMapForGlyph(glyphs[i])); - glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8); glyph_width = glyph_im.width(); Q_ASSERT(glyph_width >= 0); // pad the glyph width to an even number @@ -4855,15 +4854,21 @@ void QGLGlyphCache::cacheGlyphs(QGLContext *context, QFontEngine *fontEngine, #endif if (!glyph_im.isNull()) { - int idx = 0; uchar *tex_data = (uchar *) malloc(glyph_width*glyph_im.height()*2); memset(tex_data, 0, glyph_width*glyph_im.height()*2); + bool is8BitGray = false; +#ifdef Q_WS_QPA + if (glyph_im.format() == QImage::Format_Indexed8) { + is8BitGray = true; + } +#endif + glyph_im = glyph_im.convertToFormat(QImage::Format_Indexed8); for (int y=0; y Date: Tue, 5 Apr 2011 10:58:53 +0200 Subject: Use OpenGL backend for proof of concept UIKit lighthouse plugin. --- .../qmltest/qmltest.xcodeproj/project.pbxproj | 20 ++ src/plugins/platforms/uikit/quikiteventloop.mm | 4 - src/plugins/platforms/uikit/quikitwindow.h | 32 ++- src/plugins/platforms/uikit/quikitwindow.mm | 226 ++++++++++++++++++++- src/plugins/platforms/uikit/quikitwindowsurface.h | 22 +- src/plugins/platforms/uikit/quikitwindowsurface.mm | 198 +++--------------- src/plugins/platforms/uikit/uikit.pro | 2 + 7 files changed, 303 insertions(+), 201 deletions(-) diff --git a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj index 84f0d3a..10bb20f 100755 --- a/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj +++ b/src/plugins/platforms/uikit/examples/qmltest/qmltest.xcodeproj/project.pbxproj @@ -12,6 +12,12 @@ 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; D316594E1338B29E00760B02 /* libQtXml_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D31659431338B21000760B02 /* libQtXml_debug.a */; }; D316594F1338B29E00760B02 /* libQtXmlPatterns_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D31659441338B21000760B02 /* libQtXmlPatterns_debug.a */; }; + D35784241345D8C90046D202 /* libQtOpenGL_debug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D35784231345D8C90046D202 /* libQtOpenGL_debug.a */; }; + D35784261345D9940046D202 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D35784251345D9940046D202 /* OpenGLES.framework */; }; + D35784281345D9E00046D202 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D35784271345D9E00046D202 /* QuartzCore.framework */; }; + D3578436134A09990046D202 /* libQtOpenGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3578435134A09990046D202 /* libQtOpenGL.a */; }; + D3578439134A0AAE0046D202 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D35784251345D9940046D202 /* OpenGLES.framework */; }; + D357843A134A0AB10046D202 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D35784271345D9E00046D202 /* QuartzCore.framework */; }; D3CAA7C813264AAD008BB877 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7C713264AAD008BB877 /* main.mm */; }; D3CAA7E613264EA6008BB877 /* moc_qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */; }; D3CAA7E713264EA6008BB877 /* qmlapplicationviewer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */; }; @@ -54,6 +60,10 @@ 8D1107310486CEB800E47090 /* qmltest-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "qmltest-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; D31659431338B21000760B02 /* libQtXml_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXml_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtXml_debug.a"; sourceTree = SOURCE_ROOT; }; D31659441338B21000760B02 /* libQtXmlPatterns_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtXmlPatterns_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtXmlPatterns_debug.a"; sourceTree = SOURCE_ROOT; }; + D35784231345D8C90046D202 /* libQtOpenGL_debug.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtOpenGL_debug.a; path = "../../../../../../../qt-lighthouse-ios-simulator/lib/libQtOpenGL_debug.a"; sourceTree = ""; }; + D35784251345D9940046D202 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; + D35784271345D9E00046D202 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + D3578435134A09990046D202 /* libQtOpenGL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libQtOpenGL.a; path = "../../../../../../../qt-lighthouse-ios-device/lib/libQtOpenGL.a"; sourceTree = ""; }; D3CAA7C713264AAD008BB877 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; D3CAA7E313264EA6008BB877 /* moc_qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = moc_qmlapplicationviewer.cpp; path = qmlapplicationviewer/moc_qmlapplicationviewer.cpp; sourceTree = ""; }; D3CAA7E413264EA6008BB877 /* qmlapplicationviewer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = qmlapplicationviewer.cpp; path = qmlapplicationviewer/qmlapplicationviewer.cpp; sourceTree = ""; }; @@ -85,9 +95,11 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D35784281345D9E00046D202 /* QuartzCore.framework in Frameworks */, 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, + D35784261345D9940046D202 /* OpenGLES.framework in Frameworks */, D3CAA7FA13264F8A008BB877 /* libz.1.2.3.dylib in Frameworks */, D3CAA81B13265056008BB877 /* libQtCore_debug.a in Frameworks */, D3CAA81C13265056008BB877 /* libQtDeclarative_debug.a in Frameworks */, @@ -98,6 +110,7 @@ D3CAA82813265220008BB877 /* libQtNetwork_debug.a in Frameworks */, D316594E1338B29E00760B02 /* libQtXml_debug.a in Frameworks */, D316594F1338B29E00760B02 /* libQtXmlPatterns_debug.a in Frameworks */, + D35784241345D8C90046D202 /* libQtOpenGL_debug.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -105,6 +118,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D357843A134A0AB10046D202 /* QuartzCore.framework in Frameworks */, + D3578439134A0AAE0046D202 /* OpenGLES.framework in Frameworks */, D3CAA7F013264F52008BB877 /* Foundation.framework in Frameworks */, D3CAA7F113264F52008BB877 /* UIKit.framework in Frameworks */, D3CAA7F213264F52008BB877 /* CoreGraphics.framework in Frameworks */, @@ -118,6 +133,7 @@ D3D817B8132A2CFD00CDE422 /* libQtXml.a in Frameworks */, D3D817B9132A2CFD00CDE422 /* libQtXmlPatterns.a in Frameworks */, D3D817BB132A2D0E00CDE422 /* libquikit.a in Frameworks */, + D3578436134A09990046D202 /* libQtOpenGL.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -172,6 +188,8 @@ 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 1D30AB110D05D00D00671497 /* Foundation.framework */, 288765A40DF7441C002DB57D /* CoreGraphics.framework */, + D35784251345D9940046D202 /* OpenGLES.framework */, + D35784271345D9E00046D202 /* QuartzCore.framework */, D3CAA7F913264F8A008BB877 /* libz.1.2.3.dylib */, ); name = Frameworks; @@ -195,6 +213,7 @@ D3D817AB132A2CFD00CDE422 /* libQtDeclarative.a */, D3D817AC132A2CFD00CDE422 /* libQtGui.a */, D3D817AD132A2CFD00CDE422 /* libQtNetwork.a */, + D3578435134A09990046D202 /* libQtOpenGL.a */, D3D817AE132A2CFD00CDE422 /* libQtScript.a */, D3D817AF132A2CFD00CDE422 /* libQtSql.a */, D3D817B0132A2CFD00CDE422 /* libQtXml.a */, @@ -211,6 +230,7 @@ D3CAA81713265056008BB877 /* libQtDeclarative_debug.a */, D3CAA81813265056008BB877 /* libQtGui_debug.a */, D3CAA82713265220008BB877 /* libQtNetwork_debug.a */, + D35784231345D8C90046D202 /* libQtOpenGL_debug.a */, D3CAA81913265056008BB877 /* libQtScript_debug.a */, D3CAA81A13265056008BB877 /* libQtSql_debug.a */, D31659431338B21000760B02 /* libQtXml_debug.a */, diff --git a/src/plugins/platforms/uikit/quikiteventloop.mm b/src/plugins/platforms/uikit/quikiteventloop.mm index 70757b1..d3afd86 100644 --- a/src/plugins/platforms/uikit/quikiteventloop.mm +++ b/src/plugins/platforms/uikit/quikiteventloop.mm @@ -78,10 +78,6 @@ } QUIKitWindow *platformWindow = static_cast(widget->platformWindow()); platformWindow->ensureNativeWindow(); - QUIKitWindowSurface *surface = static_cast(widget->windowSurface()); - UIView *view = surface->nativeView(); - [platformWindow->nativeWindow() addSubview:view]; - [platformWindow->nativeWindow() makeKeyAndVisible]; } return YES; } diff --git a/src/plugins/platforms/uikit/quikitwindow.h b/src/plugins/platforms/uikit/quikitwindow.h index d5a6690..f6d2c27 100644 --- a/src/plugins/platforms/uikit/quikitwindow.h +++ b/src/plugins/platforms/uikit/quikitwindow.h @@ -43,7 +43,33 @@ #define QUIKITWINDOW_H #include -#include + +#import +#import +#import +#import + +@interface EAGLView : UIView +{ + QPlatformWindow *mWindow; + EAGLContext *mContext; + + GLint mFramebufferWidth; + GLint mFramebufferHeight; + + GLuint mFramebuffer, mColorRenderbuffer, mDepthRenderbuffer; +} + +- (void)setContext:(EAGLContext *)newContext; +- (void)presentFramebuffer; +- (void)deleteFramebuffer; +- (void)createFramebuffer; +- (void)makeCurrent; +- (void)setWindow:(QPlatformWindow *)window; +- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons; +@end + +class EAGLPlatformContext; QT_BEGIN_NAMESPACE @@ -60,9 +86,13 @@ public: UIWindow *ensureNativeWindow(); + QPlatformGLContext *glContext() const; + private: QUIKitScreen *mScreen; UIWindow *mWindow; + EAGLView *mView; + mutable EAGLPlatformContext *mContext; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/uikit/quikitwindow.mm b/src/plugins/platforms/uikit/quikitwindow.mm index ebdee06..aafbfa1 100644 --- a/src/plugins/platforms/uikit/quikitwindow.mm +++ b/src/plugins/platforms/uikit/quikitwindow.mm @@ -39,17 +39,221 @@ ** ****************************************************************************/ +#import + #include "quikitwindow.h" #include "quikitscreen.h" #include +#include +#include + +#include + +class EAGLPlatformContext : public QPlatformGLContext +{ +public: + EAGLPlatformContext(EAGLView *view) + : mView(view) + { + mFormat.setWindowApi(QPlatformWindowFormat::OpenGL); + mFormat.setDepthBufferSize(24); + mFormat.setAccumBufferSize(0); + mFormat.setRedBufferSize(8); + mFormat.setGreenBufferSize(8); + mFormat.setBlueBufferSize(8); + mFormat.setAlphaBufferSize(8); + mFormat.setStencilBufferSize(8); + mFormat.setSampleBuffers(false); + mFormat.setSamples(1); +// mFormat.setSwapInterval(?) + mFormat.setDoubleBuffer(true); + mFormat.setDepth(true); + mFormat.setRgba(true); + mFormat.setAlpha(true); + mFormat.setAccum(false); + mFormat.setStencil(true); + mFormat.setStereo(false); + mFormat.setDirectRendering(false); + mFormat.setUseDefaultSharedContext(false); + + EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + [mView setContext:aContext]; + } + + ~EAGLPlatformContext() { } + + void makeCurrent() + { + QPlatformGLContext::makeCurrent(); + [mView makeCurrent]; + } + + void doneCurrent() + { + QPlatformGLContext::doneCurrent(); + } + + void swapBuffers() + { + [mView presentFramebuffer]; + } + + void* getProcAddress(const QString& ) { return 0; } + + QPlatformWindowFormat platformWindowFormat() const + { + return mFormat; + } + +private: + EAGLView *mView; + + QPlatformWindowFormat mFormat; +}; + +@implementation EAGLView + ++ (Class)layerClass +{ + return [CAEAGLLayer class]; +} + +- (id)init +{ + if ((self = [super init])) { + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + eaglLayer.opaque = TRUE; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, + kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, + nil]; + } + return self; +} + +- (void)setContext:(EAGLContext *)newContext +{ + if (mContext != newContext) + { + [self deleteFramebuffer]; + [mContext release]; + mContext = [newContext retain]; + [EAGLContext setCurrentContext:nil]; + } +} + +- (void)presentFramebuffer +{ + if (mContext) { + [EAGLContext setCurrentContext:mContext]; + glBindRenderbufferOES(GL_RENDERBUFFER_OES, mColorRenderbuffer); + [mContext presentRenderbuffer:GL_RENDERBUFFER_OES]; + } +} + +- (void)deleteFramebuffer +{ + if (mContext) + { + [EAGLContext setCurrentContext:mContext]; + if (mFramebuffer) { + glDeleteFramebuffersOES(1, &mFramebuffer); + mFramebuffer = 0; + } + if (mColorRenderbuffer) { + glDeleteRenderbuffersOES(1, &mColorRenderbuffer); + mColorRenderbuffer = 0; + } + if (mDepthRenderbuffer) { + glDeleteRenderbuffersOES(1, &mDepthRenderbuffer); + mDepthRenderbuffer = 0; + } + } +} + +- (void)createFramebuffer +{ + if (mContext && !mFramebuffer) + { + [EAGLContext setCurrentContext:mContext]; + glGenFramebuffersOES(1, &mFramebuffer); + glBindFramebufferOES(GL_FRAMEBUFFER_OES, mFramebuffer); + + glGenRenderbuffersOES(1, &mColorRenderbuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, mColorRenderbuffer); + [mContext renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer *)self.layer]; + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &mFramebufferWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &mFramebufferHeight); + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, mColorRenderbuffer); + + glGenRenderbuffersOES(1, &mDepthRenderbuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, mDepthRenderbuffer); + glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH24_STENCIL8_OES, mFramebufferWidth, mFramebufferHeight); + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, mDepthRenderbuffer); + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, mDepthRenderbuffer); + + if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) + NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); + } +} + +- (void)makeCurrent +{ + if (mContext) + { + [EAGLContext setCurrentContext:mContext]; + if (!mFramebuffer) + [self createFramebuffer]; + glBindFramebufferOES(GL_FRAMEBUFFER_OES, mFramebuffer); + glViewport(0, 0, mFramebufferWidth, mFramebufferHeight); + } +} + +- (void)setWindow:(QPlatformWindow *)window +{ + mWindow = window; +} + +- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons +{ + UITouch *touch = [touches anyObject]; + CGPoint locationInView = [touch locationInView:self]; + QPoint p(locationInView.x, locationInView.y); + // TODO handle global touch point? for status bar? + QWindowSystemInterface::handleMouseEvent(mWindow->widget(), (ulong)(event.timestamp*1000), + p, p, buttons); +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton]; +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ + [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton]; +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ + [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::NoButton]; +} + +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event +{ + [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::NoButton]; +} + +@end QT_BEGIN_NAMESPACE QUIKitWindow::QUIKitWindow(QWidget *tlw) : QPlatformWindow(tlw), - mWindow(nil) + mWindow(nil), + mContext(0) { mScreen = static_cast(QPlatformScreen::platformScreenForWidget(tlw)); CGRect screenBounds = [mScreen->uiScreen() bounds]; @@ -60,6 +264,8 @@ QUIKitWindow::QUIKitWindow(QWidget *tlw) : QUIKitWindow::~QUIKitWindow() { + delete mContext; mContext = 0; + [mView release]; [mWindow release]; } @@ -67,6 +273,8 @@ void QUIKitWindow::setGeometry(const QRect &rect) { if (mWindow) { mWindow.frame = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()); + mView.frame = CGRectMake(0, 0, rect.width(), rect.height()); + [mView deleteFramebuffer]; [mWindow setNeedsDisplay]; } QPlatformWindow::setGeometry(rect); @@ -75,15 +283,31 @@ void QUIKitWindow::setGeometry(const QRect &rect) UIWindow *QUIKitWindow::ensureNativeWindow() { if (!mWindow) { + // window CGRect screenBounds = [mScreen->uiScreen() bounds]; QRect geom = geometry(); CGRect frame = CGRectMake(geom.x(), geom.y(), geom.width(), geom.height()); mWindow = [[UIWindow alloc] initWithFrame:frame]; mWindow.screen = mScreen->uiScreen(); mWindow.frame = frame; // for some reason setting the screen resets frame.origin + + // view + mView = [[EAGLView alloc] initWithFrame:CGRectMake(0, 0, geom.width(), geom.height())]; + [mView setMultipleTouchEnabled:YES]; + [mView setWindow:this]; + [mWindow addSubview:mView]; [mWindow setNeedsDisplay]; + [mWindow makeKeyAndVisible]; } return mWindow; } +QPlatformGLContext *QUIKitWindow::glContext() const +{ + if (!mContext) { + mContext = new EAGLPlatformContext(mView); + } + return mContext; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/uikit/quikitwindowsurface.h b/src/plugins/platforms/uikit/quikitwindowsurface.h index 81f60f5..58ccb1b 100644 --- a/src/plugins/platforms/uikit/quikitwindowsurface.h +++ b/src/plugins/platforms/uikit/quikitwindowsurface.h @@ -43,23 +43,6 @@ #define QUIKITWINDOWSURFACE_H #include -#include -#include - -#include - -@interface QImageView : UIView -{ - CGImageRef m_cgImage; - QWidget *m_widget; -} - -- (void)setImage:(QImage *)image; -- (void)setWidget:(QWidget *)widget; - -//- (QList)touchPointsForTouches:(NSSet *)touches; -- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons; -@end QT_BEGIN_NAMESPACE @@ -70,12 +53,9 @@ public: QPaintDevice *paintDevice(); void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void resize (const QSize &size); - UIView *nativeView() const { return mView; } private: - QImage *mImage; - QImageView *mView; + QPaintDevice *mPaintDevice; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/uikit/quikitwindowsurface.mm b/src/plugins/platforms/uikit/quikitwindowsurface.mm index 1274fca..dd188fb 100644 --- a/src/plugins/platforms/uikit/quikitwindowsurface.mm +++ b/src/plugins/platforms/uikit/quikitwindowsurface.mm @@ -42,201 +42,51 @@ #include "quikitwindowsurface.h" #include "quikitwindow.h" -#include - -@implementation QImageView - -- (void)dealloc -{ - CGImageRelease(m_cgImage); - [super dealloc]; -} - -- (void)setImage:(QImage *)image -{ - CGImageRelease(m_cgImage); - - const uchar *imageData = image->bits(); - int bitDepth = image->depth(); - int colorBufferSize = 8; - int bytesPrLine = image->bytesPerLine(); - int width = image->width(); - int height = image->height(); - - CGColorSpaceRef cgColourSpaceRef = CGColorSpaceCreateDeviceRGB(); - - CGDataProviderRef cgDataProviderRef = CGDataProviderCreateWithData( - NULL, - imageData, - image->byteCount(), - NULL); - - m_cgImage = CGImageCreate(width, - height, - colorBufferSize, - bitDepth, - bytesPrLine, - cgColourSpaceRef, - kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little, - cgDataProviderRef, - NULL, - false, - kCGRenderingIntentDefault); +#include +#include - CGDataProviderRelease(cgDataProviderRef); - CGColorSpaceRelease(cgColourSpaceRef); -} - -- (void)setWidget:(QWidget *)widget -{ - m_widget = widget; -} - -- (void)drawRect:(CGRect)rect -{ - - if (!m_cgImage) - return; - - CGContextRef cgContext = UIGraphicsGetCurrentContext(); - CGContextSaveGState( cgContext ); - - int dy = rect.origin.y + CGRectGetMaxY(rect); - CGContextTranslateCTM(cgContext, 0, dy); - CGContextScaleCTM(cgContext, 1, -1); - CGImageRef subImage = CGImageCreateWithImageInRect(m_cgImage, rect); - CGContextDrawImage(cgContext,rect,subImage); - CGImageRelease(subImage); - - CGContextRestoreGState(cgContext); -} - -//- (QList)touchPointsForTouches:(NSSet *)touches -//{ -// NSEnumerator *enumerator = [touches objectEnumerator]; -// id touch; -// int count = 0; -// QList result; -// while ((touch = [enumerator nextObject])) { -// CGPoint locationInView = [touch locationInView:self]; -// CGRect bounds = [self bounds]; -// struct QWindowSystemInterface::TouchPoint p; -// p.id = count; -// p.isPrimary = true; -// p.normalPosition = QPointF(locationInView.x / bounds.size.width, -// locationInView.y / bounds.size.height); -// p.area = QRectF(locationInView.x, locationInView.y, 1, 1); -// p.pressure = 1.; -// switch ([touch phase]) { -// case UITouchPhaseBegan: -// p.state = Qt::TouchPointPressed; -// break; -// case UITouchPhaseMoved: -// p.state = Qt::TouchPointMoved; -// break; -// case UITouchPhaseStationary: -// p.state = Qt::TouchPointStationary; -// break; -// case UITouchPhaseEnded: -// case UITouchPhaseCancelled: -// p.state = Qt::TouchPointReleased; -// break; -// } -// result << p; -// qDebug() << p.id << ":" << p.normalPosition << p.area << p.state; -// ++count; -// } -// qDebug() << result.size(); -// return result; -//} - -- (void)sendMouseEventForTouches:(NSSet *)touches withEvent:(UIEvent *)event fakeButtons:(Qt::MouseButtons)buttons -{ - UITouch *touch = [touches anyObject]; - CGPoint locationInView = [touch locationInView:self]; - QPoint p(locationInView.x, locationInView.y); - // TODO handle global touch point? for status bar? - QWindowSystemInterface::handleMouseEvent(m_widget, (ulong)(event.timestamp*1000), - p, p, buttons); -} +#include -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +class EAGLPaintDevice : public QGLPaintDevice { - //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000), - // QEvent::TouchBegin, QTouchEvent::TouchScreen, - // [self touchPointsForTouches:touches]); - [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton]; -} +public: + EAGLPaintDevice(QPlatformWindow *window) + :QGLPaintDevice(), mWindow(window) + { + } -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event -{ - //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000), - // QEvent::TouchUpdate, QTouchEvent::TouchScreen, - // [self touchPointsForTouches:touches]); - [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton]; -} + int devType() const { return QInternal::OpenGL; } + QSize size() const { return mWindow->geometry().size(); } + QGLContext* context() const { return QGLContext::fromPlatformGLContext(mWindow->glContext()); } -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ - //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000), - // QEvent::TouchEnd, QTouchEvent::TouchScreen, - // [self touchPointsForTouches:touches]); - [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::NoButton]; -} + QPaintEngine *paintEngine() const { return qt_qgl_paint_engine(); } -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - //QWindowSystemInterface::handleTouchEvent(m_widget, (ulong)(event.timestamp*1000), - // QEvent::TouchEnd, QTouchEvent::TouchScreen, - // [self touchPointsForTouches:touches]); - [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::NoButton]; -} - -@end + void beginPaint(){ + QGLPaintDevice::beginPaint(); + } +private: + QPlatformWindow *mWindow; +}; QT_BEGIN_NAMESPACE QUIKitWindowSurface::QUIKitWindowSurface(QWidget *window) - : QWindowSurface(window) + : QWindowSurface(window), mPaintDevice(new EAGLPaintDevice(window->platformWindow())) { - QUIKitWindow *platformWindow = static_cast(window->platformWindow()); - Q_ASSERT(platformWindow); - const QRect geo = window->geometry(); - mView = [[QImageView alloc] initWithFrame:CGRectMake(geo.x(),geo.y(),geo.width(),geo.height())]; - [mView setMultipleTouchEnabled:YES]; - [mView setWidget:window]; - mImage = new QImage(window->size(),QImage::Format_ARGB32_Premultiplied); - [mView setImage:mImage]; - if (platformWindow->nativeWindow()) { - [platformWindow->nativeWindow() addSubview:mView]; - [mView setNeedsDisplay]; - } + setPartialUpdateSupport(false); } QPaintDevice *QUIKitWindowSurface::paintDevice() { - return mImage; + return mPaintDevice; } void QUIKitWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); + Q_UNUSED(region); Q_UNUSED(offset); - - QRect geo = region.boundingRect(); - [mView setNeedsDisplayInRect:CGRectMake(geo.x(),geo.y(),geo.width(),geo.height())]; -} - -void QUIKitWindowSurface::resize (const QSize &size) -{ - QWindowSurface::resize(size); - - delete mImage; - mImage = new QImage(size,QImage::Format_ARGB32_Premultiplied); - [mView setImage:mImage]; - const QRect geo = geometry(); - [mView setFrame:CGRectMake(geo.x(), geo.y(), size.width(), size.height())]; - [mView setNeedsDisplay]; + widget->platformWindow()->glContext()->swapBuffers(); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/uikit/uikit.pro b/src/plugins/platforms/uikit/uikit.pro index b73c334..1589ee9 100644 --- a/src/plugins/platforms/uikit/uikit.pro +++ b/src/plugins/platforms/uikit/uikit.pro @@ -2,6 +2,8 @@ TARGET = quikit include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms +QT += opengl + OBJECTIVE_SOURCES = main.mm \ quikitintegration.mm \ quikitwindow.mm \ -- cgit v0.12 From c08089639f540cb61cebc92bc6ad2a587550af47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Apr 2011 10:32:05 +0200 Subject: Implemented _NET_WM_PING protocol in XCB backend. --- src/plugins/platforms/xcb/qxcbwindow.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 1f4a13c..4a9409c 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -169,7 +169,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw) int propertyCount = 0; properties[propertyCount++] = atom(QXcbAtom::WM_DELETE_WINDOW); properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS); -// properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); + properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); @@ -466,6 +466,14 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even if (event->format == 32 && event->type == atom(QXcbAtom::WM_PROTOCOLS)) { if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) { QWindowSystemInterface::handleCloseEvent(widget()); + } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) { + xcb_client_message_event_t reply = *event; + + reply.response_type = XCB_CLIENT_MESSAGE; + reply.window = m_screen->root(); + + xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&reply); + xcb_flush(xcb_connection()); } } } -- cgit v0.12 From 4de04d2b15e63287e7436a4ad60a383d959aee34 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 6 Apr 2011 10:37:52 +0200 Subject: use at() instead of [] for const access --- src/gui/painting/qcolormap_qpa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qcolormap_qpa.cpp b/src/gui/painting/qcolormap_qpa.cpp index 1f4fea8..f66607b 100644 --- a/src/gui/painting/qcolormap_qpa.cpp +++ b/src/gui/painting/qcolormap_qpa.cpp @@ -70,7 +70,7 @@ void QColormap::initialize() QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); QList screens = pi->screens(); - screenMap->depth = screens[0]->depth(); + screenMap->depth = screens.at(0)->depth(); if (screenMap->depth < 8) { screenMap->mode = QColormap::Indexed; screenMap->numcolors = 256; -- cgit v0.12 From e19229a9f1f69d9f486c8adbba17a4b6ab3cb26b Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 6 Apr 2011 10:39:40 +0200 Subject: qFatal() if no connection to wayland is available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit abort here is the only thing that makes sense, otherwise, we'll get crashes all over Qt. Reviewed-by: Jørgen Lind --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index b79f355..1c1702f 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -53,6 +53,7 @@ #include #include #include +#include struct wl_surface *QWaylandDisplay::createSurface(void *handle) { @@ -186,8 +187,8 @@ QWaylandDisplay::QWaylandDisplay(void) { mDisplay = wl_display_connect(NULL); if (mDisplay == NULL) { - fprintf(stderr, "failed to create display: %m\n"); - return; + qErrnoWarning(errno, "Failed to create display"); + qFatal("No wayland connection available."); } wl_display_add_global_listener(mDisplay, -- cgit v0.12 From 97581fbc6ba777936e101b6819f364c18ad4429c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Apr 2011 10:39:36 +0200 Subject: Flush XCB connection before blocking. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 2a220af..674bbfd 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -462,6 +462,8 @@ void QXcbConnection::processXcbEvents() else printXcbEvent("Unhandled XCB event", event); } + + xcb_flush(xcb_connection()); } static const char * xcb_atomnames = { -- cgit v0.12 From db566040b68dd175200c1e99a0ae410ed89df25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Apr 2011 10:40:39 +0200 Subject: Re-added missing call log in XCB backend. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 674bbfd..84d98e8 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -375,6 +375,7 @@ void QXcbConnection::log(const char *file, int line, int sequence) info.sequence = sequence; info.file = file; info.line = line; + m_callLog << info; } #endif -- cgit v0.12 From 58b426fb62774b328be77f0c1b7bd31e0321daf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 31 Mar 2011 15:58:46 +0200 Subject: Lighthouse: Make wayland event handling happen in a separate thread --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 101 ++++----------------- src/plugins/platforms/wayland/qwaylanddisplay.h | 30 ++---- src/plugins/platforms/wayland/qwaylandscreen.cpp | 1 + .../platforms/wayland/qwaylandshmsurface.cpp | 4 +- .../platforms/wayland/qwaylandshmwindow.cpp | 37 +------- src/plugins/platforms/wayland/qwaylandshmwindow.h | 9 -- src/plugins/platforms/wayland/qwaylandwindow.cpp | 56 +++++++++++- src/plugins/platforms/wayland/qwaylandwindow.h | 14 ++- src/plugins/platforms/wayland/wayland.pro | 6 +- 9 files changed, 104 insertions(+), 154 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 1c1702f..4f456c9 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -45,11 +45,14 @@ #include "qwaylandscreen.h" #include "qwaylandcursor.h" #include "qwaylandinputdevice.h" +#include "qwaylandeventthread.h" #ifdef QT_WAYLAND_GL_SUPPORT #include "gl_integration/qwaylandglintegration.h" #endif +#include + #include #include #include @@ -110,117 +113,53 @@ const struct wl_shell_listener QWaylandDisplay::shellListener = { QWaylandDisplay::shellHandleConfigure, }; -void QWaylandDisplay::outputHandleGeometry(void *data, - struct wl_output *output, - int32_t x, int32_t y, - int32_t width, int32_t height) -{ - QWaylandDisplay *waylandDisplay = (QWaylandDisplay *) data; - - QRect outputRect = QRect(x, y, width, height); - waylandDisplay->createNewScreen(output, outputRect); -} - -const struct wl_output_listener QWaylandDisplay::outputListener = { - QWaylandDisplay::outputHandleGeometry -}; - -void QWaylandDisplay::displayHandleGlobal(struct wl_display *display, - uint32_t id, - const char *interface, - uint32_t version, void *data) +void QWaylandDisplay::displayHandleGlobal(uint32_t id, QByteArray interface, uint32_t version) { Q_UNUSED(version); - QWaylandDisplay *qwd = (QWaylandDisplay *) data; - - if (strcmp(interface, "compositor") == 0) { - qwd->mCompositor = wl_compositor_create(display, id); - } else if (strcmp(interface, "shm") == 0) { - qwd->mShm = wl_shm_create(display, id); - } else if (strcmp(interface, "shell") == 0) { - qwd->mShell = wl_shell_create(display, id); - wl_shell_add_listener(qwd->mShell, &shellListener, qwd); - } else if (strcmp(interface, "output") == 0) { - struct wl_output *output = wl_output_create(display, id); - wl_output_add_listener(output, &outputListener, qwd); - } else if (strcmp(interface, "input_device") == 0) { + + if (interface == "compositor") { + mCompositor = wl_compositor_create(mDisplay, id); + } else if (interface == "shm") { + mShm = wl_shm_create(mDisplay, id); + } else if (interface == "shell"){ + mShell = wl_shell_create(mDisplay, id); + wl_shell_add_listener(mShell, &shellListener, this); + } else if (interface == "input_device") { QWaylandInputDevice *inputDevice = - new QWaylandInputDevice(display, id); - qwd->mInputDevices.append(inputDevice); + new QWaylandInputDevice(mDisplay, id); + mInputDevices.append(inputDevice); } } -void QWaylandDisplay::iterate() -{ - wl_display_iterate(mDisplay, WL_DISPLAY_READABLE | WL_DISPLAY_WRITABLE); -} - -void QWaylandDisplay::readEvents(void) -{ - wl_display_iterate(mDisplay, WL_DISPLAY_READABLE); -} - -int -QWaylandDisplay::sourceUpdate(uint32_t mask, void *data) -{ - QWaylandDisplay *qwd = (QWaylandDisplay *) data; - - /* FIXME: We get a callback here when we ask wl_display for the - * fd, but at that point we don't have the socket notifier as we - * need the fd to create that. We'll probably need to split that - * API into get_fd and set_update_func functions. */ - if (qwd->mWriteNotifier == NULL) - return 0; - - qwd->mWriteNotifier->setEnabled(mask & WL_DISPLAY_WRITABLE); - - return 0; -} - -void QWaylandDisplay::flushRequests(void) -{ - wl_display_iterate(mDisplay, WL_DISPLAY_WRITABLE); -} - QWaylandDisplay::QWaylandDisplay(void) - : mWriteNotifier(0) { mDisplay = wl_display_connect(NULL); if (mDisplay == NULL) { qErrnoWarning(errno, "Failed to create display"); qFatal("No wayland connection available."); } - - wl_display_add_global_listener(mDisplay, - QWaylandDisplay::displayHandleGlobal, this); - #ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration = QWaylandGLIntegration::createGLIntegration(this); #endif - readEvents(); + mEventThread = new QWaylandEventThread(this); + + + mEventThread->waitForScreens(); #ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration->initialize(); #endif - int fd = wl_display_get_fd(mDisplay, sourceUpdate, this); - mReadNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); - connect(mReadNotifier, - SIGNAL(activated(int)), this, SLOT(readEvents())); - mWriteNotifier = new QSocketNotifier(fd, QSocketNotifier::Write, this); - connect(mWriteNotifier, - SIGNAL(activated(int)), this, SLOT(flushRequests())); - mWriteNotifier->setEnabled(false); } QWaylandDisplay::~QWaylandDisplay(void) { - close(mFd); #ifdef QT_WAYLAND_GL_SUPPORT delete mEglIntegration; #endif + delete mEventThread; wl_display_destroy(mDisplay); } diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 481f829..4cfb7b5 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -45,6 +45,8 @@ #include #include +#include + #include class QWaylandInputDevice; @@ -53,6 +55,7 @@ class QWaylandBuffer; class QPlatformScreen; class QWaylandScreen; class QWaylandGLIntegration; +class QWaylandEventThread; class QWaylandDisplay : public QObject { Q_OBJECT @@ -61,7 +64,6 @@ public: QWaylandDisplay(void); ~QWaylandDisplay(void); - void createNewScreen(struct wl_output *output, QRect geometry); QList screens() const { return mScreens; } struct wl_surface *createSurface(void *handle); struct wl_buffer *createShmBuffer(int fd, int width, int height, @@ -76,49 +78,33 @@ public: #endif void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y); + void syncCallback(wl_display_sync_func_t func, void *data); void frameCallback(wl_display_frame_func_t func, void *data); - void iterate(); - struct wl_display *wl_display() const { return mDisplay; } public slots: - void readEvents(void); - void flushRequests(void); + void createNewScreen(struct wl_output *output, QRect geometry); + void displayHandleGlobal(uint32_t id, QByteArray interface, uint32_t version); private: struct wl_display *mDisplay; + QWaylandEventThread *mEventThread; struct wl_compositor *mCompositor; struct wl_shm *mShm; struct wl_shell *mShell; - char *mDeviceName; - int mFd; QList mScreens; QList mInputDevices; - QSocketNotifier *mReadNotifier; - QSocketNotifier *mWriteNotifier; + #ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration *mEglIntegration; #endif - static void displayHandleGlobal(struct wl_display *display, - uint32_t id, - const char *interface, - uint32_t version, void *data); - - static void outputHandleGeometry(void *data, - struct wl_output *output, - int32_t x, int32_t y, - int32_t width, int32_t height); - static void shellHandleConfigure(void *data, struct wl_shell *shell, uint32_t time, uint32_t edges, struct wl_surface *surface, int32_t width, int32_t height); - static int sourceUpdate(uint32_t mask, void *data); - - static const struct wl_output_listener outputListener; static const struct wl_shell_listener shellListener; }; diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index 35e2532..4f50cb6 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -53,6 +53,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, struct wl_output , mFormat(QImage::Format_ARGB32_Premultiplied) , mWaylandCursor(new QWaylandCursor(this)) { + moveToThread(waylandDisplay->thread()); } QWaylandScreen::~QWaylandScreen() diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp index cc6b2a1..34f4436 100644 --- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp @@ -111,9 +111,7 @@ void QWaylandShmWindowSurface::beginPaint(const QRegion &) { QWaylandShmWindow *waylandWindow = static_cast(window()->platformWindow()); Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm); - while (waylandWindow->waitingForFrameSync()) { - mDisplay->iterate(); - } + waylandWindow->waitForFrameSync(); } void QWaylandShmWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp index 2808ed6..c083e58 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp @@ -45,10 +45,10 @@ #include +#include + QWaylandShmWindow::QWaylandShmWindow(QWidget *widget) : QWaylandWindow(widget) - , mBuffer(0) - , mWaitingForFrameSync(false) { newSurfaceCreated(); } @@ -69,36 +69,3 @@ QPlatformGLContext * QWaylandShmWindow::glContext() const return 0; } -void QWaylandShmWindow::attach(QWaylandBuffer *buffer) -{ - mBuffer = buffer; - if (mSurface) { - wl_surface_attach(mSurface, buffer->buffer(),0,0); - } -} - - -void QWaylandShmWindow::damage(const QRegion ®ion) -{ - QVector rects = region.rects(); - for (int i = 0; i < rects.size(); i++) { - const QRect rect = rects.at(i); - wl_surface_damage(mSurface, - rect.x(), rect.y(), rect.width(), rect.height()); - } - mWaitingForFrameSync = true; - mDisplay->frameCallback(QWaylandShmWindow::frameCallback, this); -} - -void QWaylandShmWindow::newSurfaceCreated() -{ - if (mBuffer) { - wl_surface_attach(mSurface,mBuffer->buffer(),0,0); - } -} - -void QWaylandShmWindow::frameCallback(void *data, uint32_t time) -{ - QWaylandShmWindow *self = static_cast(data); - self->mWaitingForFrameSync = false; -} diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h index 3876c52..5dc6351 100644 --- a/src/plugins/platforms/wayland/qwaylandshmwindow.h +++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h @@ -53,15 +53,6 @@ public: WindowType windowType() const; QPlatformGLContext *glContext() const; - void attach(QWaylandBuffer *buffer); - void damage(const QRegion ®ion); - bool waitingForFrameSync() const { return mWaitingForFrameSync; } -protected: - void newSurfaceCreated(); -private: - static void frameCallback(void *data, uint32_t time); - QWaylandBuffer *mBuffer; - bool mWaitingForFrameSync; }; #endif // QWAYLANDSHMWINDOW_H diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index e994616..aa72ad5 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -43,6 +43,7 @@ #include "qwaylanddisplay.h" #include "qwaylandscreen.h" +#include "qwaylandbuffer.h" #include #include @@ -52,6 +53,8 @@ QWaylandWindow::QWaylandWindow(QWidget *window) : QPlatformWindow(window) , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display()) + , mBuffer(0) + , mWaitingForFrameSync(false) { static WId id = 1; mWindowId = id++; @@ -73,7 +76,7 @@ WId QWaylandWindow::winId() const void QWaylandWindow::setParent(const QPlatformWindow *parent) { Q_UNUSED(parent); - qWarning("Trying to add a raster window as a sub-window"); + qWarning("Sub window is not supported"); } void QWaylandWindow::setVisible(bool visible) @@ -103,3 +106,54 @@ void QWaylandWindow::configure(uint32_t time, uint32_t edges, QWindowSystemInterface::handleGeometryChange(widget(), geometry); } + +void QWaylandWindow::attach(QWaylandBuffer *buffer) +{ + mBuffer = buffer; + if (mSurface) { + wl_surface_attach(mSurface, buffer->buffer(),0,0); + } +} + + +void QWaylandWindow::damage(const QRegion ®ion) +{ + //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, this); + mWaitingForFrameSync = true; + + QVector rects = region.rects(); + for (int i = 0; i < rects.size(); i++) { + const QRect rect = rects.at(i); + wl_surface_damage(mSurface, + rect.x(), rect.y(), rect.width(), rect.height()); + } +} + +void QWaylandWindow::newSurfaceCreated() +{ + if (mBuffer) { + wl_surface_attach(mSurface,mBuffer->buffer(),0,0); + } +} + +void QWaylandWindow::frameCallback(void *data, uint32_t time) +{ + Q_UNUSED(time); + QWaylandWindow *self = static_cast(data); + if (self->mWaitingForFrameSync) { + self->mWaitingForFrameSync = false; + self->mFrameSyncWait.wakeAll(); + } +} + +void QWaylandWindow::waitForFrameSync() +{ + if (!mWaitingForFrameSync) { + return; + } + QMutex lock; + lock.lock(); + mFrameSyncWait.wait(&lock); +} diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h index afc214e..ad4bba4 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.h +++ b/src/plugins/platforms/wayland/qwaylandwindow.h @@ -43,6 +43,8 @@ #define QWAYLANDWINDOW_H #include +#include +#include #include "qwaylanddisplay.h" @@ -69,11 +71,21 @@ public: void configure(uint32_t time, uint32_t edges, int32_t x, int32_t y, int32_t width, int32_t height); + void attach(QWaylandBuffer *buffer); + void damage(const QRegion ®ion); + + void waitForFrameSync(); protected: struct wl_surface *mSurface; - virtual void newSurfaceCreated() = 0; + virtual void newSurfaceCreated(); QWaylandDisplay *mDisplay; + QWaylandBuffer *mBuffer; WId mWindowId; + bool mWaitingForFrameSync; + QWaitCondition mFrameSyncWait; + +private: + static void frameCallback(void *data, uint32_t time); }; diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index e5c866b..849299a 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -14,7 +14,8 @@ SOURCES = main.cpp \ qwaylanddisplay.cpp \ qwaylandwindow.cpp \ qwaylandscreen.cpp \ - qwaylandshmwindow.cpp + qwaylandshmwindow.cpp \ + qwaylandeventthread.cpp HEADERS = qwaylandintegration.h \ qwaylandcursor.h \ @@ -23,7 +24,8 @@ HEADERS = qwaylandintegration.h \ qwaylandscreen.h \ qwaylandshmsurface.h \ qwaylandbuffer.h \ - qwaylandshmwindow.h + qwaylandshmwindow.h \ + qwaylandeventthread.h INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND LIBS += $$QMAKE_LIBS_WAYLAND -- cgit v0.12 From fa5ae72b036f64b6f30c6b25a8c3feffcb56b51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 31 Mar 2011 15:13:28 +0200 Subject: After we make the QPlatformIntegration process events --- src/gui/kernel/qapplication_qpa.cpp | 2 + .../platforms/wayland/qwaylandeventthread.cpp | 158 +++++++++++++++++++++ .../platforms/wayland/qwaylandeventthread.h | 87 ++++++++++++ 3 files changed, 247 insertions(+) create mode 100644 src/plugins/platforms/wayland/qwaylandeventthread.cpp create mode 100644 src/plugins/platforms/wayland/qwaylandeventthread.h diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index 1d4400a..b1f26fd 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -564,6 +564,8 @@ void qt_init(QApplicationPrivate *priv, int type) init_platform(QLatin1String(platformName), platformPluginPath); init_plugins(pluginList); + QApplication::processEvents(); + QColormap::initialize(); QFont::initialize(); #ifndef QT_NO_CURSOR diff --git a/src/plugins/platforms/wayland/qwaylandeventthread.cpp b/src/plugins/platforms/wayland/qwaylandeventthread.cpp new file mode 100644 index 0000000..1474d9c --- /dev/null +++ b/src/plugins/platforms/wayland/qwaylandeventthread.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandeventthread.h" + +#include + +QWaylandEventThread::QWaylandEventThread(QWaylandDisplay *display) + : QObject() + , mDisplay(display) + , mReadNotifier(0) + , mWriteNotifier(0) + , mFd(0) + , mScreensInitialized(false) +{ + qRegisterMetaType("uint32_t"); + QThread *thread = new QThread(this); + moveToThread(thread); + connect(thread,SIGNAL(started()),SLOT(runningInThread())); + thread->start(); + +} + +QWaylandEventThread::~QWaylandEventThread() +{ + close(mFd); +} + +void QWaylandEventThread::runningInThread() +{ + + wl_display_add_global_listener(mDisplay->wl_display(), + QWaylandEventThread::displayHandleGlobal, this); + int fd = wl_display_get_fd(mDisplay->wl_display(), sourceUpdate, this); + mReadNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); + connect(mReadNotifier, + SIGNAL(activated(int)), this, SLOT(readEvents())); + + mWriteNotifier = new QSocketNotifier(fd, QSocketNotifier::Write, this); + connect(mWriteNotifier, + SIGNAL(activated(int)), this, SLOT(flushRequests())); + mWriteNotifier->setEnabled(false); + + readEvents(); +} + + +int QWaylandEventThread::sourceUpdate(uint32_t mask, void *data) +{ + QWaylandEventThread *eventThread = (QWaylandEventThread *) data; + + /* FIXME: We get a callback here when we ask wl_display for the + * fd, but at that point we don't have the socket notifier as we + * need the fd to create that. We'll probably need to split that + * API into get_fd and set_update_func functions. */ + if (eventThread->mWriteNotifier == NULL) + return 0; + + QMetaObject::invokeMethod(eventThread->mWriteNotifier,"setEnabled",Qt::QueuedConnection, + Q_ARG(bool,mask & WL_DISPLAY_WRITABLE)); +// eventThread->mWriteNotifier->setEnabled(mask & WL_DISPLAY_WRITABLE); + + return 0; +} + +void QWaylandEventThread::readEvents() +{ + wl_display_iterate(mDisplay->wl_display(), WL_DISPLAY_READABLE); +} + + +void QWaylandEventThread::flushRequests() +{ + wl_display_iterate(mDisplay->wl_display(), WL_DISPLAY_WRITABLE); +} + +void QWaylandEventThread::outputHandleGeometry(void *data, + struct wl_output *output, + int32_t x, int32_t y, + int32_t width, int32_t height) +{ + //call back function called from another thread; + //but its safe to call createScreen from another thread since + //QWaylandScreen does a moveToThread + QWaylandEventThread *waylandEventThread = static_cast(data); + QRect outputRect = QRect(x, y, width, height); + waylandEventThread->mDisplay->createNewScreen(output,outputRect); + waylandEventThread->mScreensInitialized = true; + waylandEventThread->mWaitForScreens.wakeAll(); +} + +const struct wl_output_listener QWaylandEventThread::outputListener = { + QWaylandEventThread::outputHandleGeometry +}; + +void QWaylandEventThread::displayHandleGlobal(wl_display *display, + uint32_t id, + const char *interface, + uint32_t version, + void *data) +{ + if (strcmp(interface, "output") == 0) { + struct wl_output *output = wl_output_create(display, id); + wl_output_add_listener(output, &outputListener, data); + } + Q_UNUSED(display); + QWaylandEventThread *that = static_cast(data); + QByteArray interfaceByteArray(interface); + QMetaObject::invokeMethod(that->mDisplay,"displayHandleGlobal",Qt::QueuedConnection, + Q_ARG(uint32_t,id),Q_ARG(QByteArray,interfaceByteArray),Q_ARG(uint32_t,version)); +} + +void QWaylandEventThread::waitForScreens() +{ + QMutex lock; + lock.lock(); + if (!mScreensInitialized) { + mWaitForScreens.wait(&lock); + } +} diff --git a/src/plugins/platforms/wayland/qwaylandeventthread.h b/src/plugins/platforms/wayland/qwaylandeventthread.h new file mode 100644 index 0000000..7a5189e --- /dev/null +++ b/src/plugins/platforms/wayland/qwaylandeventthread.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDEVENTTHREAD_H +#define QWAYLANDEVENTTHREAD_H + +#include "qwaylanddisplay.h" + +#include +#include +#include +#include + +class QWaylandEventThread : public QObject +{ + Q_OBJECT +public: + explicit QWaylandEventThread(QWaylandDisplay *display); + ~QWaylandEventThread(); + + static int sourceUpdate(uint32_t mask, void *data); + + void waitForScreens(); + +signals: +public slots: + void runningInThread(); + void readEvents(); + void flushRequests(); +private: + QWaylandDisplay *mDisplay; + QSocketNotifier *mReadNotifier; + QSocketNotifier *mWriteNotifier; + int mFd; + QWaitCondition mWaitForScreens; + bool mScreensInitialized; + + static const struct wl_output_listener outputListener; + static void displayHandleGlobal(struct wl_display *display, + uint32_t id, + const char *interface, + uint32_t version, void *data); + static void outputHandleGeometry(void *data, + struct wl_output *output, + int32_t x, int32_t y, + int32_t width, int32_t height); +}; + +#endif // QWAYLANDEVENTTHREAD_H -- cgit v0.12 From 111b2e2ba991f1406928c81780308ef832156fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 6 Apr 2011 10:15:05 +0200 Subject: Lighthouse: More meaning full output when choosing glx configs --- src/plugins/platforms/glxconvenience/qglxconvenience.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp index f548ad9..fd3c4c4 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp @@ -108,7 +108,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow } if (!chosenConfig) - qWarning("Warning no context created"); + qWarning("Warning: no suitable glx confiuration found"); return chosenConfig; } -- cgit v0.12 From e82b69ed193d331072b9f398b214a0322ed7b1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 6 Apr 2011 10:16:51 +0200 Subject: Lighthouse: Implement xcomposite extension for wayland --- .../wayland/gl_integration/gl_integration.pri | 4 + .../qwaylandxcompositeglxcontext.cpp | 101 +++++++++++++++++ .../xcomposite_glx/qwaylandxcompositeglxcontext.h | 43 +++++++ .../qwaylandxcompositeglxintegration.cpp | 85 ++++++++++++++ .../qwaylandxcompositeglxintegration.h | 52 +++++++++ .../xcomposite_glx/qwaylandxcompositeglxwindow.cpp | 36 ++++++ .../xcomposite_glx/qwaylandxcompositeglxwindow.h | 24 ++++ .../xcomposite_glx/xcomposite_glx.pri | 13 +++ .../xcomposite_share/qwaylandxcompositebuffer.cpp | 18 +++ .../xcomposite_share/qwaylandxcompositebuffer.h | 21 ++++ .../wayland-xcomposite-client-protocol.h | 126 +++++++++++++++++++++ .../xcomposite_share/wayland-xcomposite-protocol.c | 41 +++++++ .../xcomposite_share/xcomposite_share.pri | 9 ++ 13 files changed, 573 insertions(+) create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_share/xcomposite_share.pri diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index 10567cd..52272c3 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -17,3 +17,7 @@ xpixmap_egl { xpixmap_glx { include ($$PWD/xpixmap_glx/xpixmap_glx.pri) } + +xcomposite_glx { + include ($$PWD/xcomposite_glx/xcomposite_glx.pri) +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp new file mode 100644 index 0000000..679772c --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -0,0 +1,101 @@ +#include "qwaylandxcompositeglxcontext.h" + +#include "qwaylandxcompositeglxwindow.h" +#include "qwaylandxcompositebuffer.h" + +#include "wayland-xcomposite-client-protocol.h" +#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->widget()->platformWindowFormat())) +{ + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); + mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE); + + geometryChanged(); +} + +void QWaylandXCompositeGLXContext::makeCurrent() +{ + QPlatformGLContext::makeCurrent(); + glXMakeCurrent(mGlxIntegration->xDisplay(),mXWindow,mContext); +} + +void QWaylandXCompositeGLXContext::doneCurrent() +{ + glXMakeCurrent(mGlxIntegration->xDisplay(),0,0); + QPlatformGLContext::doneCurrent(); +} + +void QWaylandXCompositeGLXContext::swapBuffers() +{ + QSize size = mWindow->geometry().size(); + + glXSwapBuffers(mGlxIntegration->xDisplay(),mXWindow); + mWindow->damage(QRegion(QRect(QPoint(0,0),size))); + mWindow->waitForFrameSync(); +} + +void * QWaylandXCompositeGLXContext::getProcAddress(const QString &procName) +{ + return (void *) glXGetProcAddress(reinterpret_cast(procName.toLatin1().data())); +} + +QPlatformWindowFormat QWaylandXCompositeGLXContext::platformWindowFormat() const +{ + return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); +} + +void QWaylandXCompositeGLXContext::sync_function(void *data) +{ + QWaylandXCompositeGLXContext *that = static_cast(data); + that->mWaitCondition.wakeAll(); +} + +void QWaylandXCompositeGLXContext::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(mGlxIntegration->xDisplay(),mXWindow); + } + + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(mGlxIntegration->xDisplay(),mConfig); + Colormap cmap = XCreateColormap(mGlxIntegration->xDisplay(),mGlxIntegration->rootWindow(),visualInfo->visual,AllocNone); + + XSetWindowAttributes a; + a.colormap = cmap; + mXWindow = XCreateWindow(mGlxIntegration->xDisplay(), mGlxIntegration->rootWindow(),0, 0, size.width(), size.height(), + 0, visualInfo->depth, InputOutput, visualInfo->visual, + 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); + wl_display_sync_callback(mGlxIntegration->waylandDisplay()->wl_display(), + QWaylandXCompositeGLXContext::sync_function, + this); + QMutex lock; + lock.lock(); + wl_display_sync(mGlxIntegration->waylandDisplay()->wl_display(),0); + mWaitCondition.wait(&lock); +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h new file mode 100644 index 0000000..e5ccd9e --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -0,0 +1,43 @@ +#ifndef QWAYLANDXCOMPOSITEGLXCONTEXT_H +#define QWAYLANDXCOMPOSITEGLXCONTEXT_H + +#include + +#include + +#include "qwaylandbuffer.h" +#include "qwaylandxcompositeglxintegration.h" + +#include "qglxconvenience.h" + +class QWaylandXCompositeGLXWindow; +class QWaylandShmBuffer; + +class QWaylandXCompositeGLXContext : public QPlatformGLContext +{ +public: + QWaylandXCompositeGLXContext(QWaylandXCompositeGLXIntegration *glxIntegration, QWaylandXCompositeGLXWindow *window); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + + QPlatformWindowFormat platformWindowFormat() const; + + void geometryChanged(); + +private: + QWaylandXCompositeGLXIntegration *mGlxIntegration; + QWaylandXCompositeGLXWindow *mWindow; + QWaylandBuffer *mBuffer; + + Window mXWindow; + GLXFBConfig mConfig; + GLXContext mContext; + + static void sync_function(void *data); + QWaitCondition mWaitCondition; +}; + +#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 new file mode 100644 index 0000000..dce3d27 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -0,0 +1,85 @@ +#include "qwaylandxcompositeglxintegration.h" + +#include "qwaylandxcompositeglxwindow.h" + +#include + +#include "wayland-xcomposite-client-protocol.h" + +QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandXCompositeGLXIntegration(waylandDisplay); +} + +QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDisplay * waylandDispaly) + : QWaylandGLIntegration() + , mWaylandDisplay(waylandDispaly) +{ + wl_display_add_global_listener(waylandDispaly->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal, + this); +} + +QWaylandXCompositeGLXIntegration::~QWaylandXCompositeGLXIntegration() +{ + XCloseDisplay(mDisplay); +} + +void QWaylandXCompositeGLXIntegration::initialize() +{ +} + +QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWidget *widget) +{ + return new QWaylandXCompositeGLXWindow(widget,this); +} + +Display * QWaylandXCompositeGLXIntegration::xDisplay() const +{ + return mDisplay; +} + +int QWaylandXCompositeGLXIntegration::screen() const +{ + return mScreen; +} + +Window QWaylandXCompositeGLXIntegration::rootWindow() const +{ + return mRootWindow; +} + +QWaylandDisplay * QWaylandXCompositeGLXIntegration::waylandDisplay() const +{ + return mWaylandDisplay; +} +wl_xcomposite * QWaylandXCompositeGLXIntegration::waylandXComposite() const +{ + return mWaylandComposite; +} + +const struct wl_xcomposite_listener QWaylandXCompositeGLXIntegration::xcomposite_listener = { + QWaylandXCompositeGLXIntegration::rootInformation +}; + +void QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) +{ + Q_UNUSED(version); + if (strcmp(interface, "xcomposite") == 0) { + QWaylandXCompositeGLXIntegration *integration = static_cast(data); + integration->mWaylandComposite = wl_xcomposite_create(display,id); + wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration); + } + +} + +void QWaylandXCompositeGLXIntegration::rootInformation(void *data, wl_xcomposite *xcomposite, const char *display_name, uint32_t root_window) +{ + Q_UNUSED(xcomposite); + QWaylandXCompositeGLXIntegration *integration = static_cast(data); + + qDebug() << "ROOT INFORMATION" << integration->mDisplay << integration->mRootWindow << integration->mScreen; + 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/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h new file mode 100644 index 0000000..650fdcf --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h @@ -0,0 +1,52 @@ +#ifndef QWAYLANDXCOMPOSITEGLXINTEGRATION_H +#define QWAYLANDXCOMPOSITEGLXINTEGRATION_H + +#include "gl_integration/qwaylandglintegration.h" +#include "wayland-client.h" + +#include +#include +#include +#include +#include + +#include + +struct wl_xcomposite; + +class QWaylandXCompositeGLXIntegration : public QWaylandGLIntegration +{ +public: + QWaylandXCompositeGLXIntegration(QWaylandDisplay * waylandDispaly); + ~QWaylandXCompositeGLXIntegration(); + + void initialize(); + + QWaylandWindow *createEglWindow(QWidget *widget); + + QWaylandDisplay *waylandDisplay() const; + struct wl_xcomposite *waylandXComposite() const; + + Display *xDisplay() const; + int screen() const; + Window rootWindow() const; + +private: + QWaylandDisplay *mWaylandDisplay; + struct wl_xcomposite *mWaylandComposite; + + Display *mDisplay; + int mScreen; + Window mRootWindow; + + static void wlDisplayHandleGlobal(struct wl_display *display, uint32_t id, + const char *interface, uint32_t version, void *data); + + static const struct wl_xcomposite_listener xcomposite_listener; + static void rootInformation(void *data, + struct wl_xcomposite *xcomposite, + const char *display_name, + uint32_t root_window); +}; + +#endif // QWAYLANDXCOMPOSITEGLXINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp new file mode 100644 index 0000000..57ee27e --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp @@ -0,0 +1,36 @@ +#include "qwaylandxcompositeglxwindow.h" + +#include + +QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration) + : QWaylandWindow(window) + , mGlxIntegration(glxIntegration) + , mContext(0) +{ + +} + +QWaylandWindow::WindowType QWaylandXCompositeGLXWindow::windowType() const +{ + //yeah. this type needs a new name + return QWaylandWindow::Egl; +} + +QPlatformGLContext * QWaylandXCompositeGLXWindow::glContext() const +{ + if (!mContext) { + qDebug() << "creating glcontext;"; + QWaylandXCompositeGLXWindow *that = const_cast(this); + that->mContext = new QWaylandXCompositeGLXContext(mGlxIntegration,that); + } + return mContext; +} + +void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect) +{ + QWaylandWindow::setGeometry(rect); + + if (mContext) { + mContext->geometryChanged(); + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h new file mode 100644 index 0000000..75058a5 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h @@ -0,0 +1,24 @@ +#ifndef QWAYLANDXCOMPOSITEGLXWINDOW_H +#define QWAYLANDXCOMPOSITEGLXWINDOW_H + +#include "qwaylandwindow.h" +#include "qwaylandxcompositeglxintegration.h" +#include "qwaylandxcompositeglxcontext.h" + +class QWaylandXCompositeGLXWindow : public QWaylandWindow +{ +public: + QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration); + WindowType windowType() const; + + QPlatformGLContext *glContext() const; + + void setGeometry(const QRect &rect); + +private: + QWaylandXCompositeGLXIntegration *mGlxIntegration; + QWaylandXCompositeGLXContext *mContext; + +}; + +#endif // QWAYLANDXCOMPOSITEGLXWINDOW_H 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 new file mode 100644 index 0000000..43295e9 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/xcomposite_glx.pri @@ -0,0 +1,13 @@ +include (../xcomposite_share/xcomposite_share.pri) +include (../../../glxconvenience/glxconvenience.pri) + +LIBS += -lXcomposite +SOURCES += \ + $$PWD/qwaylandxcompositeglxcontext.cpp \ + $$PWD/qwaylandxcompositeglxintegration.cpp \ + $$PWD/qwaylandxcompositeglxwindow.cpp + +HEADERS += \ + $$PWD/qwaylandxcompositeglxcontext.h \ + $$PWD/qwaylandxcompositeglxintegration.h \ + $$PWD/qwaylandxcompositeglxwindow.h diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp new file mode 100644 index 0000000..218907e --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp @@ -0,0 +1,18 @@ +#include "qwaylandxcompositebuffer.h" + +#include "wayland-client.h" + +QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(wl_xcomposite *xcomposite, uint32_t window, const QSize &size, wl_visual *visual) + :mSize(size) +{ + mBuffer = wl_xcomposite_create_buffer(xcomposite, + window, + size.width(), + size.height(), + visual); +} + +QSize QWaylandXCompositeBuffer::size() const +{ + return mSize; +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h new file mode 100644 index 0000000..c9332d9 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h @@ -0,0 +1,21 @@ +#ifndef QWAYLANDXCOMPOSITEBUFFER_H +#define QWAYLANDXCOMPOSITEBUFFER_H + +#include "qwaylandbuffer.h" + +#include "wayland-xcomposite-client-protocol.h" + +class QWaylandXCompositeBuffer : public QWaylandBuffer +{ +public: + QWaylandXCompositeBuffer(struct wl_xcomposite *xcomposite, + uint32_t window, + const QSize &size, + struct wl_visual *visual); + + QSize size() const; +private: + QSize mSize; +}; + +#endif // QWAYLANDXCOMPOSITEBUFFER_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h new file mode 100644 index 0000000..1955a74 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h @@ -0,0 +1,126 @@ +/* + * Copyright © 2010 Kristian Høgsberg + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#ifndef XCOMPOSITE_CLIENT_PROTOCOL_H +#define XCOMPOSITE_CLIENT_PROTOCOL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "wayland-util.h" + +struct wl_client; + +struct wl_xcomposite; + +struct wl_proxy; + +extern void +wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...); +extern struct wl_proxy * +wl_proxy_create(struct wl_proxy *factory, + const struct wl_interface *interface); +extern struct wl_proxy * +wl_proxy_create_for_id(struct wl_display *display, + const struct wl_interface *interface, uint32_t id); +extern void +wl_proxy_destroy(struct wl_proxy *proxy); + +extern int +wl_proxy_add_listener(struct wl_proxy *proxy, + void (**implementation)(void), void *data); + +extern void +wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data); + +extern void * +wl_proxy_get_user_data(struct wl_proxy *proxy); + +extern const struct wl_interface wl_xcomposite_interface; + +struct wl_xcomposite_listener { + void (*root)(void *data, + struct wl_xcomposite *xcomposite, + const char *display_name, + uint32_t root_window); +}; + +static inline int +wl_xcomposite_add_listener(struct wl_xcomposite *xcomposite, + const struct wl_xcomposite_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) xcomposite, + (void (**)(void)) listener, data); +} + +#define WL_XCOMPOSITE_CREATE_BUFFER 0 + +static inline struct wl_xcomposite * +wl_xcomposite_create(struct wl_display *display, uint32_t id) +{ + return (struct wl_xcomposite *) + wl_proxy_create_for_id(display, &wl_xcomposite_interface, id); +} + +static inline void +wl_xcomposite_set_user_data(struct wl_xcomposite *xcomposite, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) xcomposite, user_data); +} + +static inline void * +wl_xcomposite_get_user_data(struct wl_xcomposite *xcomposite) +{ + return wl_proxy_get_user_data((struct wl_proxy *) xcomposite); +} + +static inline void +wl_xcomposite_destroy(struct wl_xcomposite *xcomposite) +{ + wl_proxy_destroy((struct wl_proxy *) xcomposite); +} + +static inline struct wl_buffer * +wl_xcomposite_create_buffer(struct wl_xcomposite *xcomposite, uint32_t x_window, int width, int height, struct wl_visual *visual) +{ + struct wl_proxy *id; + + id = wl_proxy_create((struct wl_proxy *) xcomposite, + &wl_buffer_interface); + if (!id) + return NULL; + + wl_proxy_marshal((struct wl_proxy *) xcomposite, + WL_XCOMPOSITE_CREATE_BUFFER, id, x_window, width, height, visual); + + return (struct wl_buffer *) id; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c new file mode 100644 index 0000000..da2e4a2 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c @@ -0,0 +1,41 @@ +/* + * Copyright © 2010 Kristian Høgsberg + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#include +#include +#include "wayland-util.h" + +static const struct wl_message xcomposite_requests[] = { + { "create_buffer", "nuiio" }, +}; + +static const struct wl_message xcomposite_events[] = { + { "root", "su" }, +}; + +WL_EXPORT const struct wl_interface wl_xcomposite_interface = { + "xcomposite", 1, + ARRAY_LENGTH(xcomposite_requests), xcomposite_requests, + ARRAY_LENGTH(xcomposite_events), xcomposite_events, +}; + diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/xcomposite_share.pri b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/xcomposite_share.pri new file mode 100644 index 0000000..03b3521 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/xcomposite_share.pri @@ -0,0 +1,9 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/wayland-xcomposite-client-protocol.h \ + gl_integration/xcomposite_share/qwaylandxcompositebuffer.h + +SOURCES += \ + $$PWD/wayland-xcomposite-protocol.c \ + gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp -- cgit v0.12 From 9086024565cac2fd9ebc7eeb8abd6449ecf960d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 6 Apr 2011 11:11:00 +0200 Subject: Remove output that wass added by misstake in 39ede7e7914b486d5971491dd742da3712a1d7e5 --- src/plugins/platforms/fontdatabases/genericunix/genericunix.pri | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri b/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri index 7b0db41..1153ab3 100644 --- a/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri +++ b/src/plugins/platforms/fontdatabases/genericunix/genericunix.pri @@ -5,7 +5,6 @@ contains(QT_CONFIG, fontconfig) { include(../basicunix/basicunix.pri) } -message("GENERIC UNIX") INCLUDEPATH += $$PWD HEADERS += \ $$PWD/qgenericunixfontdatabase.h -- cgit v0.12 From 8fe7b21fbd55e3121925e6f5a51be8d14081957f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 31 Mar 2011 16:05:42 +0200 Subject: Lighthouse: Native interface for xlib --- src/plugins/platforms/xlib/qxlibintegration.cpp | 8 +- src/plugins/platforms/xlib/qxlibintegration.h | 4 + .../platforms/xlib/qxlibnativeinterface.cpp | 133 +++++++++++++++++++++ src/plugins/platforms/xlib/qxlibnativeinterface.h | 75 ++++++++++++ src/plugins/platforms/xlib/xlib.pro | 6 +- 5 files changed, 223 insertions(+), 3 deletions(-) create mode 100644 src/plugins/platforms/xlib/qxlibnativeinterface.cpp create mode 100644 src/plugins/platforms/xlib/qxlibnativeinterface.h diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp index 63197b0..8deb2f3 100644 --- a/src/plugins/platforms/xlib/qxlibintegration.cpp +++ b/src/plugins/platforms/xlib/qxlibintegration.cpp @@ -49,6 +49,7 @@ #include "qxlibscreen.h" #include "qxlibclipboard.h" #include "qxlibdisplay.h" +#include "qxlibnativeinterface.h" #if !defined(QT_NO_OPENGL) #if !defined(QT_OPENGL_ES_2) @@ -66,6 +67,7 @@ QXlibIntegration::QXlibIntegration(bool useOpenGL) : mUseOpenGL(useOpenGL) , mFontDb(new QGenericUnixFontDatabase()) , mClipboard(0) + , mNativeInterface(new QXlibNativeInterface) { mPrimaryScreen = new QXlibScreen(); mScreens.append(mPrimaryScreen); @@ -130,6 +132,11 @@ QPlatformClipboard * QXlibIntegration::clipboard() const return mClipboard; } +QPlatformNativeInterface * QXlibIntegration::nativeInterface() const +{ + return mNativeInterface; +} + bool QXlibIntegration::hasOpenGL() const { #if !defined(QT_NO_OPENGL) @@ -154,5 +161,4 @@ bool QXlibIntegration::hasOpenGL() const return false; } - QT_END_NAMESPACE diff --git a/src/plugins/platforms/xlib/qxlibintegration.h b/src/plugins/platforms/xlib/qxlibintegration.h index 3bbf897..f8efae0 100644 --- a/src/plugins/platforms/xlib/qxlibintegration.h +++ b/src/plugins/platforms/xlib/qxlibintegration.h @@ -47,6 +47,7 @@ #include #include +#include #include "qxlibstatic.h" @@ -70,6 +71,8 @@ public: QPlatformFontDatabase *fontDatabase() const; QPlatformClipboard *clipboard() const; + QPlatformNativeInterface *nativeInterface() const; + bool hasOpenGL() const; private: @@ -78,6 +81,7 @@ private: QList mScreens; QPlatformFontDatabase *mFontDb; QPlatformClipboard *mClipboard; + QPlatformNativeInterface *mNativeInterface; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xlib/qxlibnativeinterface.cpp b/src/plugins/platforms/xlib/qxlibnativeinterface.cpp new file mode 100644 index 0000000..4e950ff --- /dev/null +++ b/src/plugins/platforms/xlib/qxlibnativeinterface.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qxlibnativeinterface.h" + +#include "qxlibdisplay.h" +#include + +class QXlibResourceMap : public QMap +{ +public: + QXlibResourceMap() + :QMap() + { + insert("display",QXlibNativeInterface::Display); + insert("egldisplay",QXlibNativeInterface::EglDisplay); + insert("connection",QXlibNativeInterface::Connection); + insert("screen",QXlibNativeInterface::Screen); + insert("graphicsdevice",QXlibNativeInterface::GraphicsDevice); + insert("eglcontext",QXlibNativeInterface::EglContext); + } +}; + +Q_GLOBAL_STATIC(QXlibResourceMap, qXlibResourceMap) + + +void * QXlibNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget) +{ + QByteArray lowerCaseResource = resourceString.toLower(); + ResourceType resource = qXlibResourceMap()->value(lowerCaseResource); + void *result = 0; + switch(resource) { + case Display: + result = displayForWidget(widget); + break; + case EglDisplay: + result = eglDisplayForWidget(widget); + break; + case Connection: + result = connectionForWidget(widget); + break; + case Screen: + result = reinterpret_cast(qPlatformScreenForWidget(widget)->xScreenNumber()); + break; + case GraphicsDevice: + result = graphicsDeviceForWidget(widget); + break; + case EglContext: + result = eglContextForWidget(widget); + break; + default: + result = 0; + } + return result; +} + +void * QXlibNativeInterface::displayForWidget(QWidget *widget) +{ + return qPlatformScreenForWidget(widget)->display()->nativeDisplay(); +} + +void * QXlibNativeInterface::eglDisplayForWidget(QWidget *widget) +{ + Q_UNUSED(widget); + return 0; +} + +void * QXlibNativeInterface::screenForWidget(QWidget *widget) +{ + Q_UNUSED(widget); + return 0; +} + +void * QXlibNativeInterface::graphicsDeviceForWidget(QWidget *widget) +{ + Q_UNUSED(widget); + return 0; +} + +void * QXlibNativeInterface::eglContextForWidget(QWidget *widget) +{ + Q_UNUSED(widget); + return 0; +} + +QXlibScreen * QXlibNativeInterface::qPlatformScreenForWidget(QWidget *widget) +{ + QXlibScreen *screen; + if (widget) { + screen = static_cast(QPlatformScreen::platformScreenForWidget(widget)); + }else { + screen = static_cast(QApplicationPrivate::platformIntegration()->screens()[0]); + } + return screen; +} diff --git a/src/plugins/platforms/xlib/qxlibnativeinterface.h b/src/plugins/platforms/xlib/qxlibnativeinterface.h new file mode 100644 index 0000000..5ba0768 --- /dev/null +++ b/src/plugins/platforms/xlib/qxlibnativeinterface.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QXLIBNATIVEINTERFACE_H +#define QXLIBNATIVEINTERFACE_H + +#include "qxlibscreen.h" + +#include + +class QXlibNativeInterface : public QPlatformNativeInterface +{ +public: + enum ResourceType { + Display, + EglDisplay, + Connection, + Screen, + GraphicsDevice, + EglContext + }; + + void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget); + + void *displayForWidget(QWidget *widget); + void *eglDisplayForWidget(QWidget *widget); + void *connectionForWidget(QWidget *widget); + void *screenForWidget(QWidget *widget); + void *graphicsDeviceForWidget(QWidget *widget); + void *eglContextForWidget(QWidget *widget); + +private: + static QXlibScreen *qPlatformScreenForWidget(QWidget *widget); +}; + + +#endif // QXLIBNATIVEINTERFACE_H diff --git a/src/plugins/platforms/xlib/xlib.pro b/src/plugins/platforms/xlib/xlib.pro index 4cda1a7..ea77a29 100644 --- a/src/plugins/platforms/xlib/xlib.pro +++ b/src/plugins/platforms/xlib/xlib.pro @@ -14,7 +14,8 @@ SOURCES = \ qxlibclipboard.cpp \ qxlibmime.cpp \ qxlibstatic.cpp \ - qxlibdisplay.cpp + qxlibdisplay.cpp \ + qxlibnativeinterface.cpp HEADERS = \ qxlibintegration.h \ @@ -26,7 +27,8 @@ HEADERS = \ qxlibclipboard.h \ qxlibmime.h \ qxlibstatic.h \ - qxlibdisplay.h + qxlibdisplay.h \ + qxlibnativeinterface.h LIBS += -lX11 -lXext -- cgit v0.12 From 22a79e81758d0b6a07168ac937ad3a42db8ff21a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Apr 2011 12:41:30 +0200 Subject: Prevent crashes and X errors in QXcbWindowSurface::flush() Make sure the region to flush is inside the bounds (it might be outside if the window surface hasn't been initialized yet or if a resize just happened and we get an Expose event too soon). --- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index a4607dc..318ac15 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -186,8 +186,10 @@ void QXcbWindowSurface::endPaint(const QRegion &) void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { - Q_UNUSED(region); - Q_UNUSED(offset); + QRect bounds = region.boundingRect(); + + if (size().isEmpty() || !geometry().contains(bounds)) + return; Q_XCB_NOOP(connection()); -- cgit v0.12 From dfa586395b0dabbf6b81e77625a4f8d43ee9a80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Apr 2011 14:17:54 +0200 Subject: Prevent synchronization errors and memory leaks in QXcbWindowSurface. --- src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 318ac15..c068d1c 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -53,6 +53,8 @@ #include +#include + class QXcbShmImage : public QXcbObject { public: @@ -93,13 +95,21 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size) 0, ~0, 0); + m_shm_info.shmid = shmget (IPC_PRIVATE, m_xcb_image->stride * m_xcb_image->height, IPC_CREAT|0777); m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat (m_shm_info.shmid, 0, 0); m_shm_info.shmseg = xcb_generate_id(xcb_connection()); - Q_XCB_CALL(xcb_shm_attach(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false)); + xcb_generic_error_t *error = xcb_request_check(xcb_connection(), xcb_shm_attach_checked(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false)); + if (error) { + qWarning() << "QXcbWindowSurface: Unable to attach to shared memory segment"; + free(error); + } + + if (shmctl(m_shm_info.shmid, IPC_RMID, 0) == -1) + qWarning() << "QXcbWindowSurface: Error while marking the shared memory segment to be destroyed"; m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, screen->format()); } -- cgit v0.12 From 3a7a03f5ab0f927211050d2dcceb9440e2b0aeeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Apr 2011 17:17:50 +0200 Subject: Implemented _NET_WM_SYNC_REQUEST protocol in XCB plugin. Excluded KWin for now, as it sends multiple ConfigureNotify events per _NET_WM_SYNC_REQUEST message. --- src/plugins/platforms/xcb/README | 3 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 59 +++++++++++++------------ src/plugins/platforms/xcb/qxcbconnection.h | 1 + src/plugins/platforms/xcb/qxcbscreen.cpp | 36 +++++++++++++++ src/plugins/platforms/xcb/qxcbscreen.h | 6 +++ src/plugins/platforms/xcb/qxcbwindow.cpp | 48 +++++++++++++++++++- src/plugins/platforms/xcb/qxcbwindow.h | 9 ++++ src/plugins/platforms/xcb/qxcbwindowsurface.cpp | 13 ++++++ src/plugins/platforms/xcb/qxcbwindowsurface.h | 1 + src/plugins/platforms/xcb/xcb.pro | 2 +- 10 files changed, 146 insertions(+), 32 deletions(-) diff --git a/src/plugins/platforms/xcb/README b/src/plugins/platforms/xcb/README index e88596b..17a86e6 100644 --- a/src/plugins/platforms/xcb/README +++ b/src/plugins/platforms/xcb/README @@ -1,2 +1,3 @@ Required packages: -libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev +libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm1 libxcb-icccm1-dev libxcb-sync0 libxcb-sync0-dev + diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 84d98e8..2413a32 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -105,6 +105,8 @@ QXcbConnection::QXcbConnection(const char *displayName) #endif //XCB_USE_XLIB m_setup = xcb_get_setup(xcb_connection()); + initializeAllAtoms(); + xcb_screen_iterator_t it = xcb_setup_roots_iterator(m_setup); int screenNumber = 0; @@ -115,8 +117,6 @@ QXcbConnection::QXcbConnection(const char *displayName) m_keyboard = new QXcbKeyboard(this); - initializeAllAtoms(); - #ifdef XCB_USE_DRI2 initializeDri2(); #endif @@ -379,6 +379,34 @@ void QXcbConnection::log(const char *file, int line, int sequence) } #endif +void QXcbConnection::handleXcbError(xcb_generic_error_t *error) +{ + uint clamped_error_code = qMin(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1); + uint clamped_major_code = qMin(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1); + + printf("XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d\n", + int(error->error_code), xcb_errors[clamped_error_code], + int(error->sequence), int(error->resource_id), + int(error->major_code), xcb_protocol_request_codes[clamped_major_code], + int(error->minor_code)); +#ifdef Q_XCB_DEBUG + int i = 0; + for (; i < m_callLog.size(); ++i) { + if (m_callLog.at(i).sequence == error->sequence) { + printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + break; + } else if (m_callLog.at(i).sequence > error->sequence) { + printf("Caused some time before: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); + if (i > 0) + printf("and after: %s:%d\n", qPrintable(m_callLog.at(i-1).file), m_callLog.at(i-1).line); + break; + } + } + if (i == m_callLog.size() && !m_callLog.isEmpty()) + printf("Caused some time after: %s:%d\n", qPrintable(m_callLog.first().file), m_callLog.first().line); +#endif +} + void QXcbConnection::processXcbEvents() { while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection())) { @@ -387,32 +415,7 @@ void QXcbConnection::processXcbEvents() uint response_type = event->response_type & ~0x80; if (!response_type) { - xcb_generic_error_t *error = (xcb_generic_error_t *)event; - - uint clamped_error_code = qMin(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1); - uint clamped_major_code = qMin(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1); - - printf("XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d\n", - int(error->error_code), xcb_errors[clamped_error_code], - int(error->sequence), int(error->resource_id), - int(error->major_code), xcb_protocol_request_codes[clamped_major_code], - int(error->minor_code)); -#ifdef Q_XCB_DEBUG - int i = 0; - for (; i < m_callLog.size(); ++i) { - if (m_callLog.at(i).sequence == error->sequence) { - printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); - break; - } else if (m_callLog.at(i).sequence > error->sequence) { - printf("Caused some time before: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); - if (i > 0) - printf("and after: %s:%d\n", qPrintable(m_callLog.at(i-1).file), m_callLog.at(i-1).line); - break; - } - } - if (i == m_callLog.size() && !m_callLog.isEmpty()) - printf("Caused some time after: %s:%d\n", qPrintable(m_callLog.first().file), m_callLog.first().line); -#endif + handleXcbError((xcb_generic_error_t *)event); continue; } diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 53846f1..e38b44e 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -252,6 +252,7 @@ public: #endif void sync(); + void handleXcbError(xcb_generic_error_t *error); private slots: void processXcbEvents(); diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 49ed44c..1c12ee3 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -66,6 +66,42 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int num }; xcb_change_window_attributes(xcb_connection(), screen->root, mask, values); + + xcb_generic_error_t *error; + + xcb_get_property_reply_t *reply = + xcb_get_property_reply(xcb_connection(), + xcb_get_property(xcb_connection(), false, screen->root, + atom(QXcbAtom::_NET_SUPPORTING_WM_CHECK), + XCB_ATOM_WINDOW, 0, 1024), &error); + + if (reply && reply->format == 32 && reply->type == XCB_ATOM_WINDOW) { + xcb_window_t windowManager = *((xcb_window_t *)xcb_get_property_value(reply)); + + if (windowManager != XCB_WINDOW_NONE) { + xcb_get_property_reply_t *windowManagerReply = + xcb_get_property_reply(xcb_connection(), + xcb_get_property(xcb_connection(), false, windowManager, + atom(QXcbAtom::_NET_WM_NAME), + atom(QXcbAtom::UTF8_STRING), 0, 1024), &error); + if (windowManagerReply && windowManagerReply->format == 8 && windowManagerReply->type == atom(QXcbAtom::UTF8_STRING)) { + m_windowManagerName = QString::fromUtf8((const char *)xcb_get_property_value(windowManagerReply), xcb_get_property_value_length(windowManagerReply)); + printf("Running window manager: %s\n", qPrintable(m_windowManagerName)); + } else if (error) { + connection->handleXcbError(error); + free(error); + } + + free(windowManagerReply); + } + } else if (error) { + connection->handleXcbError(error); + free(error); + } + + free(reply); + + m_syncRequestSupported = m_windowManagerName != QLatin1String("KWin"); } QXcbScreen::~QXcbScreen() diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 6f69fc7..9547d01 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -43,6 +43,7 @@ #define QXCBSCREEN_H #include +#include #include @@ -66,9 +67,14 @@ public: xcb_screen_t *screen() const { return m_screen; } xcb_window_t root() const { return m_screen->root; } + QString windowManagerName() const { return m_windowManagerName; } + bool syncRequestSupported() const { return m_syncRequestSupported; } + private: xcb_screen_t *m_screen; int m_number; + QString m_windowManagerName; + bool m_syncRequestSupported; }; #endif diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 4a9409c..1e9a0f8 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -41,6 +41,8 @@ #include "qxcbwindow.h" +#include + #include "qxcbconnection.h" #include "qxcbscreen.h" #ifdef XCB_USE_DRI2 @@ -171,6 +173,9 @@ QXcbWindow::QXcbWindow(QWidget *tlw) properties[propertyCount++] = atom(QXcbAtom::WM_TAKE_FOCUS); properties[propertyCount++] = atom(QXcbAtom::_NET_WM_PING); + if (m_screen->syncRequestSupported()) + properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST); + if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint) properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP); @@ -178,10 +183,26 @@ QXcbWindow::QXcbWindow(QWidget *tlw) XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::WM_PROTOCOLS), - 4, + XCB_ATOM_ATOM, 32, propertyCount, properties)); + m_syncValue.hi = 0; + m_syncValue.lo = 0; + + if (m_screen->syncRequestSupported()) { + m_syncCounter = xcb_generate_id(xcb_connection()); + Q_XCB_CALL(xcb_sync_create_counter(xcb_connection(), m_syncCounter, m_syncValue)); + + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_window, + atom(QXcbAtom::_NET_WM_SYNC_REQUEST_COUNTER), + XCB_ATOM_CARDINAL, + 32, + 1, + &m_syncCounter)); + } if (isTransient(tlw) && tlw->parentWidget()) { // ICCCM 4.1.2.6 @@ -197,6 +218,8 @@ QXcbWindow::QXcbWindow(QWidget *tlw) QXcbWindow::~QXcbWindow() { delete m_context; + if (m_screen->syncRequestSupported()) + Q_XCB_CALL(xcb_sync_destroy_counter(xcb_connection(), m_syncCounter)); Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); } @@ -474,6 +497,13 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even xcb_send_event(xcb_connection(), 0, m_screen->root(), XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&reply); xcb_flush(xcb_connection()); + } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_SYNC_REQUEST)) { + if (!m_hasReceivedSyncRequest) { + m_hasReceivedSyncRequest = true; + printf("Window manager supports _NET_WM_SYNC_REQUEST, syncing resizes\n"); + } + m_syncValue.lo = event->data.data32[2]; + m_syncValue.hi = event->data.data32[3]; } } } @@ -489,8 +519,11 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * } QRect rect(xpos, ypos, event->width, event->height); - QPlatformWindow::setGeometry(rect); + if (rect == geometry()) + return; + + QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(widget(), rect); #if XCB_USE_DRI2 @@ -593,3 +626,14 @@ void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *) QWindowSystemInterface::handleWindowActivated(0); } +void QXcbWindow::updateSyncRequestCounter() +{ + if (m_screen->syncRequestSupported() && m_syncValue.lo != 0 || m_syncValue.hi != 0) { + Q_XCB_CALL(xcb_sync_set_counter(xcb_connection(), m_syncCounter, m_syncValue)); + xcb_flush(xcb_connection()); + connection()->sync(); + + m_syncValue.lo = 0; + m_syncValue.hi = 0; + } +} diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 1e9930d..0fa4d0f 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -46,6 +46,7 @@ #include #include +#include #include "qxcbobject.h" @@ -88,11 +89,19 @@ public: void handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_timestamp_t time, const QPoint &local, const QPoint &global); + void updateSyncRequestCounter(); + private: + QXcbScreen *m_screen; xcb_window_t m_window; QPlatformGLContext *m_context; + + xcb_sync_int64_t m_syncValue; + xcb_sync_counter_t m_syncCounter; + + bool m_hasReceivedSyncRequest; }; #endif diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index c068d1c..718f093 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -170,6 +170,7 @@ void QXcbShmImage::preparePaint(const QRegion ®ion) QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface) : QWindowSurface(widget, setDefaultSurface) , m_image(0) + , m_syncingResize(false) { QXcbScreen *screen = static_cast(QPlatformScreen::platformScreenForWidget(widget)); setConnection(screen->connection()); @@ -213,10 +214,20 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset)); Q_XCB_NOOP(connection()); + + if (m_syncingResize) { + xcb_flush(xcb_connection()); + connection()->sync(); + m_syncingResize = false; + window->updateSyncRequestCounter(); + } } void QXcbWindowSurface::resize(const QSize &size) { + if (size == QWindowSurface::size()) + return; + Q_XCB_NOOP(connection()); QWindowSurface::resize(size); @@ -225,6 +236,8 @@ void QXcbWindowSurface::resize(const QSize &size) delete m_image; m_image = new QXcbShmImage(screen, size); Q_XCB_NOOP(connection()); + + m_syncingResize = true; } extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset); diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbwindowsurface.h index f87e122..23d32ef 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.h +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.h @@ -66,6 +66,7 @@ public: private: QXcbShmImage *m_image; + bool m_syncingResize; }; #endif diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro index 122cb40..101bdcd 100644 --- a/src/plugins/platforms/xcb/xcb.pro +++ b/src/plugins/platforms/xcb/xcb.pro @@ -62,7 +62,7 @@ contains(QT_CONFIG, opengl) { } } -LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm +LIBS += -lxcb -lxcb-image -lxcb-keysyms -lxcb-icccm -lxcb-sync include (../fontdatabases/genericunix/genericunix.pri) -- cgit v0.12 From 2149763b7293be2360beb3ec1fe9117c508eedd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 7 Apr 2011 13:57:03 +0200 Subject: Wayland: Fix xpixmap_glx readback after multi threading --- .../gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp index f98e026..e856c03 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp @@ -46,10 +46,6 @@ void QWaylandXPixmapGLXContext::makeCurrent() { QPlatformGLContext::makeCurrent(); - while(mWindow->waitingForFrameSync()) { - mGlxIntegration->waylandDisplay()->iterate(); - } - glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext); } @@ -82,6 +78,7 @@ void QWaylandXPixmapGLXContext::swapBuffers() mWindow->damage(QRegion(QRect(QPoint(0,0),size))); + mWindow->waitForFrameSync(); } @@ -103,8 +100,7 @@ void QWaylandXPixmapGLXContext::geometryChanged() size = QSize(1,1); } - while (mWindow->waitingForFrameSync()) - mGlxIntegration->waylandDisplay()->iterate(); + mWindow->waitForFrameSync(); delete mBuffer; //XFreePixmap deletes the glxPixmap as well -- cgit v0.12 From c238398e8e120c870c7581dc3a415c5d8d910e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 7 Apr 2011 16:25:02 +0200 Subject: Made wayland plugin single-threaded, yay :) Not calling QApplication::processEvents() in qt_init any more, and not using a write socket notifier to send data over the wayland protocol. --- src/gui/kernel/qapplication_qpa.cpp | 2 - src/plugins/platforms/wayland/qwaylanddisplay.cpp | 111 +++++++++++---- src/plugins/platforms/wayland/qwaylanddisplay.h | 28 +++- .../platforms/wayland/qwaylandeventthread.cpp | 158 --------------------- .../platforms/wayland/qwaylandeventthread.h | 87 ------------ src/plugins/platforms/wayland/qwaylandwindow.cpp | 14 +- src/plugins/platforms/wayland/qwaylandwindow.h | 1 - src/plugins/platforms/wayland/wayland.pro | 6 +- 8 files changed, 117 insertions(+), 290 deletions(-) delete mode 100644 src/plugins/platforms/wayland/qwaylandeventthread.cpp delete mode 100644 src/plugins/platforms/wayland/qwaylandeventthread.h diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp index b1f26fd..1d4400a 100644 --- a/src/gui/kernel/qapplication_qpa.cpp +++ b/src/gui/kernel/qapplication_qpa.cpp @@ -564,8 +564,6 @@ void qt_init(QApplicationPrivate *priv, int type) init_platform(QLatin1String(platformName), platformPluginPath); init_plugins(pluginList); - QApplication::processEvents(); - QColormap::initialize(); QFont::initialize(); #ifndef QT_NO_CURSOR diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 4f456c9..e2bfaa2 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -45,12 +45,12 @@ #include "qwaylandscreen.h" #include "qwaylandcursor.h" #include "qwaylandinputdevice.h" -#include "qwaylandeventthread.h" #ifdef QT_WAYLAND_GL_SUPPORT #include "gl_integration/qwaylandglintegration.h" #endif +#include #include #include @@ -113,24 +113,6 @@ const struct wl_shell_listener QWaylandDisplay::shellListener = { QWaylandDisplay::shellHandleConfigure, }; -void QWaylandDisplay::displayHandleGlobal(uint32_t id, QByteArray interface, uint32_t version) -{ - Q_UNUSED(version); - - if (interface == "compositor") { - mCompositor = wl_compositor_create(mDisplay, id); - } else if (interface == "shm") { - mShm = wl_shm_create(mDisplay, id); - } else if (interface == "shell"){ - mShell = wl_shell_create(mDisplay, id); - wl_shell_add_listener(mShell, &shellListener, this); - } else if (interface == "input_device") { - QWaylandInputDevice *inputDevice = - new QWaylandInputDevice(mDisplay, id); - mInputDevices.append(inputDevice); - } -} - QWaylandDisplay::QWaylandDisplay(void) { mDisplay = wl_display_connect(NULL); @@ -142,24 +124,29 @@ QWaylandDisplay::QWaylandDisplay(void) mEglIntegration = QWaylandGLIntegration::createGLIntegration(this); #endif - mEventThread = new QWaylandEventThread(this); - - - mEventThread->waitForScreens(); + qRegisterMetaType("uint32_t"); #ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration->initialize(); #endif + connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); + + wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this); + mFd = wl_display_get_fd(mDisplay, sourceUpdate, this); + mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this); + connect(mReadNotifier, SIGNAL(activated(int)), this, SLOT(readEvents())); + + waitForScreens(); } QWaylandDisplay::~QWaylandDisplay(void) { + close(mFd); #ifdef QT_WAYLAND_GL_SUPPORT delete mEglIntegration; #endif - delete mEventThread; wl_display_destroy(mDisplay); } @@ -179,3 +166,79 @@ void QWaylandDisplay::frameCallback(wl_display_frame_func_t func, void *data) wl_display_frame_callback(mDisplay, func, data); } +void QWaylandDisplay::flushRequests() +{ + if (mSocketMask & WL_DISPLAY_WRITABLE) + wl_display_iterate(mDisplay, WL_DISPLAY_WRITABLE); +} + +void QWaylandDisplay::readEvents() +{ + wl_display_iterate(mDisplay, WL_DISPLAY_READABLE); +} + +int QWaylandDisplay::sourceUpdate(uint32_t mask, void *data) +{ + QWaylandDisplay *waylandDisplay = static_cast(data); + waylandDisplay->mSocketMask = mask; + + return 0; +} + +void QWaylandDisplay::outputHandleGeometry(void *data, + struct wl_output *output, + int32_t x, int32_t y, + int32_t width, int32_t height) +{ + //call back function called from another thread; + //but its safe to call createScreen from another thread since + //QWaylandScreen does a moveToThread + QWaylandDisplay *waylandDisplay = static_cast(data); + QRect outputRect = QRect(x, y, width, height); + waylandDisplay->createNewScreen(output,outputRect); +} + +const struct wl_output_listener QWaylandDisplay::outputListener = { + QWaylandDisplay::outputHandleGeometry +}; + +void QWaylandDisplay::waitForScreens() +{ + flushRequests(); + while (mScreens.isEmpty()) + readEvents(); +} + +void QWaylandDisplay::displayHandleGlobal(struct wl_display *display, + uint32_t id, + const char *interface, + uint32_t version, + void *data) +{ + Q_UNUSED(display); + QWaylandDisplay *that = static_cast(data); + that->displayHandleGlobal(id, QByteArray(interface), version); +} + +void QWaylandDisplay::displayHandleGlobal(uint32_t id, + const QByteArray &interface, + uint32_t version) +{ + Q_UNUSED(version); + + if (interface == "output") { + struct wl_output *output = wl_output_create(mDisplay, id); + wl_output_add_listener(output, &outputListener, this); + } else if (interface == "compositor") { + mCompositor = wl_compositor_create(mDisplay, id); + } else if (interface == "shm") { + mShm = wl_shm_create(mDisplay, id); + } else if (interface == "shell"){ + mShell = wl_shell_create(mDisplay, id); + wl_shell_add_listener(mShell, &shellListener, this); + } else if (interface == "input_device") { + QWaylandInputDevice *inputDevice = + new QWaylandInputDevice(mDisplay, id); + mInputDevices.append(inputDevice); + } +} diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index 4cfb7b5..ac0ad71 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -55,8 +55,6 @@ class QWaylandBuffer; class QPlatformScreen; class QWaylandScreen; class QWaylandGLIntegration; -class QWaylandEventThread; - class QWaylandDisplay : public QObject { Q_OBJECT @@ -85,17 +83,39 @@ public: struct wl_display *wl_display() const { return mDisplay; } public slots: void createNewScreen(struct wl_output *output, QRect geometry); - void displayHandleGlobal(uint32_t id, QByteArray interface, uint32_t version); + void readEvents(); + void flushRequests(); private: + void waitForScreens(); + void displayHandleGlobal(uint32_t id, + const QByteArray &interface, + uint32_t version); + struct wl_display *mDisplay; - QWaylandEventThread *mEventThread; struct wl_compositor *mCompositor; struct wl_shm *mShm; struct wl_shell *mShell; QList mScreens; QList mInputDevices; + QSocketNotifier *mReadNotifier; + int mFd; + bool mScreensInitialized; + + uint32_t mSocketMask; + + static const struct wl_output_listener outputListener; + static int sourceUpdate(uint32_t mask, void *data); + static void displayHandleGlobal(struct wl_display *display, + uint32_t id, + const char *interface, + uint32_t version, void *data); + static void outputHandleGeometry(void *data, + struct wl_output *output, + int32_t x, int32_t y, + int32_t width, int32_t height); + #ifdef QT_WAYLAND_GL_SUPPORT QWaylandGLIntegration *mEglIntegration; #endif diff --git a/src/plugins/platforms/wayland/qwaylandeventthread.cpp b/src/plugins/platforms/wayland/qwaylandeventthread.cpp deleted file mode 100644 index 1474d9c..0000000 --- a/src/plugins/platforms/wayland/qwaylandeventthread.cpp +++ /dev/null @@ -1,158 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandeventthread.h" - -#include - -QWaylandEventThread::QWaylandEventThread(QWaylandDisplay *display) - : QObject() - , mDisplay(display) - , mReadNotifier(0) - , mWriteNotifier(0) - , mFd(0) - , mScreensInitialized(false) -{ - qRegisterMetaType("uint32_t"); - QThread *thread = new QThread(this); - moveToThread(thread); - connect(thread,SIGNAL(started()),SLOT(runningInThread())); - thread->start(); - -} - -QWaylandEventThread::~QWaylandEventThread() -{ - close(mFd); -} - -void QWaylandEventThread::runningInThread() -{ - - wl_display_add_global_listener(mDisplay->wl_display(), - QWaylandEventThread::displayHandleGlobal, this); - int fd = wl_display_get_fd(mDisplay->wl_display(), sourceUpdate, this); - mReadNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); - connect(mReadNotifier, - SIGNAL(activated(int)), this, SLOT(readEvents())); - - mWriteNotifier = new QSocketNotifier(fd, QSocketNotifier::Write, this); - connect(mWriteNotifier, - SIGNAL(activated(int)), this, SLOT(flushRequests())); - mWriteNotifier->setEnabled(false); - - readEvents(); -} - - -int QWaylandEventThread::sourceUpdate(uint32_t mask, void *data) -{ - QWaylandEventThread *eventThread = (QWaylandEventThread *) data; - - /* FIXME: We get a callback here when we ask wl_display for the - * fd, but at that point we don't have the socket notifier as we - * need the fd to create that. We'll probably need to split that - * API into get_fd and set_update_func functions. */ - if (eventThread->mWriteNotifier == NULL) - return 0; - - QMetaObject::invokeMethod(eventThread->mWriteNotifier,"setEnabled",Qt::QueuedConnection, - Q_ARG(bool,mask & WL_DISPLAY_WRITABLE)); -// eventThread->mWriteNotifier->setEnabled(mask & WL_DISPLAY_WRITABLE); - - return 0; -} - -void QWaylandEventThread::readEvents() -{ - wl_display_iterate(mDisplay->wl_display(), WL_DISPLAY_READABLE); -} - - -void QWaylandEventThread::flushRequests() -{ - wl_display_iterate(mDisplay->wl_display(), WL_DISPLAY_WRITABLE); -} - -void QWaylandEventThread::outputHandleGeometry(void *data, - struct wl_output *output, - int32_t x, int32_t y, - int32_t width, int32_t height) -{ - //call back function called from another thread; - //but its safe to call createScreen from another thread since - //QWaylandScreen does a moveToThread - QWaylandEventThread *waylandEventThread = static_cast(data); - QRect outputRect = QRect(x, y, width, height); - waylandEventThread->mDisplay->createNewScreen(output,outputRect); - waylandEventThread->mScreensInitialized = true; - waylandEventThread->mWaitForScreens.wakeAll(); -} - -const struct wl_output_listener QWaylandEventThread::outputListener = { - QWaylandEventThread::outputHandleGeometry -}; - -void QWaylandEventThread::displayHandleGlobal(wl_display *display, - uint32_t id, - const char *interface, - uint32_t version, - void *data) -{ - if (strcmp(interface, "output") == 0) { - struct wl_output *output = wl_output_create(display, id); - wl_output_add_listener(output, &outputListener, data); - } - Q_UNUSED(display); - QWaylandEventThread *that = static_cast(data); - QByteArray interfaceByteArray(interface); - QMetaObject::invokeMethod(that->mDisplay,"displayHandleGlobal",Qt::QueuedConnection, - Q_ARG(uint32_t,id),Q_ARG(QByteArray,interfaceByteArray),Q_ARG(uint32_t,version)); -} - -void QWaylandEventThread::waitForScreens() -{ - QMutex lock; - lock.lock(); - if (!mScreensInitialized) { - mWaitForScreens.wait(&lock); - } -} diff --git a/src/plugins/platforms/wayland/qwaylandeventthread.h b/src/plugins/platforms/wayland/qwaylandeventthread.h deleted file mode 100644 index 7a5189e..0000000 --- a/src/plugins/platforms/wayland/qwaylandeventthread.h +++ /dev/null @@ -1,87 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDEVENTTHREAD_H -#define QWAYLANDEVENTTHREAD_H - -#include "qwaylanddisplay.h" - -#include -#include -#include -#include - -class QWaylandEventThread : public QObject -{ - Q_OBJECT -public: - explicit QWaylandEventThread(QWaylandDisplay *display); - ~QWaylandEventThread(); - - static int sourceUpdate(uint32_t mask, void *data); - - void waitForScreens(); - -signals: -public slots: - void runningInThread(); - void readEvents(); - void flushRequests(); -private: - QWaylandDisplay *mDisplay; - QSocketNotifier *mReadNotifier; - QSocketNotifier *mWriteNotifier; - int mFd; - QWaitCondition mWaitForScreens; - bool mScreensInitialized; - - static const struct wl_output_listener outputListener; - static void displayHandleGlobal(struct wl_display *display, - uint32_t id, - const char *interface, - uint32_t version, void *data); - static void outputHandleGeometry(void *data, - struct wl_output *output, - int32_t x, int32_t y, - int32_t width, int32_t height); -}; - -#endif // QWAYLANDEVENTTHREAD_H diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index aa72ad5..c7cd147 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -142,18 +142,12 @@ void QWaylandWindow::frameCallback(void *data, uint32_t time) { Q_UNUSED(time); QWaylandWindow *self = static_cast(data); - if (self->mWaitingForFrameSync) { - self->mWaitingForFrameSync = false; - self->mFrameSyncWait.wakeAll(); - } + self->mWaitingForFrameSync = false; } void QWaylandWindow::waitForFrameSync() { - if (!mWaitingForFrameSync) { - return; - } - QMutex lock; - lock.lock(); - mFrameSyncWait.wait(&lock); + mDisplay->flushRequests(); + while (mWaitingForFrameSync) + mDisplay->readEvents(); } diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h index ad4bba4..35b82bd 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.h +++ b/src/plugins/platforms/wayland/qwaylandwindow.h @@ -44,7 +44,6 @@ #include #include -#include #include "qwaylanddisplay.h" diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index 849299a..e5c866b 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -14,8 +14,7 @@ SOURCES = main.cpp \ qwaylanddisplay.cpp \ qwaylandwindow.cpp \ qwaylandscreen.cpp \ - qwaylandshmwindow.cpp \ - qwaylandeventthread.cpp + qwaylandshmwindow.cpp HEADERS = qwaylandintegration.h \ qwaylandcursor.h \ @@ -24,8 +23,7 @@ HEADERS = qwaylandintegration.h \ qwaylandscreen.h \ qwaylandshmsurface.h \ qwaylandbuffer.h \ - qwaylandshmwindow.h \ - qwaylandeventthread.h + qwaylandshmwindow.h INCLUDEPATH += $$QMAKE_INCDIR_WAYLAND LIBS += $$QMAKE_LIBS_WAYLAND -- cgit v0.12 From f94a2cb583c579652b3d7d9af5100fd03da6e421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 7 Apr 2011 16:54:26 +0200 Subject: Fixed crash in XCB backend. We need to sync here for some reason. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 2413a32..7ad12fe 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -126,6 +126,8 @@ QXcbConnection::QXcbConnection(const char *displayName) QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance(qApp->thread()); connect(dispatcher, SIGNAL(aboutToBlock()), this, SLOT(processXcbEvents())); + + sync(); } QXcbConnection::~QXcbConnection() -- cgit v0.12 From 5b48f0fadd7624d8535f7d9b2d4c4af452d3b9dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 7 Apr 2011 17:54:23 +0200 Subject: Wayland: Add a egl xcomposite backend --- .../platforms/eglconvenience/eglconvenience.pri | 7 ++ .../eglconvenience/xlibeglintegration.pri | 7 ++ .../wayland/gl_integration/gl_integration.pri | 4 + .../qwaylandxcompositeeglcontext.cpp | 128 +++++++++++++++++++++ .../xcomposite_egl/qwaylandxcompositeeglcontext.h | 41 +++++++ .../qwaylandxcompositeeglintegration.cpp | 97 ++++++++++++++++ .../qwaylandxcompositeeglintegration.h | 57 +++++++++ .../xcomposite_egl/qwaylandxcompositeeglwindow.cpp | 36 ++++++ .../xcomposite_egl/qwaylandxcompositeeglwindow.h | 24 ++++ .../xcomposite_egl/xcomposite_egl.pri | 15 +++ src/plugins/platforms/wayland/wayland.pro | 5 +- 11 files changed, 420 insertions(+), 1 deletion(-) create mode 100644 src/plugins/platforms/eglconvenience/eglconvenience.pri create mode 100644 src/plugins/platforms/eglconvenience/xlibeglintegration.pri create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h create mode 100644 src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri diff --git a/src/plugins/platforms/eglconvenience/eglconvenience.pri b/src/plugins/platforms/eglconvenience/eglconvenience.pri new file mode 100644 index 0000000..322d4e4 --- /dev/null +++ b/src/plugins/platforms/eglconvenience/eglconvenience.pri @@ -0,0 +1,7 @@ +INCLUDEPATH += $$PWD + +SOURCES += \ + $$PWD/qeglconvenience.cpp + +HEADERS += \ + $$PWD/qeglconvenience.h diff --git a/src/plugins/platforms/eglconvenience/xlibeglintegration.pri b/src/plugins/platforms/eglconvenience/xlibeglintegration.pri new file mode 100644 index 0000000..9404a70 --- /dev/null +++ b/src/plugins/platforms/eglconvenience/xlibeglintegration.pri @@ -0,0 +1,7 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qxlibeglintegration.h + +SOURCES += \ + $$PWD/qxlibeglintegration.cpp diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index 52272c3..73a0c25 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -21,3 +21,7 @@ xpixmap_glx { xcomposite_glx { include ($$PWD/xcomposite_glx/xcomposite_glx.pri) } + +xcomposite_egl { + include ($$PWD/xcomposite_egl/xcomposite_egl.pri) +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp new file mode 100644 index 0000000..33ab7c5 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -0,0 +1,128 @@ +#include "qwaylandxcompositeeglcontext.h" + +#include "qwaylandxcompositeeglwindow.h" +#include "qwaylandxcompositebuffer.h" + +#include "wayland-xcomposite-client-protocol.h" +#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_configFromQPlatformWindowFormat(glxIntegration->eglDisplay(),window->widget()->platformWindowFormat(),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() +{ + QPlatformGLContext::makeCurrent(); + + eglMakeCurrent(mEglIntegration->eglDisplay(),mEglWindowSurface,mEglWindowSurface,mContext); +} + +void QWaylandXCompositeEGLContext::doneCurrent() +{ + QPlatformGLContext::doneCurrent(); + eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT); +} + +void QWaylandXCompositeEGLContext::swapBuffers() +{ + 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)); +} + +QPlatformWindowFormat QWaylandXCompositeEGLContext::platformWindowFormat() const +{ + return qt_qPlatformWindowFormatFromConfig(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); + + mEglWindowSurface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mConfig,mXWindow,0); + if (mEglWindowSurface == EGL_NO_SURFACE) { + qFatal("Could not make eglsurface"); + } + + 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); + + mWaitingForSync = true; + wl_display_sync(mEglIntegration->waylandDisplay()->wl_display(),0); + mEglIntegration->waylandDisplay()->flushRequests(); + while (mWaitingForSync) { + mEglIntegration->waylandDisplay()->readEvents(); + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h new file mode 100644 index 0000000..a6ca49e --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h @@ -0,0 +1,41 @@ +#ifndef QWAYLANDXCOMPOSITEEGLCONTEXT_H +#define QWAYLANDXCOMPOSITEEGLCONTEXT_H + +#include + +#include + +#include "qwaylandbuffer.h" +#include "qwaylandxcompositeeglintegration.h" + +class QWaylandXCompositeEGLWindow; + +class QWaylandXCompositeEGLContext : public QPlatformGLContext +{ +public: + QWaylandXCompositeEGLContext(QWaylandXCompositeEGLIntegration *glxIntegration, QWaylandXCompositeEGLWindow *window); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + + QPlatformWindowFormat platformWindowFormat() const; + + void geometryChanged(); + +private: + QWaylandXCompositeEGLIntegration *mEglIntegration; + QWaylandXCompositeEGLWindow *mWindow; + QWaylandBuffer *mBuffer; + + Window mXWindow; + EGLConfig mConfig; + EGLContext mContext; + EGLSurface mEglWindowSurface; + + static void sync_function(void *data); + bool mWaitingForSync; +}; + +#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 new file mode 100644 index 0000000..e8b4fd4 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp @@ -0,0 +1,97 @@ +#include "qwaylandxcompositeeglintegration.h" + +#include "qwaylandxcompositeeglwindow.h" + +#include + +#include "wayland-xcomposite-client-protocol.h" + +QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandXCompositeEGLIntegration(waylandDisplay); +} + +QWaylandXCompositeEGLIntegration::QWaylandXCompositeEGLIntegration(QWaylandDisplay * waylandDispaly) + : QWaylandGLIntegration() + , mWaylandDisplay(waylandDispaly) +{ + wl_display_add_global_listener(mWaylandDisplay->wl_display(), QWaylandXCompositeEGLIntegration::wlDisplayHandleGlobal, + this); +} + +QWaylandXCompositeEGLIntegration::~QWaylandXCompositeEGLIntegration() +{ + XCloseDisplay(mDisplay); +} + +void QWaylandXCompositeEGLIntegration::initialize() +{ +} + +QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWidget *widget) +{ + return new QWaylandXCompositeEGLWindow(widget,this); +} + +Display * QWaylandXCompositeEGLIntegration::xDisplay() const +{ + return mDisplay; +} + +EGLDisplay QWaylandXCompositeEGLIntegration::eglDisplay() const +{ + return mEglDisplay; +} + +int QWaylandXCompositeEGLIntegration::screen() const +{ + return mScreen; +} + +Window QWaylandXCompositeEGLIntegration::rootWindow() const +{ + return mRootWindow; +} + +QWaylandDisplay * QWaylandXCompositeEGLIntegration::waylandDisplay() const +{ + return mWaylandDisplay; +} +wl_xcomposite * QWaylandXCompositeEGLIntegration::waylandXComposite() const +{ + return mWaylandComposite; +} + +const struct wl_xcomposite_listener QWaylandXCompositeEGLIntegration::xcomposite_listener = { + QWaylandXCompositeEGLIntegration::rootInformation +}; + +void QWaylandXCompositeEGLIntegration::wlDisplayHandleGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) +{ + Q_UNUSED(version); + if (strcmp(interface, "xcomposite") == 0) { + QWaylandXCompositeEGLIntegration *integration = static_cast(data); + integration->mWaylandComposite = wl_xcomposite_create(display,id); + wl_xcomposite_add_listener(integration->mWaylandComposite,&xcomposite_listener,integration); + } + +} + +void QWaylandXCompositeEGLIntegration::rootInformation(void *data, wl_xcomposite *xcomposite, const char *display_name, uint32_t root_window) +{ + Q_UNUSED(xcomposite); + QWaylandXCompositeEGLIntegration *integration = static_cast(data); + + integration->mDisplay = XOpenDisplay(display_name); + integration->mRootWindow = (Window) root_window; + integration->mScreen = XDefaultScreen(integration->mDisplay); + integration->mEglDisplay = eglGetDisplay(integration->mDisplay); + eglBindAPI(EGL_OPENGL_ES_API); + EGLint minor,major; + if (!eglInitialize(integration->mEglDisplay,&major,&minor)) { + qFatal("Failed to initialize EGL"); + } + eglSwapInterval(integration->eglDisplay(),0); + qDebug() << "ROOT INFORMATION" << integration->mDisplay << integration->mRootWindow << integration->mScreen; +} + diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h new file mode 100644 index 0000000..3289c9a --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h @@ -0,0 +1,57 @@ +#ifndef QWAYLANDXCOMPOSITEEGLINTEGRATION_H +#define QWAYLANDXCOMPOSITEEGLINTEGRATION_H + +#include "gl_integration/qwaylandglintegration.h" +#include "wayland-client.h" + +#include +#include +#include +#include +#include + +#include + +#include +#include + +struct wl_xcomposite; + +class QWaylandXCompositeEGLIntegration : public QWaylandGLIntegration +{ +public: + QWaylandXCompositeEGLIntegration(QWaylandDisplay * waylandDispaly); + ~QWaylandXCompositeEGLIntegration(); + + void initialize(); + + QWaylandWindow *createEglWindow(QWidget *widget); + + QWaylandDisplay *waylandDisplay() const; + struct wl_xcomposite *waylandXComposite() const; + + Display *xDisplay() const; + EGLDisplay eglDisplay() const; + int screen() const; + Window rootWindow() const; + +private: + QWaylandDisplay *mWaylandDisplay; + struct wl_xcomposite *mWaylandComposite; + + Display *mDisplay; + EGLDisplay mEglDisplay; + int mScreen; + Window mRootWindow; + + static void wlDisplayHandleGlobal(struct wl_display *display, uint32_t id, + const char *interface, uint32_t version, void *data); + + static const struct wl_xcomposite_listener xcomposite_listener; + static void rootInformation(void *data, + struct wl_xcomposite *xcomposite, + const char *display_name, + uint32_t root_window); +}; + +#endif // QWAYLANDXCOMPOSITEEGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp new file mode 100644 index 0000000..ab3f7ae --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp @@ -0,0 +1,36 @@ +#include "qwaylandxcompositeeglwindow.h" + +#include + +QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration) + : QWaylandWindow(window) + , mGlxIntegration(glxIntegration) + , mContext(0) +{ + +} + +QWaylandWindow::WindowType QWaylandXCompositeEGLWindow::windowType() const +{ + //yeah. this type needs a new name + return QWaylandWindow::Egl; +} + +QPlatformGLContext * QWaylandXCompositeEGLWindow::glContext() const +{ + if (!mContext) { + qDebug() << "creating glcontext;"; + QWaylandXCompositeEGLWindow *that = const_cast(this); + that->mContext = new QWaylandXCompositeEGLContext(mGlxIntegration,that); + } + return mContext; +} + +void QWaylandXCompositeEGLWindow::setGeometry(const QRect &rect) +{ + QWaylandWindow::setGeometry(rect); + + if (mContext) { + mContext->geometryChanged(); + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h new file mode 100644 index 0000000..5cdde70 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h @@ -0,0 +1,24 @@ +#ifndef QWAYLANDXCOMPOSITEEGLWINDOW_H +#define QWAYLANDXCOMPOSITEEGLWINDOW_H + +#include "qwaylandwindow.h" +#include "qwaylandxcompositeeglintegration.h" +#include "qwaylandxcompositeeglcontext.h" + +class QWaylandXCompositeEGLWindow : public QWaylandWindow +{ +public: + QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration); + WindowType windowType() const; + + QPlatformGLContext *glContext() const; + + void setGeometry(const QRect &rect); + +private: + QWaylandXCompositeEGLIntegration *mGlxIntegration; + QWaylandXCompositeEGLContext *mContext; + +}; + +#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 new file mode 100644 index 0000000..c3533f9 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/xcomposite_egl.pri @@ -0,0 +1,15 @@ +include (../xcomposite_share/xcomposite_share.pri) +include (../../../eglconvenience/eglconvenience.pri) +include (../../../eglconvenience/xlibeglintegration.pri) + +LIBS += -lXcomposite -lEGL + +SOURCES += \ + $$PWD/qwaylandxcompositeeglcontext.cpp \ + $$PWD/qwaylandxcompositeeglintegration.cpp \ + $$PWD/qwaylandxcompositeeglwindow.cpp + +HEADERS += \ + $$PWD/qwaylandxcompositeeglcontext.h \ + $$PWD/qwaylandxcompositeeglintegration.h \ + $$PWD/qwaylandxcompositeeglwindow.h diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index e5c866b..bd017cc 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -38,8 +38,11 @@ contains(QT_CONFIG, opengl) { contains(QT_CONFIG, opengles2) { CONFIG += wayland_egl #CONFIG += xpixmap_egl + #CONFIG += xcomposite_egl } else { - CONFIG += xpixmap_glx + CONFIG += xpixmap_glx + #CONFIG += xcomposite_gl + } include ($$PWD/gl_integration/gl_integration.pri) -- cgit v0.12 From 77843fdd856cef5d48e5851d0d961fe5bf4455b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Thu, 7 Apr 2011 18:02:15 +0200 Subject: Wayland: Add license headers to new files --- .../gl_integration/qwaylandglintegration.cpp | 41 ++++++++++++++ .../wayland/gl_integration/qwaylandglintegration.h | 41 ++++++++++++++ .../gl_integration/qwaylandglwindowsurface.h | 2 +- .../wayland_egl/qwaylandeglinclude.h | 41 ++++++++++++++ .../wayland_egl/qwaylandeglintegration.cpp | 41 ++++++++++++++ .../wayland_egl/qwaylandeglintegration.h | 41 ++++++++++++++ .../wayland_egl/qwaylandeglwindow.cpp | 2 +- .../gl_integration/wayland_egl/qwaylandeglwindow.h | 2 +- .../qwaylandxcompositeeglcontext.cpp | 41 ++++++++++++++ .../xcomposite_egl/qwaylandxcompositeeglcontext.h | 41 ++++++++++++++ .../qwaylandxcompositeeglintegration.cpp | 41 ++++++++++++++ .../qwaylandxcompositeeglintegration.h | 41 ++++++++++++++ .../xcomposite_egl/qwaylandxcompositeeglwindow.cpp | 41 ++++++++++++++ .../xcomposite_egl/qwaylandxcompositeeglwindow.h | 41 ++++++++++++++ .../qwaylandxcompositeglxcontext.cpp | 41 ++++++++++++++ .../xcomposite_glx/qwaylandxcompositeglxcontext.h | 41 ++++++++++++++ .../qwaylandxcompositeglxintegration.cpp | 41 ++++++++++++++ .../qwaylandxcompositeglxintegration.h | 41 ++++++++++++++ .../xcomposite_glx/qwaylandxcompositeglxwindow.cpp | 41 ++++++++++++++ .../xcomposite_glx/qwaylandxcompositeglxwindow.h | 41 ++++++++++++++ .../xcomposite_share/qwaylandxcompositebuffer.cpp | 41 ++++++++++++++ .../xcomposite_share/qwaylandxcompositebuffer.h | 41 ++++++++++++++ .../wayland-xcomposite-client-protocol.h | 61 +++++++++++++-------- .../xcomposite_share/wayland-xcomposite-protocol.c | 62 ++++++++++++++-------- .../xpixmap_egl/qwaylandxpixmapeglcontext.cpp | 41 ++++++++++++++ .../xpixmap_egl/qwaylandxpixmapeglcontext.h | 41 ++++++++++++++ .../xpixmap_egl/qwaylandxpixmapeglintegration.cpp | 41 ++++++++++++++ .../xpixmap_egl/qwaylandxpixmapeglintegration.h | 41 ++++++++++++++ .../xpixmap_egl/qwaylandxpixmapwindow.cpp | 41 ++++++++++++++ .../xpixmap_egl/qwaylandxpixmapwindow.h | 41 ++++++++++++++ .../xpixmap_glx/qwaylandxpixmapglxcontext.cpp | 41 ++++++++++++++ .../xpixmap_glx/qwaylandxpixmapglxcontext.h | 41 ++++++++++++++ .../xpixmap_glx/qwaylandxpixmapglxintegration.cpp | 41 ++++++++++++++ .../xpixmap_glx/qwaylandxpixmapglxintegration.h | 41 ++++++++++++++ .../xpixmap_glx/qwaylandxpixmapglxwindow.cpp | 41 ++++++++++++++ .../xpixmap_glx/qwaylandxpixmapglxwindow.h | 41 ++++++++++++++ src/plugins/platforms/wayland/qwaylandbuffer.h | 2 +- 37 files changed, 1355 insertions(+), 47 deletions(-) diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp index 9a0a824..9c8ef4e 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandglintegration.h" QWaylandGLIntegration::QWaylandGLIntegration() diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h index 16115d5..ac16039 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDGLINTEGRATION_H #define QWAYLANDGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h index faff872..8d53b42 100644 --- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h +++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the config.tests of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h index 778c3db..5dc2add 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglinclude.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDEGLINCLUDE_H #define QWAYLANDEGLINCLUDE_H 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 942e591..39e7be5 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandeglintegration.h" #include "gl_integration/qwaylandglintegration.h" 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 8b166ce..bf4c3fe 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDEGLINTEGRATION_H #define 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 a9aa46f..d7cf0a5 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the config.tests of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage 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 ef1e02a..549d039 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the config.tests of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage 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 33ab7c5..92acf75 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxcompositeeglcontext.h" #include "qwaylandxcompositeeglwindow.h" 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 a6ca49e..f0693d4 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXCOMPOSITEEGLCONTEXT_H #define 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 e8b4fd4..352e651 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxcompositeeglintegration.h" #include "qwaylandxcompositeeglwindow.h" 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 3289c9a..590ae37 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXCOMPOSITEEGLINTEGRATION_H #define QWAYLANDXCOMPOSITEEGLINTEGRATION_H 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 ab3f7ae..1c9d36f 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxcompositeeglwindow.h" #include 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 5cdde70..fc33b32 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXCOMPOSITEEGLWINDOW_H #define QWAYLANDXCOMPOSITEEGLWINDOW_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 679772c..c108fbd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxcompositeglxcontext.h" #include "qwaylandxcompositeglxwindow.h" 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 e5ccd9e..b45ec3f 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXCOMPOSITEGLXCONTEXT_H #define 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 dce3d27..da92bc8 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxcompositeglxintegration.h" #include "qwaylandxcompositeglxwindow.h" 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 650fdcf..24a4016 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXCOMPOSITEGLXINTEGRATION_H #define QWAYLANDXCOMPOSITEGLXINTEGRATION_H 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 57ee27e..db0f254 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxcompositeglxwindow.h" #include 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 75058a5..536153d 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXCOMPOSITEGLXWINDOW_H #define QWAYLANDXCOMPOSITEGLXWINDOW_H 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 218907e..4b0d3a0 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxcompositebuffer.h" #include "wayland-client.h" 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 c9332d9..b346651 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXCOMPOSITEBUFFER_H #define QWAYLANDXCOMPOSITEBUFFER_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h index 1955a74..72376e1 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-client-protocol.h @@ -1,24 +1,43 @@ -/* - * Copyright © 2010 Kristian Høgsberg - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ #ifndef XCOMPOSITE_CLIENT_PROTOCOL_H diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c index da2e4a2..5c966fd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/wayland-xcomposite-protocol.c @@ -1,25 +1,43 @@ -/* - * Copyright © 2010 Kristian Høgsberg - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ #include #include diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp index 32ba6de..b8ff4c4 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxpixmapeglcontext.h" #include "../../../eglconvenience/qeglconvenience.h" diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h index e6c6e8d..811d75d 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QXPIXMAPREADBACKGLCONTEXT_H #define QXPIXMAPREADBACKGLCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp index 8ccfc67..f6967e1 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxpixmapeglintegration.h" #include diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h index 9e7cb66..16c3632 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXPIXMAPEGLINTEGRATION_H #define QWAYLANDXPIXMAPEGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp index 35ce41a..43a80b5 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxpixmapwindow.h" #include "qwaylandxpixmapeglcontext.h" diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h index 1f10112..f6cae1d 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXPIXMAPWINDOW_H #define QWAYLANDXPIXMAPWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp index e856c03..8ccd7c9 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxpixmapglxcontext.h" #include "qwaylandshmsurface.h" diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h index c4c3796..3ea9dfe 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXPIXMAPGLXCONTEXT_H #define QWAYLANDXPIXMAPGLXCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp index f094946..33d6b06 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxpixmapglxintegration.h" #include "qwaylandxpixmapglxwindow.h" diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h index c48abb4..c7a80de 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXPIXMAPGLXINTEGRATION_H #define QWAYLANDXPIXMAPGLXINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp index a191320..065a6fd 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qwaylandxpixmapglxwindow.h" QWaylandXPixmapGLXWindow::QWaylandXPixmapGLXWindow(QWidget *window, QWaylandXPixmapGLXIntegration *glxIntegration) diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h index 6aba21c..5f4d24f 100644 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h +++ b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QWAYLANDXPIXMAPGLXWINDOW_H #define QWAYLANDXPIXMAPGLXWINDOW_H diff --git a/src/plugins/platforms/wayland/qwaylandbuffer.h b/src/plugins/platforms/wayland/qwaylandbuffer.h index 643e89c..8779d5f 100644 --- a/src/plugins/platforms/wayland/qwaylandbuffer.h +++ b/src/plugins/platforms/wayland/qwaylandbuffer.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the config.tests of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage -- cgit v0.12 From 7cad215190414cc2a146d95f4077dffa3bd4e6a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 8 Apr 2011 09:33:38 +0200 Subject: Added _NET_WM_PID in XCB backend. --- src/plugins/platforms/xcb/qxcbwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 1e9a0f8..f0b9e32 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -213,6 +213,12 @@ QXcbWindow::QXcbWindow(QWidget *tlw) 1, &parentWindow)); } + + // set the PID to let the WM kill the application if unresponsive + long pid = getpid(); + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + atom(QXcbAtom::_NET_WM_PID), XCB_ATOM_CARDINAL, 32, + 1, &pid)); } QXcbWindow::~QXcbWindow() -- cgit v0.12 From b42914ba7b2c2ec08abeb4ec658ffaea019e3e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 8 Apr 2011 09:44:34 +0200 Subject: Set the _NET_WM_WINDOW_TYPE property in the XCB backend. --- src/plugins/platforms/xcb/qxcbwindow.cpp | 38 ++++++++++++++++++++++++++++++++ src/plugins/platforms/xcb/qxcbwindow.h | 1 + 2 files changed, 39 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index f0b9e32..ad91602 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -304,6 +304,8 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags) { Qt::WindowType type = static_cast(int(flags & Qt::WindowType_Mask)); + setNetWmWindowTypes(flags); + if (type == Qt::ToolTip) flags |= Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint; if (type == Qt::Popup) @@ -407,6 +409,42 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags) return QPlatformWindow::setWindowFlags(flags); } +void QXcbWindow::setNetWmWindowTypes(Qt::WindowFlags flags) +{ + // in order of decreasing priority + QVector windowTypes; + + Qt::WindowType type = static_cast(int(flags & Qt::WindowType_Mask)); + + switch (type) { + case Qt::Dialog: + case Qt::Sheet: + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG)); + break; + case Qt::Tool: + case Qt::Drawer: + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY)); + break; + case Qt::ToolTip: + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP)); + break; + case Qt::SplashScreen: + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH)); + break; + default: + break; + } + + if (flags & Qt::FramelessWindowHint) + windowTypes.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE)); + + windowTypes.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL)); + + Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, + atom(QXcbAtom::_NET_WM_WINDOW_TYPE), XCB_ATOM_ATOM, 32, + windowTypes.count(), windowTypes.constData())); +} + WId QXcbWindow::winId() const { return m_window; diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 0fa4d0f..e049837 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -92,6 +92,7 @@ public: void updateSyncRequestCounter(); private: + void setNetWmWindowTypes(Qt::WindowFlags flags); QXcbScreen *m_screen; -- cgit v0.12 From 41132f22be02fe4ec73e8e3b5795bdd630344414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 8 Apr 2011 09:46:08 +0200 Subject: Fixed logical error in XCB backend. --- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index ad91602..107e004 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -672,7 +672,7 @@ void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *) void QXcbWindow::updateSyncRequestCounter() { - if (m_screen->syncRequestSupported() && m_syncValue.lo != 0 || m_syncValue.hi != 0) { + if (m_screen->syncRequestSupported() && (m_syncValue.lo != 0 || m_syncValue.hi != 0)) { Q_XCB_CALL(xcb_sync_set_counter(xcb_connection(), m_syncCounter, m_syncValue)); xcb_flush(xcb_connection()); connection()->sync(); -- cgit v0.12 From 32a2ccfedd0aa09311a173525f89f8e4894319f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 8 Apr 2011 13:40:26 +0200 Subject: Prevented crash due to dangling pointer in QWaylandInputDevice. When a QWaylandWindow is destroyed we need to make sure it's not still referenced by QWaylandInputDevice. --- src/plugins/platforms/wayland/qwaylanddisplay.h | 4 +++- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 8 ++++++++ src/plugins/platforms/wayland/qwaylandinputdevice.h | 1 + src/plugins/platforms/wayland/qwaylandwindow.cpp | 7 ++++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index ac0ad71..e02767d 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -76,11 +76,13 @@ public: #endif void setCursor(QWaylandBuffer *buffer, int32_t x, int32_t y); - void syncCallback(wl_display_sync_func_t func, void *data); void frameCallback(wl_display_frame_func_t func, void *data); struct wl_display *wl_display() const { return mDisplay; } + + QList inputDevices() const { return mInputDevices; } + public slots: void createNewScreen(struct wl_output *output, QRect geometry); void readEvents(); diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 47f9c91..6c2f341 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -83,6 +83,14 @@ QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display, #endif } +void QWaylandInputDevice::handleWindowDestroyed(QWaylandWindow *window) +{ + if (window == mPointerFocus) + mPointerFocus = 0; + if (window == mKeyboardFocus) + mKeyboardFocus = 0; +} + void QWaylandInputDevice::inputHandleMotion(void *data, struct wl_input_device *input_device, uint32_t time, diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h index 2328db8..3c83252 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h @@ -59,6 +59,7 @@ class QWaylandInputDevice { public: QWaylandInputDevice(struct wl_display *display, uint32_t id); void attach(QWaylandBuffer *buffer, int x, int y); + void handleWindowDestroyed(QWaylandWindow *window); private: struct wl_display *mDisplay; diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index c7cd147..d58b39d 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -41,9 +41,10 @@ #include "qwaylandwindow.h" +#include "qwaylandbuffer.h" #include "qwaylanddisplay.h" +#include "qwaylandinputdevice.h" #include "qwaylandscreen.h" -#include "qwaylandbuffer.h" #include #include @@ -66,6 +67,10 @@ QWaylandWindow::~QWaylandWindow() { if (mSurface) wl_surface_destroy(mSurface); + + QList inputDevices = mDisplay->inputDevices(); + for (int i = 0; i < inputDevices.size(); ++i) + inputDevices.at(i)->handleWindowDestroyed(this); } WId QWaylandWindow::winId() const -- cgit v0.12 From fb1de89d4debd6c26c774fed20e5ad7ee7185832 Mon Sep 17 00:00:00 2001 From: con Date: Fri, 8 Apr 2011 16:11:24 +0200 Subject: Adapt drag distance for uikit. --- src/plugins/platforms/uikit/quikitscreen.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/uikit/quikitscreen.mm b/src/plugins/platforms/uikit/quikitscreen.mm index ec94e3a..97382e3 100644 --- a/src/plugins/platforms/uikit/quikitscreen.mm +++ b/src/plugins/platforms/uikit/quikitscreen.mm @@ -41,6 +41,8 @@ #include "quikitscreen.h" +#include + #include QT_BEGIN_NAMESPACE @@ -65,7 +67,10 @@ QUIKitScreen::QUIKitScreen(int screenIndex) m_depth = 24; const qreal inch = 25.4; - m_physicalSize = QSize(qRound(bounds.size.width * inch / 160.), qRound(bounds.size.height * inch / 160.)); + const qreal dpi = 160.; + m_physicalSize = QSize(qRound(bounds.size.width * inch / dpi), qRound(bounds.size.height * inch / dpi)); + if (m_index == 0) + qApp->setStartDragDistance(12); [pool release]; } -- cgit v0.12 From 59e20b0eedb7308d3428e7744e076a8b49b1cf25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 11 Apr 2011 09:00:14 +0200 Subject: Wayland: Rename XPixmap GL integrations to Readback --- .../wayland/gl_integration/gl_integration.pri | 8 +- .../readback_egl/qwaylandreadbackeglcontext.cpp | 174 ++++++++++++++++++++ .../readback_egl/qwaylandreadbackeglcontext.h | 80 ++++++++++ .../qwaylandreadbackeglintegration.cpp | 112 +++++++++++++ .../readback_egl/qwaylandreadbackeglintegration.h | 82 ++++++++++ .../readback_egl/qwaylandreadbackeglwindow.cpp | 76 +++++++++ .../readback_egl/qwaylandreadbackeglwindow.h | 66 ++++++++ .../gl_integration/readback_egl/readback_egl.pri | 14 ++ .../readback_glx/qwaylandreadbackglxcontext.cpp | 163 +++++++++++++++++++ .../readback_glx/qwaylandreadbackglxcontext.h | 79 +++++++++ .../qwaylandreadbackglxintegration.cpp | 97 +++++++++++ .../readback_glx/qwaylandreadbackglxintegration.h | 80 ++++++++++ .../readback_glx/qwaylandreadbackglxwindow.cpp | 73 +++++++++ .../readback_glx/qwaylandreadbackglxwindow.h | 65 ++++++++ .../gl_integration/readback_glx/readback_glx.pri | 12 ++ .../xpixmap_egl/qwaylandxpixmapeglcontext.cpp | 177 --------------------- .../xpixmap_egl/qwaylandxpixmapeglcontext.h | 80 ---------- .../xpixmap_egl/qwaylandxpixmapeglintegration.cpp | 112 ------------- .../xpixmap_egl/qwaylandxpixmapeglintegration.h | 82 ---------- .../xpixmap_egl/qwaylandxpixmapwindow.cpp | 75 --------- .../xpixmap_egl/qwaylandxpixmapwindow.h | 66 -------- .../gl_integration/xpixmap_egl/xpixmap_egl.pri | 14 -- .../xpixmap_glx/qwaylandxpixmapglxcontext.cpp | 163 ------------------- .../xpixmap_glx/qwaylandxpixmapglxcontext.h | 79 --------- .../xpixmap_glx/qwaylandxpixmapglxintegration.cpp | 97 ----------- .../xpixmap_glx/qwaylandxpixmapglxintegration.h | 80 ---------- .../xpixmap_glx/qwaylandxpixmapglxwindow.cpp | 73 --------- .../xpixmap_glx/qwaylandxpixmapglxwindow.h | 65 -------- .../gl_integration/xpixmap_glx/xpixmap_glx.pri | 12 -- src/plugins/platforms/wayland/wayland.pro | 4 +- 30 files changed, 1179 insertions(+), 1181 deletions(-) create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h create mode 100644 src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_egl/xpixmap_egl.pri delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h delete mode 100644 src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index 73a0c25..835f880 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -10,12 +10,12 @@ wayland_egl { include ($$PWD/wayland_egl/wayland_egl.pri) } -xpixmap_egl { - include ($$PWD/xpixmap_egl/xpixmap_egl.pri) +readback_egl { + include ($$PWD/readback_egl/readback_egl.pri) } -xpixmap_glx { - include ($$PWD/xpixmap_glx/xpixmap_glx.pri) +readback_glx { + include ($$PWD/readback_glx/readback_glx.pri) } xcomposite_glx { diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp new file mode 100644 index 0000000..d63087d --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandreadbackeglcontext.h" + +#include "../../../eglconvenience/qeglconvenience.h" + +#include +#include + +#include "qwaylandshmsurface.h" + +#include + +static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) +{ + const int width = img.width(); + const int height = img.height(); + + if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV + || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) + { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); + } + } else { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff); + } + } +} + +QWaylandReadbackEglContext::QWaylandReadbackEglContext(QWaylandReadbackEglIntegration *eglIntegration, QWaylandReadbackEglWindow *window) + : mEglIntegration(eglIntegration) + , mWindow(window) + , mBuffer(0) + , mPixmap(0) + , mConfig(q_configFromQPlatformWindowFormat(eglIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_PIXMAP_BIT)) + , mPixmapSurface(EGL_NO_SURFACE) +{ + QVector eglContextAttrs; + eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); + eglContextAttrs.append(2); + eglContextAttrs.append(EGL_NONE); + + mContext = eglCreateContext(eglIntegration->eglDisplay(),mConfig,0,eglContextAttrs.constData()); + + geometryChanged(); +} + +QWaylandReadbackEglContext::~QWaylandReadbackEglContext() +{ + eglDestroyContext(mEglIntegration->eglDisplay(),mContext); +} + +void QWaylandReadbackEglContext::makeCurrent() +{ + QPlatformGLContext::makeCurrent(); + + mWindow->waitForFrameSync(); + + eglMakeCurrent(mEglIntegration->eglDisplay(),mPixmapSurface,mPixmapSurface,mContext); +} + +void QWaylandReadbackEglContext::doneCurrent() +{ + QPlatformGLContext::doneCurrent(); + eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT); +} + +void QWaylandReadbackEglContext::swapBuffers() +{ + eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface); + + if (QPlatformGLContext::currentContext() != this) { + makeCurrent(); + } + + QSize size = mWindow->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); + + img = img.mirrored(); + qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV); + constBits = img.bits(); + + const uchar *constDstBits = mBuffer->image()->bits(); + uchar *dstBits = const_cast(constDstBits); + memcpy(dstBits,constBits,(img.width()*4) * img.height()); + + + mWindow->damage(QRegion(QRect(QPoint(0,0),size))); +} + +void * QWaylandReadbackEglContext::getProcAddress(const QString &procName) +{ + return (void *) eglGetProcAddress(procName.toLatin1().data()); +} + +QPlatformWindowFormat QWaylandReadbackEglContext::platformWindowFormat() const +{ + return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); +} + +void QWaylandReadbackEglContext::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; + if (mPixmap) + XFreePixmap(mEglIntegration->xDisplay(),mPixmap); + + mBuffer = new QWaylandShmBuffer(mEglIntegration->waylandDisplay(),size,QImage::Format_ARGB32); + mWindow->attach(mBuffer); + mPixmap = XCreatePixmap(mEglIntegration->xDisplay(),mEglIntegration->rootWindow(),size.width(),size.height(),mEglIntegration->depth()); + XSync(mEglIntegration->xDisplay(),False); + + mPixmapSurface = eglCreatePixmapSurface(mEglIntegration->eglDisplay(),mConfig,mPixmap,0); + if (mPixmapSurface == EGL_NO_SURFACE) { + qDebug() << "Could not make egl surface out of pixmap :("; + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h new file mode 100644 index 0000000..ac68275 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDREADBACKEGLGLCONTEXT_H +#define QWAYLANDREADBACKEGLGLCONTEXT_H + +#include +#include + +#include "qwaylandreadbackeglintegration.h" +#include "qwaylandreadbackeglwindow.h" + +class QWaylandShmBuffer; + +class QWaylandReadbackEglContext : public QPlatformGLContext +{ +public: + QWaylandReadbackEglContext(QWaylandReadbackEglIntegration *eglIntegration, QWaylandReadbackEglWindow *window); + ~QWaylandReadbackEglContext(); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + + virtual QPlatformWindowFormat platformWindowFormat() const; + + void geometryChanged(); + +private: + QWaylandReadbackEglIntegration *mEglIntegration; + QWaylandReadbackEglWindow *mWindow; + QWaylandShmBuffer *mBuffer; + + Pixmap mPixmap; + + EGLConfig mConfig; + EGLContext mContext; + EGLSurface mPixmapSurface; +}; + +#endif // QWAYLANDREADBACKEGLGLCONTEXT_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 new file mode 100644 index 0000000..9347691 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandreadbackeglintegration.h" + +#include + +#include "qwaylandreadbackeglwindow.h" + +QWaylandReadbackEglIntegration::QWaylandReadbackEglIntegration(QWaylandDisplay *display) + : QWaylandGLIntegration() + , mWaylandDisplay(display) +{ + qDebug() << "Using Wayland Readback-EGL"; + char *display_name = getenv("DISPLAY"); + mDisplay = XOpenDisplay(display_name); + mScreen = XDefaultScreen(mDisplay); + mRootWindow = XDefaultRootWindow(mDisplay); + XSync(mDisplay, False); +} + +QWaylandReadbackEglIntegration::~QWaylandReadbackEglIntegration() +{ + XCloseDisplay(mDisplay); +} + + +QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandReadbackEglIntegration(waylandDisplay); +} + +void QWaylandReadbackEglIntegration::initialize() +{ + eglBindAPI(EGL_OPENGL_ES_API); + mEglDisplay = eglGetDisplay(mDisplay); + EGLint major, minor; + EGLBoolean initialized = eglInitialize(mEglDisplay,&major,&minor); + if (initialized) { + qDebug() << "EGL initialized successfully" << major << "," << minor; + } else { + qDebug() << "EGL could not initialized. All EGL and GL operations will fail"; + } +} + +QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWidget *widget) +{ + return new QWaylandReadbackEglWindow(widget,this); +} + +EGLDisplay QWaylandReadbackEglIntegration::eglDisplay() +{ + return mEglDisplay; +} + +Window QWaylandReadbackEglIntegration::rootWindow() const +{ + return mRootWindow; +} + +int QWaylandReadbackEglIntegration::depth() const +{ + return XDefaultDepth(mDisplay,mScreen); +} + +Display * QWaylandReadbackEglIntegration::xDisplay() const +{ + return mDisplay; +} + +QWaylandDisplay * QWaylandReadbackEglIntegration::waylandDisplay() const +{ + return mWaylandDisplay; +} diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h new file mode 100644 index 0000000..84fa64f --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h @@ -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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDREADBACKEGLINTEGRATION_H +#define QWAYLANDREADBACKEGLINTEGRATION_H + +#include "gl_integration/qwaylandglintegration.h" + +#include +#include +#include +#include +#include + +#include + +#include + +class QWaylandReadbackEglIntegration : public QWaylandGLIntegration +{ +public: + QWaylandReadbackEglIntegration(QWaylandDisplay *display); + ~QWaylandReadbackEglIntegration(); + + void initialize(); + QWaylandWindow *createEglWindow(QWidget *widget); + + QWaylandDisplay *waylandDisplay() const; + Display *xDisplay() const; + Window rootWindow() const; + int depth() const; + + EGLDisplay eglDisplay(); + +private: + QWaylandDisplay *mWaylandDisplay; + Display *mDisplay; + int mScreen; + Window mRootWindow; + EGLDisplay mEglDisplay; + +}; + +#endif // QWAYLANDREADBACKEGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp new file mode 100644 index 0000000..2ae212b --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandreadbackeglwindow.h" + +#include "qwaylandreadbackeglcontext.h" + +QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration) + : QWaylandShmWindow(window) + , mEglIntegration(eglIntegration) + , mContext(0) +{ +} + +QWaylandWindow::WindowType QWaylandReadbackEglWindow::windowType() const +{ + //We'r lying, maybe we should add a type, but for now it will do + //since this is primarly used by the windowsurface. + return QWaylandWindow::Egl; +} + +QPlatformGLContext *QWaylandReadbackEglWindow::glContext() const +{ + if (!mContext) { + QWaylandReadbackEglWindow *that = const_cast(this); + that->mContext = new QWaylandReadbackEglContext(mEglIntegration,that); + } + return mContext; +} + +void QWaylandReadbackEglWindow::setGeometry(const QRect &rect) +{ + QPlatformWindow::setGeometry(rect); + + if (mContext) + mContext->geometryChanged(); +} + diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h new file mode 100644 index 0000000..453ad27 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDREADBACKEGLWINDOW_H +#define QWAYLANDREADBACKEGLWINDOW_H + +#include "qwaylandshmwindow.h" +#include "qwaylandreadbackeglintegration.h" + +class QWaylandReadbackEglContext; + +class QWaylandReadbackEglWindow : public QWaylandShmWindow +{ +public: + QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration); + + WindowType windowType() const; + + QPlatformGLContext *glContext() const; + + void setGeometry(const QRect &rect); + +private: + QWaylandReadbackEglIntegration *mEglIntegration; + QWaylandReadbackEglContext *mContext; +}; + +#endif // QWAYLANDREADBACKEGLWINDOW_H 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 new file mode 100644 index 0000000..0d8e01b --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/readback_egl.pri @@ -0,0 +1,14 @@ + +LIBS += -lX11 -lXext -lEGL + +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/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp new file mode 100644 index 0000000..08c5cf6c --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandreadbackglxcontext.h" + +#include "qwaylandshmsurface.h" +#include "qwaylandreadbackglxwindow.h" + +#include + +static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) +{ + const int width = img.width(); + const int height = img.height(); + + if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV + || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) + { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); + } + } else { + for (int i = 0; i < height; ++i) { + uint *p = (uint *) img.scanLine(i); + for (int x = 0; x < width; ++x) + p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff); + } + } +} + +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) +{ + XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); + mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE); + + geometryChanged(); +} + +void QWaylandReadbackGlxContext::makeCurrent() +{ + QPlatformGLContext::makeCurrent(); + + glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext); +} + +void QWaylandReadbackGlxContext::doneCurrent() +{ + QPlatformGLContext::doneCurrent(); +} + +void QWaylandReadbackGlxContext::swapBuffers() +{ + if (QPlatformGLContext::currentContext() != this) { + makeCurrent(); + } + + QSize size = mWindow->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); + + img = img.mirrored(); + qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV); + constBits = img.bits(); + + const uchar *constDstBits = mBuffer->image()->bits(); + uchar *dstBits = const_cast(constDstBits); + memcpy(dstBits,constBits,(img.width()*4) * img.height()); + + + mWindow->damage(QRegion(QRect(QPoint(0,0),size))); + mWindow->waitForFrameSync(); + +} + +void * QWaylandReadbackGlxContext::getProcAddress(const QString &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 :("; + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h new file mode 100644 index 0000000..5fafcf0 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDREADBACKGLXCONTEXT_H +#define QWAYLANDREADBACKGLXCONTEXT_H + +#include + +#include "qwaylandreadbackglxintegration.h" + +#include "qglxconvenience.h" + +class QWaylandReadbackGlxWindow; +class QWaylandShmBuffer; + +class QWaylandReadbackGlxContext : public QPlatformGLContext +{ +public: + QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegration *glxIntegration, QWaylandReadbackGlxWindow *window); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void* getProcAddress(const QString& procName); + + QPlatformWindowFormat platformWindowFormat() const; + + void geometryChanged(); + +private: + QWaylandReadbackGlxIntegration *mGlxIntegration; + QWaylandReadbackGlxWindow *mWindow; + QWaylandShmBuffer *mBuffer; + + Pixmap mPixmap; + GLXFBConfig mConfig; + GLXContext mContext; + GLXPixmap mGlxPixmap; +}; + +#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 new file mode 100644 index 0000000..7e2a74d --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandreadbackglxintegration.h" + +#include "qwaylandreadbackglxwindow.h" + +#include + +QWaylandReadbackGlxIntegration::QWaylandReadbackGlxIntegration(QWaylandDisplay * waylandDispaly) + : QWaylandGLIntegration() + , mWaylandDisplay(waylandDispaly) +{ + qDebug() << "Using Wayland Readback-GLX"; + char *display_name = getenv("DISPLAY"); + mDisplay = XOpenDisplay(display_name); + mScreen = XDefaultScreen(mDisplay); + mRootWindow = XDefaultRootWindow(mDisplay); + XSync(mDisplay, False); +} + +QWaylandReadbackGlxIntegration::~QWaylandReadbackGlxIntegration() +{ + XCloseDisplay(mDisplay); +} + +void QWaylandReadbackGlxIntegration::initialize() +{ +} + +QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWidget *widget) +{ + return new QWaylandReadbackGlxWindow(widget,this); +} + +QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) +{ + return new QWaylandReadbackGlxIntegration(waylandDisplay); +} + +Display * QWaylandReadbackGlxIntegration::xDisplay() const +{ + return mDisplay; +} + +int QWaylandReadbackGlxIntegration::screen() const +{ + return mScreen; +} + +Window QWaylandReadbackGlxIntegration::rootWindow() const +{ + return mRootWindow; +} + +QWaylandDisplay * QWaylandReadbackGlxIntegration::waylandDisplay() const +{ + return mWaylandDisplay; +} diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h new file mode 100644 index 0000000..9056393 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDREADBACKGLXINTEGRATION_H +#define QWAYLANDREADBACKGLXINTEGRATION_H + +#include "gl_integration/qwaylandglintegration.h" + +#include +#include +#include +#include +#include + +#include + +class QWaylandReadbackGlxIntegration : public QWaylandGLIntegration +{ +public: + QWaylandReadbackGlxIntegration(QWaylandDisplay * waylandDispaly); + ~QWaylandReadbackGlxIntegration(); + + void initialize(); + + QWaylandWindow *createEglWindow(QWidget *widget); + + QWaylandDisplay *waylandDisplay() const; + + Display *xDisplay() const; + int screen() const; + Window rootWindow() const; + +private: + QWaylandDisplay *mWaylandDisplay; + + Display *mDisplay; + int mScreen; + Window mRootWindow; + +}; + +#endif // QWAYLANDREADBACKGLXINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp new file mode 100644 index 0000000..ca1603c --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwaylandreadbackglxwindow.h" + +QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration) + : QWaylandShmWindow(window) + , mGlxIntegration(glxIntegration) + , mContext(0) +{ +} + +QWaylandWindow::WindowType QWaylandReadbackGlxWindow::windowType() const +{ + //yeah. this type needs a new name + return QWaylandWindow::Egl; +} + +QPlatformGLContext * QWaylandReadbackGlxWindow::glContext() const +{ + if (!mContext) { + QWaylandReadbackGlxWindow *that = const_cast(this); + that->mContext = new QWaylandReadbackGlxContext(mGlxIntegration,that); + } + return mContext; +} + +void QWaylandReadbackGlxWindow::setGeometry(const QRect &rect) +{ + QWaylandShmWindow::setGeometry(rect); + + if (mContext) { + mContext->geometryChanged(); + } +} diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h new file mode 100644 index 0000000..4d7bb3e --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWAYLANDREADBACKGLXWINDOW_H +#define QWAYLANDREADBACKGLXWINDOW_H + +#include "qwaylandshmwindow.h" +#include "qwaylandreadbackglxintegration.h" +#include "qwaylandreadbackglxcontext.h" + +class QWaylandReadbackGlxWindow : public QWaylandShmWindow +{ +public: + QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration); + WindowType windowType() const; + + QPlatformGLContext *glContext() const; + + void setGeometry(const QRect &rect); + +private: + QWaylandReadbackGlxIntegration *mGlxIntegration; + QWaylandReadbackGlxContext *mContext; + +}; + +#endif // QWAYLANDREADBACKGLXWINDOW_H 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 new file mode 100644 index 0000000..f8ea005 --- /dev/null +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/readback_glx.pri @@ -0,0 +1,12 @@ +include (../../../glxconvenience/glxconvenience.pri) +HEADERS += \ + $$PWD/qwaylandreadbackglxintegration.h \ + $$PWD/qwaylandreadbackglxwindow.h \ + $$PWD/qwaylandreadbackglxcontext.h + +SOURCES += \ + $$PWD/qwaylandreadbackglxintegration.cpp \ + $$PWD/qwaylandreadbackglxwindow.cpp \ + $$PWD/qwaylandreadbackglxcontext.cpp + +LIBS += -lX11 diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp deleted file mode 100644 index b8ff4c4..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp +++ /dev/null @@ -1,177 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxpixmapeglcontext.h" - -#include "../../../eglconvenience/qeglconvenience.h" - -#include -#include - -#include "qwaylandshmsurface.h" - -#include - -static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) -{ - const int width = img.width(); - const int height = img.height(); - - if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV - || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) - { - for (int i = 0; i < height; ++i) { - uint *p = (uint *) img.scanLine(i); - for (int x = 0; x < width; ++x) - p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); - } - } else { - for (int i = 0; i < height; ++i) { - uint *p = (uint *) img.scanLine(i); - for (int x = 0; x < width; ++x) - p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff); - } - } -} - -QXPixmapReadbackGLContext::QXPixmapReadbackGLContext(QWaylandXPixmapEglIntegration *eglIntegration, QWaylandXPixmapWindow *window) - : mEglIntegration(eglIntegration) - , mWindow(window) - , mBuffer(0) - , mPixmap(0) - , mConfig(q_configFromQPlatformWindowFormat(eglIntegration->eglDisplay(),window->widget()->platformWindowFormat(),true,EGL_PIXMAP_BIT)) - , mPixmapSurface(EGL_NO_SURFACE) -{ - QVector eglContextAttrs; - eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); - eglContextAttrs.append(2); - eglContextAttrs.append(EGL_NONE); - - mContext = eglCreateContext(eglIntegration->eglDisplay(),mConfig,0,eglContextAttrs.constData()); - - geometryChanged(); -} - -QXPixmapReadbackGLContext::~QXPixmapReadbackGLContext() -{ - eglDestroyContext(mEglIntegration->eglDisplay(),mContext); -} - -void QXPixmapReadbackGLContext::makeCurrent() -{ - QPlatformGLContext::makeCurrent(); - - while(mWindow->waitingForFrameSync()) { - mEglIntegration->waylandDisplay()->iterate(); - } - - eglMakeCurrent(mEglIntegration->eglDisplay(),mPixmapSurface,mPixmapSurface,mContext); -} - -void QXPixmapReadbackGLContext::doneCurrent() -{ - QPlatformGLContext::doneCurrent(); - eglMakeCurrent(mEglIntegration->eglDisplay(),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT); -} - -void QXPixmapReadbackGLContext::swapBuffers() -{ - eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface); - - if (QPlatformGLContext::currentContext() != this) { - makeCurrent(); - } - - QSize size = mWindow->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); - - img = img.mirrored(); - qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV); - constBits = img.bits(); - - const uchar *constDstBits = mBuffer->image()->bits(); - uchar *dstBits = const_cast(constDstBits); - memcpy(dstBits,constBits,(img.width()*4) * img.height()); - - - mWindow->damage(QRegion(QRect(QPoint(0,0),size))); -} - -void * QXPixmapReadbackGLContext::getProcAddress(const QString &procName) -{ - return (void *) eglGetProcAddress(procName.toLatin1().data()); -} - -QPlatformWindowFormat QXPixmapReadbackGLContext::platformWindowFormat() const -{ - return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig); -} - -void QXPixmapReadbackGLContext::geometryChanged() -{ - QSize size(mWindow->geometry().size()); - if (size.isEmpty()) { - //QGLWidget wants a context for a window without geometry - size = QSize(1,1); - } - - while (mWindow->waitingForFrameSync()) - mEglIntegration->waylandDisplay()->iterate(); - - delete mBuffer; - if (mPixmap) - XFreePixmap(mEglIntegration->xDisplay(),mPixmap); - - mBuffer = new QWaylandShmBuffer(mEglIntegration->waylandDisplay(),size,QImage::Format_ARGB32); - mWindow->attach(mBuffer); - mPixmap = XCreatePixmap(mEglIntegration->xDisplay(),mEglIntegration->rootWindow(),size.width(),size.height(),mEglIntegration->depth()); - XSync(mEglIntegration->xDisplay(),False); - - mPixmapSurface = eglCreatePixmapSurface(mEglIntegration->eglDisplay(),mConfig,mPixmap,0); - if (mPixmapSurface == EGL_NO_SURFACE) { - qDebug() << "Could not make egl surface out of pixmap :("; - } -} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h deleted file mode 100644 index 811d75d..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h +++ /dev/null @@ -1,80 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QXPIXMAPREADBACKGLCONTEXT_H -#define QXPIXMAPREADBACKGLCONTEXT_H - -#include -#include - -#include "qwaylandxpixmapeglintegration.h" -#include "qwaylandxpixmapwindow.h" - -class QWaylandShmBuffer; - -class QXPixmapReadbackGLContext : public QPlatformGLContext -{ -public: - QXPixmapReadbackGLContext(QWaylandXPixmapEglIntegration *eglIntegration, QWaylandXPixmapWindow *window); - ~QXPixmapReadbackGLContext(); - - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString& procName); - - virtual QPlatformWindowFormat platformWindowFormat() const; - - void geometryChanged(); - -private: - QWaylandXPixmapEglIntegration *mEglIntegration; - QWaylandXPixmapWindow *mWindow; - QWaylandShmBuffer *mBuffer; - - Pixmap mPixmap; - - EGLConfig mConfig; - EGLContext mContext; - EGLSurface mPixmapSurface; -}; - -#endif // QXPIXMAPREADBACKGLCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp deleted file mode 100644 index f6967e1..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp +++ /dev/null @@ -1,112 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxpixmapeglintegration.h" - -#include - -#include "qwaylandxpixmapwindow.h" - -QWaylandXPixmapEglIntegration::QWaylandXPixmapEglIntegration(QWaylandDisplay *display) - : QWaylandGLIntegration() - , mWaylandDisplay(display) -{ - qDebug() << "Using Wayland XPixmap-EGL"; - char *display_name = getenv("DISPLAY"); - mDisplay = XOpenDisplay(display_name); - mScreen = XDefaultScreen(mDisplay); - mRootWindow = XDefaultRootWindow(mDisplay); - XSync(mDisplay, False); -} - -QWaylandXPixmapEglIntegration::~QWaylandXPixmapEglIntegration() -{ - XCloseDisplay(mDisplay); -} - - -QWaylandGLIntegration *QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) -{ - return new QWaylandXPixmapEglIntegration(waylandDisplay); -} - -void QWaylandXPixmapEglIntegration::initialize() -{ - eglBindAPI(EGL_OPENGL_ES_API); - mEglDisplay = eglGetDisplay(mDisplay); - EGLint major, minor; - EGLBoolean initialized = eglInitialize(mEglDisplay,&major,&minor); - if (initialized) { - qDebug() << "EGL initialized successfully" << major << "," << minor; - } else { - qDebug() << "EGL could not initialized. All EGL and GL operations will fail"; - } -} - -QWaylandWindow * QWaylandXPixmapEglIntegration::createEglWindow(QWidget *widget) -{ - return new QWaylandXPixmapWindow(widget,this); -} - -EGLDisplay QWaylandXPixmapEglIntegration::eglDisplay() -{ - return mEglDisplay; -} - -Window QWaylandXPixmapEglIntegration::rootWindow() const -{ - return mRootWindow; -} - -int QWaylandXPixmapEglIntegration::depth() const -{ - return XDefaultDepth(mDisplay,mScreen); -} - -Display * QWaylandXPixmapEglIntegration::xDisplay() const -{ - return mDisplay; -} - -QWaylandDisplay * QWaylandXPixmapEglIntegration::waylandDisplay() const -{ - return mWaylandDisplay; -} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h deleted file mode 100644 index 16c3632..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h +++ /dev/null @@ -1,82 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXPIXMAPEGLINTEGRATION_H -#define QWAYLANDXPIXMAPEGLINTEGRATION_H - -#include "gl_integration/qwaylandglintegration.h" - -#include -#include -#include -#include -#include - -#include - -#include - -class QWaylandXPixmapEglIntegration : public QWaylandGLIntegration -{ -public: - QWaylandXPixmapEglIntegration(QWaylandDisplay *display); - ~QWaylandXPixmapEglIntegration(); - - void initialize(); - QWaylandWindow *createEglWindow(QWidget *widget); - - QWaylandDisplay *waylandDisplay() const; - Display *xDisplay() const; - Window rootWindow() const; - int depth() const; - - EGLDisplay eglDisplay(); - -private: - QWaylandDisplay *mWaylandDisplay; - Display *mDisplay; - int mScreen; - Window mRootWindow; - EGLDisplay mEglDisplay; - -}; - -#endif // QWAYLANDXPIXMAPEGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp deleted file mode 100644 index 43a80b5..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp +++ /dev/null @@ -1,75 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxpixmapwindow.h" - -#include "qwaylandxpixmapeglcontext.h" -QWaylandXPixmapWindow::QWaylandXPixmapWindow(QWidget *window, QWaylandXPixmapEglIntegration *eglIntegration) - : QWaylandShmWindow(window) - , mEglIntegration(eglIntegration) - , mContext(0) -{ -} - -QWaylandWindow::WindowType QWaylandXPixmapWindow::windowType() const -{ - //We'r lying, maybe we should add a type, but for now it will do - //since this is primarly used by the windowsurface. - return QWaylandWindow::Egl; -} - -QPlatformGLContext *QWaylandXPixmapWindow::glContext() const -{ - if (!mContext) { - QWaylandXPixmapWindow *that = const_cast(this); - that->mContext = new QXPixmapReadbackGLContext(mEglIntegration,that); - } - return mContext; -} - -void QWaylandXPixmapWindow::setGeometry(const QRect &rect) -{ - QPlatformWindow::setGeometry(rect); - - if (mContext) - mContext->geometryChanged(); -} - diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h deleted file mode 100644 index f6cae1d..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h +++ /dev/null @@ -1,66 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXPIXMAPWINDOW_H -#define QWAYLANDXPIXMAPWINDOW_H - -#include "qwaylandshmwindow.h" -#include "qwaylandxpixmapeglintegration.h" - -class QXPixmapReadbackGLContext; - -class QWaylandXPixmapWindow : public QWaylandShmWindow -{ -public: - QWaylandXPixmapWindow(QWidget *window, QWaylandXPixmapEglIntegration *eglIntegration); - - WindowType windowType() const; - - QPlatformGLContext *glContext() const; - - void setGeometry(const QRect &rect); - -private: - QWaylandXPixmapEglIntegration *mEglIntegration; - QXPixmapReadbackGLContext *mContext; -}; - -#endif // QWAYLANDXPIXMAPWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/xpixmap_egl.pri b/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/xpixmap_egl.pri deleted file mode 100644 index 87e2d28..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_egl/xpixmap_egl.pri +++ /dev/null @@ -1,14 +0,0 @@ - -LIBS += -lX11 -lXext -lEGL - -HEADERS += \ - gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.h \ - gl_integration/xpixmap_egl/qwaylandxpixmapwindow.h \ - gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.h \ - $$PWD/../../../eglconvenience/qeglconvenience.h - -SOURCES += \ - gl_integration/xpixmap_egl/qwaylandxpixmapeglintegration.cpp \ - gl_integration/xpixmap_egl/qwaylandxpixmapwindow.cpp \ - gl_integration/xpixmap_egl/qwaylandxpixmapeglcontext.cpp \ - $$PWD/../../../eglconvenience/qeglconvenience.cpp diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp deleted file mode 100644 index 8ccd7c9..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp +++ /dev/null @@ -1,163 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxpixmapglxcontext.h" - -#include "qwaylandshmsurface.h" -#include "qwaylandxpixmapglxwindow.h" - -#include - -static inline void qgl_byteSwapImage(QImage &img, GLenum pixel_type) -{ - const int width = img.width(); - const int height = img.height(); - - if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV - || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) - { - for (int i = 0; i < height; ++i) { - uint *p = (uint *) img.scanLine(i); - for (int x = 0; x < width; ++x) - p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00); - } - } else { - for (int i = 0; i < height; ++i) { - uint *p = (uint *) img.scanLine(i); - for (int x = 0; x < width; ++x) - p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff); - } - } -} - -QWaylandXPixmapGLXContext::QWaylandXPixmapGLXContext(QWaylandXPixmapGLXIntegration *glxIntegration, QWaylandXPixmapGLXWindow *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) -{ - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); - mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE); - - geometryChanged(); -} - -void QWaylandXPixmapGLXContext::makeCurrent() -{ - QPlatformGLContext::makeCurrent(); - - glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext); -} - -void QWaylandXPixmapGLXContext::doneCurrent() -{ - QPlatformGLContext::doneCurrent(); -} - -void QWaylandXPixmapGLXContext::swapBuffers() -{ - if (QPlatformGLContext::currentContext() != this) { - makeCurrent(); - } - - QSize size = mWindow->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); - - img = img.mirrored(); - qgl_byteSwapImage(img,GL_UNSIGNED_INT_8_8_8_8_REV); - constBits = img.bits(); - - const uchar *constDstBits = mBuffer->image()->bits(); - uchar *dstBits = const_cast(constDstBits); - memcpy(dstBits,constBits,(img.width()*4) * img.height()); - - - mWindow->damage(QRegion(QRect(QPoint(0,0),size))); - mWindow->waitForFrameSync(); - -} - -void * QWaylandXPixmapGLXContext::getProcAddress(const QString &procName) -{ - return (void *) glXGetProcAddress(reinterpret_cast(procName.toLatin1().data())); -} - -QPlatformWindowFormat QWaylandXPixmapGLXContext::platformWindowFormat() const -{ - return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext); -} - -void QWaylandXPixmapGLXContext::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 :("; - } -} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h deleted file mode 100644 index 3ea9dfe..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h +++ /dev/null @@ -1,79 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXPIXMAPGLXCONTEXT_H -#define QWAYLANDXPIXMAPGLXCONTEXT_H - -#include - -#include "qwaylandxpixmapglxintegration.h" - -#include "qglxconvenience.h" - -class QWaylandXPixmapGLXWindow; -class QWaylandShmBuffer; - -class QWaylandXPixmapGLXContext : public QPlatformGLContext -{ -public: - QWaylandXPixmapGLXContext(QWaylandXPixmapGLXIntegration *glxIntegration, QWaylandXPixmapGLXWindow *window); - - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString& procName); - - QPlatformWindowFormat platformWindowFormat() const; - - void geometryChanged(); - -private: - QWaylandXPixmapGLXIntegration *mGlxIntegration; - QWaylandXPixmapGLXWindow *mWindow; - QWaylandShmBuffer *mBuffer; - - Pixmap mPixmap; - GLXFBConfig mConfig; - GLXContext mContext; - GLXPixmap mGlxPixmap; -}; - -#endif // QWAYLANDXPIXMAPGLXCONTEXT_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp deleted file mode 100644 index 33d6b06..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.cpp +++ /dev/null @@ -1,97 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxpixmapglxintegration.h" - -#include "qwaylandxpixmapglxwindow.h" - -#include - -QWaylandXPixmapGLXIntegration::QWaylandXPixmapGLXIntegration(QWaylandDisplay * waylandDispaly) - : QWaylandGLIntegration() - , mWaylandDisplay(waylandDispaly) -{ - qDebug() << "Using Wayland XPixmap-GLX"; - char *display_name = getenv("DISPLAY"); - mDisplay = XOpenDisplay(display_name); - mScreen = XDefaultScreen(mDisplay); - mRootWindow = XDefaultRootWindow(mDisplay); - XSync(mDisplay, False); -} - -QWaylandXPixmapGLXIntegration::~QWaylandXPixmapGLXIntegration() -{ - XCloseDisplay(mDisplay); -} - -void QWaylandXPixmapGLXIntegration::initialize() -{ -} - -QWaylandWindow * QWaylandXPixmapGLXIntegration::createEglWindow(QWidget *widget) -{ - return new QWaylandXPixmapGLXWindow(widget,this); -} - -QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay) -{ - return new QWaylandXPixmapGLXIntegration(waylandDisplay); -} - -Display * QWaylandXPixmapGLXIntegration::xDisplay() const -{ - return mDisplay; -} - -int QWaylandXPixmapGLXIntegration::screen() const -{ - return mScreen; -} - -Window QWaylandXPixmapGLXIntegration::rootWindow() const -{ - return mRootWindow; -} - -QWaylandDisplay * QWaylandXPixmapGLXIntegration::waylandDisplay() const -{ - return mWaylandDisplay; -} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h deleted file mode 100644 index c7a80de..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxintegration.h +++ /dev/null @@ -1,80 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXPIXMAPGLXINTEGRATION_H -#define QWAYLANDXPIXMAPGLXINTEGRATION_H - -#include "gl_integration/qwaylandglintegration.h" - -#include -#include -#include -#include -#include - -#include - -class QWaylandXPixmapGLXIntegration : public QWaylandGLIntegration -{ -public: - QWaylandXPixmapGLXIntegration(QWaylandDisplay * waylandDispaly); - ~QWaylandXPixmapGLXIntegration(); - - void initialize(); - - QWaylandWindow *createEglWindow(QWidget *widget); - - QWaylandDisplay *waylandDisplay() const; - - Display *xDisplay() const; - int screen() const; - Window rootWindow() const; - -private: - QWaylandDisplay *mWaylandDisplay; - - Display *mDisplay; - int mScreen; - Window mRootWindow; - -}; - -#endif // QWAYLANDXPIXMAPGLXINTEGRATION_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp deleted file mode 100644 index 065a6fd..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp +++ /dev/null @@ -1,73 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandxpixmapglxwindow.h" - -QWaylandXPixmapGLXWindow::QWaylandXPixmapGLXWindow(QWidget *window, QWaylandXPixmapGLXIntegration *glxIntegration) - : QWaylandShmWindow(window) - , mGlxIntegration(glxIntegration) - , mContext(0) -{ -} - -QWaylandWindow::WindowType QWaylandXPixmapGLXWindow::windowType() const -{ - //yeah. this type needs a new name - return QWaylandWindow::Egl; -} - -QPlatformGLContext * QWaylandXPixmapGLXWindow::glContext() const -{ - if (!mContext) { - QWaylandXPixmapGLXWindow *that = const_cast(this); - that->mContext = new QWaylandXPixmapGLXContext(mGlxIntegration,that); - } - return mContext; -} - -void QWaylandXPixmapGLXWindow::setGeometry(const QRect &rect) -{ - QWaylandShmWindow::setGeometry(rect); - - if (mContext) { - mContext->geometryChanged(); - } -} diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h deleted file mode 100644 index 5f4d24f..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h +++ /dev/null @@ -1,65 +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$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, 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. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWAYLANDXPIXMAPGLXWINDOW_H -#define QWAYLANDXPIXMAPGLXWINDOW_H - -#include "qwaylandshmwindow.h" -#include "qwaylandxpixmapglxintegration.h" -#include "qwaylandxpixmapglxcontext.h" - -class QWaylandXPixmapGLXWindow : public QWaylandShmWindow -{ -public: - QWaylandXPixmapGLXWindow(QWidget *window, QWaylandXPixmapGLXIntegration *glxIntegration); - WindowType windowType() const; - - QPlatformGLContext *glContext() const; - - void setGeometry(const QRect &rect); - -private: - QWaylandXPixmapGLXIntegration *mGlxIntegration; - QWaylandXPixmapGLXContext *mContext; - -}; - -#endif // QWAYLANDXPIXMAPGLXWINDOW_H diff --git a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri b/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri deleted file mode 100644 index 2b6ae0d..0000000 --- a/src/plugins/platforms/wayland/gl_integration/xpixmap_glx/xpixmap_glx.pri +++ /dev/null @@ -1,12 +0,0 @@ -include (../../../glxconvenience/glxconvenience.pri) -HEADERS += \ - $$PWD/qwaylandxpixmapglxintegration.h \ - gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.h \ - gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.h - -SOURCES += \ - $$PWD/qwaylandxpixmapglxintegration.cpp \ - gl_integration/xpixmap_glx/qwaylandxpixmapglxwindow.cpp \ - gl_integration/xpixmap_glx/qwaylandxpixmapglxcontext.cpp - -LIBS += -lX11 diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index bd017cc..ae17a14 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -37,10 +37,10 @@ contains(QT_CONFIG, opengl) { contains(QT_CONFIG, opengles2) { CONFIG += wayland_egl - #CONFIG += xpixmap_egl + #CONFIG += readback_egl #CONFIG += xcomposite_egl } else { - CONFIG += xpixmap_glx + CONFIG += readback_glx #CONFIG += xcomposite_gl } -- cgit v0.12 From f5f4e258a989e05fe89a4294db85c8513b24a04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 11 Apr 2011 13:44:49 +0200 Subject: Make sure the global listener gets registered even when using drm. --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index e2bfaa2..a6fdd46 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -120,6 +120,9 @@ QWaylandDisplay::QWaylandDisplay(void) qErrnoWarning(errno, "Failed to create display"); qFatal("No wayland connection available."); } + + wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this); + #ifdef QT_WAYLAND_GL_SUPPORT mEglIntegration = QWaylandGLIntegration::createGLIntegration(this); #endif @@ -132,7 +135,6 @@ QWaylandDisplay::QWaylandDisplay(void) connect(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock()), this, SLOT(flushRequests())); - wl_display_add_global_listener(mDisplay, QWaylandDisplay::displayHandleGlobal, this); mFd = wl_display_get_fd(mDisplay, sourceUpdate, this); mReadNotifier = new QSocketNotifier(mFd, QSocketNotifier::Read, this); -- cgit v0.12 From f067aa05c030fd02d46f10ab2023059978b4f816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 11 Apr 2011 10:41:40 +0200 Subject: Make the xcomposite the default gl integration backend The others can be opted in with the environment variable: QT_WAYLAND_GL_CONFIG --- .../wayland/gl_integration/gl_integration.pri | 30 ++++++++++++++++++++++ src/plugins/platforms/wayland/wayland.pro | 17 +----------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri index 835f880..d9b5fa9 100644 --- a/src/plugins/platforms/wayland/gl_integration/gl_integration.pri +++ b/src/plugins/platforms/wayland/gl_integration/gl_integration.pri @@ -1,3 +1,7 @@ +contains(QT_CONFIG, opengl) { + DEFINES += QT_WAYLAND_GL_SUPPORT + QT += opengl + HEADERS += \ $$PWD/qwaylandglintegration.h \ $$PWD/qwaylandglwindowsurface.h @@ -6,6 +10,32 @@ SOURCES += \ $$PWD/qwaylandglintegration.cpp \ $$PWD/qwaylandglwindowsurface.cpp + QT_WAYLAND_GL_CONFIG = $$(QT_WAYLAND_GL_CONFIG) + contains(QT_CONFIG, opengles2) { + isEqual(QT_WAYLAND_GL_CONFIG, wayland_egl) { + QT_WAYLAND_GL_INTEGRATION = $$QT_WAYLAND_GL_CONFIG + CONFIG += wayland_egl + } else:isEqual(QT_WAYLAND_GL_CONFIG,readback) { + QT_WAYLAND_GL_INTEGRATION = readback_egl + CONFIG += readback_egl + } else { + QT_WAYLAND_GL_INTEGRATION = xcomposite_egl + CONFIG += xcomposite_egl + } + } else { + isEqual(QT_WAYLAND_GL_CONFIG, readback) { + QT_WAYLAND_GL_INTEGRATION = readback_glx + CONFIG += readback_glx + } else { + QT_WAYLAND_GL_INTEGRATION = xcomposite_glx + CONFIG += xcomposite_glx + } + } + + message("Wayland GL Integration: $$QT_WAYLAND_GL_INTEGRATION") +} + + wayland_egl { include ($$PWD/wayland_egl/wayland_egl.pri) } diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro index ae17a14..5945438 100644 --- a/src/plugins/platforms/wayland/wayland.pro +++ b/src/plugins/platforms/wayland/wayland.pro @@ -31,22 +31,7 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND INCLUDEPATH += $$PWD -contains(QT_CONFIG, opengl) { - DEFINES += QT_WAYLAND_GL_SUPPORT - QT += opengl - - contains(QT_CONFIG, opengles2) { - CONFIG += wayland_egl - #CONFIG += readback_egl - #CONFIG += xcomposite_egl - } else { - CONFIG += readback_glx - #CONFIG += xcomposite_gl - - } - - include ($$PWD/gl_integration/gl_integration.pri) -} +include ($$PWD/gl_integration/gl_integration.pri) include (../fontdatabases/genericunix/genericunix.pri) -- cgit v0.12 From 15d84435d0b41b866da77367e41ebc523409ce95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 11 Apr 2011 12:37:36 +0200 Subject: Wayland: compile fix after making the event handling single threaded --- .../qwaylandxcompositeglxcontext.cpp | 24 ++++++++++++++-------- .../xcomposite_glx/qwaylandxcompositeglxcontext.h | 3 ++- 2 files changed, 18 insertions(+), 9 deletions(-) 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 c108fbd..caf5117 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp @@ -56,6 +56,7 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLX , mBuffer(0) , mXWindow(0) , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat())) + , mWaitingForSyncCallback(false) { XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig); mContext = glXCreateContext(glxIntegration->xDisplay(),visualInfo,0,TRUE); @@ -97,7 +98,20 @@ QPlatformWindowFormat QWaylandXCompositeGLXContext::platformWindowFormat() const void QWaylandXCompositeGLXContext::sync_function(void *data) { QWaylandXCompositeGLXContext *that = static_cast(data); - that->mWaitCondition.wakeAll(); + that->mWaitingForSyncCallback = false; +} + +void QWaylandXCompositeGLXContext::waitForSync() +{ + 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(); + } } void QWaylandXCompositeGLXContext::geometryChanged() @@ -132,11 +146,5 @@ void QWaylandXCompositeGLXContext::geometryChanged() size, mGlxIntegration->waylandDisplay()->argbVisual()); mWindow->attach(mBuffer); - wl_display_sync_callback(mGlxIntegration->waylandDisplay()->wl_display(), - QWaylandXCompositeGLXContext::sync_function, - this); - QMutex lock; - lock.lock(); - wl_display_sync(mGlxIntegration->waylandDisplay()->wl_display(),0); - mWaitCondition.wait(&lock); + waitForSync(); } 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 b45ec3f..eb2e5a5 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h @@ -78,7 +78,8 @@ private: GLXContext mContext; static void sync_function(void *data); - QWaitCondition mWaitCondition; + void waitForSync(); + bool mWaitingForSyncCallback; }; #endif // QWAYLANDXCOMPOSITEGLXCONTEXT_H -- cgit v0.12 From 1ce473ee7e2f76e0e670ed645881282288e5ab29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 11 Apr 2011 13:38:53 +0200 Subject: Wayland: Tell what backend we use for xcomposite glx --- .../gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 da92bc8..2b123cc 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -56,6 +56,7 @@ QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDispl : QWaylandGLIntegration() , mWaylandDisplay(waylandDispaly) { + qDebug() << "Wayland XComposite GLX Integration"; wl_display_add_global_listener(waylandDispaly->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal, this); } @@ -118,7 +119,6 @@ void QWaylandXCompositeGLXIntegration::rootInformation(void *data, wl_xcomposite Q_UNUSED(xcomposite); QWaylandXCompositeGLXIntegration *integration = static_cast(data); - qDebug() << "ROOT INFORMATION" << integration->mDisplay << integration->mRootWindow << integration->mScreen; integration->mDisplay = XOpenDisplay(display_name); integration->mRootWindow = (Window) root_window; integration->mScreen = XDefaultScreen(integration->mDisplay); -- cgit v0.12 From fb297b316b1acfda133ce6d5b46c89eaf8475199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Mon, 11 Apr 2011 13:53:38 +0200 Subject: Wayland: Show what backend is being used --- .../gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp | 2 +- .../gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp | 2 +- .../gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp | 1 + .../gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) 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 9347691..20f7ffb 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp @@ -49,7 +49,7 @@ QWaylandReadbackEglIntegration::QWaylandReadbackEglIntegration(QWaylandDisplay * : QWaylandGLIntegration() , mWaylandDisplay(display) { - qDebug() << "Using Wayland Readback-EGL"; + qDebug() << "Using Readback-EGL"; char *display_name = getenv("DISPLAY"); mDisplay = XOpenDisplay(display_name); mScreen = XDefaultScreen(mDisplay); 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 7e2a74d..4651f0c 100644 --- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp @@ -49,7 +49,7 @@ QWaylandReadbackGlxIntegration::QWaylandReadbackGlxIntegration(QWaylandDisplay * : QWaylandGLIntegration() , mWaylandDisplay(waylandDispaly) { - qDebug() << "Using Wayland Readback-GLX"; + qDebug() << "Using Readback-GLX"; char *display_name = getenv("DISPLAY"); mDisplay = XOpenDisplay(display_name); mScreen = XDefaultScreen(mDisplay); 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 352e651..95b4112 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp @@ -56,6 +56,7 @@ QWaylandXCompositeEGLIntegration::QWaylandXCompositeEGLIntegration(QWaylandDispl : QWaylandGLIntegration() , mWaylandDisplay(waylandDispaly) { + qDebug() << "Using XComposite-EGL"; wl_display_add_global_listener(mWaylandDisplay->wl_display(), QWaylandXCompositeEGLIntegration::wlDisplayHandleGlobal, this); } 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 2b123cc..43c0135 100644 --- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp +++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp @@ -56,7 +56,7 @@ QWaylandXCompositeGLXIntegration::QWaylandXCompositeGLXIntegration(QWaylandDispl : QWaylandGLIntegration() , mWaylandDisplay(waylandDispaly) { - qDebug() << "Wayland XComposite GLX Integration"; + qDebug() << "Using XComposite-GLX"; wl_display_add_global_listener(waylandDispaly->wl_display(), QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal, this); } -- cgit v0.12 From 0108e888480e47e65d82d94e10a7c7c910e42d79 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 11 Apr 2011 14:48:47 +0200 Subject: Make readEvents() non-blocking Another event handler could empty the Wayland socket after the socket notifier has triggered, but before the signal is delivered. Since wl_display_iterate is blocking, we have to test whether there is data available to avoid freezing the whole application. Reviewed-by: Samuel --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 26 ++++++++++++++++++++++- src/plugins/platforms/wayland/qwaylanddisplay.h | 1 + src/plugins/platforms/wayland/qwaylandwindow.cpp | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index a6fdd46..eb9e791 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -176,6 +176,30 @@ void QWaylandDisplay::flushRequests() void QWaylandDisplay::readEvents() { +// verify that there is still data on the socket + fd_set fds; + FD_ZERO(&fds); + FD_SET(mFd, &fds); + fd_set nds; + FD_ZERO(&nds); + fd_set rs = fds; + fd_set ws = nds; + fd_set es = nds; + timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 0; + int ret = ::select(mFd+1, &rs, &ws, &es, &timeout ); + + if (ret <= 0) { + //qDebug("QWaylandDisplay::readEvents() No data... blocking avoided"); + return; + } + + wl_display_iterate(mDisplay, WL_DISPLAY_READABLE); +} + +void QWaylandDisplay::blockingReadEvents() +{ wl_display_iterate(mDisplay, WL_DISPLAY_READABLE); } @@ -208,7 +232,7 @@ void QWaylandDisplay::waitForScreens() { flushRequests(); while (mScreens.isEmpty()) - readEvents(); + blockingReadEvents(); } void QWaylandDisplay::displayHandleGlobal(struct wl_display *display, diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h index e02767d..3ddbfb2 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay.h @@ -86,6 +86,7 @@ public: public slots: void createNewScreen(struct wl_output *output, QRect geometry); void readEvents(); + void blockingReadEvents(); void flushRequests(); private: diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index d58b39d..7e94fb9 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -154,5 +154,5 @@ void QWaylandWindow::waitForFrameSync() { mDisplay->flushRequests(); while (mWaitingForFrameSync) - mDisplay->readEvents(); + mDisplay->blockingReadEvents(); } -- cgit v0.12 From 3ba6c3b7a4261147addc1d7fb06060dae7522691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 13 Apr 2011 08:49:52 +0200 Subject: Remove DefaultSharedContext from Lighthouse API. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QPlatformWindowFormat::setUseDefaultSharedContext was meant as a convenience, but it adds complexity in the platform plugin implementation, and can be implemented by the above layers using QPlatformWindowFormat::setSharedContext. Reviewed-by: Jørgen Lind --- src/gui/kernel/qplatformglcontext_qpa.cpp | 18 --------- src/gui/kernel/qplatformglcontext_qpa.h | 5 +-- src/gui/kernel/qplatformwindowformat_qpa.cpp | 13 +----- src/gui/kernel/qplatformwindowformat_qpa.h | 11 +----- src/opengl/qwindowsurface_gl.cpp | 14 ------- src/opengl/qwindowsurface_gl_p.h | 4 -- .../eglconvenience/qeglplatformcontext.cpp | 5 --- .../platforms/eglconvenience/qeglplatformcontext.h | 2 - src/plugins/platforms/eglfs/qeglfsscreen.cpp | 1 - .../platforms/openkode/qopenkodeintegration.cpp | 4 +- .../platforms/openkode/qopenkodeintegration.h | 4 ++ src/plugins/platforms/openkode/qopenkodewindow.cpp | 10 ++--- .../wayland_egl/qwaylandglcontext.cpp | 31 +-------------- .../gl_integration/wayland_egl/qwaylandglcontext.h | 1 - src/plugins/platforms/xcb/qglxintegration.cpp | 46 +--------------------- src/plugins/platforms/xcb/qglxintegration.h | 2 - src/plugins/platforms/xlib/qglxintegration.cpp | 44 +-------------------- src/plugins/platforms/xlib/qglxintegration.h | 2 - 18 files changed, 18 insertions(+), 199 deletions(-) diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp index 86740e8..1810532 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.cpp +++ b/src/gui/kernel/qplatformglcontext_qpa.cpp @@ -125,24 +125,6 @@ QPlatformGLContext::~QPlatformGLContext() } - -/*! - Makes it possible to set the context which can be the default for making new contexts. -*/ -void QPlatformGLContext::setDefaultSharedContext(QPlatformGLContext *sharedContext) -{ - QPlatformGLContextPrivate::staticSharedContext = sharedContext; -} - -/*! - Default shared context is intended to be a globally awailable pointer to a context which can - be used for sharing resources when creating new contexts. Its default value is 0; -*/ -QPlatformGLContext *QPlatformGLContext::defaultSharedContext() -{ - return QPlatformGLContextPrivate::staticSharedContext; -} - /*! Reimplement in subclass to do makeCurrent on native GL context */ diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index a680c85..28923a9 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -69,13 +69,10 @@ public: virtual QPlatformWindowFormat platformWindowFormat() const = 0; const static QPlatformGLContext *currentContext(); - static QPlatformGLContext *defaultSharedContext(); protected: - - static void setDefaultSharedContext(QPlatformGLContext *sharedContext); - QScopedPointer d_ptr; + private: //hack to make it work with QGLContext::CurrentContext friend class QGLContext; diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp index ddc6239..c165c85 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.cpp +++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp @@ -53,7 +53,7 @@ public: , opts(QPlatformWindowFormat::DoubleBuffer | QPlatformWindowFormat::DepthBuffer | QPlatformWindowFormat::Rgba | QPlatformWindowFormat::DirectRendering | QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions - | QPlatformWindowFormat::UseDefaultSharedContext | QPlatformWindowFormat::HasWindowSurface) + | QPlatformWindowFormat::HasWindowSurface) , depthSize(-1) , accumSize(-1) , stencilSize(-1) @@ -525,16 +525,6 @@ void QPlatformWindowFormat::setSampleBuffers(bool enable) setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers); } -void QPlatformWindowFormat::setUseDefaultSharedContext(bool enable) -{ - if (enable) { - setOption(QPlatformWindowFormat::UseDefaultSharedContext); - d->sharedContext = 0; - } else { - setOption(QPlatformWindowFormat::NoDefaultSharedContext); - } -} - /*! Returns the number of samples per pixel when multisampling is enabled. By default, the highest number of samples that is @@ -613,7 +603,6 @@ QPlatformWindowFormat::WindowApi QPlatformWindowFormat::windowApi() const void QPlatformWindowFormat::setSharedContext(QPlatformGLContext *context) { - setUseDefaultSharedContext(false); d->sharedContext = context; } diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h index fa01a8a..ba21ba4 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.h +++ b/src/gui/kernel/qplatformwindowformat_qpa.h @@ -66,8 +66,7 @@ public: HasOverlay = 0x0100, SampleBuffers = 0x0200, DeprecatedFunctions = 0x0400, - UseDefaultSharedContext = 0x0800, - HasWindowSurface = 0x1000, + HasWindowSurface = 0x0800, SingleBuffer = DoubleBuffer << 16, NoDepthBuffer = DepthBuffer << 16, ColorIndex = Rgba << 16, @@ -79,7 +78,6 @@ public: NoOverlay = HasOverlay << 16, NoSampleBuffers = SampleBuffers << 16, NoDeprecatedFunctions = DeprecatedFunctions << 16, - NoDefaultSharedContext = UseDefaultSharedContext << 16, NoWindowSurface = HasWindowSurface << 16 }; @@ -149,8 +147,6 @@ public: void setStereo(bool enable); bool directRendering() const; void setDirectRendering(bool enable); - bool useDefaultSharedContext() const; - void setUseDefaultSharedContext(bool enable); bool hasWindowSurface() const; void setWindowSurface(bool enable); @@ -231,11 +227,6 @@ inline bool QPlatformWindowFormat::sampleBuffers() const return testOption(QPlatformWindowFormat::SampleBuffers); } -inline bool QPlatformWindowFormat::useDefaultSharedContext() const -{ - return testOption(QPlatformWindowFormat::UseDefaultSharedContext); -} - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 681ab69..a6489a6 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -181,7 +181,6 @@ QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL) // // QGLWindowSurface // -#ifndef Q_WS_QPA class QGLGlobalShareWidget { public: @@ -257,22 +256,13 @@ void qt_destroy_gl_share_widget() { _qt_gl_share_widget()->destroy(); } -#endif//Q_WS_QPA const QGLContext *qt_gl_share_context() { -#ifdef Q_WS_QPA - //make it possible to have an assesor to defaultSharedGLContext. - const QPlatformGLContext *platformContext = QPlatformGLContext::defaultSharedContext(); - if (!platformContext) - qDebug() << "Please implement a defaultSharedContext for your platformplugin"; - return QGLContext::fromPlatformGLContext(const_cast(platformContext)); -#else QGLWidget *widget = qt_gl_share_widget(); if (widget) return widget->context(); return 0; -#endif } #ifdef QGL_USE_TEXTURE_POOL @@ -405,7 +395,6 @@ QGLWindowSurface::~QGLWindowSurface() delete d_ptr->fbo; delete d_ptr; -#ifndef Q_WS_QPA if (QGLGlobalShareWidget::cleanedUp) return; @@ -426,7 +415,6 @@ QGLWindowSurface::~QGLWindowSurface() qt_destroy_gl_share_widget(); } #endif // QGL_USE_TEXTURE_POOL -#endif // Q_WS_QPA } void QGLWindowSurface::deleted(QObject *object) @@ -476,10 +464,8 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) ctx->create(qt_gl_share_context()); -#ifndef Q_WS_QPA if (widget != qt_gl_share_widget()) ++(_qt_gl_share_widget()->widgetRefCount); -#endif #ifndef QT_NO_EGL static bool checkedForNOKSwapRegion = false; diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index 67f9f41..a8d8381 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -66,12 +66,8 @@ class QRegion; class QWidget; struct QGLWindowSurfacePrivate; -#ifdef Q_WS_QPA -Q_OPENGL_EXPORT const QGLContext* qt_gl_share_context(); -#else Q_OPENGL_EXPORT QGLWidget* qt_gl_share_widget(); Q_OPENGL_EXPORT void qt_destroy_gl_share_widget(); -#endif class QGLWindowSurfaceGLPaintDevice : public QGLPaintDevice { diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp index 9a2bc61..ae5215f 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp @@ -146,11 +146,6 @@ void* QEGLPlatformContext::getProcAddress(const QString& procName) return (void *)eglGetProcAddress(qPrintable(procName)); } -void QEGLPlatformContext::makeDefaultSharedContext() -{ - setDefaultSharedContext(this); -} - QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const { return m_windowFormat; diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h index d688660..69835d7 100644 --- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h +++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h @@ -56,8 +56,6 @@ public: void swapBuffers(); void* getProcAddress(const QString& procName); - void makeDefaultSharedContext(); - QPlatformWindowFormat platformWindowFormat() const; EGLContext eglContext() const; diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp index 2200d1d..b6f2805 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp @@ -203,7 +203,6 @@ void QEglFSScreen::createAndSetPlatformContext() attribList[temp++] = EGL_NONE; QEGLPlatformContext *platformContext = new QEGLPlatformContext(m_dpy,config,attribList,m_surface,EGL_OPENGL_ES_API); - platformContext->makeDefaultSharedContext(); m_platformContext = platformContext; EGLint w,h; // screen size detection diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.cpp b/src/plugins/platforms/openkode/qopenkodeintegration.cpp index 35e744be..e98f322 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.cpp +++ b/src/plugins/platforms/openkode/qopenkodeintegration.cpp @@ -122,7 +122,9 @@ QOpenKODEScreen::QOpenKODEScreen(KDDisplayNV *kdDisplay, KDDesktopNV *kdDesktop } QOpenKODEIntegration::QOpenKODEIntegration() - : mEventLoopIntegration(0), mFontDb(new QGenericUnixFontDatabase()) + : mEventLoopIntegration(0) + , mFontDb(new QGenericUnixFontDatabase()) + , mMainGlContext(0) { if (kdInitializeNV() == KD_ENOTINITIALIZED) { qFatal("Did not manage to initialize openkode"); diff --git a/src/plugins/platforms/openkode/qopenkodeintegration.h b/src/plugins/platforms/openkode/qopenkodeintegration.h index 7582e60..a788091 100644 --- a/src/plugins/platforms/openkode/qopenkodeintegration.h +++ b/src/plugins/platforms/openkode/qopenkodeintegration.h @@ -106,10 +106,14 @@ public: static GLuint blitterProgram(); + void setMainGLContext(QEGLPlatformContext *ctx) { mMainGlContext = ctx; } + void mainGLContext() const { return mMainGlContext; } + private: QList mScreens; QOpenKODEEventLoopIntegration *mEventLoopIntegration; QPlatformFontDatabase *mFontDb; + QEGLPlatformContext *mMainGlContext; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp index 66530a5..d34dff8 100644 --- a/src/plugins/platforms/openkode/qopenkodewindow.cpp +++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp @@ -147,9 +147,9 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) } + QOpenKODEIntegration *integration = static_cast(QApplicationPrivate::platformIntegration()); - - if (!isFullScreen || (isFullScreen && !QPlatformGLContext::defaultSharedContext())) { + if (!isFullScreen || (isFullScreen && !integration->mainGLContext())) { if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) { qErrnoWarning(kdGetError(), "Could not realize native window"); return; @@ -158,9 +158,9 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData()); m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(), m_eglConfig, m_eglContextAttrs.data(), surface, m_eglApi); - m_platformGlContext->makeDefaultSharedContext(); + integration->setMainGLContext(m_platformGLContext); } else { - m_platformGlContext = const_cast(static_cast(QPlatformGLContext::defaultSharedContext())); + m_platformGlContext = integration->mainGLContext(); kdDestroyWindow(m_kdWindow); m_kdWindow = 0; } @@ -169,7 +169,7 @@ QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw) QOpenKODEWindow::~QOpenKODEWindow() { - if (m_platformGlContext != QPlatformGLContext::defaultSharedContext()) { + if (m_platformGlContext != static_cast(QApplicationPrivate::platformIntegration())) { delete m_platformGlContext; } if (m_kdWindow) 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 89ba12b..d293019 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp @@ -50,8 +50,6 @@ #include #include -Q_GLOBAL_STATIC(QMutex,qt_defaultSharedContextMutex) - QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format) : QPlatformGLContext() , mEglDisplay(eglDisplay) @@ -60,20 +58,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindo , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig)) { QPlatformGLContext *sharePlatformContext = 0; - if (format.useDefaultSharedContext()) { - if (!QPlatformGLContext::defaultSharedContext()) { - if (qt_defaultSharedContextMutex()->tryLock()){ - createDefaultSharedContext(eglDisplay); - qt_defaultSharedContextMutex()->unlock(); - } else { - qt_defaultSharedContextMutex()->lock(); //wait to the the shared context is created - qt_defaultSharedContextMutex()->unlock(); - } - } - sharePlatformContext = QPlatformGLContext::defaultSharedContext(); - } else { - sharePlatformContext = format.sharedGLContext(); - } + sharePlatformContext = format.sharedGLContext(); mFormat.setSharedContext(sharePlatformContext); EGLContext shareEGLContext = EGL_NO_CONTEXT; if (sharePlatformContext) @@ -128,20 +113,6 @@ void *QWaylandGLContext::getProcAddress(const QString &string) return (void *) eglGetProcAddress(string.toLatin1().data()); } -void QWaylandGLContext::createDefaultSharedContext(EGLDisplay display) -{ - QVector eglContextAttrs; - eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); - eglContextAttrs.append(2); - eglContextAttrs.append(EGL_NONE); - - QWaylandGLContext *defaultSharedContext = new QWaylandGLContext; - defaultSharedContext->mEglDisplay = display; - defaultSharedContext->mContext = eglCreateContext(mEglDisplay,mConfig, - EGL_NO_CONTEXT, eglContextAttrs.constData()); - QPlatformGLContext::setDefaultSharedContext(defaultSharedContext); -} - void QWaylandGLContext::setEglSurface(EGLSurface surface) { doneCurrent(); 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 a3befdc..76caffa 100644 --- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h +++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.h @@ -72,7 +72,6 @@ private: EGLConfig mConfig; QPlatformWindowFormat mFormat; - void createDefaultSharedContext(EGLDisplay eglDisplay); QWaylandGLContext(); }; diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index 19a9503..190221c 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -57,8 +57,6 @@ #include #endif -QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive); - QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_screen(screen) @@ -67,20 +65,7 @@ QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindo { Q_XCB_NOOP(m_screen->connection()); const QPlatformGLContext *sharePlatformContext; - if (format.useDefaultSharedContext()) { - if (!QPlatformGLContext::defaultSharedContext()) { - if (m_defaultSharedContextMutex.tryLock()){ - createDefaultSharedContext(screen); - m_defaultSharedContextMutex.unlock(); - } else { - m_defaultSharedContextMutex.lock(); //wait to the the shared context is created - m_defaultSharedContextMutex.unlock(); - } - } - sharePlatformContext = QPlatformGLContext::defaultSharedContext(); - } else { - sharePlatformContext = format.sharedGLContext(); - } + sharePlatformContext = format.sharedGLContext(); GLXContext shareGlxContext = 0; if (sharePlatformContext) shareGlxContext = static_cast(sharePlatformContext)->glxContext(); @@ -105,35 +90,6 @@ QGLXContext::~QGLXContext() Q_XCB_NOOP(m_screen->connection()); } -void QGLXContext::createDefaultSharedContext(QXcbScreen *screen) -{ - Q_XCB_NOOP(screen->connection()); - int x = 0; - int y = 0; - int w = 3; - int h = 3; - - QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat(); - GLXContext context; - GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format); - if (config) { - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(DISPLAY_FROM_XCB(screen), config); - Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(screen), screen->root(), visualInfo->visual, AllocNone); - XSetWindowAttributes a; - a.colormap = cmap; - Window sharedWindow = XCreateWindow(DISPLAY_FROM_XCB(screen), screen->root(), x, y, w, h, - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); - - context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, 0, TRUE); - QPlatformGLContext *sharedContext = new QGLXContext(screen, sharedWindow, context); - QPlatformGLContext::setDefaultSharedContext(sharedContext); - } else { - qWarning("Warning no shared context created"); - } - Q_XCB_NOOP(screen->connection()); -} - void QGLXContext::makeCurrent() { Q_XCB_NOOP(m_screen->connection()); diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h index 2e19cf2..99b72a0 100644 --- a/src/plugins/platforms/xcb/qglxintegration.h +++ b/src/plugins/platforms/xcb/qglxintegration.h @@ -73,8 +73,6 @@ private: QPlatformWindowFormat m_windowFormat; QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context); - static QMutex m_defaultSharedContextMutex; - static void createDefaultSharedContext(QXcbScreen *xd); }; #endif diff --git a/src/plugins/platforms/xlib/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp index 6746e22..7a0f36d 100644 --- a/src/plugins/platforms/xlib/qglxintegration.cpp +++ b/src/plugins/platforms/xlib/qglxintegration.cpp @@ -61,8 +61,6 @@ QT_BEGIN_NAMESPACE -QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive); - QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_screen(screen) @@ -71,20 +69,7 @@ QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWind { const QPlatformGLContext *sharePlatformContext; - if (format.useDefaultSharedContext()) { - if (!QPlatformGLContext::defaultSharedContext()) { - if (m_defaultSharedContextMutex.tryLock()){ - createDefaultSharedContext(screen); - m_defaultSharedContextMutex.unlock(); - } else { - m_defaultSharedContextMutex.lock(); //wait to the the shared context is created - m_defaultSharedContextMutex.unlock(); - } - } - sharePlatformContext = QPlatformGLContext::defaultSharedContext(); - } else { - sharePlatformContext = format.sharedGLContext(); - } + sharePlatformContext = format.sharedGLContext(); GLXContext shareGlxContext = 0; if (sharePlatformContext) shareGlxContext = static_cast(sharePlatformContext)->glxContext(); @@ -112,33 +97,6 @@ QGLXContext::~QGLXContext() } } -void QGLXContext::createDefaultSharedContext(QXlibScreen *screen) -{ - int x = 0; - int y = 0; - int w = 3; - int h = 3; - - QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat(); - GLXContext context; - GLXFBConfig config = qglx_findConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),format); - if (config) { - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config); - Colormap cmap = XCreateColormap(screen->display()->nativeDisplay(),screen->rootWindow(),visualInfo->visual,AllocNone); - XSetWindowAttributes a; - a.colormap = cmap; - Window sharedWindow = XCreateWindow(screen->display()->nativeDisplay(), screen->rootWindow(),x, y, w, h, - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); - - context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,0,TRUE); - QPlatformGLContext *sharedContext = new QGLXContext(screen,sharedWindow,context); - QPlatformGLContext::setDefaultSharedContext(sharedContext); - } else { - qWarning("Warning no shared context created"); - } -} - void QGLXContext::makeCurrent() { QPlatformGLContext::makeCurrent(); diff --git a/src/plugins/platforms/xlib/qglxintegration.h b/src/plugins/platforms/xlib/qglxintegration.h index cf6b006..57c716b 100644 --- a/src/plugins/platforms/xlib/qglxintegration.h +++ b/src/plugins/platforms/xlib/qglxintegration.h @@ -76,8 +76,6 @@ private: QPlatformWindowFormat m_windowFormat; QGLXContext (QXlibScreen *screen, Drawable drawable, GLXContext context); - static QMutex m_defaultSharedContextMutex; - static void createDefaultSharedContext(QXlibScreen *xd); }; QT_END_NAMESPACE -- cgit v0.12 From 5cca700ee5ecc5b5c06851137703455fcce9c24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 13 Apr 2011 14:02:01 +0200 Subject: Fix configure for Lighthouse Dont assume that we are QWS :) --- configure | 76 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/configure b/configure index 167ae1b..43615a1 100755 --- a/configure +++ b/configure @@ -3701,6 +3701,9 @@ Usage: $relconf [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir Installation options: + -qpa ................ This will enable the QPA build. + QPA is a window system agnostic implementation of Qt. + These are optional, but you may specify install directories. -prefix ...... This will install everything relative to @@ -3870,7 +3873,8 @@ fi See the README file for a list of supported operating systems and compilers. EOF -if [ "${PLATFORM_QWS}" != "yes" ]; then + +if [ "${PLATFORM_QWS}" != "yes" -a "${PLATFORM_QPA}" != "yes" ]; then cat << EOF -graphicssystem Sets an alternate graphics system. Available options are: raster - Software rasterizer @@ -3879,6 +3883,7 @@ cat << EOF EOF fi + cat << EOF -no-mmx ............ Do not compile with use of MMX instructions. @@ -4233,10 +4238,24 @@ Qt/Mac only: EOF fi -if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then +if [ "$PLATFORM_QWS" = "yes" ]; then + cat << EOF +Qt for Embedded Linux: + + -embedded .... This will enable the embedded build, you must have a + proper license for this switch to work. + Example values for : arm mips x86 generic +EOF +fi + +if [ "$PLATFORM_QPA" = "yes" ]; then cat << EOF +Qt for QPA only: +EOF +fi -Qt for Embedded Linux only: +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then + cat << EOF -xplatform target ... The target platform when cross-compiling. @@ -4244,14 +4263,6 @@ Qt for Embedded Linux only: -feature- .. Compile in . The available features are described in src/corelib/global/qfeatures.txt - -embedded .... This will enable the embedded build, you must have a - proper license for this switch to work. - Example values for : arm mips x86 generic - - -qpa ......... This will enable the QPA build. - Example values for : arm mips x86 generic - QPA is a window system agnostic implementation of Qt. - -armfpa ............. Target platform uses the ARM-FPA floating point format. -no-armfpa .......... Target platform does not use the ARM-FPA floating point format. @@ -4276,6 +4287,17 @@ Qt for Embedded Linux only: -qconfig local ...... Use src/corelib/global/qconfig-local.h rather than the default ($CFG_QCONFIG). + -no-opengl .......... Do not support OpenGL. + -opengl ....... Enable OpenGL ES support + With no parameter, this will attempt to auto-detect OpenGL ES 1.x + or 2.x, or regular desktop OpenGL. + Use es1 or es2 for to override auto-detection. +EOF +fi + +if [ "$PLATFORM_QWS" = "yes" ]; then + cat << EOF + -depths ...... Comma-separated list of supported bit-per-pixel depths, from: 1, 4, 8, 12, 15, 16, 18, 24, 32 and 'all'. @@ -4288,14 +4310,6 @@ Qt for Embedded Linux only: -no-decoration-