2023-04-12 08:05:26 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2023 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "kwin_export.h"
|
2023-04-20 12:46:51 +00:00
|
|
|
#include "utils/filedescriptor.h"
|
2023-04-12 08:05:26 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
2023-04-13 09:37:42 +00:00
|
|
|
#include <QSize>
|
2023-04-12 08:05:26 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2023-04-20 12:46:51 +00:00
|
|
|
struct DmaBufAttributes
|
|
|
|
{
|
|
|
|
int planeCount = 0;
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
uint32_t format = 0;
|
|
|
|
uint64_t modifier = 0;
|
|
|
|
|
|
|
|
FileDescriptor fd[4];
|
|
|
|
int offset[4] = {0, 0, 0, 0};
|
|
|
|
int pitch[4] = {0, 0, 0, 0};
|
|
|
|
};
|
2023-04-17 08:50:58 +00:00
|
|
|
|
2023-04-13 09:37:42 +00:00
|
|
|
struct ShmAttributes
|
|
|
|
{
|
|
|
|
FileDescriptor fd;
|
|
|
|
int stride;
|
|
|
|
off_t offset;
|
|
|
|
QSize size;
|
|
|
|
uint32_t format;
|
|
|
|
};
|
|
|
|
|
2023-04-12 08:05:26 +00:00
|
|
|
/**
|
|
|
|
* The GraphicsBuffer class represents a chunk of memory containing graphics data.
|
|
|
|
*
|
|
|
|
* A graphics buffer can be referenced. In which case, it won't be destroyed until all
|
|
|
|
* references are dropped. You can use the isDropped() function to check whether the
|
|
|
|
* buffer has been marked as destroyed.
|
|
|
|
*/
|
|
|
|
class KWIN_EXPORT GraphicsBuffer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit GraphicsBuffer(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
bool isReferenced() const;
|
|
|
|
bool isDropped() const;
|
|
|
|
|
|
|
|
void ref();
|
|
|
|
void unref();
|
|
|
|
void drop();
|
|
|
|
|
|
|
|
virtual QSize size() const = 0;
|
|
|
|
virtual bool hasAlphaChannel() const = 0;
|
|
|
|
|
2023-04-17 08:50:58 +00:00
|
|
|
virtual const DmaBufAttributes *dmabufAttributes() const;
|
2023-04-13 09:37:42 +00:00
|
|
|
virtual const ShmAttributes *shmAttributes() const;
|
|
|
|
|
|
|
|
static bool alphaChannelFromDrmFormat(uint32_t format);
|
2023-04-17 08:50:58 +00:00
|
|
|
|
2023-04-12 08:05:26 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void released();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_refCount = 0;
|
|
|
|
bool m_dropped = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KWin
|