Currently, there exists the separation between the buffers provided by the clients and the buffers created by the compositor. In hindsight, this separation is not great because it leads to specialized code paths in the output backend. For example, we have a separate code path for direct scanout and presenting composited frame. But you could view the latter case as "direct scanout of a compositor buffer". The main idea behind the buffer type is to provide a base buffer type for client buffers and composited frame buffers (not drm fbs) that we could pass around, import as textures, etc.
59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
/*
|
|
SPDX-FileCopyrightText: 2023 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "kwin_export.h"
|
|
|
|
#include <QObject>
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
/**
|
|
* 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);
|
|
|
|
/**
|
|
* This enum type is used to specify the corner where the origin is. That is, the
|
|
* buffer corner where 0,0 is located.
|
|
*/
|
|
enum class Origin {
|
|
TopLeft,
|
|
BottomLeft,
|
|
};
|
|
|
|
bool isReferenced() const;
|
|
bool isDropped() const;
|
|
|
|
void ref();
|
|
void unref();
|
|
void drop();
|
|
|
|
virtual QSize size() const = 0;
|
|
virtual bool hasAlphaChannel() const = 0;
|
|
virtual Origin origin() const = 0;
|
|
|
|
Q_SIGNALS:
|
|
void released();
|
|
void dropped();
|
|
|
|
protected:
|
|
int m_refCount = 0;
|
|
bool m_dropped = false;
|
|
};
|
|
|
|
} // namespace KWin
|