diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-03-25 14:19:55 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-29 10:09:31 +0200 |
commit | fc439e40e37f9c0b3108225f951fb19bb3abee80 (patch) | |
tree | 851bf52ee2004b3b201b5e86df7a4d4db7f79a2c /examples | |
parent | c551e6df6c77f65a0db62b3ad4db539e86b75a30 (diff) |
Rework the way buffers are used and rendered
The current way buffers are handled is sub-optimal. They are hidden
inside QtWayland::Surface and the actual renderer, be it QtQuick or
anything else, cannot get a direct hold of them, nor it can directly
control when the underlying textures are created or deleted.
The main additions in this commit are the splitting of the QtQuick
code path and the new QWaylandBufferRef and QWaylandBufferAttacher
classes.
QWaylandBufferRef allows a renderer to retain a reference
to a wl_buffer even after the underlying Surface discarded it.
That allows the renderer to directly decide when to destroy the texture
of the buffer.
QWaylandBufferAttacher is a pure virtual class which must be implemented
by the renderer. Instances of it will be assigned to the QWaylandSurfaces,
created. Its attach() virtual method will then be called when a new buffer
is committed to the surface. The renderer can then choose to immediately
create a texture or wait for some later time. It is its responsibility to
create and destroy the GL texture, it will not happen automatically.
This functionality is implemented for QtQuick in the new QWaylandQuickCompositor
and QWaylandQuickSurface classes.
Change-Id: I674b4e5fb8c65c3b1c582e33ff3a0b0e45f2acc9
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qml-compositor/WindowContainer.qml | 27 | ||||
-rw-r--r-- | examples/qml-compositor/main.cpp | 48 | ||||
-rw-r--r-- | examples/qml-compositor/main.qml | 30 | ||||
-rw-r--r-- | examples/qwindow-compositor/qwindowcompositor.cpp | 108 | ||||
-rw-r--r-- | examples/qwindow-compositor/qwindowcompositor.h | 4 | ||||
-rw-r--r-- | examples/server-buffer/compositor/main.cpp | 34 | ||||
-rw-r--r-- | examples/server-buffer/compositor/qml/main.qml | 17 |
7 files changed, 135 insertions, 133 deletions
diff --git a/examples/qml-compositor/WindowContainer.qml b/examples/qml-compositor/WindowContainer.qml index 701b46d24..77dd1d4dc 100644 --- a/examples/qml-compositor/WindowContainer.qml +++ b/examples/qml-compositor/WindowContainer.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtQuick.Window 2.0 +import QtCompositor 1.0 Item { id: container @@ -52,10 +53,20 @@ Item { visible: isFullscreen || !root.hasFullscreenWindow onVisibleChanged: { - child.clientRenderingEnabled = visible + child.surface.clientRenderingEnabled = visible console.log("visibility changed: " + visible); } + WaylandSurfaceItem { + id: surfaceItem + anchors.fill: parent + touchEventsEnabled: true + + onSurfaceDestroyed: { + destroyAnimation.start(); + } + } + opacity: 0 property real targetX @@ -64,7 +75,7 @@ Item { property real targetHeight property real targetScale - property variant child: null + property variant child: surfaceItem property variant chrome: null property bool animationsEnabled: false property bool isFullscreen: state === "fullscreen" @@ -168,11 +179,17 @@ Item { NumberAnimation { target: scaleTransform; property: "yScale"; easing.type: Easing.Linear; to: 0.01; duration: 200; } NumberAnimation { target: scaleTransform; property: "xScale"; easing.type: Easing.Linear; to: 0.01; duration: 150; } NumberAnimation { target: container; property: "opacity"; easing.type: Easing.Linear; to: 0.0; duration: 150; } - ScriptAction { script: container.parent.removeWindow(child); } + ScriptAction { script: container.parent.removeWindow(container) } + } + SequentialAnimation { + id: unmapAnimation + NumberAnimation { target: container; property: "opacity"; easing.type: Easing.Linear; to: 0.0; duration: 150; } + ScriptAction { script: container.parent.removeWindow(container) } } - function runDestroyAnimation() { - destroyAnimation.start(); + Connections { + target: container.child.surface + onUnmapped: unmapAnimation.start() } Image { diff --git a/examples/qml-compositor/main.cpp b/examples/qml-compositor/main.cpp index 93b23c0e3..7ebcb6c29 100644 --- a/examples/qml-compositor/main.cpp +++ b/examples/qml-compositor/main.cpp @@ -38,9 +38,8 @@ ** ****************************************************************************/ -#include "qwaylandcompositor.h" -#include "qwaylandsurface.h" -#include "qwaylandsurfaceitem.h" +#include "qwaylandquickcompositor.h" +#include "qwaylandquicksurface.h" #include <QGuiApplication> #include <QTimer> @@ -52,14 +51,14 @@ #include <QQuickItem> #include <QQuickView> -class QmlCompositor : public QQuickView, public QWaylandCompositor +class QmlCompositor : public QQuickView, public QWaylandQuickCompositor { Q_OBJECT - Q_PROPERTY(QWaylandSurface* fullscreenSurface READ fullscreenSurface WRITE setFullscreenSurface NOTIFY fullscreenSurfaceChanged) + Q_PROPERTY(QWaylandQuickSurface* fullscreenSurface READ fullscreenSurface WRITE setFullscreenSurface NOTIFY fullscreenSurfaceChanged) public: QmlCompositor() - : QWaylandCompositor(this, 0, DefaultExtensions | SubSurfaceExtension) + : QWaylandQuickCompositor(this, 0, DefaultExtensions | SubSurfaceExtension) , m_fullscreenSurface(0) { setSource(QUrl("main.qml")); @@ -67,11 +66,10 @@ public: setColor(Qt::black); winId(); - connect(this, SIGNAL(beforeSynchronizing()), this, SLOT(startFrame()), Qt::DirectConnection); connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks())); } - QWaylandSurface *fullscreenSurface() const + QWaylandQuickSurface *fullscreenSurface() const { return m_fullscreenSurface; } @@ -87,12 +85,7 @@ public slots: qvariant_cast<QObject *>(window)->deleteLater(); } - void destroyClientForWindow(QVariant window) { - QWaylandSurface *surface = qobject_cast<QWaylandSurfaceItem *>(qvariant_cast<QObject *>(window))->surface(); - destroyClientForSurface(surface); - } - - void setFullscreenSurface(QWaylandSurface *surface) { + void setFullscreenSurface(QWaylandQuickSurface *surface) { if (surface == m_fullscreenSurface) return; m_fullscreenSurface = surface; @@ -101,34 +94,25 @@ public slots: private slots: void surfaceMapped() { - QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender()); + QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(sender()); //Ignore surface if it's not a window surface if (!surface->hasShellSurface()) return; - QWaylandSurfaceItem *item = surface->surfaceItem(); - //Create a WaylandSurfaceItem if we have not yet - if (!item) - item = new QWaylandSurfaceItem(surface, rootObject()); - - item->setTouchEventsEnabled(true); - //item->takeFocus(); - emit windowAdded(QVariant::fromValue(static_cast<QQuickItem *>(item))); + emit windowAdded(QVariant::fromValue(surface)); } void surfaceUnmapped() { - QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender()); + QWaylandQuickSurface *surface = qobject_cast<QWaylandQuickSurface *>(sender()); if (surface == m_fullscreenSurface) m_fullscreenSurface = 0; - QQuickItem *item = surface->surfaceItem(); - emit windowDestroyed(QVariant::fromValue(item)); + emit windowDestroyed(QVariant::fromValue(surface)); } void surfaceDestroyed(QObject *object) { - QWaylandSurface *surface = static_cast<QWaylandSurface *>(object); + QWaylandQuickSurface *surface = static_cast<QWaylandQuickSurface *>(object); if (surface == m_fullscreenSurface) m_fullscreenSurface = 0; - QQuickItem *item = surface->surfaceItem(); - emit windowDestroyed(QVariant::fromValue(item)); + emit windowDestroyed(QVariant::fromValue(surface)); } void sendCallbacks() { @@ -137,9 +121,6 @@ private slots: else sendFrameCallbacks(surfaces()); } - void startFrame() { - frameStarted(); - } protected: void resizeEvent(QResizeEvent *event) @@ -155,7 +136,7 @@ protected: } private: - QWaylandSurface *m_fullscreenSurface; + QWaylandQuickSurface *m_fullscreenSurface; }; int main(int argc, char *argv[]) @@ -170,7 +151,6 @@ int main(int argc, char *argv[]) compositor.rootContext()->setContextProperty("compositor", &compositor); QObject::connect(&compositor, SIGNAL(windowAdded(QVariant)), compositor.rootObject(), SLOT(windowAdded(QVariant))); - QObject::connect(&compositor, SIGNAL(windowDestroyed(QVariant)), compositor.rootObject(), SLOT(windowDestroyed(QVariant))); QObject::connect(&compositor, SIGNAL(windowResized(QVariant)), compositor.rootObject(), SLOT(windowResized(QVariant))); return app.exec(); diff --git a/examples/qml-compositor/main.qml b/examples/qml-compositor/main.qml index 7b152280e..120c92bdb 100644 --- a/examples/qml-compositor/main.qml +++ b/examples/qml-compositor/main.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtCompositor 1.0 import "compositor.js" as CompositorLogic Item { @@ -84,15 +85,15 @@ Item { function windowAdded(window) { var windowContainerComponent = Qt.createComponent("WindowContainer.qml"); var windowContainer = windowContainerComponent.createObject(root); + console.log(windowContainerComponent.errorString()); - window.parent = windowContainer; + windowContainer.child.surface = window; - windowContainer.targetWidth = window.width; - windowContainer.targetHeight = window.height; - windowContainer.child = window; + windowContainer.targetWidth = window.size.width; + windowContainer.targetHeight = window.size.height; var windowChromeComponent = Qt.createComponent("WindowChrome.qml"); - var windowChrome = windowChromeComponent.createObject(window); + var windowChrome = windowChromeComponent.createObject(windowContainer.child); CompositorLogic.addWindow(windowContainer); @@ -102,25 +103,16 @@ Item { } function windowResized(window) { - var windowContainer = window.parent; - windowContainer.width = window.width; - windowContainer.height = window.height; + window.width = window.surface.size.width; + window.height = window.surface.size.height; CompositorLogic.relayout(); } - function windowDestroyed(window) { - var windowContainer = window.parent; - if (windowContainer.runDestroyAnimation) - windowContainer.runDestroyAnimation(); - } - function removeWindow(window) { - var windowContainer = window.parent; - CompositorLogic.removeWindow(windowContainer); - windowContainer.chrome.destroy(); - windowContainer.destroy(); - compositor.destroyWindow(window); + CompositorLogic.removeWindow(window); + window.chrome.destroy(); + window.destroy(); } onHeightChanged: CompositorLogic.relayout(); diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp index e0f213aa4..aa6afd7aa 100644 --- a/examples/qwindow-compositor/qwindowcompositor.cpp +++ b/examples/qwindow-compositor/qwindowcompositor.cpp @@ -52,6 +52,55 @@ #include <QPainter> #include <QtCompositor/qwaylandinput.h> +#include <QtCompositor/qwaylandbufferref.h> + +static GLuint textureFromImage(const QImage &image) +{ + GLuint texture = 0; + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + QImage tx = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tx.width(), tx.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, tx.constBits()); + glBindTexture(GL_TEXTURE_2D, 0); + return texture; +} + +class BufferAttacher : public QWaylandBufferAttacher +{ +public: + void attach(const QWaylandBufferRef &ref) Q_DECL_OVERRIDE + { + if (bufferRef) { + if (ownTexture) + glDeleteTextures(1, &texture); + else + bufferRef.destroyTexture(); + } + + bufferRef = ref; + + if (bufferRef) { + if (bufferRef.isShm()) { + texture = textureFromImage(bufferRef.image()); + ownTexture = true; + } else { + texture = bufferRef.createTexture(); + ownTexture = false; + } + } + } + + QImage image() const + { + if (!bufferRef || !bufferRef.isShm()) + return QImage(); + return bufferRef.image(); + } + + QWaylandBufferRef bufferRef; + GLuint texture; + bool ownTexture; +}; QWindowCompositor::QWindowCompositor(QOpenGLWindow *window) : QWaylandCompositor(window, 0, DefaultExtensions | SubSurfaceExtension) @@ -118,9 +167,9 @@ void QWindowCompositor::ensureKeyboardFocusSurface(QWaylandSurface *oldSurface) defaultInputDevice()->setKeyboardFocus(m_surfaces.isEmpty() ? 0 : m_surfaces.last()); } -void QWindowCompositor::surfaceDestroyed(QObject *object) +void QWindowCompositor::surfaceDestroyed() { - QWaylandSurface *surface = static_cast<QWaylandSurface *>(object); + QWaylandSurface *surface = static_cast<QWaylandSurface *>(sender()); m_surfaces.removeOne(surface); ensureKeyboardFocusSurface(surface); m_renderScheduler.start(0); @@ -157,6 +206,7 @@ void QWindowCompositor::surfaceUnmapped() m_surfaces.insert(0, surface); ensureKeyboardFocusSurface(surface); + m_renderScheduler.start(0); } void QWindowCompositor::surfaceCommitted() @@ -178,13 +228,15 @@ void QWindowCompositor::surfaceCommitted(QWaylandSurface *surface) void QWindowCompositor::surfaceCreated(QWaylandSurface *surface) { - connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); + connect(surface, SIGNAL(surfaceDestroyed()), this, SLOT(surfaceDestroyed())); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped())); - connect(surface, SIGNAL(committed()), this, SLOT(surfaceCommitted())); + connect(surface, SIGNAL(redraw()), this, SLOT(surfaceCommitted())); connect(surface, SIGNAL(extendedSurfaceReady()), this, SLOT(sendExpose())); connect(surface, SIGNAL(posChanged()), this, SLOT(surfacePosChanged())); m_renderScheduler.start(0); + + surface->setBufferAttacher(new BufferAttacher); } void QWindowCompositor::sendExpose() @@ -197,7 +249,10 @@ void QWindowCompositor::updateCursor() { if (!m_cursorSurface) return; - QCursor cursor(QPixmap::fromImage(m_cursorSurface->image()), m_cursorHotspotX, m_cursorHotspotY); + + QImage image = static_cast<BufferAttacher *>(m_cursorSurface->bufferAttacher())->image(); + + QCursor cursor(QPixmap::fromImage(image), m_cursorHotspotX, m_cursorHotspotY); static bool cursorIsSet = false; if (cursorIsSet) { QGuiApplication::changeOverrideCursor(cursor); @@ -215,11 +270,13 @@ QPointF QWindowCompositor::toSurface(QWaylandSurface *surface, const QPointF &po void QWindowCompositor::setCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY) { if ((m_cursorSurface != surface) && surface) - connect(surface, SIGNAL(damaged(QRect)), this, SLOT(updateCursor())); + connect(surface, SIGNAL(configure()), this, SLOT(updateCursor())); m_cursorSurface = surface; m_cursorHotspotX = hotspotX; m_cursorHotspotY = hotspotY; + if (!m_cursorSurface->bufferAttacher()) + m_cursorSurface->setBufferAttacher(new BufferAttacher); } QWaylandSurface *QWindowCompositor::surfaceAt(const QPointF &point, QPointF *local) @@ -236,34 +293,14 @@ QWaylandSurface *QWindowCompositor::surfaceAt(const QPointF &point, QPointF *loc return 0; } -static GLuint textureFromImage(const QImage &image) -{ - GLuint texture = 0; - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - QImage tx = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tx.width(), tx.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, tx.constBits()); - glBindTexture(GL_TEXTURE_2D, 0); - return texture; -} - -GLuint QWindowCompositor::composeSurface(QWaylandSurface *surface, bool *textureOwned) +GLuint QWindowCompositor::composeSurface(QWaylandSurface *surface) { - GLuint texture = 0; - QSize windowSize = surface->size(); - surface->swapBuffers(); QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions(); functions->glBindFramebuffer(GL_FRAMEBUFFER, m_surface_fbo); - if (surface->type() == QWaylandSurface::Shm) { - texture = textureFromImage(surface->image()); - *textureOwned = true; - } else if (surface->type() == QWaylandSurface::Texture) { - texture = surface->texture(); - *textureOwned = false; - } + GLuint texture = static_cast<BufferAttacher *>(surface->bufferAttacher())->texture; functions->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); @@ -287,19 +324,11 @@ void QWindowCompositor::paintChildren(QWaylandSurface *surface, QWaylandSurface QWaylandSurface *subSurface = i.next(); QPointF p = subSurface->mapTo(window,QPointF(0,0)); QSize subSize = subSurface->size(); - subSurface->swapBuffers(); if (subSize.isValid()) { - GLuint texture = 0; - if (subSurface->type() == QWaylandSurface::Texture) { - texture = subSurface->texture(); - } else if (surface->type() == QWaylandSurface::Shm) { - texture = textureFromImage(subSurface->image()); - } + GLuint texture = static_cast<BufferAttacher *>(subSurface->bufferAttacher())->texture; QRect geo(p.toPoint(),subSize); if (texture > 0) m_textureBlitter->drawTexture(texture,geo,windowSize,0,window->isYInverted(),subSurface->isYInverted()); - if (surface->type() == QWaylandSurface::Shm) - glDeleteTextures(1, &texture); } paintChildren(subSurface,window,windowSize); } @@ -326,12 +355,9 @@ void QWindowCompositor::render() foreach (QWaylandSurface *surface, m_surfaces) { if (!surface->visible()) continue; - bool ownsTexture; - GLuint texture = composeSurface(surface, &ownsTexture); + GLuint texture = composeSurface(surface); QRect geo(surface->pos().toPoint(),surface->size()); m_textureBlitter->drawTexture(texture,geo,m_window->size(),0,false,surface->isYInverted()); - if (ownsTexture) - glDeleteTextures(1, &texture); } m_textureBlitter->release(); diff --git a/examples/qwindow-compositor/qwindowcompositor.h b/examples/qwindow-compositor/qwindowcompositor.h index e26a09ebc..3ecbdbc1a 100644 --- a/examples/qwindow-compositor/qwindowcompositor.h +++ b/examples/qwindow-compositor/qwindowcompositor.h @@ -58,7 +58,7 @@ public: ~QWindowCompositor(); private slots: - void surfaceDestroyed(QObject *object); + void surfaceDestroyed(); void surfaceMapped(); void surfaceUnmapped(); void surfaceCommitted(); @@ -71,7 +71,7 @@ protected: QWaylandSurface* surfaceAt(const QPointF &point, QPointF *local = 0); - GLuint composeSurface(QWaylandSurface *surface, bool *textureOwned); + GLuint composeSurface(QWaylandSurface *surface); void paintChildren(QWaylandSurface *surface, QWaylandSurface *window, const QSize &windowSize); diff --git a/examples/server-buffer/compositor/main.cpp b/examples/server-buffer/compositor/main.cpp index ff375a8c6..a30ea0895 100644 --- a/examples/server-buffer/compositor/main.cpp +++ b/examples/server-buffer/compositor/main.cpp @@ -38,9 +38,8 @@ ** ****************************************************************************/ -#include "qwaylandcompositor.h" +#include "qwaylandquickcompositor.h" #include "qwaylandsurface.h" -#include "qwaylandsurfaceitem.h" #include <QGuiApplication> #include <QTimer> @@ -63,14 +62,14 @@ class QmlCompositor : public QQuickView - , public QWaylandCompositor + , public QWaylandQuickCompositor , public QtWaylandServer::qt_share_buffer { Q_OBJECT public: QmlCompositor() - : QWaylandCompositor(this, 0, DefaultExtensions | SubSurfaceExtension) + : QWaylandQuickCompositor(this, 0, DefaultExtensions | SubSurfaceExtension) , QtWaylandServer::qt_share_buffer(QWaylandCompositor::handle()->wl_display()) , m_server_buffer_32_bit(0) , m_server_buffer_item_32_bit(0) @@ -83,7 +82,6 @@ public: create(); grabWindow(); - connect(this, SIGNAL(beforeSynchronizing()), this, SLOT(startFrame()), Qt::DirectConnection); connect(this, SIGNAL(afterRendering()), this, SLOT(sendCallbacks())); connect(this, SIGNAL(sceneGraphInitialized()), this, SLOT(initiateServerBuffer()),Qt::DirectConnection); @@ -98,38 +96,26 @@ signals: void serverBuffersCreated(); public slots: - void destroyWindow(QVariant window) - { - qvariant_cast<QObject *>(window)->deleteLater(); - } - void destroyClientForWindow(QVariant window) { - QWaylandSurface *surface = qobject_cast<QWaylandSurfaceItem *>(qvariant_cast<QObject *>(window))->surface(); + QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(qvariant_cast<QObject *>(window)); destroyClientForSurface(surface); } private slots: void surfaceMapped() { QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender()); - QQuickItem *item = surface->surfaceItem(); - emit windowAdded(QVariant::fromValue(static_cast<QQuickItem *>(item))); + emit windowAdded(QVariant::fromValue(surface)); } void surfaceUnmapped() { QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender()); - QQuickItem *item = surface->surfaceItem(); - emit windowDestroyed(QVariant::fromValue(item)); + emit windowDestroyed(QVariant::fromValue(surface)); } void surfaceDestroyed(QObject *object) { QWaylandSurface *surface = static_cast<QWaylandSurface *>(object); - QQuickItem *item = surface->surfaceItem(); - emit windowDestroyed(QVariant::fromValue(item)); - } - - void startFrame() { - frameStarted(); + emit windowDestroyed(QVariant::fromValue(surface)); } void sendCallbacks() { @@ -219,11 +205,6 @@ protected: } void surfaceCreated(QWaylandSurface *surface) { - QWaylandSurfaceItem *item = new QWaylandSurfaceItem(surface, rootObject()); - item->setUseTextureAlpha(true); - item->setTouchEventsEnabled(true); - - connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *))); connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped())); connect(surface,SIGNAL(unmapped()), this,SLOT(surfaceUnmapped())); } @@ -270,7 +251,6 @@ int main(int argc, char *argv[]) compositor.rootContext()->setContextProperty("compositor", &compositor); QObject::connect(&compositor, SIGNAL(windowAdded(QVariant)), compositor.rootObject(), SLOT(windowAdded(QVariant))); - QObject::connect(&compositor, SIGNAL(windowDestroyed(QVariant)), compositor.rootObject(), SLOT(windowDestroyed(QVariant))); QObject::connect(&compositor, SIGNAL(windowResized(QVariant)), compositor.rootObject(), SLOT(windowResized(QVariant))); QObject::connect(&compositor, SIGNAL(serverBufferItemCreated(QVariant)), compositor.rootObject(), SLOT(serverBufferItemCreated(QVariant))); diff --git a/examples/server-buffer/compositor/qml/main.qml b/examples/server-buffer/compositor/qml/main.qml index 231fb5169..1beddbf1d 100644 --- a/examples/server-buffer/compositor/qml/main.qml +++ b/examples/server-buffer/compositor/qml/main.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.0 +import QtCompositor 1.0 Item { id: root @@ -58,15 +59,21 @@ Item { anchors.fill: parent } - function windowAdded(window) { - window.parent = root; + Component { + id: windowItem + WaylandSurfaceItem { + onSurfaceDestroyed: { + destroy(); + } + } } - function windowResized(window) { + function windowAdded(window) { + var item = windowItem.createObject(root); + item.surface = window; } - function windowDestroyed(window) { - compositor.destroyWindow(window); + function windowResized(window) { } function removeWindow(window) { |