diff --git a/tests/auto/wayland/client.pro b/tests/auto/wayland/client.pro index 6bfe82b78f5..9a7e2c8c2b7 100644 --- a/tests/auto/wayland/client.pro +++ b/tests/auto/wayland/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/wayland/mockcompositor.cpp b/tests/auto/wayland/mockcompositor.cpp index c751bccb27d..119adc0544a 100644 --- a/tests/auto/wayland/mockcompositor.cpp +++ b/tests/auto/wayland/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/wayland/mockshm.cpp b/tests/auto/wayland/mockshm.cpp deleted file mode 100644 index 5c0ba38a35d..00000000000 --- a/tests/auto/wayland/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(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(buffer->user_data)->refresh(); -} - -static void shm_buffer_destroyed(wl_buffer *buffer) -{ - delete static_cast(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/wayland/mockshm.h b/tests/auto/wayland/mockshm.h deleted file mode 100644 index 96c77129fad..00000000000 --- a/tests/auto/wayland/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 -#include - -#include - -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/wayland/mocksurface.cpp b/tests/auto/wayland/mocksurface.cpp index 68c18bac634..f149822f68e 100644 --- a/tests/auto/wayland/mocksurface.cpp +++ b/tests/auto/wayland/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(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(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/wayland/tst_client.cpp b/tests/auto/wayland/tst_client.cpp index b6d434f8a5f..5b594198e75 100644 --- a/tests/auto/wayland/tst_client.cpp +++ b/tests/auto/wayland/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();