Update wayland_sha1 and implement buffer_pool interface
Change-Id: I0628a7655a6deb061a5d0b6c6304c89d8655cf11 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
parent
fa72d60dbe
commit
e009b62037
@ -33,9 +33,7 @@ SOURCES += tst_client.cpp \
|
|||||||
mockcompositor.cpp \
|
mockcompositor.cpp \
|
||||||
mockinput.cpp \
|
mockinput.cpp \
|
||||||
mockshell.cpp \
|
mockshell.cpp \
|
||||||
mockshm.cpp \
|
|
||||||
mocksurface.cpp \
|
mocksurface.cpp \
|
||||||
mockoutput.cpp
|
mockoutput.cpp
|
||||||
HEADERS += mockcompositor.h \
|
HEADERS += mockcompositor.h \
|
||||||
mockshm.h \
|
|
||||||
mocksurface.h
|
mocksurface.h
|
||||||
|
@ -204,7 +204,7 @@ Compositor::Compositor()
|
|||||||
wl_display_add_global(m_display, &wl_output_interface, this, bindOutput);
|
wl_display_add_global(m_display, &wl_output_interface, this, bindOutput);
|
||||||
wl_display_add_global(m_display, &wl_shell_interface, this, bindShell);
|
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_loop = wl_display_get_event_loop(m_display);
|
||||||
m_fd = wl_event_loop_get_fd(m_loop);
|
m_fd = wl_event_loop_get_fd(m_loop);
|
||||||
@ -212,7 +212,6 @@ Compositor::Compositor()
|
|||||||
|
|
||||||
Compositor::~Compositor()
|
Compositor::~Compositor()
|
||||||
{
|
{
|
||||||
wl_shm_finish(m_shm);
|
|
||||||
wl_display_destroy(m_display);
|
wl_display_destroy(m_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
#include "mocksurface.h"
|
#include "mocksurface.h"
|
||||||
#include "mockcompositor.h"
|
#include "mockcompositor.h"
|
||||||
#include "mockshm.h"
|
|
||||||
|
|
||||||
namespace Impl {
|
namespace Impl {
|
||||||
|
|
||||||
@ -87,8 +86,15 @@ void surface_damage(wl_client *client, wl_resource *surfaceResource,
|
|||||||
if (!buffer)
|
if (!buffer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (wl_buffer_is_shm(buffer))
|
if (wl_buffer_is_shm(buffer)) {
|
||||||
surface->m_mockSurface->image = static_cast<ShmBuffer *>(buffer->user_data)->image();
|
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_resource *frameCallback;
|
||||||
wl_list_for_each(frameCallback, &surface->m_frameCallbackList, link) {
|
wl_list_for_each(frameCallback, &surface->m_frameCallbackList, link) {
|
||||||
|
@ -230,8 +230,8 @@ void tst_WaylandClient::backingStore()
|
|||||||
|
|
||||||
backingStore.flush(rect);
|
backingStore.flush(rect);
|
||||||
|
|
||||||
QTRY_COMPARE(surface->image.size(), rect.size());
|
QTRY_COMPARE(surface->image.size(), window.frameGeometry().size());
|
||||||
QTRY_COMPARE(surface->image.pixel(0, 0), color.rgba());
|
QTRY_COMPARE(surface->image.pixel(window.frameMargins().left(), window.frameMargins().top()), color.rgba());
|
||||||
|
|
||||||
window.hide();
|
window.hide();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user