diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2012-04-06 13:35:43 +0200 |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2012-04-10 18:54:33 +0200 |
commit | a72e662b4e5c45988bbe06d587e167901b5606da (patch) | |
tree | 74f4aa9e6338ac62b90403bcd914065d8f08a8b0 /tests | |
parent | 585a1080cc755c0c7820a06ecfd059f75af60bfd (diff) |
Update wayland_sha1 and implement buffer_pool interface
Change-Id: I0628a7655a6deb061a5d0b6c6304c89d8655cf11
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/client/client.pro | 2 | ||||
-rw-r--r-- | tests/auto/client/mockcompositor.cpp | 3 | ||||
-rw-r--r-- | tests/auto/client/mockshm.cpp | 96 | ||||
-rw-r--r-- | tests/auto/client/mockshm.h | 62 | ||||
-rw-r--r-- | tests/auto/client/mocksurface.cpp | 12 | ||||
-rw-r--r-- | tests/auto/client/tst_client.cpp | 4 | ||||
-rw-r--r-- | tests/auto/compositor/mockclient.cpp | 4 | ||||
-rw-r--r-- | tests/auto/compositor/mockclient.h | 4 |
8 files changed, 18 insertions, 169 deletions
diff --git a/tests/auto/client/client.pro b/tests/auto/client/client.pro index 6bfe82b78..9a7e2c8c2 100644 --- a/tests/auto/client/client.pro +++ b/tests/auto/client/client.pro @@ -33,9 +33,7 @@ SOURCES += tst_client.cpp \ mockcompositor.cpp \ mockinput.cpp \ mockshell.cpp \ - mockshm.cpp \ mocksurface.cpp \ mockoutput.cpp HEADERS += mockcompositor.h \ - mockshm.h \ mocksurface.h diff --git a/tests/auto/client/mockcompositor.cpp b/tests/auto/client/mockcompositor.cpp index c751bccb2..119adc054 100644 --- a/tests/auto/client/mockcompositor.cpp +++ b/tests/auto/client/mockcompositor.cpp @@ -204,7 +204,7 @@ Compositor::Compositor() wl_display_add_global(m_display, &wl_output_interface, this, bindOutput); wl_display_add_global(m_display, &wl_shell_interface, this, bindShell); - initShm(); + wl_display_init_shm(m_display); m_loop = wl_display_get_event_loop(m_display); m_fd = wl_event_loop_get_fd(m_loop); @@ -212,7 +212,6 @@ Compositor::Compositor() Compositor::~Compositor() { - wl_shm_finish(m_shm); wl_display_destroy(m_display); } diff --git a/tests/auto/client/mockshm.cpp b/tests/auto/client/mockshm.cpp deleted file mode 100644 index 5c0ba38a3..000000000 --- a/tests/auto/client/mockshm.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "mockcompositor.h" -#include "mockshm.h" - -namespace Impl { - -ShmBuffer::ShmBuffer(wl_buffer *buffer) - : m_buffer(buffer) -{ - refresh(); -} - -void ShmBuffer::refresh() -{ - m_image = QImage(static_cast<uint8_t *>(wl_shm_buffer_get_data(m_buffer)), - m_buffer->width, m_buffer->height, - wl_shm_buffer_get_stride(m_buffer), - QImage::Format_ARGB32_Premultiplied); -} - -QImage ShmBuffer::image() const -{ - return m_image; -} - -static void shm_buffer_created(wl_buffer *buffer) -{ - buffer->user_data = new ShmBuffer(buffer); -} - -static void shm_buffer_damaged(wl_buffer *buffer, - int32_t x, int32_t y, - int32_t width, int32_t height) -{ - Q_UNUSED(QRect(x, y, width, height)); - static_cast<ShmBuffer *>(buffer->user_data)->refresh(); -} - -static void shm_buffer_destroyed(wl_buffer *buffer) -{ - delete static_cast<ShmBuffer *>(buffer->user_data); -} - -void Compositor::initShm() -{ - static struct wl_shm_callbacks shmCallbacks = { - shm_buffer_created, - shm_buffer_damaged, - shm_buffer_destroyed - }; - - m_shm = wl_shm_init(m_display, &shmCallbacks); -} - -} - diff --git a/tests/auto/client/mockshm.h b/tests/auto/client/mockshm.h deleted file mode 100644 index 96c77129f..000000000 --- a/tests/auto/client/mockshm.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qglobal.h> -#include <wayland-server.h> - -#include <QImage> - -namespace Impl { - -class ShmBuffer -{ -public: - ShmBuffer(wl_buffer *buffer); - - void refresh(); - QImage image() const; - -private: - wl_buffer *m_buffer; - QImage m_image; -}; - -} diff --git a/tests/auto/client/mocksurface.cpp b/tests/auto/client/mocksurface.cpp index 68c18bac6..f149822f6 100644 --- a/tests/auto/client/mocksurface.cpp +++ b/tests/auto/client/mocksurface.cpp @@ -41,7 +41,6 @@ #include "mocksurface.h" #include "mockcompositor.h" -#include "mockshm.h" namespace Impl { @@ -87,8 +86,15 @@ void surface_damage(wl_client *client, wl_resource *surfaceResource, if (!buffer) return; - if (wl_buffer_is_shm(buffer)) - surface->m_mockSurface->image = static_cast<ShmBuffer *>(buffer->user_data)->image(); + if (wl_buffer_is_shm(buffer)) { + int stride = wl_shm_buffer_get_stride(buffer); + uint format = wl_shm_buffer_get_format(buffer); + (void) format; + void *data = wl_shm_buffer_get_data(buffer); + const uchar *char_data = static_cast<const uchar *>(data); + QImage img(char_data, buffer->width, buffer->height, stride, QImage::Format_ARGB32_Premultiplied); + surface->m_mockSurface->image = img; + } wl_resource *frameCallback; wl_list_for_each(frameCallback, &surface->m_frameCallbackList, link) { diff --git a/tests/auto/client/tst_client.cpp b/tests/auto/client/tst_client.cpp index b6d434f8a..5b594198e 100644 --- a/tests/auto/client/tst_client.cpp +++ b/tests/auto/client/tst_client.cpp @@ -230,8 +230,8 @@ void tst_WaylandClient::backingStore() backingStore.flush(rect); - QTRY_COMPARE(surface->image.size(), rect.size()); - QTRY_COMPARE(surface->image.pixel(0, 0), color.rgba()); + QTRY_COMPARE(surface->image.size(), window.frameGeometry().size()); + QTRY_COMPARE(surface->image.pixel(window.frameMargins().left(), window.frameMargins().top()), color.rgba()); window.hide(); diff --git a/tests/auto/compositor/mockclient.cpp b/tests/auto/compositor/mockclient.cpp index 5dabfcd57..4b04164b6 100644 --- a/tests/auto/compositor/mockclient.cpp +++ b/tests/auto/compositor/mockclient.cpp @@ -167,7 +167,8 @@ ShmBuffer::ShmBuffer(const QSize &size, wl_shm *shm) } image = QImage(static_cast<uchar *>(data), size.width(), size.height(), stride, QImage::Format_ARGB32_Premultiplied); - handle = wl_shm_create_buffer(shm,fd, size.width(), size.height(), + shm_pool = wl_shm_create_pool(shm,fd,alloc); + handle = wl_shm_pool_create_buffer(shm_pool,0, size.width(), size.height(), stride, WL_SHM_FORMAT_ARGB8888); close(fd); } @@ -176,5 +177,6 @@ ShmBuffer::~ShmBuffer() { munmap(image.bits(), image.byteCount()); wl_buffer_destroy(handle); + wl_shm_pool_destroy(shm_pool); } diff --git a/tests/auto/compositor/mockclient.h b/tests/auto/compositor/mockclient.h index 2f2f665cd..e6be12fe7 100644 --- a/tests/auto/compositor/mockclient.h +++ b/tests/auto/compositor/mockclient.h @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "string.h" #include "wayland-client.h" #include <QObject> @@ -51,7 +52,8 @@ public: ShmBuffer(const QSize &size, wl_shm *shm); ~ShmBuffer(); - wl_buffer *handle; + struct wl_buffer *handle; + struct wl_shm_pool *shm_pool; QImage image; }; |