File indexing completed on 2024-05-12 05:32:22

0001 /*
0002     SPDX-FileCopyrightText: 2018 Fredrik Höglund <fredrik@kde.org>
0003     SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
0004     SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0005     SPDX-FileCopyrightText: 2021 Xaver Hugl <xaver.hugl@gmail.com>
0006 
0007     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0008 */
0009 #pragma once
0010 
0011 #include "core/graphicsbuffer.h"
0012 
0013 #include <QHash>
0014 #include <QSet>
0015 #include <sys/types.h>
0016 #include <wayland-server.h>
0017 
0018 namespace KWin
0019 {
0020 
0021 class Display;
0022 class LinuxDmaBufV1ClientBufferIntegrationPrivate;
0023 class LinuxDmaBufV1FeedbackPrivate;
0024 class RenderBackend;
0025 
0026 class KWIN_EXPORT LinuxDmaBufV1Feedback : public QObject
0027 {
0028     Q_OBJECT
0029 public:
0030     ~LinuxDmaBufV1Feedback() override;
0031 
0032     enum class TrancheFlag : uint32_t {
0033         Scanout = 1,
0034     };
0035     Q_DECLARE_FLAGS(TrancheFlags, TrancheFlag)
0036 
0037     struct Tranche
0038     {
0039         dev_t device;
0040         TrancheFlags flags;
0041         QHash<uint32_t, QList<uint64_t>> formatTable;
0042     };
0043     /**
0044      * Sets the list of tranches for this feedback object, with lower indices
0045      * indicating a higher priority / a more optimal configuration.
0046      * The main device does not need to be included
0047      */
0048     void setTranches(const QList<Tranche> &tranches);
0049 
0050 private:
0051     LinuxDmaBufV1Feedback(LinuxDmaBufV1ClientBufferIntegrationPrivate *integration);
0052     friend class LinuxDmaBufV1ClientBufferIntegrationPrivate;
0053     friend class LinuxDmaBufV1FeedbackPrivate;
0054     std::unique_ptr<LinuxDmaBufV1FeedbackPrivate> d;
0055 };
0056 
0057 /**
0058  * The LinuxDmaBufV1ClientBufferIntegration class provides support for linux dma-buf buffers.
0059  */
0060 class KWIN_EXPORT LinuxDmaBufV1ClientBufferIntegration : public QObject
0061 {
0062     Q_OBJECT
0063 
0064 public:
0065     explicit LinuxDmaBufV1ClientBufferIntegration(Display *display);
0066     ~LinuxDmaBufV1ClientBufferIntegration() override;
0067 
0068     RenderBackend *renderBackend() const;
0069     void setRenderBackend(RenderBackend *renderBackend);
0070 
0071     void setSupportedFormatsWithModifiers(const QList<LinuxDmaBufV1Feedback::Tranche> &tranches);
0072 
0073 private:
0074     friend class LinuxDmaBufV1ClientBufferIntegrationPrivate;
0075     std::unique_ptr<LinuxDmaBufV1ClientBufferIntegrationPrivate> d;
0076 };
0077 
0078 } // namespace KWin