diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-07-08 09:20:55 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2020-08-21 07:09:11 +0200 |
commit | d806bbf08b8501e053c791bdd44a267362436c42 (patch) | |
tree | 9178a9e8a1c75f61c24ef2bb09aa0c6f9b9fe4d2 /src/compositor/compositor_api/qwaylandcompositor.cpp | |
parent | f3d40b02558f5eca54ddb33b132d350b958cac1e (diff) |
Add API for selecting supported wl_shm formats
We would always reported all formats we could convert from
as supported on the wl_shm protocol. This would sometimes
cause clients to pick formats that required internal conversion
when creating OpenGL textures from the images. To avoid
this, we default to only supporting the RGB32 and
ARGB32_Premultiplied formats (which are required and advertised
automatically) and if the user wants to add additional formats,
we now have a additionalShmFormats property for this.
[ChangeLog][QtWaylandCompositor] The compositor will now by
default only advertise support for the required wl_shm formats.
Additional formats can be added to the list by setting the
additionalShmFormats property on the compositor.
Fixes: QTBUG-77531
Change-Id: Ibd5d5be2a37968353c00308abbfff7ca6f8d310d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandcompositor.cpp')
-rw-r--r-- | src/compositor/compositor_api/qwaylandcompositor.cpp | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index fb99f9413..5912bab25 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWaylandCompositor module of the Qt Toolkit. @@ -199,9 +199,9 @@ void QWaylandCompositorPrivate::init() buffer_manager = new QtWayland::BufferManager(q); wl_display_init_shm(display); - const QList<wl_shm_format> formats = QWaylandSharedMemoryFormatHelper::supportedWaylandFormats(); - for (wl_shm_format format : formats) - wl_display_add_shm_format(display, format); + + for (QWaylandCompositor::ShmFormat format : shmFormats) + wl_display_add_shm_format(display, wl_shm_format(format)); if (!socket_name.isEmpty()) { if (wl_display_add_socket(display, socket_name.constData())) @@ -1017,6 +1017,52 @@ void QWaylandCompositor::grabSurface(QWaylandSurfaceGrabber *grabber, const QWay } } +/*! + * \qmlproperty list<enum> QtWaylandCompositor::WaylandCompositor::additionalShmFormats + * + * This property holds the list of additional wl_shm formats advertised as supported by the + * compositor. + * + * By default, only the required ShmFormat_ARGB8888 and ShmFormat_XRGB8888 are listed and this + * list will empty. Additional formats may require conversion internally and can thus affect + * performance. + * + * This property must be set before the compositor component is completed. Subsequent changes + * will have no effect. + * + * \since 6.0 + */ + +/*! + * \property QWaylandCompositor::additionalShmFormats + * + * This property holds the list of additional wl_shm formats advertised as supported by the + * compositor. + * + * By default, only the required ShmFormat_ARGB8888 and ShmFormat_XRGB8888 are listed and this + * list will empty. + * + * This property must be set before the compositor is \l{create()}{created}. Subsequent changes + * will have no effect. + * + * \since 6.0 + */ +void QWaylandCompositor::setAdditionalShmFormats(const QVector<ShmFormat> &additionalShmFormats) +{ + Q_D(QWaylandCompositor); + if (d->initialized) + qCWarning(qLcWaylandCompositorHardwareIntegration) << "Setting QWaylandCompositor::additionalShmFormats after initialization has no effect"; + + d->shmFormats = additionalShmFormats; + emit additionalShmFormatsChanged(); +} + +QVector<QWaylandCompositor::ShmFormat> QWaylandCompositor::additionalShmFormats() const +{ + Q_D(const QWaylandCompositor); + return d->shmFormats; +} + QT_END_NAMESPACE #include "moc_qwaylandcompositor.cpp" |