summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGiulio Camuffo <giulio.camuffo@jollamobile.com>2014-03-25 14:19:55 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-29 10:09:31 +0200
commitfc439e40e37f9c0b3108225f951fb19bb3abee80 (patch)
tree851bf52ee2004b3b201b5e86df7a4d4db7f79a2c /tests
parentc551e6df6c77f65a0db62b3ad4db539e86b75a30 (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 'tests')
-rw-r--r--tests/auto/compositor/tst_compositor.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/auto/compositor/tst_compositor.cpp b/tests/auto/compositor/tst_compositor.cpp
index 44fb2ff96..99f08a4e5 100644
--- a/tests/auto/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/tst_compositor.cpp
@@ -42,6 +42,8 @@
#include "mockclient.h"
#include "testcompositor.h"
+#include "qwaylandbufferref.h"
+
#include <QtTest/QtTest>
class tst_WaylandCompositor : public QObject
@@ -186,6 +188,24 @@ static void registerFrameCallback(wl_surface *surface, int *counter)
void tst_WaylandCompositor::frameCallback()
{
+ class BufferAttacher : public QWaylandBufferAttacher
+ {
+ public:
+ void attach(const QWaylandBufferRef &ref) Q_DECL_OVERRIDE
+ {
+ bufferRef = ref;
+ }
+
+ QImage image() const
+ {
+ if (!bufferRef || !bufferRef.isShm())
+ return QImage();
+ return bufferRef.image();
+ }
+
+ QWaylandBufferRef bufferRef;
+ };
+
TestCompositor compositor;
MockClient client;
@@ -200,7 +220,9 @@ void tst_WaylandCompositor::frameCallback()
QTRY_COMPARE(compositor.surfaces.size(), 1);
QWaylandSurface *waylandSurface = compositor.surfaces.at(0);
- QSignalSpy damagedSpy(waylandSurface, SIGNAL(damaged(const QRect &)));
+ BufferAttacher attacher;
+ waylandSurface->setBufferAttacher(&attacher);
+ QSignalSpy damagedSpy(waylandSurface, SIGNAL(damaged(const QRegion &)));
for (int i = 0; i < 10; ++i) {
registerFrameCallback(surface, &frameCounter);
@@ -209,7 +231,7 @@ void tst_WaylandCompositor::frameCallback()
QTRY_COMPARE(waylandSurface->type(), QWaylandSurface::Shm);
QTRY_COMPARE(damagedSpy.count(), i + 1);
- QCOMPARE(waylandSurface->image(), buffer.image);
+ QCOMPARE(static_cast<BufferAttacher *>(waylandSurface->bufferAttacher())->image(), buffer.image);
compositor.sendFrameCallbacks(QList<QWaylandSurface *>() << waylandSurface);
QTRY_COMPARE(frameCounter, i + 1);