1// Copyright (C) 2016 LG Electronics Inc, author: <mikko.levonmaa@lge.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#include <QtWaylandClient/private/qwaylandshm_p.h>
4#include <QtWaylandClient/private/qwaylanddisplay_p.h>
5
6#include "qwaylandsharedmemoryformathelper_p.h"
7
8QT_BEGIN_NAMESPACE
9
10namespace QtWaylandClient {
11
12QWaylandShm::QWaylandShm(QWaylandDisplay *display, int version, uint32_t id)
13 : QtWayland::wl_shm(display->wl_registry(), id, qMin(version, 1))
14{
15}
16
17QWaylandShm::~QWaylandShm()
18{
19
20}
21
22void QWaylandShm::shm_format(uint32_t format)
23{
24 m_formats << format;
25}
26
27bool QWaylandShm::formatSupported(wl_shm_format format) const
28{
29 return m_formats.contains(format);
30}
31
32bool QWaylandShm::formatSupported(QImage::Format format) const
33{
34 wl_shm_format fmt = formatFrom(format);
35 return formatSupported(format: fmt);
36}
37
38wl_shm_format QWaylandShm::formatFrom(QImage::Format format)
39{
40 return QWaylandSharedMemoryFormatHelper::fromQImageFormat(format);
41}
42
43QImage::Format QWaylandShm::formatFrom(wl_shm_format format)
44{
45 return QWaylandSharedMemoryFormatHelper::fromWaylandShmFormat(format);
46}
47
48}
49
50QT_END_NAMESPACE
51

source code of qtwayland/src/client/qwaylandshm.cpp