From c7d146428d0de9a19abe834a7bd0ae54c5b30327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simo=20F=C3=A4lt?= Date: Wed, 5 Feb 2014 11:08:43 +0200 Subject: Fix build break in linux Fixes build break when built on linux with wayland libs installed via pkg manager. Change-Id: I17be64e702d07e817a2e34e76ddbe8dde064f3d2 Reviewed-by: Andrew Knight --- examples/server-buffer/compositor/compositor.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/server-buffer/compositor/compositor.pro b/examples/server-buffer/compositor/compositor.pro index 8d7f48820..9f7751a09 100644 --- a/examples/server-buffer/compositor/compositor.pro +++ b/examples/server-buffer/compositor/compositor.pro @@ -17,4 +17,7 @@ RESOURCES += compositor.qrc CONFIG +=wayland-scanner WAYLANDSERVERSOURCES += ../share-buffer.xml +CONFIG += link_pkgconfig +PKGCONFIG += wayland-server + DEFINES += QT_COMPOSITOR_QUICK -- cgit v1.2.3 From a237778666666ab77c4e8e6b501cf0fbe7c9223e Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Fri, 24 Jan 2014 12:10:17 +0200 Subject: Improve the frame callbacks handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improve the way wl_surface's frame callbacks are handled. The sooner they are sent the better is for the clients, as they have more time to render the next frame, but reducing the time for the compositor to render its frame. The best compromise is probably to send them out after the compositor has issued its GL calls but before calling eglSwapBuffers(), and before the GPU actually draws anything. Rename the function to send the callbacks to only reflect its purpose, leaving the compositors free to choose when they want to send them. Change-Id: Ifcdfcad9e54b4d07d5c087898123ac724395a194 Reviewed-by: Jørgen Lind --- examples/qml-compositor/main.cpp | 9 ++-- examples/qwidget-compositor/main.cpp | 2 +- examples/qwindow-compositor/qwindowcompositor.cpp | 3 +- examples/server-buffer/compositor/main.cpp | 6 +-- .../compositor_api/qwaylandcompositor.cpp | 15 ++++-- src/compositor/compositor_api/qwaylandcompositor.h | 3 +- src/compositor/compositor_api/qwaylandsurface.cpp | 6 --- src/compositor/compositor_api/qwaylandsurface.h | 2 - src/compositor/wayland_wrapper/qwlcompositor.cpp | 20 ++----- src/compositor/wayland_wrapper/qwlcompositor_p.h | 5 +- src/compositor/wayland_wrapper/qwlsurface.cpp | 62 +++++++++++++++++----- src/compositor/wayland_wrapper/qwlsurface_p.h | 7 +-- 12 files changed, 85 insertions(+), 55 deletions(-) diff --git a/examples/qml-compositor/main.cpp b/examples/qml-compositor/main.cpp index 88bab787a..79611a2cb 100644 --- a/examples/qml-compositor/main.cpp +++ b/examples/qml-compositor/main.cpp @@ -67,7 +67,7 @@ public: setColor(Qt::black); winId(); - connect(this, SIGNAL(frameSwapped()), this, SLOT(frameSwappedSlot())); + connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()), Qt::DirectConnection); } QWaylandSurface *fullscreenSurface() const @@ -130,8 +130,11 @@ private slots: emit windowDestroyed(QVariant::fromValue(item)); } - void frameSwappedSlot() { - frameFinished(m_fullscreenSurface); + void sendCallbacks() { + if (m_fullscreenSurface) + sendFrameCallbacks(QList() << m_fullscreenSurface); + else + sendFrameCallbacks(surfaces()); } protected: diff --git a/examples/qwidget-compositor/main.cpp b/examples/qwidget-compositor/main.cpp index 1badb06ac..c0e688cf2 100644 --- a/examples/qwidget-compositor/main.cpp +++ b/examples/qwidget-compositor/main.cpp @@ -245,7 +245,7 @@ protected: #endif //QT_COMPOSITOR_WAYLAND_GL } - frameFinished(); + sendFrameCallbacks(surfaces()); #ifdef QT_COMPOSITOR_WAYLAND_GL //jl:FIX FIX FIX:) diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp index 19f7ce5ec..1d9c3d5e9 100644 --- a/examples/qwindow-compositor/qwindowcompositor.cpp +++ b/examples/qwindow-compositor/qwindowcompositor.cpp @@ -335,7 +335,8 @@ void QWindowCompositor::render() } m_textureBlitter->release(); - frameFinished(); + sendFrameCallbacks(surfaces()); + // N.B. Never call glFinish() here as the busylooping with vsync 'feature' of the nvidia binary driver is not desirable. m_window->swapBuffers(); } diff --git a/examples/server-buffer/compositor/main.cpp b/examples/server-buffer/compositor/main.cpp index c266b2241..bf93c4838 100644 --- a/examples/server-buffer/compositor/main.cpp +++ b/examples/server-buffer/compositor/main.cpp @@ -83,7 +83,7 @@ public: create(); grabWindow(); - connect(this, SIGNAL(frameSwapped()), this, SLOT(frameSwappedSlot())); + connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()), Qt::DirectConnection); connect(this, SIGNAL(sceneGraphInitialized()), this, SLOT(initiateServerBuffer()),Qt::DirectConnection); connect(this, SIGNAL(serverBuffersCreated()), this, SLOT(createServerBufferItems())); @@ -134,8 +134,8 @@ private slots: emit windowDestroyed(QVariant::fromValue(item)); } - void frameSwappedSlot() { - frameFinished(); + void sendCallbacks() { + sendFrameCallbacks(surfaces()); } void initiateServerBuffer() diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index be001a9ce..639815be4 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -93,10 +93,10 @@ struct wl_display *QWaylandCompositor::waylandDisplay() const { return m_compositor->wl_display(); } -void QWaylandCompositor::frameFinished(QWaylandSurface *surface) + +void QWaylandCompositor::sendFrameCallbacks(QList visibleSurfaces) { - QtWayland::Surface *surfaceImpl = surface? surface->handle():0; - m_compositor->frameFinished(surfaceImpl); + m_compositor->sendFrameCallbacks(visibleSurfaces); } void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface) @@ -126,6 +126,15 @@ QList QWaylandCompositor::surfacesForClient(WaylandClient* c) return result; } +QList QWaylandCompositor::surfaces() const +{ + QList surfaces = m_compositor->surfaces(); + QList surfs; + foreach (QtWayland::Surface *s, surfaces) + surfs << s->waylandSurface(); + return surfs; +} + QWindow * QWaylandCompositor::window() const { return m_toplevel_window; diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h index 639ddd6cf..6ed9cd894 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.h +++ b/src/compositor/compositor_api/qwaylandcompositor.h @@ -84,12 +84,13 @@ public: struct wl_display *waylandDisplay() const; - void frameFinished(QWaylandSurface *surface = 0); + void sendFrameCallbacks(QList visibleSurfaces); void destroyClientForSurface(QWaylandSurface *surface); void destroyClient(WaylandClient *client); QList surfacesForClient(WaylandClient* client) const; + QList surfaces() const; QWindow *window()const; diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index 01704160e..a865f32d9 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -305,12 +305,6 @@ QWaylandCompositor *QWaylandSurface::compositor() const return d->surface->compositor()->waylandCompositor(); } -void QWaylandSurface::frameFinished() -{ - Q_D(QWaylandSurface); - d->surface->frameFinished(); -} - QWaylandSurface *QWaylandSurface::transientParent() const { Q_D(const QWaylandSurface); diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index e4126b807..7dc219d9a 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -144,8 +144,6 @@ public: void setVisibility(QWindow::Visibility visibility); Q_INVOKABLE void sendOnScreenVisibilityChange(bool visible); // Compat - void frameFinished(); - QWaylandSurface *transientParent() const; QtWayland::Surface *handle() const; diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp index 8a7b1617d..7d5cd35f1 100644 --- a/src/compositor/wayland_wrapper/qwlcompositor.cpp +++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp @@ -242,16 +242,10 @@ Compositor::~Compositor() delete m_display; } -void Compositor::frameFinished(Surface *surface) -{ - if (surface && m_dirty_surfaces.contains(surface)) { - m_dirty_surfaces.remove(surface); - surface->sendFrameCallback(); - } else if (!surface) { - QSet dirty = m_dirty_surfaces; - m_dirty_surfaces.clear(); - foreach (Surface *surface, dirty) - surface->sendFrameCallback(); +void Compositor::sendFrameCallbacks(QList visibleSurfaces) +{ + foreach (QWaylandSurface *surface, visibleSurfaces) { + surface->handle()->sendFrameCallback(); } } @@ -294,7 +288,6 @@ void Compositor::destroySurface(Surface *surface) dev->setKeyboardFocus(0); m_surfaces.removeOne(surface); - m_dirty_surfaces.remove(surface); waylandCompositor()->surfaceAboutToBeDestroyed(surface->waylandSurface()); @@ -312,11 +305,6 @@ void Compositor::cleanupGraphicsResources() m_destroyed_surfaces.clear(); } -void Compositor::markSurfaceAsDirty(QtWayland::Surface *surface) -{ - m_dirty_surfaces.insert(surface); -} - void Compositor::destroyClient(WaylandClient *c) { wl_client *client = static_cast(c); diff --git a/src/compositor/wayland_wrapper/qwlcompositor_p.h b/src/compositor/wayland_wrapper/qwlcompositor_p.h index 90529e5ec..bd60a5cfd 100644 --- a/src/compositor/wayland_wrapper/qwlcompositor_p.h +++ b/src/compositor/wayland_wrapper/qwlcompositor_p.h @@ -62,6 +62,7 @@ class QWaylandServerBufferIntegration; class WindowManagerServerIntegration; class QMimeData; class QPlatformScreenBuffer; +class QWaylandSurface; namespace QtWayland { @@ -88,13 +89,12 @@ public: Compositor(QWaylandCompositor *qt_compositor, QWaylandCompositor::ExtensionFlags extensions); ~Compositor(); - void frameFinished(Surface *surface = 0); + void sendFrameCallbacks(QList visibleSurfaces); InputDevice *defaultInputDevice(); //we just have 1 default device for now (since QPA doesn't give us anything else) void createSurface(struct wl_client *client, uint32_t id); void destroySurface(Surface *surface); - void markSurfaceAsDirty(Surface *surface); void destroyClient(WaylandClient *client); @@ -182,7 +182,6 @@ private: QElapsedTimer m_timer; QList m_surfaces; - QSet m_dirty_surfaces; QSet m_destroyed_surfaces; QSet m_destroyed_buffers; diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index 00a69d289..b7f45c675 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -73,6 +73,39 @@ namespace QtWayland { static bool QT_WAYLAND_PRINT_BUFFERING_WARNINGS = qEnvironmentVariableIsSet("QT_WAYLAND_PRINT_BUFFERING_WARNINGS"); +class FrameCallback { +public: + FrameCallback(Surface *surf, wl_resource *res) + : surface(surf) + , resource(res) + { + wl_resource_set_implementation(res, 0, this, destroyCallback); + } + ~FrameCallback() + { + } + void destroy() + { + if (resource) + wl_resource_destroy(resource); + else + delete this; + } + void send(uint time) + { + wl_callback_send_done(resource, time); + wl_resource_destroy(resource); + } + static void destroyCallback(wl_resource *res) + { + FrameCallback *_this = static_cast(wl_resource_get_user_data(res)); + _this->surface->removeFrameCallback(_this); + delete _this; + } + Surface *surface; + wl_resource *resource; +}; + Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) : QtWaylandServer::wl_surface(client, id) , m_compositor(compositor) @@ -87,7 +120,6 @@ Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) , m_transientInactive(false) , m_isCursorSurface(false) { - wl_list_init(&m_frame_callback_list); } Surface::~Surface() @@ -97,6 +129,11 @@ Surface::~Surface() for (int i = 0; i < m_bufferPool.size(); i++) delete m_bufferPool[i]; + + foreach (FrameCallback *c, m_pendingFrameCallbacks) + c->destroy(); + foreach (FrameCallback *c, m_frameCallbacks) + c->destroy(); } void Surface::releaseSurfaces() @@ -146,9 +183,8 @@ bool Surface::isYInverted() const bool Surface::visible() const { - SurfaceBuffer *surfacebuffer = currentSurfaceBuffer(); - return surfacebuffer->waylandBufferHandle(); + return surfacebuffer ? surfacebuffer->waylandBufferHandle() : 0; } QPointF Surface::pos() const @@ -222,17 +258,15 @@ GLuint Surface::textureId() const void Surface::sendFrameCallback() { uint time = m_compositor->currentTimeMsecs(); - struct wl_resource *frame_callback, *next; - wl_list_for_each_safe(frame_callback, next, &m_frame_callback_list, link) { - wl_callback_send_done(frame_callback, time); - wl_resource_destroy(frame_callback); - } - wl_list_init(&m_frame_callback_list); + foreach (FrameCallback *callback, m_frameCallbacks) + callback->send(time); + m_frameCallbacks.clear(); } -void Surface::frameFinished() +void Surface::removeFrameCallback(FrameCallback *callback) { - m_compositor->frameFinished(this); + m_pendingFrameCallbacks.removeOne(callback); + m_frameCallbacks.removeOne(callback); } QWaylandSurface * Surface::waylandSurface() const @@ -344,7 +378,6 @@ void Surface::setBackBuffer(SurfaceBuffer *buffer) emit m_waylandSurface->unmapped(); } - m_compositor->markSurfaceAsDirty(this); emit m_waylandSurface->damaged(m_backBuffer->damageRect()); } else { InputDevice *inputDevice = m_compositor->defaultInputDevice(); @@ -438,7 +471,7 @@ void Surface::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, in void Surface::surface_frame(Resource *resource, uint32_t callback) { struct wl_resource *frame_callback = wl_client_add_object(resource->client(), &wl_callback_interface, 0, callback, this); - wl_list_insert(&m_frame_callback_list, &frame_callback->link); + m_pendingFrameCallbacks << new FrameCallback(this, frame_callback); } void Surface::surface_set_opaque_region(Resource *, struct wl_resource *region) @@ -474,6 +507,9 @@ void Surface::surface_commit(Resource *) setBackBuffer(surfaceBuffer); m_bufferQueue.takeFirst(); } + + m_frameCallbacks << m_pendingFrameCallbacks; + m_pendingFrameCallbacks.clear(); } void Surface::setClassName(const QString &className) diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h index 92b49ed74..bad65e935 100644 --- a/src/compositor/wayland_wrapper/qwlsurface_p.h +++ b/src/compositor/wayland_wrapper/qwlsurface_p.h @@ -73,6 +73,7 @@ class ExtendedSurface; class InputPanelSurface; class SubSurface; class ShellSurface; +class FrameCallback; class Q_COMPOSITOR_EXPORT Surface : public QtWaylandServer::wl_surface { @@ -106,8 +107,7 @@ public: #endif void sendFrameCallback(); - - void frameFinished(); + void removeFrameCallback(FrameCallback *callback); QWaylandSurface *waylandSurface() const; @@ -156,7 +156,8 @@ private: QPoint m_lastLocalMousePos; QPoint m_lastGlobalMousePos; - struct wl_list m_frame_callback_list; + QList m_pendingFrameCallbacks; + QList m_frameCallbacks; ExtendedSurface *m_extendedSurface; SubSurface *m_subSurface; -- cgit v1.2.3 From 73fa84a4408126e05a1f0706f0e5aa92d0d6de69 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Fri, 7 Feb 2014 16:06:40 +0200 Subject: Make the compositor test build Change-Id: Ic4137ff7f69b293db60fa1232602cd4560497d6e Reviewed-by: Robin Burchell --- tests/auto/compositor/tst_compositor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/compositor/tst_compositor.cpp b/tests/auto/compositor/tst_compositor.cpp index 8656338ef..44fb2ff96 100644 --- a/tests/auto/compositor/tst_compositor.cpp +++ b/tests/auto/compositor/tst_compositor.cpp @@ -210,7 +210,7 @@ void tst_WaylandCompositor::frameCallback() QTRY_COMPARE(damagedSpy.count(), i + 1); QCOMPARE(waylandSurface->image(), buffer.image); - waylandSurface->frameFinished(); + compositor.sendFrameCallbacks(QList() << waylandSurface); QTRY_COMPARE(frameCounter, i + 1); } -- cgit v1.2.3 From c7c788de03b2285a1e3f278dcbcf86368cedeec2 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Thu, 6 Feb 2014 15:58:39 +0200 Subject: Fix build with Wayland <= 1.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idd12c0db73203daa008d93c0dc8053e25dff09e2 Reviewed-by: Jørgen Lind --- src/compositor/wayland_wrapper/qwlsurface.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index b7f45c675..1d01667b3 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -79,7 +79,12 @@ public: : surface(surf) , resource(res) { +#if WAYLAND_VERSION_MAJOR < 1 || (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR <= 2) + res->data = this; + res->destroy = destroyCallback; +#else wl_resource_set_implementation(res, 0, this, destroyCallback); +#endif } ~FrameCallback() { @@ -98,7 +103,11 @@ public: } static void destroyCallback(wl_resource *res) { +#if WAYLAND_VERSION_MAJOR < 1 || (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR <= 2) + FrameCallback *_this = static_cast(res->data); +#else FrameCallback *_this = static_cast(wl_resource_get_user_data(res)); +#endif _this->surface->removeFrameCallback(_this); delete _this; } -- cgit v1.2.3 From 6d038fb664de833725d13ee6b548d85eabf1ff3a Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Sat, 8 Feb 2014 10:48:18 +0100 Subject: Strip custom prefix from interface name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Interface names for some protocols might not start with wl_ or qt_, with this change users can specify a prefix of their liking. Change-Id: I70d40985165c49114b525bdec2a872aa5b0dad6d Reviewed-by: Jørgen Lind --- src/qtwaylandscanner/qtwaylandscanner.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp index 437832229..48a71a560 100644 --- a/src/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/qtwaylandscanner/qtwaylandscanner.cpp @@ -313,8 +313,10 @@ void printEnums(const QList &enums) } } -QByteArray stripInterfaceName(const QByteArray &name) +QByteArray stripInterfaceName(const QByteArray &name, const QByteArray &prefix) { + if (!prefix.isEmpty() && name.startsWith(prefix)) + return name.mid(prefix.size()); if (name.startsWith("qt_") || name.startsWith("wl_")) return name.mid(3); @@ -327,7 +329,7 @@ bool ignoreInterface(const QByteArray &name) || (isServerSide() && name == "wl_registry"); } -void process(QXmlStreamReader &xml, const QByteArray &headerPath) +void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArray &prefix) { if (!xml.readNextStartElement()) return; @@ -409,7 +411,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath) const char *interfaceName = interface.name.constData(); - QByteArray stripped = stripInterfaceName(interface.name); + QByteArray stripped = stripInterfaceName(interface.name, prefix); const char *interfaceNameStripped = stripped.constData(); printf(" class %s %s\n {\n", serverExport.constData(), interfaceName); @@ -546,7 +548,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath) const char *interfaceName = interface.name.constData(); - QByteArray stripped = stripInterfaceName(interface.name); + QByteArray stripped = stripInterfaceName(interface.name, prefix); const char *interfaceNameStripped = stripped.constData(); printf(" %s::%s(struct ::wl_client *client, int id)\n", interfaceName, interfaceName); @@ -815,7 +817,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath) const char *interfaceName = interface.name.constData(); - QByteArray stripped = stripInterfaceName(interface.name); + QByteArray stripped = stripInterfaceName(interface.name, prefix); const char *interfaceNameStripped = stripped.constData(); printf(" class %s %s\n {\n", clientExport.constData(), interfaceName); @@ -901,7 +903,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath) const char *interfaceName = interface.name.constData(); - QByteArray stripped = stripInterfaceName(interface.name); + QByteArray stripped = stripInterfaceName(interface.name, prefix); const char *interfaceNameStripped = stripped.constData(); bool hasEvents = !interface.events.isEmpty(); @@ -1065,15 +1067,18 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath) int main(int argc, char **argv) { if (argc <= 2 || !parseOption(argv[1], &option)) { - fprintf(stderr, "Usage: %s [client-header|server-header|client-code|server-code] specfile [header-path]\n", argv[0]); + fprintf(stderr, "Usage: %s [client-header|server-header|client-code|server-code] specfile [header-path] [prefix]\n", argv[0]); return 1; } QCoreApplication app(argc, argv); QByteArray headerPath; - if (argc == 4) + if (argc >= 4) headerPath = QByteArray(argv[3]); + QByteArray prefix; + if (argc == 5) + prefix = QByteArray(argv[4]); QFile file(argv[2]); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { fprintf(stderr, "Unable to open file %s\n", argv[2]); @@ -1081,7 +1086,7 @@ int main(int argc, char **argv) } QXmlStreamReader xml(&file); - process(xml, headerPath); + process(xml, headerPath, prefix); if (xml.hasError()) { fprintf(stderr, "XML error: %s\nLine %lld, column %lld\n", xml.errorString().toLocal8Bit().constData(), xml.lineNumber(), xml.columnNumber()); -- cgit v1.2.3 From d30758c987ff7899872dd0021a740e67f0f470e6 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Thu, 27 Feb 2014 12:51:41 +0200 Subject: Change the minimum required Wayland version back to 1.2 As discussed, Wayland 1.3 is not common in distributions yet, and that is a problem for the C.I. machines. Change-Id: Iec5c6d8ae1d1a50199f66d45ca9269694db78efe Reviewed-by: Andrew Knight Reviewed-by: Robin Burchell --- README | 2 +- config.tests/wayland/main.cpp | 10 ++-- src/3rdparty/protocol/wayland.xml | 105 ++++++-------------------------------- 3 files changed, 21 insertions(+), 96 deletions(-) diff --git a/README b/README index dcfb09ce9..9dd5a3876 100644 --- a/README +++ b/README @@ -17,7 +17,7 @@ make To build the QtWayland module you need the external dependencies: xkbcommon 0.2.0 - http://xkbcommon.org/ -wayland 1.3.0 - http://wayland.freedesktop.org/ +wayland 1.2.0 - http://wayland.freedesktop.org/ We hang out at #qt-labs and #qt-lighthouse on freenode if you have any questions diff --git a/config.tests/wayland/main.cpp b/config.tests/wayland/main.cpp index fb9915305..6094f0883 100644 --- a/config.tests/wayland/main.cpp +++ b/config.tests/wayland/main.cpp @@ -43,15 +43,15 @@ int main() { #if WAYLAND_VERSION_MAJOR < 1 -# error Wayland 1.3.0 or higher required +# error Wayland 1.2.0 or higher required #endif #if WAYLAND_VERSION_MAJOR == 1 -# if WAYLAND_VERSION_MINOR < 3 -# error Wayland 1.3.0 or higher required +# if WAYLAND_VERSION_MINOR < 2 +# error Wayland 1.2.0 or higher required # endif -# if WAYLAND_VERSION_MINOR == 3 +# if WAYLAND_VERSION_MINOR == 2 # if WAYLAND_VERSION_MICRO < 0 -# error Wayland 1.3.0 or higher required +# error Wayland 1.2.0 or higher required # endif # endif #endif diff --git a/src/3rdparty/protocol/wayland.xml b/src/3rdparty/protocol/wayland.xml index a1df007d0..1442b6a03 100644 --- a/src/3rdparty/protocol/wayland.xml +++ b/src/3rdparty/protocol/wayland.xml @@ -38,7 +38,7 @@ The sync request asks the server to emit the 'done' event on the returned wl_callback object. Since requests are handled in-order and events are delivered in-order, this can - be used as a barrier to ensure all previous requests and the + used as a barrier to ensure all previous requests and the resulting events have been handled. The object returned by this request will be destroyed by the @@ -274,73 +274,10 @@ - This describes the memory layout of an individual pixel. - - All renderers should support argb8888 and xrgb8888 but any other - formats are optional and may not be supported by the particular - renderer in use. + This describes the memory layout of an individual pixel. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -584,7 +521,7 @@ This event is sent when an active drag-and-drop pointer enters a surface owned by the client. The position of the pointer at - enter time is provided by the x and y arguments, in surface + enter time is provided by the x an y arguments, in surface local coordinates. @@ -607,7 +544,7 @@ This event is sent when the drag-and-drop pointer moves within the currently focused surface. The new position of the pointer - is provided by the x and y arguments, in surface local + is provided by the x an y arguments, in surface local coordinates. @@ -640,7 +577,7 @@ - The wl_data_device_manager is a singleton global object that + The wl_data_device_manager is a a singleton global object that provides access to inter-client data transfer mechanisms such as copy-and-paste and drag-and-drop. These mechanisms are tied to a wl_seat and this interface lets a client get a wl_data_device @@ -909,9 +846,9 @@ Set a class for the surface. The surface class identifies the general class of applications - to which the surface belongs. A common convention is to use the - file name (or the full path if it is a non-standard location) of - the application's .desktop file as the class. + to which the surface belongs. A common convention is to use + the file name (full path if non-standard location) of the + applications .desktop file as the class. @@ -953,7 +890,7 @@ The popup_done event is sent out when a popup grab is broken, - that is, when the user clicks a surface that doesn't belong + that is, when the users clicks a surface that doesn't belong to the client owning the popup surface. @@ -1015,10 +952,10 @@ Destroying the wl_buffer after wl_buffer.release does not change the surface contents. However, if the client destroys the - wl_buffer before receiving the wl_buffer.release event, the surface + wl_buffer before receiving wl_buffer.release, the surface contents become undefined immediately. - If wl_surface.attach is sent with a NULL wl_buffer, the + Only if wl_surface.attach is sent with a NULL wl_buffer, the following wl_surface.commit will remove the surface content. @@ -1235,7 +1172,7 @@ - + A seat is a group of keyboards, pointer and touch devices. This object is published as a global during start up, or when such a @@ -1308,7 +1245,7 @@ - + The wl_pointer interface represents one or more input devices, such as mice, which control the pointer location and pointer_focus @@ -1357,10 +1294,6 @@ - - - - Notification that this seat's pointer is focused on a certain @@ -1460,16 +1393,12 @@ - + The wl_keyboard interface represents one or more keyboards associated with a seat. - - - - This specifies the format of the keymap provided to the @@ -1547,7 +1476,7 @@ - + The wl_touch interface represents a touchscreen associated with a seat. @@ -1559,10 +1488,6 @@ contact point can be identified by the ID of the sequence. - - - - A new touch point has appeared on the surface. This touch point is -- cgit v1.2.3 From 5c605d363e2fc42f5ec80413d093b69614027da4 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Wed, 5 Mar 2014 13:15:29 +0200 Subject: Create the egl windows and context with the right config The egl config should be calculated when creating the window, and the format of it should be set accordingly. The format of the window and the one of the context will then match if using the same format as input. Change-Id: Ie93735171d8945111a450263089e192919249b68 Reviewed-by: Laszlo Agocs --- .../client/wayland-egl/qwaylandeglwindow.cpp | 10 +++++----- src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp index dc5bbc3ba..30f649263 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp @@ -59,12 +59,15 @@ QWaylandEglWindow::QWaylandEglWindow(QWindow *window) , m_clientBufferIntegration(static_cast(mDisplay->clientBufferIntegration())) , m_waylandEglWindow(0) , m_eglSurface(0) - , m_eglConfig(0) + , m_eglConfig(q_configFromGLFormat(m_clientBufferIntegration->eglDisplay(), window->requestedFormat(), true)) , m_contentFBO(0) , m_resize(false) - , m_format(window->requestedFormat()) + , m_format(q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(), m_eglConfig)) { setGeometry(window->geometry()); + + EGLNativeWindowType eglw = (EGLNativeWindowType) m_waylandEglWindow; + m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->eglDisplay(), m_eglConfig, eglw, 0); } QWaylandEglWindow::~QWaylandEglWindow() @@ -129,9 +132,6 @@ EGLSurface QWaylandEglWindow::eglSurface() const } if (!m_eglSurface) { - m_eglConfig = q_configFromGLFormat(m_clientBufferIntegration->eglDisplay(), window()->format(), true); - const_cast(this)->m_format = q_glFormatFromConfig(m_clientBufferIntegration->eglDisplay(),m_eglConfig); - EGLNativeWindowType window = (EGLNativeWindowType) m_waylandEglWindow; m_eglSurface = eglCreateWindowSurface(m_clientBufferIntegration->eglDisplay(), m_eglConfig, window, 0); } diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h index 9f08559d1..d6708a342 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h +++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h @@ -76,7 +76,7 @@ private: const QWaylandWindow *m_parentWindow; mutable EGLSurface m_eglSurface; - mutable EGLConfig m_eglConfig; + EGLConfig m_eglConfig; mutable QOpenGLFramebufferObject *m_contentFBO; mutable bool m_resize; -- cgit v1.2.3 From ffc1183b6fbf4fc16bbf5bc0ff5f7eaff4af1e7c Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Mon, 3 Mar 2014 13:19:05 +0200 Subject: Support changing the keymap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds new API, but does not add a way for the user to set the keymap. That should be implemented in the compositors. Change-Id: I28ee7d372f8f578c0d7efb9223cabce49504be1f Reviewed-by: Pier Luigi Fiorini Reviewed-by: Jørgen Lind --- src/compositor/compositor_api/qwaylandinput.cpp | 17 +++++++ src/compositor/compositor_api/qwaylandinput.h | 22 ++++++++ src/compositor/wayland_wrapper/qwlkeyboard.cpp | 68 ++++++++++++++++++++++--- src/compositor/wayland_wrapper/qwlkeyboard_p.h | 11 +++- 4 files changed, 109 insertions(+), 9 deletions(-) diff --git a/src/compositor/compositor_api/qwaylandinput.cpp b/src/compositor/compositor_api/qwaylandinput.cpp index c2b7c5108..14c3221f7 100644 --- a/src/compositor/compositor_api/qwaylandinput.cpp +++ b/src/compositor/compositor_api/qwaylandinput.cpp @@ -48,6 +48,17 @@ QT_BEGIN_NAMESPACE +QWaylandKeymap::QWaylandKeymap(const QString &layout, const QString &variant, const QString &options, const QString &model, const QString &rules) + : m_layout(layout) + , m_variant(variant) + , m_options(options) + , m_rules(rules) + , m_model(model) +{ +} + + + QWaylandInputDevice::QWaylandInputDevice(QWaylandCompositor *compositor) : d(new QtWayland::InputDevice(this,compositor->handle())) { @@ -141,6 +152,12 @@ bool QWaylandInputDevice::setKeyboardFocus(QWaylandSurface *surface) return d->setKeyboardFocus(wlsurface); } +void QWaylandInputDevice::setKeymap(const QWaylandKeymap &keymap) +{ + if (handle()->keyboardDevice()) + handle()->keyboardDevice()->setKeymap(keymap); +} + QWaylandSurface *QWaylandInputDevice::mouseFocus() const { QtWayland::Surface *wlsurface = d->mouseFocus(); diff --git a/src/compositor/compositor_api/qwaylandinput.h b/src/compositor/compositor_api/qwaylandinput.h index 8e453af4e..92255518a 100644 --- a/src/compositor/compositor_api/qwaylandinput.h +++ b/src/compositor/compositor_api/qwaylandinput.h @@ -43,6 +43,7 @@ #include #include +#include #include @@ -57,6 +58,26 @@ namespace QtWayland { class InputDevice; } +class Q_COMPOSITOR_EXPORT QWaylandKeymap +{ +public: + QWaylandKeymap(const QString &layout = QLatin1String("us"), const QString &variant = QString(), const QString &options = QString(), + const QString &model = QLatin1String("pc105"), const QString &rules = QLatin1String("evdev")); + + inline QString layout() const { return m_layout; } + inline QString variant() const { return m_variant; } + inline QString options() const { return m_options; } + inline QString rules() const { return m_rules; } + inline QString model() const { return m_model; } + +private: + QString m_layout; + QString m_variant; + QString m_options; + QString m_rules; + QString m_model; +}; + class Q_COMPOSITOR_EXPORT QWaylandInputDevice { public: @@ -83,6 +104,7 @@ public: QWaylandSurface *keyboardFocus() const; bool setKeyboardFocus(QWaylandSurface *surface); + void setKeymap(const QWaylandKeymap &keymap); QWaylandSurface *mouseFocus() const; void setMouseFocus(QWaylandSurface *surface, const QPointF &local_pos, const QPointF &global_pos = QPointF()); diff --git a/src/compositor/wayland_wrapper/qwlkeyboard.cpp b/src/compositor/wayland_wrapper/qwlkeyboard.cpp index 8e74a779b..29c192cb0 100644 --- a/src/compositor/wayland_wrapper/qwlkeyboard.cpp +++ b/src/compositor/wayland_wrapper/qwlkeyboard.cpp @@ -67,6 +67,8 @@ Keyboard::Keyboard(Compositor *compositor, InputDevice *seat) , m_modsLatched() , m_modsLocked() , m_group() + , m_pendingKeymap(false) + , m_state(0) { #ifndef QT_NO_WAYLAND_XKB initXKB(); @@ -79,6 +81,7 @@ Keyboard::~Keyboard() if (m_keymap_area) munmap(m_keymap_area, m_keymap_size); close(m_keymap_fd); + xkb_context_unref(m_context); xkb_state_unref(m_state); #endif } @@ -95,7 +98,7 @@ void Keyboard::setFocus(Surface *surface) if (resource && (m_focus != surface || m_focusResource != resource)) { uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); send_modifiers(resource->handle, serial, m_modsDepressed, m_modsLatched, m_modsLocked, m_group); - send_enter(resource->handle, serial, surface->resource()->handle, m_keys); + send_enter(resource->handle, serial, surface->resource()->handle, QByteArray::fromRawData((char *)m_keys.data(), m_keys.size() * sizeof(uint32_t))); } m_focusResource = resource; @@ -103,6 +106,12 @@ void Keyboard::setFocus(Surface *surface) Q_EMIT focusChanged(m_focus); } +void Keyboard::setKeymap(const QWaylandKeymap &keymap) +{ + m_keymap = keymap; + m_pendingKeymap = true; +} + void Keyboard::sendKeyModifiers(wl_keyboard::Resource *resource, uint32_t serial) { send_modifiers(resource->handle, serial, m_modsDepressed, m_modsLatched, m_modsLocked, m_group); @@ -149,10 +158,24 @@ void Keyboard::keyboard_destroy_resource(wl_keyboard::Resource *resource) void Keyboard::sendKeyEvent(uint code, uint32_t state) { + // There must be no keys pressed when changing the keymap, + // see http://lists.freedesktop.org/archives/wayland-devel/2013-October/011395.html + if (m_pendingKeymap && m_keys.isEmpty()) + updateKeymap(); if (m_focusResource) { uint32_t time = m_compositor->currentTimeMsecs(); uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); - send_key(m_focusResource->handle, serial, time, code - 8, state); + uint key = code - 8; + send_key(m_focusResource->handle, serial, time, key, state); + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { + m_keys << key; + } else { + for (int i = 0; i < m_keys.size(); ++i) { + if (m_keys.at(i) == key) { + m_keys.remove(i); + } + } + } } updateModifierState(code, state); } @@ -164,7 +187,7 @@ void Keyboard::updateModifierState(uint code, uint32_t state) uint32_t modsDepressed = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_DEPRESSED); uint32_t modsLatched = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_LATCHED); - uint32_t modsLocked = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_LATCHED); + uint32_t modsLocked = xkb_state_serialize_mods(m_state, (xkb_state_component)XKB_STATE_LOCKED); uint32_t group = xkb_state_serialize_group(m_state, (xkb_state_component)XKB_STATE_EFFECTIVE); if (modsDepressed == m_modsDepressed @@ -186,6 +209,21 @@ void Keyboard::updateModifierState(uint code, uint32_t state) #endif } +void Keyboard::updateKeymap() +{ + m_pendingKeymap = false; +#ifndef QT_NO_WAYLAND_XKB + createXKBKeymap(); + foreach (Resource *res, resourceMap()) { + send_keymap(res->handle, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, m_keymap_fd, m_keymap_size); + } + + xkb_state_update_mask(m_state, 0, m_modsLatched, m_modsLocked, 0, 0, 0); + if (m_focusResource) + sendKeyModifiers(m_focusResource, wl_display_next_serial(m_compositor->wl_display())); +#endif +} + #ifndef QT_NO_WAYLAND_XKB static int createAnonymousFile(size_t size) { @@ -217,10 +255,21 @@ static int createAnonymousFile(size_t size) void Keyboard::initXKB() { - struct xkb_context *context = xkb_context_new(static_cast(0)); + m_context = xkb_context_new(static_cast(0)); + createXKBKeymap(); +} + +void Keyboard::createXKBKeymap() +{ + if (m_state) + xkb_state_unref(m_state); - struct xkb_rule_names rule_names = {0, 0, 0, 0, 0}; - struct xkb_keymap *keymap = xkb_keymap_new_from_names(context, &rule_names, static_cast(0)); + struct xkb_rule_names rule_names = { strdup(qPrintable(m_keymap.rules())), + strdup(qPrintable(m_keymap.model())), + strdup(qPrintable(m_keymap.layout())), + strdup(qPrintable(m_keymap.variant())), + strdup(qPrintable(m_keymap.options())) }; + struct xkb_keymap *keymap = xkb_keymap_new_from_names(m_context, &rule_names, static_cast(0)); char *keymap_str = xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1); if (!keymap_str) @@ -242,7 +291,12 @@ void Keyboard::initXKB() m_state = xkb_state_new(keymap); xkb_keymap_unref(keymap); - xkb_context_unref(context); + + free((char *)rule_names.rules); + free((char *)rule_names.model); + free((char *)rule_names.layout); + free((char *)rule_names.variant); + free((char *)rule_names.options); } #endif diff --git a/src/compositor/wayland_wrapper/qwlkeyboard_p.h b/src/compositor/wayland_wrapper/qwlkeyboard_p.h index 4d783f77e..b20fa97f7 100644 --- a/src/compositor/wayland_wrapper/qwlkeyboard_p.h +++ b/src/compositor/wayland_wrapper/qwlkeyboard_p.h @@ -43,11 +43,12 @@ #define QTWAYLAND_QWLKEYBOARD_P_H #include +#include #include #include -#include +#include #ifndef QT_NO_WAYLAND_XKB #include @@ -70,6 +71,7 @@ public: ~Keyboard(); void setFocus(Surface *surface); + void setKeymap(const QWaylandKeymap &keymap); void sendKeyModifiers(Resource *resource, uint32_t serial); void sendKeyPressEvent(uint code); @@ -88,9 +90,11 @@ protected: private: void sendKeyEvent(uint code, uint32_t state); void updateModifierState(uint code, uint32_t state); + void updateKeymap(); #ifndef QT_NO_WAYLAND_XKB void initXKB(); + void createXKBKeymap(); #endif Compositor *m_compositor; @@ -99,16 +103,19 @@ private: Surface *m_focus; Resource *m_focusResource; - QByteArray m_keys; + QVector m_keys; uint32_t m_modsDepressed; uint32_t m_modsLatched; uint32_t m_modsLocked; uint32_t m_group; + QWaylandKeymap m_keymap; + bool m_pendingKeymap; #ifndef QT_NO_WAYLAND_XKB size_t m_keymap_size; int m_keymap_fd; char *m_keymap_area; + struct xkb_context *m_context; struct xkb_state *m_state; #endif }; -- cgit v1.2.3 From b7baaeeeafbdcecaa077bd07c200da6528f5c333 Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Mon, 10 Mar 2014 09:09:03 +0100 Subject: Updated required version Change-Id: I0284bcac551c13d3f8a7e71c00f0f68cd7872f08 Reviewed-by: Laszlo Agocs --- qtwayland.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qtwayland.pro b/qtwayland.pro index d6971baae..497483bd3 100644 --- a/qtwayland.pro +++ b/qtwayland.pro @@ -13,7 +13,7 @@ qtCompileTest(drm_egl_server) load(qt_parts) !config_wayland { - warning("QtWayland requires Wayland 1.1.0 or higher") + warning("QtWayland requires Wayland 1.2.0 or higher") SUBDIRS = } -- cgit v1.2.3 From 8643053f8f5255fb8e21911c9e7287e675f4b4ed Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 11 Mar 2014 13:45:21 +0100 Subject: Fix build break MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the removed argument from the EGL platform context constructor. Change-Id: I6203d07c356f7191a698d8d5bc958923cbdc2d96 Reviewed-by: Jørgen Lind --- .../client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp index 1ebcdde13..b9a2bb445 100644 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp +++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglcontext.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display) - : QEGLPlatformContext(format, share, display, q_configFromGLFormat(display, format, true, EGL_WINDOW_BIT | EGL_PIXMAP_BIT), EGL_OPENGL_ES_API) + : QEGLPlatformContext(format, share, display, q_configFromGLFormat(display, format, true, EGL_WINDOW_BIT | EGL_PIXMAP_BIT)) { } -- cgit v1.2.3 From 666f597ccd2ced23ecc71ba497981d1a88c34d77 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Mon, 10 Feb 2014 13:29:49 +0200 Subject: Remove the buffer queue. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A client calling attach(A);commit();attach(B);commit() should result in its back buffer be set to B, and A be discarded. If the client wants to have a queue it should keep it client side or a protocol extension tailored for that purpose should be developed. Change-Id: Ia0048f311504d85821df9f5b9225887801efec71 Reviewed-by: Jørgen Lind --- examples/qwidget-compositor/main.cpp | 10 +- examples/qwindow-compositor/qwindowcompositor.cpp | 10 +- examples/qwindow-compositor/qwindowcompositor.h | 4 +- src/compositor/compositor_api/qwaylandsurface.cpp | 4 +- src/compositor/compositor_api/qwaylandsurface.h | 4 +- .../compositor_api/qwaylandsurfaceitem.cpp | 4 +- .../compositor_api/qwaylandsurfaceitem.h | 2 +- src/compositor/wayland_wrapper/qwlsurface.cpp | 101 ++++++--------------- src/compositor/wayland_wrapper/qwlsurface_p.h | 15 ++- .../wayland_wrapper/qwlsurfacebuffer.cpp | 13 --- .../wayland_wrapper/qwlsurfacebuffer_p.h | 4 - 11 files changed, 59 insertions(+), 112 deletions(-) diff --git a/examples/qwidget-compositor/main.cpp b/examples/qwidget-compositor/main.cpp index c0e688cf2..cf7fdda73 100644 --- a/examples/qwidget-compositor/main.cpp +++ b/examples/qwidget-compositor/main.cpp @@ -110,13 +110,13 @@ private slots: update(); } - void surfaceDamaged(const QRect &rect) { + void surfaceDamaged(const QRegion &rect) { QWaylandSurface *surface = qobject_cast(sender()); surfaceDamaged(surface, rect); } protected: - void surfaceDamaged(QWaylandSurface *surface, const QRect &rect) + void surfaceDamaged(QWaylandSurface *surface, const QRegion &rect) { #ifdef QT_COMPOSITOR_WAYLAND_GL Q_UNUSED(surface); @@ -130,7 +130,7 @@ protected: void surfaceCreated(QWaylandSurface *surface) { connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); - connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &))); + connect(surface, SIGNAL(damaged(const QRegion &)), this, SLOT(surfaceDamaged(const QRegion &))); update(); } @@ -140,7 +140,7 @@ protected: QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); QSize windowSize = surface->size(); - surface->advanceBufferQueue(); + surface->swapBuffers(); if (!m_surfaceCompositorFbo) functions->glGenFramebuffers(1,&m_surfaceCompositorFbo); @@ -173,7 +173,7 @@ protected: QWaylandSurface *subSurface = i.next(); QPointF p = subSurface->mapTo(window,QPoint(0,0)); QSize size = subSurface->size(); - subSurface->advanceBufferQueue(); + subSurface->swapBuffers(); if (size.isValid()) { GLuint texture = 0; if (subSurface->type() == QWaylandSurface::Texture) { diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp index 1d9c3d5e9..9eef717ef 100644 --- a/examples/qwindow-compositor/qwindowcompositor.cpp +++ b/examples/qwindow-compositor/qwindowcompositor.cpp @@ -159,7 +159,7 @@ void QWindowCompositor::surfaceUnmapped() ensureKeyboardFocusSurface(surface); } -void QWindowCompositor::surfaceDamaged(const QRect &rect) +void QWindowCompositor::surfaceDamaged(const QRegion &rect) { QWaylandSurface *surface = qobject_cast(sender()); surfaceDamaged(surface, rect); @@ -170,7 +170,7 @@ void QWindowCompositor::surfacePosChanged() m_renderScheduler.start(0); } -void QWindowCompositor::surfaceDamaged(QWaylandSurface *surface, const QRect &rect) +void QWindowCompositor::surfaceDamaged(QWaylandSurface *surface, const QRegion &rect) { Q_UNUSED(surface) Q_UNUSED(rect) @@ -182,7 +182,7 @@ void QWindowCompositor::surfaceCreated(QWaylandSurface *surface) connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped())); - connect(surface, SIGNAL(damaged(const QRect &)), this, SLOT(surfaceDamaged(const QRect &))); + connect(surface, SIGNAL(damaged(const QRegion &)), this, SLOT(surfaceDamaged(const QRegion &))); connect(surface, SIGNAL(extendedSurfaceReady()), this, SLOT(sendExpose())); connect(surface, SIGNAL(posChanged()), this, SLOT(surfacePosChanged())); m_renderScheduler.start(0); @@ -253,7 +253,7 @@ GLuint QWindowCompositor::composeSurface(QWaylandSurface *surface, bool *texture GLuint texture = 0; QSize windowSize = surface->size(); - surface->advanceBufferQueue(); + surface->swapBuffers(); QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); functions->glBindFramebuffer(GL_FRAMEBUFFER, m_surface_fbo); @@ -288,7 +288,7 @@ void QWindowCompositor::paintChildren(QWaylandSurface *surface, QWaylandSurface QWaylandSurface *subSurface = i.next(); QPointF p = subSurface->mapTo(window,QPointF(0,0)); QSize subSize = subSurface->size(); - subSurface->advanceBufferQueue(); + subSurface->swapBuffers(); if (subSize.isValid()) { GLuint texture = 0; if (subSurface->type() == QWaylandSurface::Texture) { diff --git a/examples/qwindow-compositor/qwindowcompositor.h b/examples/qwindow-compositor/qwindowcompositor.h index c58c0d571..f8d354c36 100644 --- a/examples/qwindow-compositor/qwindowcompositor.h +++ b/examples/qwindow-compositor/qwindowcompositor.h @@ -61,12 +61,12 @@ private slots: void surfaceDestroyed(QObject *object); void surfaceMapped(); void surfaceUnmapped(); - void surfaceDamaged(const QRect &rect); + void surfaceDamaged(const QRegion &rect); void surfacePosChanged(); void render(); protected: - void surfaceDamaged(QWaylandSurface *surface, const QRect &rect); + void surfaceDamaged(QWaylandSurface *surface, const QRegion &rect); void surfaceCreated(QWaylandSurface *surface); QWaylandSurface* surfaceAt(const QPointF &point, QPointF *local = 0); diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index a865f32d9..f9eda135b 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -104,10 +104,10 @@ QWaylandSurface::QWaylandSurface(QtWayland::Surface *surface) #endif } -void QWaylandSurface::advanceBufferQueue() +void QWaylandSurface::swapBuffers() { Q_D(const QWaylandSurface); - d->surface->advanceBufferQueue(); + d->surface->swapBuffers(); } WaylandClient *QWaylandSurface::client() const diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index 7dc219d9a..774464a8a 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -178,7 +178,7 @@ public: Q_INVOKABLE void destroySurfaceByForce(); Q_INVOKABLE void ping(); - void advanceBufferQueue(); + void swapBuffers(); public slots: void updateSelection(); @@ -186,7 +186,7 @@ public slots: signals: void mapped(); void unmapped(); - void damaged(const QRect &rect); + void damaged(const QRegion &rect); void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); void sizeChanged(); void posChanged(); diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp index 04649fa76..b87bbb614 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp @@ -298,7 +298,7 @@ void QWaylandSurfaceItem::setDamagedFlag(bool on) } -void QWaylandSurfaceItem::surfaceDamaged(const QRect &) +void QWaylandSurfaceItem::surfaceDamaged(const QRegion &) { m_damaged = true; if (m_surface) { @@ -390,7 +390,7 @@ QSGNode *QWaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeD // Order here is important, as the state of visible is that of the pending // buffer but will be replaced after we advance the buffer queue. bool visible = m_surface->visible(); - surface()->advanceBufferQueue(); + surface()->swapBuffers(); if (visible) updateTexture(); diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.h b/src/compositor/compositor_api/qwaylandsurfaceitem.h index 26288a7df..b17b892fa 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceitem.h +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.h @@ -112,7 +112,7 @@ private slots: void surfaceMapped(); void surfaceUnmapped(); void surfaceDestroyed(QObject *object); - void surfaceDamaged(const QRect &); + void surfaceDamaged(const QRegion &); void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); void updateSize(); void updateSurfaceSize(); diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index 79b83ab7e..a0e61bc22 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -129,6 +129,8 @@ Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) , m_transientInactive(false) , m_isCursorSurface(false) { + m_pending.buffer = 0; + m_pending.newlyAttached = false; } Surface::~Surface() @@ -335,7 +337,7 @@ Compositor *Surface::compositor() const return m_compositor; } -void Surface::advanceBufferQueue() +void Surface::swapBuffers() { SurfaceBuffer *front = m_frontBuffer; @@ -349,16 +351,6 @@ void Surface::advanceBufferQueue() m_backBuffer = 0; } - // Set a new back buffer if there is something in the queue. - if (m_bufferQueue.size() && m_bufferQueue.first()->isComitted()) { - SurfaceBuffer *next = m_bufferQueue.takeFirst(); - while (next && next->isDestroyed()) { - next->disown(); - next = m_bufferQueue.size() ? m_bufferQueue.takeFirst() : 0; - } - setBackBuffer(next); - } - // Release the old front buffer if we changed it. if (front && front != m_frontBuffer) front->disown(); @@ -366,7 +358,7 @@ void Surface::advanceBufferQueue() /*! * Sets the backbuffer for this surface. The back buffer is not yet on - * screen and will become live during the next advanceBufferQueue(). + * screen and will become live during the next swapBuffers(). * * The backbuffer represents the current state of the surface for the * purpose of GUI-thread accessible properties such as size and visibility. @@ -387,7 +379,8 @@ void Surface::setBackBuffer(SurfaceBuffer *buffer) emit m_waylandSurface->unmapped(); } - emit m_waylandSurface->damaged(m_backBuffer->damageRect()); + m_damage = m_damage.intersected(QRect(QPoint(), m_size)); + emit m_waylandSurface->damaged(m_damage); } else { InputDevice *inputDevice = m_compositor->defaultInputDevice(); if (inputDevice->keyboardFocus() == this) @@ -395,6 +388,7 @@ void Surface::setBackBuffer(SurfaceBuffer *buffer) if (inputDevice->mouseFocus() == this) inputDevice->setMouseFocus(0, QPointF(), QPointF()); } + m_damage = QRegion(); } SurfaceBuffer *Surface::createSurfaceBuffer(struct ::wl_resource *buffer) @@ -419,41 +413,6 @@ SurfaceBuffer *Surface::createSurfaceBuffer(struct ::wl_resource *buffer) return newBuffer; } -void Surface::attach(struct ::wl_resource *buffer) -{ - SurfaceBuffer *last = m_bufferQueue.size()?m_bufferQueue.last():0; - if (last) { - if (last->waylandBufferHandle() == buffer) { - if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) - qWarning() << "attaching already attached buffer"; - return; - } - if (!last->damageRect().isValid() || !last->isComitted() || isCursorSurface() ){ - last->disown(); - m_bufferQueue.takeLast(); - } - } - - SurfaceBuffer *surfBuf = createSurfaceBuffer(buffer); - m_bufferQueue << surfBuf; -} - -void Surface::damage(const QRect &rect) -{ - if (m_bufferQueue.empty()) { - if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) - qWarning() << "Surface::damage() null buffer"; - return; - } - SurfaceBuffer *surfaceBuffer = m_bufferQueue.last(); - if (surfaceBuffer->isComitted()) { - if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) - qWarning("Surface::damage() on a committed surface"); - } else{ - surfaceBuffer->setDamage(rect); - } -} - void Surface::surface_destroy_resource(Resource *) { compositor()->destroySurface(this); @@ -466,15 +425,16 @@ void Surface::surface_destroy(Resource *resource) void Surface::surface_attach(Resource *, struct wl_resource *buffer, int x, int y) { - Q_UNUSED(x); - Q_UNUSED(y); - - attach(buffer); + if (m_pending.buffer) + m_pending.buffer->disown(); + m_pending.buffer = createSurfaceBuffer(buffer); + m_pending.offset = QPoint(x, y); + m_pending.newlyAttached = true; } void Surface::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, int32_t height) { - damage(QRect(x, y, width, height)); + m_pending.damage = m_pending.damage.united(QRect(x, y, width, height)); } void Surface::surface_frame(Resource *resource, uint32_t callback) @@ -495,28 +455,27 @@ void Surface::surface_set_input_region(Resource *, struct wl_resource *region) void Surface::surface_commit(Resource *) { - if (m_bufferQueue.empty()) { - if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) - qWarning("Commit on invalid surface"); - return; - } + m_damage = m_pending.damage; - SurfaceBuffer *surfaceBuffer = m_bufferQueue.last(); - if (surfaceBuffer->isComitted()) { - if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) - qWarning("Committing buffer that has already been committed"); - } else { - surfaceBuffer->setCommitted(); - } + if (m_pending.buffer || m_pending.newlyAttached) { + if (m_backBuffer && m_backBuffer != m_pending.buffer) + m_backBuffer->disown(); - // A new buffer was added to the queue, so we set it as the current - // back buffer. Second and third buffers, if the come, will be handled - // in advanceBufferQueue(). - if (!m_backBuffer && m_bufferQueue.size() == 1) { - setBackBuffer(surfaceBuffer); - m_bufferQueue.takeFirst(); + setBackBuffer(m_pending.buffer); + if (!m_backBuffer && m_surfaceMapped) { + m_surfaceMapped = false; + emit m_waylandSurface->unmapped(); + } } + m_pending.buffer = 0; + m_pending.offset = QPoint(); + m_pending.newlyAttached = false; + m_pending.damage = QRegion(); + + if (m_backBuffer) + m_backBuffer->setCommitted(); + m_frameCallbacks << m_pendingFrameCallbacks; m_pendingFrameCallbacks.clear(); } diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h index bad65e935..af7d1e0c1 100644 --- a/src/compositor/wayland_wrapper/qwlsurface_p.h +++ b/src/compositor/wayland_wrapper/qwlsurface_p.h @@ -48,6 +48,7 @@ #include #include +#include #include #include @@ -139,7 +140,7 @@ public: bool isCursorSurface() const { return m_isCursorSurface; } void setCursorSurface(bool isCursor) { m_isCursorSurface = isCursor; } - void advanceBufferQueue(); + void swapBuffers(); void releaseSurfaces(); private: @@ -149,10 +150,17 @@ private: QWaylandSurface *m_waylandSurface; SurfaceBuffer *m_backBuffer; + QRegion m_damage; SurfaceBuffer *m_frontBuffer; - QList m_bufferQueue; bool m_surfaceMapped; + struct { + SurfaceBuffer *buffer; + QRegion damage; + QPoint offset; + bool newlyAttached; + } m_pending; + QPoint m_lastLocalMousePos; QPoint m_lastGlobalMousePos; @@ -177,12 +185,9 @@ private: bool m_isCursorSurface; inline SurfaceBuffer *currentSurfaceBuffer() const; - void damage(const QRect &rect); void setBackBuffer(SurfaceBuffer *buffer); SurfaceBuffer *createSurfaceBuffer(struct ::wl_resource *buffer); - void attach(struct ::wl_resource *buffer); - void surface_destroy_resource(Resource *resource) Q_DECL_OVERRIDE; void surface_destroy(Resource *resource) Q_DECL_OVERRIDE; diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp index 1d919cdfb..b0e67e1fa 100644 --- a/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp +++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp @@ -96,7 +96,6 @@ void SurfaceBuffer::initialize(struct ::wl_resource *buffer) m_destroy_listener.listener.notify = destroy_listener_callback; if (buffer) wl_signal_add(&buffer->destroy_signal, &m_destroy_listener.listener); - m_damageRect = QRect(); } void SurfaceBuffer::destructBufferState() @@ -171,18 +170,6 @@ void SurfaceBuffer::disown() void SurfaceBuffer::setDisplayed() { m_is_displayed = true; - m_damageRect = QRect(); -} - -void SurfaceBuffer::setDamage(const QRect &rect) -{ - if (m_damageRect.isValid()) { - m_damageRect = m_damageRect.united(rect); - } else { - m_damageRect = rect; - } - m_image = QImage(); - } void SurfaceBuffer::destroyTexture() diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h index 257c82462..c2c39253a 100644 --- a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h +++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h @@ -87,9 +87,6 @@ public: inline void setCommitted() { m_committed = true; } inline bool isDisplayed() const { return m_is_displayed; } - inline QRect damageRect() const { return m_damageRect; } - void setDamage(const QRect &rect); - inline bool textureCreated() const { return m_texture; } bool isDestroyed() { return m_destroyed; } @@ -112,7 +109,6 @@ private: Compositor *m_compositor; struct ::wl_resource *m_buffer; struct surface_buffer_destroy_listener m_destroy_listener; - QRect m_damageRect; bool m_committed; bool m_is_registered_for_buffer; bool m_surface_has_buffer; -- cgit v1.2.3 From eeb365a8f164a1402c19ca5a7e38e01f4e69cf7b Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Mon, 10 Feb 2014 14:32:34 +0200 Subject: Make sure the frame callbacks are sent at the right time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When there is a rendering thread, like with QtQuick compositors, there is a race condition where the frame callbacks are sent before the last buffer the client sent is released. Assume the following scenario: attach(B1)/frame(F1)/commit()...frame started...attach(B2)/frame(F2)/ commit()...frame finished. On frame finished the callback just installed is emitted before the buffer B2 is being used and B1 released. That forces the client to allocate a third buffer to draw the next frame. Now, do not send out the frame callbacks until a new frame started. The successive draw will release B1, use the new B2 and than send out F2. Change-Id: I5743c7baf9fdd3cde28c5f594ff646c06abb74b7 Reviewed-by: Gunnar Sletta Reviewed-by: Jørgen Lind --- examples/qml-compositor/main.cpp | 4 ++++ examples/qwidget-compositor/main.cpp | 1 + examples/qwindow-compositor/qwindowcompositor.cpp | 1 + examples/server-buffer/compositor/main.cpp | 5 +++++ src/compositor/compositor_api/qwaylandcompositor.cpp | 6 ++++++ src/compositor/compositor_api/qwaylandcompositor.h | 1 + src/compositor/wayland_wrapper/qwlsurface.cpp | 17 ++++++++++++++--- src/compositor/wayland_wrapper/qwlsurface_p.h | 1 + 8 files changed, 33 insertions(+), 3 deletions(-) diff --git a/examples/qml-compositor/main.cpp b/examples/qml-compositor/main.cpp index 79611a2cb..c33eb7e63 100644 --- a/examples/qml-compositor/main.cpp +++ b/examples/qml-compositor/main.cpp @@ -67,6 +67,7 @@ public: setColor(Qt::black); winId(); + connect(this, SIGNAL(beforeSynchronizing()), this, SLOT(startFrame()), Qt::DirectConnection); connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()), Qt::DirectConnection); } @@ -136,6 +137,9 @@ private slots: else sendFrameCallbacks(surfaces()); } + void startFrame() { + frameStarted(); + } protected: void resizeEvent(QResizeEvent *event) diff --git a/examples/qwidget-compositor/main.cpp b/examples/qwidget-compositor/main.cpp index cf7fdda73..ed1c0a3fc 100644 --- a/examples/qwidget-compositor/main.cpp +++ b/examples/qwidget-compositor/main.cpp @@ -220,6 +220,7 @@ protected: void paintEvent(QPaintEvent *) { QPainter p(this); + frameStarted(); if (!m_background.isNull()) p.drawPixmap(rect(), m_backgroundScaled); diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp index 9eef717ef..f64922db5 100644 --- a/examples/qwindow-compositor/qwindowcompositor.cpp +++ b/examples/qwindow-compositor/qwindowcompositor.cpp @@ -310,6 +310,7 @@ void QWindowCompositor::paintChildren(QWaylandSurface *surface, QWaylandSurface void QWindowCompositor::render() { m_window->makeCurrent(); + frameStarted(); cleanupGraphicsResources(); diff --git a/examples/server-buffer/compositor/main.cpp b/examples/server-buffer/compositor/main.cpp index 23e337d24..1aa29029c 100644 --- a/examples/server-buffer/compositor/main.cpp +++ b/examples/server-buffer/compositor/main.cpp @@ -83,6 +83,7 @@ public: create(); grabWindow(); + connect(this, SIGNAL(beforeSynchronizing()), this, SLOT(startFrame()), Qt::DirectConnection); connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()), Qt::DirectConnection); connect(this, SIGNAL(sceneGraphInitialized()), this, SLOT(initiateServerBuffer()),Qt::DirectConnection); @@ -127,6 +128,10 @@ private slots: emit windowDestroyed(QVariant::fromValue(item)); } + void startFrame() { + frameStarted(); + } + void sendCallbacks() { sendFrameCallbacks(surfaces()); } diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index b92313818..342dce510 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -99,6 +99,12 @@ void QWaylandCompositor::sendFrameCallbacks(QList visibleSurf m_compositor->sendFrameCallbacks(visibleSurfaces); } +void QWaylandCompositor::frameStarted() +{ + for (QtWayland::Surface *surf: m_compositor->surfaces()) + surf->frameStarted(); +} + void QWaylandCompositor::destroyClientForSurface(QWaylandSurface *surface) { destroyClient(surface->client()); diff --git a/src/compositor/compositor_api/qwaylandcompositor.h b/src/compositor/compositor_api/qwaylandcompositor.h index 6ed9cd894..9009f4caa 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.h +++ b/src/compositor/compositor_api/qwaylandcompositor.h @@ -84,6 +84,7 @@ public: struct wl_display *waylandDisplay() const; + void frameStarted(); void sendFrameCallbacks(QList visibleSurfaces); void destroyClientForSurface(QWaylandSurface *surface); diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index a0e61bc22..cd5320677 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -78,6 +78,7 @@ public: FrameCallback(Surface *surf, wl_resource *res) : surface(surf) , resource(res) + , canSend(false) { #if WAYLAND_VERSION_MAJOR < 1 || (WAYLAND_VERSION_MAJOR == 1 && WAYLAND_VERSION_MINOR <= 2) res->data = this; @@ -113,6 +114,7 @@ public: } Surface *surface; wl_resource *resource; + bool canSend; }; Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) @@ -269,9 +271,12 @@ GLuint Surface::textureId() const void Surface::sendFrameCallback() { uint time = m_compositor->currentTimeMsecs(); - foreach (FrameCallback *callback, m_frameCallbacks) - callback->send(time); - m_frameCallbacks.clear(); + foreach (FrameCallback *callback, m_frameCallbacks) { + if (callback->canSend) { + callback->send(time); + m_frameCallbacks.removeOne(callback); + } + } } void Surface::removeFrameCallback(FrameCallback *callback) @@ -480,6 +485,12 @@ void Surface::surface_commit(Resource *) m_pendingFrameCallbacks.clear(); } +void Surface::frameStarted() +{ + foreach (FrameCallback *c, m_frameCallbacks) + c->canSend = true; +} + void Surface::setClassName(const QString &className) { if (m_className != className) { diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h index af7d1e0c1..14b47fce1 100644 --- a/src/compositor/wayland_wrapper/qwlsurface_p.h +++ b/src/compositor/wayland_wrapper/qwlsurface_p.h @@ -142,6 +142,7 @@ public: void swapBuffers(); void releaseSurfaces(); + void frameStarted(); private: Q_DISABLE_COPY(Surface) -- cgit v1.2.3 From a9d9fa463cd6b915fd4fda7e06317b5299c893e7 Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Mon, 10 Mar 2014 09:25:36 +0100 Subject: Compile ServerBuffer client example on desktop gl Change-Id: I8efbda3e5266c5668b2461429a21d900e2ecd175 Reviewed-by: Laszlo Agocs --- examples/server-buffer/client/main.cpp | 4 ++-- examples/server-buffer/client/serverbufferrenderer.cpp | 4 +++- examples/server-buffer/client/serverbufferrenderer.h | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/server-buffer/client/main.cpp b/examples/server-buffer/client/main.cpp index 1880f2160..ce705b6a7 100644 --- a/examples/server-buffer/client/main.cpp +++ b/examples/server-buffer/client/main.cpp @@ -112,8 +112,8 @@ public slots: } m_context->makeCurrent(this); - - glBindFramebuffer(GL_FRAMEBUFFER, m_context->defaultFramebufferObject()); + QOpenGLFunctions *funcs = m_context->functions(); + funcs->glBindFramebuffer(GL_FRAMEBUFFER, m_context->defaultFramebufferObject()); glViewport(0, 0, width() * devicePixelRatio(), height() * devicePixelRatio()); glClearColor(0.f, 0.f, 0.0f, 1.f); diff --git a/examples/server-buffer/client/serverbufferrenderer.cpp b/examples/server-buffer/client/serverbufferrenderer.cpp index 9eafddd63..2f0d204d3 100644 --- a/examples/server-buffer/client/serverbufferrenderer.cpp +++ b/examples/server-buffer/client/serverbufferrenderer.cpp @@ -42,6 +42,7 @@ #include #include + static const GLfloat uv_coords[] = { 0,0, 0,1, @@ -74,7 +75,8 @@ static const char fragment_shader[] = "}"; ServerBufferRenderer::ServerBufferRenderer(QWaylandServerBuffer *serverBuffer) - : m_server_buffer(serverBuffer) + : QOpenGLFunctions(QOpenGLContext::currentContext()) + , m_server_buffer(serverBuffer) , m_texture(0) , m_vao(new QOpenGLVertexArrayObject()) , m_program(new QOpenGLShaderProgram()) diff --git a/examples/server-buffer/client/serverbufferrenderer.h b/examples/server-buffer/client/serverbufferrenderer.h index 58f0c7040..7e8999b1c 100644 --- a/examples/server-buffer/client/serverbufferrenderer.h +++ b/examples/server-buffer/client/serverbufferrenderer.h @@ -42,14 +42,14 @@ #define SERVERBUFFERRENDERER_H #include - +#include #include QT_BEGIN_NAMESPACE class QOpenGLVertexArrayObject; class QOpenGLShaderProgram; -class ServerBufferRenderer +class ServerBufferRenderer : public QOpenGLFunctions { public: ServerBufferRenderer(QWaylandServerBuffer *serverBuffer); -- cgit v1.2.3 From 6b173d993542e2aed01b5a97d3e0fb64940ad432 Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Mon, 10 Mar 2014 09:25:04 +0100 Subject: Fixup for GLX integration Change-Id: I2de94481f7d3e109fdce7ca961f8969299cf5d9e Reviewed-by: Laszlo Agocs --- .../qwaylandclientbufferintegration_p.h | 1 - .../qwaylandxcompositeeglclientbufferintegration.cpp | 5 +++++ .../qwaylandxcompositeeglclientbufferintegration.h | 1 - .../xcomposite-glx/qwaylandxcompositeglxintegration.cpp | 4 ++++ .../xcomposite-glx/qwaylandxcompositeglxintegration.h | 7 +++---- .../client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp | 5 +---- .../client/xcomposite-glx/qwaylandxcompositeglxwindow.h | 4 +--- .../xcomposite-glx/xcompositeglxintegration.cpp | 4 +++- .../hardwareintegration/client/xcomposite-glx/main.cpp | 4 ++-- .../compositor/xcomposite-glx/xcomposite-glx.json | 2 +- src/plugins/platforms/qwayland-xcomposite-glx/main.cpp | 4 +++- .../qwayland-xcomposite-glx/qwayland-xcomposite-glx.pro | 2 ++ .../qwaylandxcompositeglxplatformintegration.h | 15 +++++++++------ 13 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h b/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h index 153b3f591..7d79f3263 100644 --- a/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h +++ b/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h @@ -61,7 +61,6 @@ public: virtual ~QWaylandClientBufferIntegration(); virtual void initialize(QWaylandDisplay *display) = 0; - virtual bool waitingForEvents() { return false; } virtual bool supportsThreadedOpenGL() const { return false; } diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp index 12ab0a47d..c26ebd6ae 100644 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp +++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.cpp @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE QWaylandXCompositeEGLClientBufferIntegration::QWaylandXCompositeEGLClientBufferIntegration() : QWaylandClientBufferIntegration() , mWaylandDisplay(0) + , mDisplay(0) { qDebug() << "Using XComposite-EGL"; } @@ -65,6 +66,10 @@ void QWaylandXCompositeEGLClientBufferIntegration::initialize(QWaylandDisplay *d { mWaylandDisplay = display; mWaylandDisplay->addRegistryListener(&wlDisplayHandleGlobal, this); + while (!mDisplay) { + display->flushRequests(); + display->blockingReadEvents(); + } } QWaylandWindow * QWaylandXCompositeEGLClientBufferIntegration::createEglWindow(QWindow *window) diff --git a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h index 9cf19e1c7..cce0e91bf 100644 --- a/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h +++ b/src/hardwareintegration/client/xcomposite-egl/qwaylandxcompositeeglclientbufferintegration.h @@ -75,7 +75,6 @@ public: ~QWaylandXCompositeEGLClientBufferIntegration(); void initialize(QWaylandDisplay *dispaly) Q_DECL_OVERRIDE; - bool waitingForEvents() Q_DECL_OVERRIDE { return !mDisplay; } QWaylandWindow *createEglWindow(QWindow *window) Q_DECL_OVERRIDE; QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const Q_DECL_OVERRIDE; diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp index b2c0dd5d3..f08f8dcb5 100644 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp +++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.cpp @@ -68,6 +68,10 @@ void QWaylandXCompositeGLXIntegration::initialize(QWaylandDisplay *display) { mWaylandDisplay = display; mWaylandDisplay->addRegistryListener(QWaylandXCompositeGLXIntegration::wlDisplayHandleGlobal, this); + while (!mDisplay) { + display->flushRequests(); + display->blockingReadEvents(); + } } QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *window) diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h index 174629159..1751f775f 100644 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h +++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxintegration.h @@ -69,11 +69,10 @@ public: QWaylandXCompositeGLXIntegration(); ~QWaylandXCompositeGLXIntegration(); - void initialize(QWaylandDisplay *display); - bool waitingForEvents() { return !mDisplay; } + void initialize(QWaylandDisplay *display) Q_DECL_OVERRIDE; - QWaylandWindow *createEglWindow(QWindow *window); - QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const; + QWaylandWindow *createEglWindow(QWindow *window) Q_DECL_OVERRIDE; + QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const Q_DECL_OVERRIDE; QWaylandDisplay *waylandDisplay() const; struct qt_xcomposite *waylandXComposite() const; diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp index f33790f33..899ed7649 100644 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp +++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.cpp @@ -56,7 +56,6 @@ QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWayla , m_glxIntegration(glxIntegration) , m_xWindow(0) , m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->format(), GLX_WINDOW_BIT | GLX_PIXMAP_BIT)) - , m_buffer(0) { } @@ -71,8 +70,6 @@ void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect) QWaylandWindow::setGeometry(rect); if (m_xWindow) { - delete m_buffer; - XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow); m_xWindow = 0; } @@ -115,7 +112,7 @@ void QWaylandXCompositeGLXWindow::createSurface() XMapWindow(m_glxIntegration->xDisplay(), m_xWindow); XSync(m_glxIntegration->xDisplay(), False); - m_buffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(), + mBuffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(), (uint32_t)m_xWindow, size); } diff --git a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h index 9866ad039..6fe99466d 100644 --- a/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h +++ b/src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxwindow.h @@ -62,7 +62,7 @@ public: Window xWindow() const; - QWaylandBuffer *buffer() { return m_buffer; } + QWaylandBuffer *buffer() { return mBuffer; } private: void createSurface(); @@ -71,8 +71,6 @@ private: Window m_xWindow; GLXFBConfig m_config; - - QWaylandBuffer *m_buffer; }; QT_END_NAMESPACE diff --git a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp index dce1fdc31..bd5ddef9a 100644 --- a/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp +++ b/src/hardwareintegration/compositor/xcomposite-glx/xcompositeglxintegration.cpp @@ -76,6 +76,7 @@ XCompositeGLXClientBufferIntegration::XCompositeGLXClientBufferIntegration() , mDisplay(0) , mHandler(0) { + qDebug() << "Loading GLX integration"; } XCompositeGLXClientBufferIntegration::~XCompositeGLXClientBufferIntegration() @@ -85,6 +86,7 @@ XCompositeGLXClientBufferIntegration::~XCompositeGLXClientBufferIntegration() void XCompositeGLXClientBufferIntegration::initializeHardware(QtWayland::Display *) { + qDebug() << "Initializing GLX integration"; QPlatformNativeInterface *nativeInterface = QGuiApplicationPrivate::platformIntegration()->nativeInterface(); if (nativeInterface) { mDisplay = static_cast(nativeInterface->nativeResourceForWindow("Display",m_compositor->window())); @@ -112,7 +114,7 @@ void XCompositeGLXClientBufferIntegration::initializeHardware(QtWayland::Display delete glContext; } -void XCompositeGLXClientBufferIntegration::updateTextureFromBuffer(struct ::wl_resource *buffer) +void XCompositeGLXClientBufferIntegration::bindTextureToBuffer(struct ::wl_resource *buffer) { XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer); Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window()); diff --git a/src/plugins/hardwareintegration/client/xcomposite-glx/main.cpp b/src/plugins/hardwareintegration/client/xcomposite-glx/main.cpp index f53caf03a..2d402194e 100644 --- a/src/plugins/hardwareintegration/client/xcomposite-glx/main.cpp +++ b/src/plugins/hardwareintegration/client/xcomposite-glx/main.cpp @@ -56,14 +56,14 @@ public: QStringList QWaylandXCompositeGlxClientBufferIntegrationPlugin::keys() const { QStringList list; - list << "xcomposite-glx"; + list << "wayland-xcomposite-glx"; return list; } QWaylandClientBufferIntegration *QWaylandXCompositeGlxClientBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "xcomposite-glx") + if (system.toLower() == "wayland-xcomposite-glx") return new QWaylandXCompositeGLXIntegration(); return 0; diff --git a/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.json b/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.json index 8ccd5b46b..0f4a3bf69 100644 --- a/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.json +++ b/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.json @@ -1,3 +1,3 @@ { - "Keys": [ "wayland-xcomposite" ] + "Keys": [ "wayland-xcomposite-glx" ] } diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp index 17b20f987..2f43b467b 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp @@ -40,7 +40,9 @@ ****************************************************************************/ #include -#include "qwaylandintegration.h" +#include + +#include "qwaylandxcompositeglxplatformintegration.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.pro b/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.pro index dcf2e1b67..307ad5ed6 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.pro +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwayland-xcomposite-glx.pro @@ -10,3 +10,5 @@ OTHER_FILES += qwayland-xcomposite-glx.json SOURCES += \ main.cpp +HEADERS += \ + qwaylandxcompositeglxplatformintegration.h diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxplatformintegration.h b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxplatformintegration.h index fe8c5b7c5..a7308f643 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxplatformintegration.h +++ b/src/plugins/platforms/qwayland-xcomposite-glx/qwaylandxcompositeglxplatformintegration.h @@ -42,7 +42,8 @@ #ifndef QWAYLANDXCOMPOSITEGLXPLATFORMINTEGRATION_H #define QWAYLANDXCOMPOSITEGLXPLATFORMINTEGRATION_H -#include +#include +#include #include "qwaylandxcompositeglxintegration.h" @@ -51,14 +52,16 @@ class QWaylandXCompositeGlxPlatformIntegration : public QWaylandIntegration public: QWaylandXCompositeGlxPlatformIntegration() : QWaylandIntegration() - , m_gl_integration(new QWaylandXCompositeGLXIntegration(display())) - { } + , m_client_buffer_integration(new QWaylandXCompositeGLXIntegration()) + { + m_client_buffer_integration->initialize(display()); + } - QWaylandGLIntegration *glIntegration() const Q_DECL_OVERRIDE - { return m_gl_integration; } + QWaylandClientBufferIntegration *clientBufferIntegration() const Q_DECL_OVERRIDE + { return m_client_buffer_integration; } private: - QWaylandGLIntegration *m_gl_integration; + QWaylandClientBufferIntegration *m_client_buffer_integration; }; #endif -- cgit v1.2.3 From 043a2893c41bbe0daa8953e9e30dd6957f216d95 Mon Sep 17 00:00:00 2001 From: Jorgen Lind Date: Mon, 10 Mar 2014 14:31:55 +0100 Subject: Take advantage of the Qt 5 plugin json structure Also change naming scheme of plugins: buffer integrations doesn't start with "wayland-" but the platform plugins have to start with "wayland-". Also update the README Change-Id: I6dd2103ab287ed569ab06cfb6eb469e3db058831 Reviewed-by: Laszlo Agocs --- README | 23 ++++++++++++++++++++++ .../client/brcm-egl/brcm-egl.json | 2 +- .../hardwareintegration/client/brcm-egl/main.cpp | 18 ++++------------- .../client/drm-egl-server/main.cpp | 18 ++++------------- .../client/wayland-egl/main.cpp | 18 ++++------------- .../client/xcomposite-egl/main.cpp | 18 ++++------------- .../client/xcomposite-egl/xcomposite-egl.json | 2 +- .../client/xcomposite-glx/main.cpp | 18 ++++------------- .../client/xcomposite-glx/xcomposite-glx.json | 2 +- .../compositor/brcm-egl/brcm-egl.json | 2 +- .../compositor/brcm-egl/main.cpp | 16 +++------------ .../compositor/drm-egl-server/main.cpp | 16 +++------------ .../compositor/wayland-egl/main.cpp | 16 +++------------ .../compositor/xcomposite-egl/main.cpp | 16 +++------------ .../compositor/xcomposite-egl/xcomposite-egl.json | 2 +- .../compositor/xcomposite-glx/main.cpp | 16 +++------------ .../compositor/xcomposite-glx/xcomposite-glx.json | 2 +- src/plugins/platforms/qwayland-brcm-egl/main.cpp | 11 ++++------- src/plugins/platforms/qwayland-egl/main.cpp | 18 ++++------------- src/plugins/platforms/qwayland-generic/main.cpp | 18 ++++------------- .../platforms/qwayland-xcomposite-egl/main.cpp | 18 ++++------------- .../qwayland-xcomposite-egl.json | 2 +- .../platforms/qwayland-xcomposite-glx/main.cpp | 16 +++------------ 23 files changed, 84 insertions(+), 204 deletions(-) diff --git a/README b/README index 9dd5a3876..368ecbc3d 100644 --- a/README +++ b/README @@ -19,6 +19,29 @@ To build the QtWayland module you need the external dependencies: xkbcommon 0.2.0 - http://xkbcommon.org/ wayland 1.2.0 - http://wayland.freedesktop.org/ +QtCompositor supports loading client buffer integrations that don't use the +wayland-egl interfaces. These client buffer integrations are picked up by +QtCompositor as plugins. To specify what plugin to load use the environment +variable QT_WAYLAND_CLIENT_BUFFER_INTEGRATION in the environment where the +compositor is started. The compositor will broadcast to the clients which +hardware integration to load when using the generic platformplugin "wayland". If +no client buffer integration is specifided, then the wayland-egl plugin will be +loaded. Please note that no Weston clients will work if the non standard +wayland-egl client buffer integration is used. + +To start the qwindow-compositor with the xcomposite-egl integration then start +the compositor as follows: +QT_WAYLAND_CLIENT_BUFFER_INTEGRATION=xcomposite-egl ./qwindow-compositor + +Now it should be possible to start an application in a separate terminal. ie: +$QTBASEDIR/examples/opengl/hellowindow/hellowindow -platform wayland --single + +Available client buffer integrations are: +wayland-egl (this is the default) +brcm +xcomposite-egl +xcomposite-glx + We hang out at #qt-labs and #qt-lighthouse on freenode if you have any questions diff --git a/src/plugins/hardwareintegration/client/brcm-egl/brcm-egl.json b/src/plugins/hardwareintegration/client/brcm-egl/brcm-egl.json index 48611c6ab..3a659a87b 100644 --- a/src/plugins/hardwareintegration/client/brcm-egl/brcm-egl.json +++ b/src/plugins/hardwareintegration/client/brcm-egl/brcm-egl.json @@ -1,3 +1,3 @@ { - "Keys": [ "wayland-brcm" ] + "Keys": [ "brcm" ] } diff --git a/src/plugins/hardwareintegration/client/brcm-egl/main.cpp b/src/plugins/hardwareintegration/client/brcm-egl/main.cpp index f77b41ef0..c023332eb 100644 --- a/src/plugins/hardwareintegration/client/brcm-egl/main.cpp +++ b/src/plugins/hardwareintegration/client/brcm-egl/main.cpp @@ -47,26 +47,16 @@ QT_BEGIN_NAMESPACE class QWaylandBrcmEglClientBufferPlugin : public QWaylandClientBufferIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.WaylandClient.QWaylandClientBufferIntegrationFactoryInterface.5.3" FILE "brcm-egl.json") + Q_PLUGIN_METADATA(IID QWaylandClientBufferIntegrationFactoryInterface_iid FILE "brcm-egl.json") public: - QStringList keys() const; - QWaylandClientBufferIntegration *create(const QString&, const QStringList&); + QWaylandClientBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandBrcmEglClientBufferPlugin::keys() const -{ - QStringList list; - list << "wayland-brcm"; - return list; -} - QWaylandClientBufferIntegration *QWaylandBrcmEglClientBufferPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-brcm") - return new QWaylandBrcmEglIntegration(); - - return 0; + Q_UNUSED(system); + return new QWaylandBrcmEglIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/client/drm-egl-server/main.cpp b/src/plugins/hardwareintegration/client/drm-egl-server/main.cpp index 33b8b4b29..6a3df4431 100644 --- a/src/plugins/hardwareintegration/client/drm-egl-server/main.cpp +++ b/src/plugins/hardwareintegration/client/drm-egl-server/main.cpp @@ -47,26 +47,16 @@ QT_BEGIN_NAMESPACE class DrmEglServerBufferPlugin : public QWaylandServerBufferIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.WaylandClient.QWaylandServerBufferIntegrationFactoryInterface.5.3" FILE "drm-egl-server.json") + Q_PLUGIN_METADATA(IID QWaylandServerBufferIntegrationFactoryInterface_iid FILE "drm-egl-server.json") public: - QStringList keys() const; - QWaylandServerBufferIntegration *create(const QString&, const QStringList&); + QWaylandServerBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList DrmEglServerBufferPlugin::keys() const -{ - QStringList list; - list << "drm-egl-server"; - return list; -} - QWaylandServerBufferIntegration *DrmEglServerBufferPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "drm-egl-server") - return new DrmEglServerBufferIntegration(); - - return 0; + Q_UNUSED(system); + return new DrmEglServerBufferIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/client/wayland-egl/main.cpp b/src/plugins/hardwareintegration/client/wayland-egl/main.cpp index 50e956644..e4cd8c1f0 100644 --- a/src/plugins/hardwareintegration/client/wayland-egl/main.cpp +++ b/src/plugins/hardwareintegration/client/wayland-egl/main.cpp @@ -47,26 +47,16 @@ QT_BEGIN_NAMESPACE class QWaylandEglClientBufferPlugin : public QWaylandClientBufferIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.WaylandClient.QWaylandClientBufferIntegrationFactoryInterface.5.3" FILE "wayland-egl.json") + Q_PLUGIN_METADATA(IID QWaylandClientBufferIntegrationFactoryInterface_iid FILE "wayland-egl.json") public: - QStringList keys() const; - QWaylandClientBufferIntegration *create(const QString&, const QStringList&); + QWaylandClientBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandEglClientBufferPlugin::keys() const -{ - QStringList list; - list << "wayland-egl"; - return list; -} - QWaylandClientBufferIntegration *QWaylandEglClientBufferPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-egl") - return new QWaylandEglClientBufferIntegration(); - - return 0; + Q_UNUSED(system); + return new QWaylandEglClientBufferIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/client/xcomposite-egl/main.cpp b/src/plugins/hardwareintegration/client/xcomposite-egl/main.cpp index 46e3eda4e..4b9835f1d 100644 --- a/src/plugins/hardwareintegration/client/xcomposite-egl/main.cpp +++ b/src/plugins/hardwareintegration/client/xcomposite-egl/main.cpp @@ -47,26 +47,16 @@ QT_BEGIN_NAMESPACE class QWaylandXCompositeEglClientBufferIntegrationPlugin : public QWaylandClientBufferIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.WaylandClient.QWaylandClientBufferIntegrationFactoryInterface.5.3" FILE "xcomposite-egl.json") + Q_PLUGIN_METADATA(IID QWaylandClientBufferIntegrationFactoryInterface_iid FILE "xcomposite-egl.json") public: - QStringList keys() const; - QWaylandClientBufferIntegration *create(const QString&, const QStringList&); + QWaylandClientBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandXCompositeEglClientBufferIntegrationPlugin::keys() const -{ - QStringList list; - list << "xcomposite" << "xcomposite-egl"; - return list; -} - QWaylandClientBufferIntegration *QWaylandXCompositeEglClientBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "xcomposite" || system.toLower() == "xcomposite-egl") - return new QWaylandXCompositeEGLClientBufferIntegration(); - - return 0; + Q_UNUSED(system); + return new QWaylandXCompositeEGLClientBufferIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/client/xcomposite-egl/xcomposite-egl.json b/src/plugins/hardwareintegration/client/xcomposite-egl/xcomposite-egl.json index 8ccd5b46b..0d119ff85 100644 --- a/src/plugins/hardwareintegration/client/xcomposite-egl/xcomposite-egl.json +++ b/src/plugins/hardwareintegration/client/xcomposite-egl/xcomposite-egl.json @@ -1,3 +1,3 @@ { - "Keys": [ "wayland-xcomposite" ] + "Keys": [ "xcomposite-egl" ] } diff --git a/src/plugins/hardwareintegration/client/xcomposite-glx/main.cpp b/src/plugins/hardwareintegration/client/xcomposite-glx/main.cpp index 2d402194e..2c6f0fde8 100644 --- a/src/plugins/hardwareintegration/client/xcomposite-glx/main.cpp +++ b/src/plugins/hardwareintegration/client/xcomposite-glx/main.cpp @@ -47,26 +47,16 @@ QT_BEGIN_NAMESPACE class QWaylandXCompositeGlxClientBufferIntegrationPlugin : public QWaylandClientBufferIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.WaylandClient.QWaylandClientBufferIntegrationFactoryInterface.5.3" FILE "xcomposite-glx.json") + Q_PLUGIN_METADATA(IID QWaylandClientBufferIntegrationFactoryInterface_iid FILE "xcomposite-glx.json") public: - QStringList keys() const; - QWaylandClientBufferIntegration *create(const QString&, const QStringList&); + QWaylandClientBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandXCompositeGlxClientBufferIntegrationPlugin::keys() const -{ - QStringList list; - list << "wayland-xcomposite-glx"; - return list; -} - QWaylandClientBufferIntegration *QWaylandXCompositeGlxClientBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-xcomposite-glx") - return new QWaylandXCompositeGLXIntegration(); - - return 0; + Q_UNUSED(system); + return new QWaylandXCompositeGLXIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/client/xcomposite-glx/xcomposite-glx.json b/src/plugins/hardwareintegration/client/xcomposite-glx/xcomposite-glx.json index 0f4a3bf69..e2c4cecd6 100644 --- a/src/plugins/hardwareintegration/client/xcomposite-glx/xcomposite-glx.json +++ b/src/plugins/hardwareintegration/client/xcomposite-glx/xcomposite-glx.json @@ -1,3 +1,3 @@ { - "Keys": [ "wayland-xcomposite-glx" ] + "Keys": [ "xcomposite-glx" ] } diff --git a/src/plugins/hardwareintegration/compositor/brcm-egl/brcm-egl.json b/src/plugins/hardwareintegration/compositor/brcm-egl/brcm-egl.json index 48611c6ab..3a659a87b 100644 --- a/src/plugins/hardwareintegration/compositor/brcm-egl/brcm-egl.json +++ b/src/plugins/hardwareintegration/compositor/brcm-egl/brcm-egl.json @@ -1,3 +1,3 @@ { - "Keys": [ "wayland-brcm" ] + "Keys": [ "brcm" ] } diff --git a/src/plugins/hardwareintegration/compositor/brcm-egl/main.cpp b/src/plugins/hardwareintegration/compositor/brcm-egl/main.cpp index 53a3f3c3e..f6bb717bc 100644 --- a/src/plugins/hardwareintegration/compositor/brcm-egl/main.cpp +++ b/src/plugins/hardwareintegration/compositor/brcm-egl/main.cpp @@ -49,24 +49,14 @@ class QWaylandBrcmClientBufferIntegration : public QtWayland::ClientBufferIntegr Q_OBJECT Q_PLUGIN_METADATA(IID QtWaylandClientBufferIntegrationFactoryInterface_iid FILE "brcm-egl.json") public: - QStringList keys() const; - QtWayland::ClientBufferIntegration *create(const QString&, const QStringList&); + QtWayland::ClientBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandBrcmClientBufferIntegration::keys() const -{ - QStringList list; - list << "wayland-brcm"; - return list; -} - QtWayland::ClientBufferIntegration *QWaylandBrcmClientBufferIntegration::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-brcm") - return new BrcmEglIntegration(); - - return 0; + Q_UNUSED(system); + return new BrcmEglIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/compositor/drm-egl-server/main.cpp b/src/plugins/hardwareintegration/compositor/drm-egl-server/main.cpp index 4bfc1b483..e85f93009 100644 --- a/src/plugins/hardwareintegration/compositor/drm-egl-server/main.cpp +++ b/src/plugins/hardwareintegration/compositor/drm-egl-server/main.cpp @@ -49,24 +49,14 @@ class DrmEglServerBufferIntegrationPlugin : public QtWayland::ServerBufferIntegr Q_OBJECT Q_PLUGIN_METADATA(IID QtWaylandServerBufferIntegrationFactoryInterface_iid FILE "drm-egl-server.json") public: - QStringList keys() const; - QtWayland::ServerBufferIntegration *create(const QString&, const QStringList&); + QtWayland::ServerBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList DrmEglServerBufferIntegrationPlugin::keys() const -{ - QStringList list; - list << "drm-egl-server"; - return list; -} - QtWayland::ServerBufferIntegration *DrmEglServerBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "drm-egl-server") - return new DrmEglServerBufferIntegration(); - - return 0; + Q_UNUSED(system); + return new DrmEglServerBufferIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/compositor/wayland-egl/main.cpp b/src/plugins/hardwareintegration/compositor/wayland-egl/main.cpp index 274dff1e6..3a7984f0a 100644 --- a/src/plugins/hardwareintegration/compositor/wayland-egl/main.cpp +++ b/src/plugins/hardwareintegration/compositor/wayland-egl/main.cpp @@ -50,24 +50,14 @@ class QWaylandIntegrationPlugin : public QtWayland::ClientBufferIntegrationPlugi Q_OBJECT Q_PLUGIN_METADATA(IID QtWaylandClientBufferIntegrationFactoryInterface_iid FILE "wayland-egl.json") public: - QStringList keys() const; - QtWayland::ClientBufferIntegration *create(const QString&, const QStringList&); + QtWayland::ClientBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandIntegrationPlugin::keys() const -{ - QStringList list; - list << "wayland-egl"; - return list; -} - QtWayland::ClientBufferIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-egl") - return new WaylandEglClientBufferIntegration(); - - return 0; + Q_UNUSED(system); + return new WaylandEglClientBufferIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/compositor/xcomposite-egl/main.cpp b/src/plugins/hardwareintegration/compositor/xcomposite-egl/main.cpp index 4ae206fa2..f0bbedaa7 100644 --- a/src/plugins/hardwareintegration/compositor/xcomposite-egl/main.cpp +++ b/src/plugins/hardwareintegration/compositor/xcomposite-egl/main.cpp @@ -49,24 +49,14 @@ class QWaylandXCompositeClientBufferIntegration : public QtWayland::ClientBuffer Q_OBJECT Q_PLUGIN_METADATA(IID QtWaylandClientBufferIntegrationFactoryInterface_iid FILE "xcomposite-egl.json") public: - QStringList keys() const; - QtWayland::ClientBufferIntegration *create(const QString&, const QStringList&); + QtWayland::ClientBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandXCompositeClientBufferIntegration::keys() const -{ - QStringList list; - list << "wayland-xcomposite"; - return list; -} - QtWayland::ClientBufferIntegration *QWaylandXCompositeClientBufferIntegration::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-xcomposite") - return new XCompositeEglClientBufferIntegration(); - - return 0; + Q_UNUSED(system); + return new XCompositeEglClientBufferIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.json b/src/plugins/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.json index 8ccd5b46b..0d119ff85 100644 --- a/src/plugins/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.json +++ b/src/plugins/hardwareintegration/compositor/xcomposite-egl/xcomposite-egl.json @@ -1,3 +1,3 @@ { - "Keys": [ "wayland-xcomposite" ] + "Keys": [ "xcomposite-egl" ] } diff --git a/src/plugins/hardwareintegration/compositor/xcomposite-glx/main.cpp b/src/plugins/hardwareintegration/compositor/xcomposite-glx/main.cpp index 4dcd9136f..37602bcc9 100644 --- a/src/plugins/hardwareintegration/compositor/xcomposite-glx/main.cpp +++ b/src/plugins/hardwareintegration/compositor/xcomposite-glx/main.cpp @@ -49,24 +49,14 @@ class QWaylandXCompositeClientBufferIntegration : public QtWayland::ClientBuffer Q_OBJECT Q_PLUGIN_METADATA(IID QtWaylandClientBufferIntegrationFactoryInterface_iid FILE "xcomposite-glx.json") public: - QStringList keys() const; - QtWayland::ClientBufferIntegration *create(const QString&, const QStringList&); + QtWayland::ClientBufferIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandXCompositeClientBufferIntegration::keys() const -{ - QStringList list; - list << "wayland-xcomposite-glx"; - return list; -} - QtWayland::ClientBufferIntegration *QWaylandXCompositeClientBufferIntegration::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-xcomposite-glx") - return new XCompositeGLXClientBufferIntegration(); - - return 0; + Q_UNUSED(system); + return new XCompositeGLXClientBufferIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.json b/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.json index 0f4a3bf69..e2c4cecd6 100644 --- a/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.json +++ b/src/plugins/hardwareintegration/compositor/xcomposite-glx/xcomposite-glx.json @@ -1,3 +1,3 @@ { - "Keys": [ "wayland-xcomposite-glx" ] + "Keys": [ "xcomposite-glx" ] } diff --git a/src/plugins/platforms/qwayland-brcm-egl/main.cpp b/src/plugins/platforms/qwayland-brcm-egl/main.cpp index c8c4eef12..bd167f618 100644 --- a/src/plugins/platforms/qwayland-brcm-egl/main.cpp +++ b/src/plugins/platforms/qwayland-brcm-egl/main.cpp @@ -47,10 +47,9 @@ QT_BEGIN_NAMESPACE class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "qwayland-brcm-egl.json") + Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "qwayland-brcm-egl.json") public: - QStringList keys() const; - QPlatformIntegration *create(const QString&, const QStringList&); + QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; QStringList QWaylandIntegrationPlugin::keys() const @@ -63,10 +62,8 @@ QStringList QWaylandIntegrationPlugin::keys() const QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-brcm") - return new QWaylandBrcmEglPlatformIntegration(); - - return 0; + Q_UNUSED(system); + return new QWaylandBrcmEglPlatformIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/qwayland-egl/main.cpp b/src/plugins/platforms/qwayland-egl/main.cpp index 6f790a14a..010a23e25 100644 --- a/src/plugins/platforms/qwayland-egl/main.cpp +++ b/src/plugins/platforms/qwayland-egl/main.cpp @@ -47,26 +47,16 @@ QT_BEGIN_NAMESPACE class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "qwayland-egl.json") + Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "qwayland-egl.json") public: - QStringList keys() const; - QPlatformIntegration *create(const QString&, const QStringList&); + QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandIntegrationPlugin::keys() const -{ - QStringList list; - list << "wayland-egl"; - return list; -} - QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-egl") - return new QWaylandEglPlatformIntegration(); - - return 0; + Q_UNUSED(system); + return new QWaylandEglPlatformIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/qwayland-generic/main.cpp b/src/plugins/platforms/qwayland-generic/main.cpp index 0575d0dc2..e1761d8e8 100644 --- a/src/plugins/platforms/qwayland-generic/main.cpp +++ b/src/plugins/platforms/qwayland-generic/main.cpp @@ -47,26 +47,16 @@ QT_BEGIN_NAMESPACE class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "qwayland-generic.json") + Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "qwayland-generic.json") public: - QStringList keys() const; - QPlatformIntegration *create(const QString&, const QStringList&); + QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandIntegrationPlugin::keys() const -{ - QStringList list; - list << "wayland"; - return list; -} - QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland") - return new QWaylandIntegration(); - - return 0; + Q_UNUSED(system); + return new QWaylandIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/main.cpp b/src/plugins/platforms/qwayland-xcomposite-egl/main.cpp index b065a4659..d3f5a0b54 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/main.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-egl/main.cpp @@ -47,26 +47,16 @@ QT_BEGIN_NAMESPACE class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "qwayland-xcomposite-egl.json") + Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "qwayland-xcomposite-egl.json") public: - QStringList keys() const; - QPlatformIntegration *create(const QString&, const QStringList&); + QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE; }; -QStringList QWaylandIntegrationPlugin::keys() const -{ - QStringList list; - list << "wayland-xcomposite" << "wayland-xcomposite-egl"; - return list; -} - QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-xcomposite" || system.toLower() == "wayland-xcomposite-egl") - return new QWaylandXCompositeEglPlatformIntegration(); - - return 0; + Q_UNUSED(system); + return new QWaylandXCompositeEglPlatformIntegration(); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.json b/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.json index 8ccd5b46b..03dac08bb 100644 --- a/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.json +++ b/src/plugins/platforms/qwayland-xcomposite-egl/qwayland-xcomposite-egl.json @@ -1,3 +1,3 @@ { - "Keys": [ "wayland-xcomposite" ] + "Keys": [ "wayland-xcomposite-egl" ] } diff --git a/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp b/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp index 2f43b467b..fb2b1414e 100644 --- a/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp +++ b/src/plugins/platforms/qwayland-xcomposite-glx/main.cpp @@ -49,26 +49,16 @@ QT_BEGIN_NAMESPACE class QWaylandIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2" FILE "qwayland-xcomposite-glx.json") + Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "qwayland-xcomposite-glx.json") public: - QStringList keys() const; QPlatformIntegration *create(const QString&, const QStringList&); }; -QStringList QWaylandIntegrationPlugin::keys() const -{ - QStringList list; - list << "wayland-xcomposite-glx"; - return list; -} - QPlatformIntegration *QWaylandIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); - if (system.toLower() == "wayland-xcomposite-glx") - return new QWaylandXCompositeGlxPlatformIntegration(); - - return 0; + Q_UNUSED(system); + return new QWaylandXCompositeGlxPlatformIntegration(); } QT_END_NAMESPACE -- cgit v1.2.3 From 7ab464dca0f303460597d4ec3f03a0ecae352be5 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Fri, 21 Feb 2014 10:58:56 +0200 Subject: Flush the clients connection after sending the frame callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to make sure the events reach the clients asap. Change-Id: I0783c6be4f4412fd5f3665faec1e57d141291ce7 Reviewed-by: Gunnar Sletta Reviewed-by: Jørgen Lind --- examples/qml-compositor/main.cpp | 2 +- examples/server-buffer/compositor/main.cpp | 2 +- src/compositor/wayland_wrapper/qwlcompositor.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/qml-compositor/main.cpp b/examples/qml-compositor/main.cpp index c33eb7e63..93b23c0e3 100644 --- a/examples/qml-compositor/main.cpp +++ b/examples/qml-compositor/main.cpp @@ -68,7 +68,7 @@ public: winId(); connect(this, SIGNAL(beforeSynchronizing()), this, SLOT(startFrame()), Qt::DirectConnection); - connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()), Qt::DirectConnection); + connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks())); } QWaylandSurface *fullscreenSurface() const diff --git a/examples/server-buffer/compositor/main.cpp b/examples/server-buffer/compositor/main.cpp index 1aa29029c..ff375a8c6 100644 --- a/examples/server-buffer/compositor/main.cpp +++ b/examples/server-buffer/compositor/main.cpp @@ -84,7 +84,7 @@ public: grabWindow(); connect(this, SIGNAL(beforeSynchronizing()), this, SLOT(startFrame()), Qt::DirectConnection); - connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks()), Qt::DirectConnection); + connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks())); connect(this, SIGNAL(sceneGraphInitialized()), this, SLOT(initiateServerBuffer()),Qt::DirectConnection); connect(this, SIGNAL(serverBuffersCreated()), this, SLOT(createServerBufferItems())); diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp index 672924ed4..34f1ab5c6 100644 --- a/src/compositor/wayland_wrapper/qwlcompositor.cpp +++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp @@ -228,6 +228,7 @@ void Compositor::sendFrameCallbacks(QList visibleSurfaces) foreach (QWaylandSurface *surface, visibleSurfaces) { surface->handle()->sendFrameCallback(); } + wl_display_flush_clients(m_display->handle()); } void Compositor::createSurface(struct wl_client *client, uint32_t id) -- cgit v1.2.3 From 1f8f991d7c61d046783b3f541d9121f0a47bcd23 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Fri, 21 Feb 2014 13:11:53 +0200 Subject: Make the compositor redraw when a surface gets a commit(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It must redraw, even if it doesn't actually redraw anything, irrespective of the fact that a attach/damage has come or not. Just calling frame();commit() is perfectly valid. Change-Id: If298654b8a7cb7c954cfbad8618f23134731cb9f Reviewed-by: Laszlo Agocs Reviewed-by: Jørgen Lind --- examples/qwidget-compositor/main.cpp | 15 +++++---------- examples/qwindow-compositor/qwindowcompositor.cpp | 9 ++++----- examples/qwindow-compositor/qwindowcompositor.h | 4 ++-- src/compositor/compositor_api/qwaylandsurface.h | 1 + src/compositor/compositor_api/qwaylandsurfaceitem.cpp | 2 +- src/compositor/wayland_wrapper/qwlsurface.cpp | 2 ++ 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/examples/qwidget-compositor/main.cpp b/examples/qwidget-compositor/main.cpp index ed1c0a3fc..7a268fbd3 100644 --- a/examples/qwidget-compositor/main.cpp +++ b/examples/qwidget-compositor/main.cpp @@ -110,27 +110,22 @@ private slots: update(); } - void surfaceDamaged(const QRegion &rect) { + void surfaceCommitted() { QWaylandSurface *surface = qobject_cast(sender()); - surfaceDamaged(surface, rect); + surfaceCommitted(surface); } protected: - void surfaceDamaged(QWaylandSurface *surface, const QRegion &rect) + void surfaceCommitted(QWaylandSurface *surface) { -#ifdef QT_COMPOSITOR_WAYLAND_GL Q_UNUSED(surface); - Q_UNUSED(rect); update(); -#else - update(rect.translated(surface->geometry().topLeft())); -#endif } void surfaceCreated(QWaylandSurface *surface) { connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); - connect(surface, SIGNAL(damaged(const QRegion &)), this, SLOT(surfaceDamaged(const QRegion &))); + connect(surface, SIGNAL(committed()), this, SLOT(surfaceCommitted())); update(); } @@ -265,7 +260,7 @@ protected: void raise(QWaylandSurface *surface) { defaultInputDevice()->setKeyboardFocus(surface); - surfaceDamaged(surface, QRect(QPoint(), surface->size())); + update(); m_surfaces.removeOne(surface); m_surfaces.append(surface); } diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp index f64922db5..e0f213aa4 100644 --- a/examples/qwindow-compositor/qwindowcompositor.cpp +++ b/examples/qwindow-compositor/qwindowcompositor.cpp @@ -159,10 +159,10 @@ void QWindowCompositor::surfaceUnmapped() ensureKeyboardFocusSurface(surface); } -void QWindowCompositor::surfaceDamaged(const QRegion &rect) +void QWindowCompositor::surfaceCommitted() { QWaylandSurface *surface = qobject_cast(sender()); - surfaceDamaged(surface, rect); + surfaceCommitted(surface); } void QWindowCompositor::surfacePosChanged() @@ -170,10 +170,9 @@ void QWindowCompositor::surfacePosChanged() m_renderScheduler.start(0); } -void QWindowCompositor::surfaceDamaged(QWaylandSurface *surface, const QRegion &rect) +void QWindowCompositor::surfaceCommitted(QWaylandSurface *surface) { Q_UNUSED(surface) - Q_UNUSED(rect) m_renderScheduler.start(0); } @@ -182,7 +181,7 @@ void QWindowCompositor::surfaceCreated(QWaylandSurface *surface) connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped())); - connect(surface, SIGNAL(damaged(const QRegion &)), this, SLOT(surfaceDamaged(const QRegion &))); + connect(surface, SIGNAL(committed()), this, SLOT(surfaceCommitted())); connect(surface, SIGNAL(extendedSurfaceReady()), this, SLOT(sendExpose())); connect(surface, SIGNAL(posChanged()), this, SLOT(surfacePosChanged())); m_renderScheduler.start(0); diff --git a/examples/qwindow-compositor/qwindowcompositor.h b/examples/qwindow-compositor/qwindowcompositor.h index f8d354c36..e26a09ebc 100644 --- a/examples/qwindow-compositor/qwindowcompositor.h +++ b/examples/qwindow-compositor/qwindowcompositor.h @@ -61,12 +61,12 @@ private slots: void surfaceDestroyed(QObject *object); void surfaceMapped(); void surfaceUnmapped(); - void surfaceDamaged(const QRegion &rect); + void surfaceCommitted(); void surfacePosChanged(); void render(); protected: - void surfaceDamaged(QWaylandSurface *surface, const QRegion &rect); + void surfaceCommitted(QWaylandSurface *surface); void surfaceCreated(QWaylandSurface *surface); QWaylandSurface* surfaceAt(const QPointF &point, QPointF *local = 0); diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h index 774464a8a..03ed73e02 100644 --- a/src/compositor/compositor_api/qwaylandsurface.h +++ b/src/compositor/compositor_api/qwaylandsurface.h @@ -187,6 +187,7 @@ signals: void mapped(); void unmapped(); void damaged(const QRegion &rect); + void committed(); void parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent); void sizeChanged(); void posChanged(); diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp index b87bbb614..2c2f3cce3 100644 --- a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp +++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp @@ -147,6 +147,7 @@ void QWaylandSurfaceItem::init(QWaylandSurface *surface) connect(surface, &QWaylandSurface::unmapped, this, &QWaylandSurfaceItem::surfaceUnmapped); connect(surface, &QWaylandSurface::destroyed, this, &QWaylandSurfaceItem::surfaceDestroyed); connect(surface, &QWaylandSurface::damaged, this, &QWaylandSurfaceItem::surfaceDamaged); + connect(surface, &QWaylandSurface::committed, this, &QQuickItem::update); connect(surface, &QWaylandSurface::parentChanged, this, &QWaylandSurfaceItem::parentChanged); connect(surface, &QWaylandSurface::sizeChanged, this, &QWaylandSurfaceItem::updateSize); connect(surface, &QWaylandSurface::posChanged, this, &QWaylandSurfaceItem::updatePosition); @@ -309,7 +310,6 @@ void QWaylandSurfaceItem::surfaceDamaged(const QRegion &) } } emit textureChanged(); - update(); } void QWaylandSurfaceItem::parentChanged(QWaylandSurface *newParent, QWaylandSurface *oldParent) diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index cd5320677..86f34279e 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -483,6 +483,8 @@ void Surface::surface_commit(Resource *) m_frameCallbacks << m_pendingFrameCallbacks; m_pendingFrameCallbacks.clear(); + + emit m_waylandSurface->committed(); } void Surface::frameStarted() -- cgit v1.2.3 From 96275509fcec8abc8e580aa6c3c53d893885b7a7 Mon Sep 17 00:00:00 2001 From: Cedric Chedaleux Date: Mon, 3 Feb 2014 15:59:23 +0100 Subject: Fix NPOT decoration texture binding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the context does not support the NPOTTextureRepeat (i.e. GL_OES_texture_npot extension), wrapping must be set to CLAMP_TO_EDGE to prevent invalid texture mapping. Change-Id: I3ededccc14a32188986529c14fa91161fb383cfc Reviewed-by: Jørgen Lind Reviewed-by: Laszlo Agocs --- src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp index 3bc1ff2b1..e7a4b5a2b 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp @@ -210,6 +210,10 @@ void QWaylandGLContext::swapBuffers(QPlatformSurface *surface) m_textureCache->bindTexture(context(), decorationImage); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + if (!context()->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat)) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); //Draw Content -- cgit v1.2.3 From d8ce5886971107d219dc1e597f979c97ace6d64f Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Thu, 20 Mar 2014 16:04:19 +0200 Subject: Remove the QWidget compositor example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QWidget API isn't well fit for a Wayland compositor, and does not have any advantage over a QWindow, which can also draw using QPainter. Besides the current implementation doesn't work properly, and no one seems to be interested in fixing it. Change-Id: Id1c337506af48e1d1fdd8d14f0ed637d299702f3 Reviewed-by: Laszlo Agocs Reviewed-by: Jørgen Lind --- examples/examples.pro | 4 - examples/qwidget-compositor/main.cpp | 394 --------------------- examples/qwidget-compositor/qwidget-compositor.pro | 23 -- examples/qwidget-compositor/qwidget-compositor.qrc | 5 - examples/qwidget-compositor/textureblitter.cpp | 158 --------- examples/qwidget-compositor/textureblitter.h | 68 ---- 6 files changed, 652 deletions(-) delete mode 100644 examples/qwidget-compositor/main.cpp delete mode 100644 examples/qwidget-compositor/qwidget-compositor.pro delete mode 100644 examples/qwidget-compositor/qwidget-compositor.qrc delete mode 100644 examples/qwidget-compositor/textureblitter.cpp delete mode 100644 examples/qwidget-compositor/textureblitter.h diff --git a/examples/examples.pro b/examples/examples.pro index 2d4cd1bb3..d633fb924 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -5,10 +5,6 @@ TEMPLATE=subdirs contains(CONFIG, wayland-compositor) { SUBDIRS += qwindow-compositor - qtHaveModule(widgets) { - SUBDIRS += qwidget-compositor - } - qtHaveModule(quick) { SUBDIRS += qml-compositor } diff --git a/examples/qwidget-compositor/main.cpp b/examples/qwidget-compositor/main.cpp deleted file mode 100644 index 7a268fbd3..000000000 --- a/examples/qwidget-compositor/main.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwaylandcompositor.h" - -#include "qwaylandsurface.h" -#include - -#include -#include -#include -#include -#include -#include - -#ifdef QT_COMPOSITOR_WAYLAND_GL -#include -#include -#include -#include "textureblitter.h" -#include -#endif - -#include - -#ifdef QT_COMPOSITOR_WAYLAND_GL -class QWidgetCompositor : public QGLWidget, public QWaylandCompositor -#else -class QWidgetCompositor : public QWidget, public WaylandCompositor -#endif -{ - Q_OBJECT -public: - QWidgetCompositor() - : QWaylandCompositor(windowHandle(), 0, DefaultExtensions | SubSurfaceExtension) -#ifdef QT_COMPOSITOR_WAYLAND_GL - , m_surfaceCompositorFbo(0) - , m_textureBlitter(0) - , m_textureCache(0) -#endif - , m_moveSurface(0) - , m_dragSourceSurface(0) - , m_cursorSurface(0) - { - setMouseTracking(true); - setRetainedSelectionEnabled(true); - m_background = QImage(QLatin1String(":/background.jpg")); - //make sure we get the window id and create the glcontext - //so that clients can successfully initialize egl - winId(); - } - -private slots: - void surfaceDestroyed(QObject *object) { - QWaylandSurface *surface = static_cast(object); - m_surfaces.removeAll(surface); - update(); - } - - void surfaceMapped() { - QWaylandSurface *surface = qobject_cast(sender()); - QPoint pos; - if (!m_surfaces.contains(surface)) { - uint px = 1 + (qrand() % (width() - surface->size().width() - 2)); - uint py = 1 + (qrand() % (height() - surface->size().height() - 2)); - pos = QPoint(px, py); - surface->setPos(pos); - if (surface->hasShellSurface()) - m_surfaces.append(surface); - } - if (surface->hasShellSurface()) - defaultInputDevice()->setKeyboardFocus(surface); - update(); - } - - void surfaceCommitted() { - QWaylandSurface *surface = qobject_cast(sender()); - surfaceCommitted(surface); - } - -protected: - void surfaceCommitted(QWaylandSurface *surface) - { - Q_UNUSED(surface); - update(); - } - - void surfaceCreated(QWaylandSurface *surface) { - connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); - connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); - connect(surface, SIGNAL(committed()), this, SLOT(surfaceCommitted())); - update(); - } - -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint composeSurface(QWaylandSurface *surface) { - GLuint texture = 0; - QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); - - QSize windowSize = surface->size(); - surface->swapBuffers(); - - if (!m_surfaceCompositorFbo) - functions->glGenFramebuffers(1,&m_surfaceCompositorFbo); - - functions->glBindFramebuffer(GL_FRAMEBUFFER, m_surfaceCompositorFbo); - - if (surface->type() == QWaylandSurface::Shm) { - texture = m_textureCache->bindTexture(context()->contextHandle(), surface->image()); - } else { - texture = surface->texture(); - } - - functions->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, texture, 0); - paintChildren(surface,surface,windowSize); - functions->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, 0, 0); - - functions->glBindFramebuffer(GL_FRAMEBUFFER, 0); - return texture; - } - - void paintChildren(QWaylandSurface *surface, QWaylandSurface *window, const QSize &windowSize) { - - if (surface->subSurfaces().size() == 0) - return; - - QLinkedListIterator i(surface->subSurfaces()); - while (i.hasNext()) { - QWaylandSurface *subSurface = i.next(); - QPointF p = subSurface->mapTo(window,QPoint(0,0)); - QSize size = subSurface->size(); - subSurface->swapBuffers(); - if (size.isValid()) { - GLuint texture = 0; - if (subSurface->type() == QWaylandSurface::Texture) { - texture = subSurface->texture(); - } else if (surface->type() == QWaylandSurface::Shm ) { - texture = m_textureCache->bindTexture(context()->contextHandle(), surface->image()); - } - m_textureBlitter->drawTexture(texture,QRect(p.toPoint(),size),windowSize,0,window->isYInverted(),subSurface->isYInverted()); - } - paintChildren(subSurface,window,windowSize); - } - } -#else //hmmm, this is actually untested :( - QImage composeSurface(WaylandSurface *surface) - { - Q_ASSER(surface->type() == WaylandSurface::Shm); - QImage img = surface->image(); - QPainter p(&img); - paintChildren(surface,p,surface); - - return img; - } - - void paintChildren(WaylandSurface *surface, QPainter *painter, WaylandSurface *window) { - if (surface->subSurfaces().size() == 0) - return; - - QLinkedListIterator i(surface->subSurfaces()); - while (i.hasNext()) { - WaylandSurface *subSurface = i.next(); - QPoint p = subSurface->mapTo(window,QPoint(0,0)); - QRect geo = subSurface->geometry(); - geo.moveTo(p); - if (geo.isValid()) { - painter->drawImage(p,subSurface->image()); - } - paintChildren(subSurface,painter,window); - } - } -#endif //QT_COMPOSITOR_WAYLAND_GL - - - - void paintEvent(QPaintEvent *) { - QPainter p(this); - - frameStarted(); - if (!m_background.isNull()) - p.drawPixmap(rect(), m_backgroundScaled); - -#ifdef QT_COMPOSITOR_WAYLAND_GL - cleanupGraphicsResources(); - if (!m_textureCache) { - m_textureCache = new QOpenGLTextureCache(context()->contextHandle()); - } - if (!m_textureBlitter) { - m_textureBlitter = new TextureBlitter(); - } - m_textureBlitter->bind(); -#endif - for (int i = 0; i < m_surfaces.size(); ++i) { -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint texture = composeSurface(m_surfaces.at(i)); - QWaylandSurface *surface = m_surfaces.at(i); - QRect geo(surface->pos().toPoint(),surface->size()); - m_textureBlitter->drawTexture(texture,geo,size(),0,false,m_surfaces.at(i)->isYInverted()); -#else - QImage img = composeSurface(m_surfaces.at(i)); - p.drawImage(m_surfaces.at(i)->geometry().topLeft(),img); -#endif //QT_COMPOSITOR_WAYLAND_GL - } - - sendFrameCallbacks(surfaces()); - -#ifdef QT_COMPOSITOR_WAYLAND_GL - //jl:FIX FIX FIX:) -// update(); - m_textureBlitter->release(); -#endif - } - - void resizeEvent(QResizeEvent *) - { - if (!m_background.isNull()) { - m_backgroundScaled = QPixmap::fromImage(m_background.scaled(size(), - Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - } - } - - void raise(QWaylandSurface *surface) { - defaultInputDevice()->setKeyboardFocus(surface); - update(); - m_surfaces.removeOne(surface); - m_surfaces.append(surface); - } - - void mousePressEvent(QMouseEvent *e) { - m_cursorPos = e->pos(); - QPointF local; - if (QWaylandSurface *surface = surfaceAt(e->pos(), &local)) { - raise(surface); - if (e->modifiers() & Qt::ControlModifier) { - m_moveSurface = surface; - m_moveOffset = local; - } else { - defaultInputDevice()->sendMousePressEvent(e->button(), local.toPoint(),e->pos()); - } - } - } - - void mouseMoveEvent(QMouseEvent *e) { - m_cursorPos = e->pos(); - if (isDragging()) { - QPoint global = e->pos(); // "global" here means the window of the compositor - QPointF local; - QWaylandSurface *surface = surfaceAt(e->pos(), &local); - if (surface) { - if (!m_dragSourceSurface) - m_dragSourceSurface = surface; - if (m_dragSourceSurface == surface) - m_lastDragSourcePos = local; - raise(surface); - } - //this should go away when draggin is reimplemented - sendDragMoveEvent(global, local.toPoint(), surface); - return; - } - if (m_moveSurface) { - m_moveSurface->setPos(e->localPos() - m_moveOffset); - update(); - return; - } - QPointF local; - if (surfaceAt(e->pos(), &local)) - defaultInputDevice()->sendMouseMoveEvent(local.toPoint(),pos()); - } - - void mouseReleaseEvent(QMouseEvent *e) { - if (isDragging()) { - sendDragEndEvent(); - if (m_dragSourceSurface) { - // Must send a release event to the source too, no matter where the cursor is now. - // This is a hack and should go away when we reimplement draging - defaultInputDevice()->sendMouseReleaseEvent(e->button(), m_lastDragSourcePos.toPoint(), e->pos()); - m_dragSourceSurface = 0; - } - } - if (m_moveSurface) { - m_moveSurface = 0; - return; - } - QPointF local; - if (surfaceAt(e->pos(), &local)) - defaultInputDevice()->sendMouseReleaseEvent(e->button(), local.toPoint(), e->pos()); - } - - void keyPressEvent(QKeyEvent *event) - { - defaultInputDevice()->sendKeyPressEvent(event->nativeScanCode()); - } - - void keyReleaseEvent(QKeyEvent *event) - { - defaultInputDevice()->sendKeyReleaseEvent(event->nativeScanCode()); - } - - QWaylandSurface *surfaceAt(const QPointF &point, QPointF *local = 0) { - for (int i = m_surfaces.size() - 1; i >= 0; --i) { - QWaylandSurface *surface = m_surfaces.at(i); - QRect geo(surface->pos().toPoint(),surface->size()); - if (geo.contains(point.toPoint())) { - if (local) - *local = point - surface->pos(); - return surface; - } - } - return 0; - } - - void setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY) { - m_cursorSurface = surface; - m_cursorHotspot = QPoint(hotspotX, hotspotY); - update(); - } - -private: - QImage m_background; - QPixmap m_backgroundScaled; - - QList m_surfaces; - -#ifdef QT_COMPOSITOR_WAYLAND_GL - GLuint m_surfaceCompositorFbo; - TextureBlitter *m_textureBlitter; - QOpenGLTextureCache *m_textureCache; -#endif - - QWaylandSurface *m_moveSurface; - QPointF m_moveOffset; - QWaylandSurface *m_dragSourceSurface; - QPointF m_lastDragSourcePos; - - QWaylandSurface* m_cursorSurface; - QPoint m_cursorPos; - QPoint m_cursorHotspot; - - friend class TouchObserver; -}; - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QWidgetCompositor compositor; - compositor.resize(800, 600); - compositor.show(); - -// QTouchScreenHandlerThread t(QString(), new TouchObserver(&compositor)); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/qwidget-compositor/qwidget-compositor.pro b/examples/qwidget-compositor/qwidget-compositor.pro deleted file mode 100644 index 688175b9f..000000000 --- a/examples/qwidget-compositor/qwidget-compositor.pro +++ /dev/null @@ -1,23 +0,0 @@ -# if you want to compile QtCompositor as part of the application -# instead of linking to it, remove the QT += compositor and uncomment -# the following line -#include (../../src/qt-compositor/qt-compositor.pri) - -# to make QtCompositor/... style includes working without installing -INCLUDEPATH += $$PWD/../../include - -HEADERS += \ - textureblitter.h - -SOURCES += \ - main.cpp \ - textureblitter.cpp - -QT += core-private gui-private widgets widgets-private opengl opengl-private compositor - -RESOURCES += qwidget-compositor.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qwidget-compositor -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qwidget-compositor.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtwayland/qwidget-compositor -INSTALLS += target sources diff --git a/examples/qwidget-compositor/qwidget-compositor.qrc b/examples/qwidget-compositor/qwidget-compositor.qrc deleted file mode 100644 index 20dd10a53..000000000 --- a/examples/qwidget-compositor/qwidget-compositor.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - ../qml-compositor/background.jpg - - diff --git a/examples/qwidget-compositor/textureblitter.cpp b/examples/qwidget-compositor/textureblitter.cpp deleted file mode 100644 index 5607274b2..000000000 --- a/examples/qwidget-compositor/textureblitter.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "textureblitter.h" - -#include -#include -#include - -TextureBlitter::TextureBlitter() - : m_shaderProgram(new QOpenGLShaderProgram()) -{ - static const char *textureVertexProgram = - "uniform highp mat4 matrix;\n" - "attribute highp vec3 vertexCoordEntry;\n" - "attribute highp vec2 textureCoordEntry;\n" - "varying highp vec2 textureCoord;\n" - "void main() {\n" - " textureCoord = textureCoordEntry;\n" - " gl_Position = matrix * vec4(vertexCoordEntry, 1);\n" - "}\n"; - - static const char *textureFragmentProgram = - "uniform sampler2D texture;\n" - "varying highp vec2 textureCoord;\n" - "void main() {\n" - " gl_FragColor = texture2D(texture, textureCoord);\n" - "}\n"; - - //Enable transparent windows - glEnable(GL_BLEND); - glBlendFunc (GL_ONE,GL_ONE_MINUS_SRC_ALPHA); - - m_shaderProgram->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram); - m_shaderProgram->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram); - m_shaderProgram->link(); -} - - -void TextureBlitter::bind() -{ - - m_shaderProgram->bind(); - - m_vertexCoordEntry = m_shaderProgram->attributeLocation("vertexCoordEntry"); - m_textureCoordEntry = m_shaderProgram->attributeLocation("textureCoordEntry"); - m_matrixLocation = m_shaderProgram->uniformLocation("matrix"); -} - -void TextureBlitter::release() -{ - m_shaderProgram->release(); -} - -void TextureBlitter::drawTexture(int textureId, const QRectF &targetRect, const QSize &targetSize, int depth, bool targethasInvertedY, bool sourceHasInvertedY) -{ - - glViewport(0,0,targetSize.width(),targetSize.height()); - GLfloat zValue = depth / 1000.0f; - //Set Texture and Vertex coordinates - const GLfloat textureCoordinates[] = { - 0, 0, - 1, 0, - 1, 1, - 0, 1 - }; - - GLfloat x1 = targetRect.left(); - GLfloat x2 = targetRect.right(); - GLfloat y1, y2; - if (targethasInvertedY) { - if (sourceHasInvertedY) { - y1 = targetRect.top(); - y2 = targetRect.bottom(); - } else { - y1 = targetRect.bottom(); - y2 = targetRect.top(); - } - } else { - if (sourceHasInvertedY) { - y1 = targetSize.height() - targetRect.top(); - y2 = targetSize.height() - targetRect.bottom(); - } else { - y1 = targetSize.height() - targetRect.bottom(); - y2 = targetSize.height() - targetRect.top(); - } - } - - const GLfloat vertexCoordinates[] = { - GLfloat(x1), GLfloat(y1), zValue, - GLfloat(x2), GLfloat(y1), zValue, - GLfloat(x2), GLfloat(y2), zValue, - GLfloat(x1), GLfloat(y2), zValue - }; - - //Set matrix to transfrom geometry values into gl coordinate space. - m_transformMatrix.setToIdentity(); - m_transformMatrix.scale( 2.0f / targetSize.width(), 2.0f / targetSize.height() ); - m_transformMatrix.translate(-targetSize.width() / 2.0f, -targetSize.height() / 2.0f); - - //attach the data! - QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - currentContext->functions()->glEnableVertexAttribArray(m_vertexCoordEntry); - currentContext->functions()->glEnableVertexAttribArray(m_textureCoordEntry); - - currentContext->functions()->glVertexAttribPointer(m_vertexCoordEntry, 3, GL_FLOAT, GL_FALSE, 0, vertexCoordinates); - currentContext->functions()->glVertexAttribPointer(m_textureCoordEntry, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinates); - m_shaderProgram->setUniformValue(m_matrixLocation, m_transformMatrix); - - glBindTexture(GL_TEXTURE_2D, textureId); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - glBindTexture(GL_TEXTURE_2D, 0); - - currentContext->functions()->glDisableVertexAttribArray(m_vertexCoordEntry); - currentContext->functions()->glDisableVertexAttribArray(m_textureCoordEntry); -} diff --git a/examples/qwidget-compositor/textureblitter.h b/examples/qwidget-compositor/textureblitter.h deleted file mode 100644 index 9a6ce59ef..000000000 --- a/examples/qwidget-compositor/textureblitter.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Compositor. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -** of its contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEXTUREBLITTER_H -#define TEXTUREBLITTER_H - -#include - -#include - -class QOpenGLShaderProgram; -class TextureBlitter -{ -public: - TextureBlitter(); - void bind(); - void release(); - void drawTexture(int textureId, const QRectF &sourceGeometry, - const QSize &targetRect, int depth, - bool targethasInvertedY, bool sourceHasInvertedY); - -private: - QOpenGLShaderProgram *m_shaderProgram; - QMatrix4x4 m_transformMatrix; - - int m_matrixLocation; - int m_vertexCoordEntry; - int m_textureCoordEntry; -}; - -#endif // TEXTUREBLITTER_H -- cgit v1.2.3 From a07bf91a15fe176f5b25e96aeea5b1b40fff947b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 7 Mar 2014 22:15:56 -0800 Subject: Add a note that qmake CONFIG+= only works in a clean tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You need to use qmake -r on a tree which already has Makefiles. But you probably need to clean up anyway in order to get the new functionality, so this is a good recommendation for the general case. Change-Id: Ie0fa10621a3fe961945da10a72e7fcc632f3fc0f Reviewed-by: Jørgen Lind --- README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README b/README index 368ecbc3d..f26089766 100644 --- a/README +++ b/README @@ -15,6 +15,9 @@ include "wayland-compositor" when building the QtWayland module: qmake CONFIG+=wayland-compositor make +Note: make sure the source tree is clean before running those commands. If in +doubt, run git clean -f -d -x. + To build the QtWayland module you need the external dependencies: xkbcommon 0.2.0 - http://xkbcommon.org/ wayland 1.2.0 - http://wayland.freedesktop.org/ -- cgit v1.2.3