2021-07-20 17:02:13 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2018 Fredrik Höglund <fredrik@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2021-11-23 13:15:41 +00:00
|
|
|
SPDX-FileCopyrightText: 2021 Xaver Hugl <xaver.hugl@gmail.com>
|
2021-07-20 17:02:13 +00:00
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "clientbuffer.h"
|
|
|
|
#include "clientbufferintegration.h"
|
|
|
|
|
2022-08-31 09:15:36 +00:00
|
|
|
#include "core/dmabufattributes.h"
|
2022-06-11 08:31:54 +00:00
|
|
|
|
2021-07-20 17:02:13 +00:00
|
|
|
#include <QHash>
|
|
|
|
#include <QSet>
|
2021-11-23 13:15:41 +00:00
|
|
|
#include <sys/types.h>
|
2021-07-20 17:02:13 +00:00
|
|
|
|
2023-04-07 10:04:06 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
class RenderBackend;
|
|
|
|
}
|
|
|
|
|
2021-07-20 17:02:13 +00:00
|
|
|
namespace KWaylandServer
|
|
|
|
{
|
|
|
|
class LinuxDmaBufV1ClientBufferPrivate;
|
|
|
|
class LinuxDmaBufV1ClientBufferIntegrationPrivate;
|
2021-11-23 13:15:41 +00:00
|
|
|
class LinuxDmaBufV1FeedbackPrivate;
|
2021-07-20 17:02:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The LinuxDmaBufV1ClientBuffer class represents a linux dma-buf client buffer.
|
|
|
|
*
|
|
|
|
* The LinuxDmaBufV1ClientBuffer can be used even after the underlying wl_buffer object
|
|
|
|
* is destroyed by the client.
|
|
|
|
*/
|
2022-04-22 09:27:33 +00:00
|
|
|
class KWIN_EXPORT LinuxDmaBufV1ClientBuffer : public ClientBuffer
|
2021-07-20 17:02:13 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_DECLARE_PRIVATE(LinuxDmaBufV1ClientBuffer)
|
|
|
|
|
|
|
|
public:
|
2022-07-14 18:27:08 +00:00
|
|
|
LinuxDmaBufV1ClientBuffer(KWin::DmaBufAttributes &&attrs, quint32 flags);
|
2021-07-20 17:02:13 +00:00
|
|
|
~LinuxDmaBufV1ClientBuffer() override;
|
|
|
|
|
|
|
|
quint32 format() const;
|
|
|
|
quint32 flags() const;
|
2022-07-14 18:27:08 +00:00
|
|
|
const KWin::DmaBufAttributes &attributes() const;
|
2021-07-20 17:02:13 +00:00
|
|
|
|
|
|
|
QSize size() const override;
|
|
|
|
bool hasAlphaChannel() const override;
|
|
|
|
Origin origin() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initialize(wl_resource *resource);
|
|
|
|
friend class LinuxDmaBufParamsV1;
|
|
|
|
};
|
|
|
|
|
2022-04-22 09:27:33 +00:00
|
|
|
class KWIN_EXPORT LinuxDmaBufV1Feedback : public QObject
|
2021-12-06 16:08:01 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
~LinuxDmaBufV1Feedback() override;
|
|
|
|
|
|
|
|
enum class TrancheFlag : uint32_t {
|
|
|
|
Scanout = 1,
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(TrancheFlags, TrancheFlag)
|
|
|
|
|
2022-04-19 10:14:26 +00:00
|
|
|
struct Tranche
|
|
|
|
{
|
2021-12-06 16:08:01 +00:00
|
|
|
dev_t device;
|
|
|
|
TrancheFlags flags;
|
2022-03-15 02:25:50 +00:00
|
|
|
QHash<uint32_t, QVector<uint64_t>> formatTable;
|
2021-12-06 16:08:01 +00:00
|
|
|
};
|
|
|
|
/**
|
|
|
|
* Sets the list of tranches for this feedback object, with lower indices
|
|
|
|
* indicating a higher priority / a more optimal configuration.
|
|
|
|
* The main device does not need to be included
|
|
|
|
*/
|
|
|
|
void setTranches(const QVector<Tranche> &tranches);
|
|
|
|
|
|
|
|
private:
|
|
|
|
LinuxDmaBufV1Feedback(LinuxDmaBufV1ClientBufferIntegrationPrivate *integration);
|
|
|
|
friend class LinuxDmaBufV1ClientBufferIntegrationPrivate;
|
|
|
|
friend class LinuxDmaBufV1FeedbackPrivate;
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<LinuxDmaBufV1FeedbackPrivate> d;
|
2021-12-06 16:08:01 +00:00
|
|
|
};
|
|
|
|
|
2021-07-20 17:02:13 +00:00
|
|
|
/**
|
|
|
|
* The LinuxDmaBufV1ClientBufferIntegration class provides support for linux dma-buf buffers.
|
|
|
|
*/
|
2022-04-22 09:27:33 +00:00
|
|
|
class KWIN_EXPORT LinuxDmaBufV1ClientBufferIntegration : public ClientBufferIntegration
|
2021-07-20 17:02:13 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit LinuxDmaBufV1ClientBufferIntegration(Display *display);
|
|
|
|
~LinuxDmaBufV1ClientBufferIntegration() override;
|
|
|
|
|
2023-04-07 10:04:06 +00:00
|
|
|
KWin::RenderBackend *renderBackend() const;
|
|
|
|
void setRenderBackend(KWin::RenderBackend *renderBackend);
|
2021-07-20 17:02:13 +00:00
|
|
|
|
2021-12-06 16:08:01 +00:00
|
|
|
void setSupportedFormatsWithModifiers(const QVector<LinuxDmaBufV1Feedback::Tranche> &tranches);
|
2021-07-20 17:02:13 +00:00
|
|
|
|
|
|
|
private:
|
2021-11-23 13:15:41 +00:00
|
|
|
friend class LinuxDmaBufV1ClientBufferIntegrationPrivate;
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<LinuxDmaBufV1ClientBufferIntegrationPrivate> d;
|
2021-07-20 17:02:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KWaylandServer
|