Add QWayland::shm object to client
Allows more flexibility for the client to determine additional shm formats supported by the compositor in addition to the standard types. For example YUV formats. Change-Id: Ib4a47c1d5bbeed9314d5ad5f5f8e1551c1dd71e4 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com> Reviewed-by: Mikko Levonmaa <mikko.levonmaa@bitfactor.fi>
This commit is contained in:
parent
23dbf71265
commit
b69db39d48
@ -83,6 +83,7 @@ SOURCES += qwaylandintegration.cpp \
|
|||||||
qwaylandwindowmanagerintegration.cpp \
|
qwaylandwindowmanagerintegration.cpp \
|
||||||
qwaylandinputcontext.cpp \
|
qwaylandinputcontext.cpp \
|
||||||
qwaylanddatadevice.cpp \
|
qwaylanddatadevice.cpp \
|
||||||
|
qwaylandshm.cpp \
|
||||||
|
|
||||||
HEADERS += qwaylandintegration_p.h \
|
HEADERS += qwaylandintegration_p.h \
|
||||||
qwaylandnativeinterface_p.h \
|
qwaylandnativeinterface_p.h \
|
||||||
@ -116,6 +117,7 @@ HEADERS += qwaylandintegration_p.h \
|
|||||||
qwaylandwindowmanagerintegration_p.h \
|
qwaylandwindowmanagerintegration_p.h \
|
||||||
qwaylandinputcontext_p.h \
|
qwaylandinputcontext_p.h \
|
||||||
qwaylanddatadevice_p.h \
|
qwaylanddatadevice_p.h \
|
||||||
|
qwaylandshm_p.h \
|
||||||
|
|
||||||
include(hardwareintegration/hardwareintegration.pri)
|
include(hardwareintegration/hardwareintegration.pri)
|
||||||
include(shellintegration/shellintegration.pri)
|
include(shellintegration/shellintegration.pri)
|
||||||
|
@ -59,7 +59,7 @@ QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
|
|||||||
int cursorSize = cursorSizeFromEnv.toInt(&hasCursorSize);
|
int cursorSize = cursorSizeFromEnv.toInt(&hasCursorSize);
|
||||||
if (!hasCursorSize || cursorSize <= 0)
|
if (!hasCursorSize || cursorSize <= 0)
|
||||||
cursorSize = 32;
|
cursorSize = 32;
|
||||||
mCursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, mDisplay->shm());
|
mCursorTheme = wl_cursor_theme_load(cursorTheme, cursorSize, mDisplay->shm()->object());
|
||||||
if (!mCursorTheme)
|
if (!mCursorTheme)
|
||||||
qDebug() << "Could not load theme" << cursorTheme;
|
qDebug() << "Could not load theme" << cursorTheme;
|
||||||
initCursorMap();
|
initCursorMap();
|
||||||
|
@ -255,7 +255,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
|
|||||||
mCompositorVersion = qMin((int)version, 3);
|
mCompositorVersion = qMin((int)version, 3);
|
||||||
mCompositor.init(registry, id, mCompositorVersion);
|
mCompositor.init(registry, id, mCompositorVersion);
|
||||||
} else if (interface == QStringLiteral("wl_shm")) {
|
} else if (interface == QStringLiteral("wl_shm")) {
|
||||||
mShm = static_cast<struct wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface,1));
|
mShm.reset(new QWaylandShm(this, version, id));
|
||||||
} else if (interface == QStringLiteral("xdg_shell")
|
} else if (interface == QStringLiteral("xdg_shell")
|
||||||
&& qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) {
|
&& qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) {
|
||||||
mShellXdg.reset(new QWaylandXdgShell(registry,id));
|
mShellXdg.reset(new QWaylandXdgShell(registry,id));
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <QtWaylandClient/private/qwayland-wayland.h>
|
#include <QtWaylandClient/private/qwayland-wayland.h>
|
||||||
#include <QtWaylandClient/private/qwaylandclientexport_p.h>
|
#include <QtWaylandClient/private/qwaylandclientexport_p.h>
|
||||||
#include <QtWaylandClient/private/qwayland-xdg-shell.h>
|
#include <QtWaylandClient/private/qwayland-xdg-shell.h>
|
||||||
|
#include <QtWaylandClient/private/qwaylandshm_p.h>
|
||||||
|
|
||||||
struct wl_cursor_image;
|
struct wl_cursor_image;
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ public:
|
|||||||
* to enable many listeners at once. */
|
* to enable many listeners at once. */
|
||||||
void addRegistryListener(RegistryListener listener, void *data);
|
void addRegistryListener(RegistryListener listener, void *data);
|
||||||
|
|
||||||
struct wl_shm *shm() const { return mShm; }
|
QWaylandShm *shm() const { return mShm.data(); }
|
||||||
|
|
||||||
static uint32_t currentTimeMillisec();
|
static uint32_t currentTimeMillisec();
|
||||||
|
|
||||||
@ -176,7 +177,7 @@ private:
|
|||||||
struct wl_display *mDisplay;
|
struct wl_display *mDisplay;
|
||||||
struct wl_event_queue *mEventQueue;
|
struct wl_event_queue *mEventQueue;
|
||||||
QtWayland::wl_compositor mCompositor;
|
QtWayland::wl_compositor mCompositor;
|
||||||
struct wl_shm *mShm;
|
QScopedPointer<QWaylandShm> mShm;
|
||||||
QThread *mEventThread;
|
QThread *mEventThread;
|
||||||
QWaylandEventThread *mEventThreadObject;
|
QWaylandEventThread *mEventThreadObject;
|
||||||
QScopedPointer<QtWayland::wl_shell> mShell;
|
QScopedPointer<QtWayland::wl_shell> mShell;
|
||||||
|
80
src/plugins/platforms/wayland/qwaylandshm.cpp
Normal file
80
src/plugins/platforms/wayland/qwaylandshm.cpp
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#include <QtWaylandClient/private/qwaylandshm_p.h>
|
||||||
|
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
|
||||||
|
|
||||||
|
#include "qwaylandshmformathelper.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace QtWaylandClient {
|
||||||
|
|
||||||
|
QWaylandShm::QWaylandShm(QWaylandDisplay *display, int version, uint32_t id)
|
||||||
|
: QtWayland::wl_shm(display->wl_registry(), id, qMin(version, 1))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QWaylandShm::~QWaylandShm()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void QWaylandShm::shm_format(uint32_t format)
|
||||||
|
{
|
||||||
|
m_formats << format;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QWaylandShm::formatSupported(wl_shm_format format) const
|
||||||
|
{
|
||||||
|
return m_formats.contains(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QWaylandShm::formatSupported(QImage::Format format) const
|
||||||
|
{
|
||||||
|
wl_shm_format fmt = formatFrom(format);
|
||||||
|
return formatSupported(fmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_shm_format QWaylandShm::formatFrom(QImage::Format format)
|
||||||
|
{
|
||||||
|
return QWaylandShmFormatHelper::fromQImageFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage::Format QWaylandShm::formatFrom(wl_shm_format format)
|
||||||
|
{
|
||||||
|
return QWaylandShmFormatHelper::fromWaylandShmFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
76
src/plugins/platforms/wayland/qwaylandshm_p.h
Normal file
76
src/plugins/platforms/wayland/qwaylandshm_p.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 LG Electronics Inc, author: <mikko.levonmaa@lge.com>
|
||||||
|
** Contact: http://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:LGPL21$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** As a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QWAYLANDSHM_H
|
||||||
|
#define QWAYLANDSHM_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
|
#include <QtWaylandClient/private/qwaylandclientexport_p.h>
|
||||||
|
#include <QtWaylandClient/private/qwayland-wayland.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
namespace QtWaylandClient {
|
||||||
|
|
||||||
|
class QWaylandDisplay;
|
||||||
|
|
||||||
|
class Q_WAYLAND_CLIENT_EXPORT QWaylandShm : public QtWayland::wl_shm
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
QWaylandShm(QWaylandDisplay *display, int version, uint32_t id);
|
||||||
|
~QWaylandShm();
|
||||||
|
|
||||||
|
bool formatSupported(wl_shm_format format) const;
|
||||||
|
bool formatSupported(QImage::Format format) const;
|
||||||
|
|
||||||
|
static wl_shm_format formatFrom(QImage::Format format);
|
||||||
|
static QImage::Format formatFrom(wl_shm_format format);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void shm_format(uint32_t format);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<uint32_t> m_formats;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -42,7 +42,6 @@
|
|||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-client-protocol.h>
|
#include <wayland-client-protocol.h>
|
||||||
#include "qwaylandshmformathelper.h"
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -85,11 +84,12 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_shm_format wl_format = QWaylandShmFormatHelper::fromQImageFormat(format);
|
QWaylandShm* shm = display->shm();
|
||||||
|
wl_shm_format wl_format = shm->formatFrom(format);
|
||||||
mImage = QImage(data, size.width(), size.height(), stride, format);
|
mImage = QImage(data, size.width(), size.height(), stride, format);
|
||||||
mImage.setDevicePixelRatio(qreal(scale));
|
mImage.setDevicePixelRatio(qreal(scale));
|
||||||
|
|
||||||
mShmPool = wl_shm_create_pool(display->shm(), fd, alloc);
|
mShmPool = wl_shm_create_pool(shm->object(), fd, alloc);
|
||||||
mBuffer = wl_shm_pool_create_buffer(mShmPool,0, size.width(), size.height(),
|
mBuffer = wl_shm_pool_create_buffer(mShmPool,0, size.width(), size.height(),
|
||||||
stride, wl_format);
|
stride, wl_format);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user