kwin/src/plugins/platforms/drm/drm_buffer_gbm.h

80 lines
1.6 KiB
C
Raw Normal View History

2020-08-02 22:22:19 +00:00
/*
KWin - the KDE window manager
This file is part of the KDE project.
2020-08-02 22:22:19 +00:00
SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
2020-08-02 22:22:19 +00:00
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KWIN_DRM_BUFFER_GBM_H
#define KWIN_DRM_BUFFER_GBM_H
#include "drm_buffer.h"
2021-03-22 14:46:09 +00:00
#include <QSharedPointer>
struct gbm_bo;
namespace KWaylandServer
{
class BufferInterface;
}
namespace KWin
{
class GbmSurface;
class GbmBuffer : public QObject
{
Q_OBJECT
public:
GbmBuffer(const QSharedPointer<GbmSurface> &surface);
GbmBuffer(gbm_bo *buffer, KWaylandServer::BufferInterface *bufferInterface);
virtual ~GbmBuffer();
gbm_bo* getBo() const {
return m_bo;
}
void releaseBuffer();
protected:
QSharedPointer<GbmSurface> m_surface;
gbm_bo *m_bo = nullptr;
KWaylandServer::BufferInterface *m_bufferInterface = nullptr;
void clearBufferInterface();
};
class DrmGbmBuffer : public DrmBuffer, public GbmBuffer
{
public:
DrmGbmBuffer(DrmGpu *gpu, const QSharedPointer<GbmSurface> &surface);
DrmGbmBuffer(DrmGpu *gpu, gbm_bo *buffer, KWaylandServer::BufferInterface *bufferInterface);
~DrmGbmBuffer() override;
bool needsModeChange(DrmBuffer *b) const override {
if (DrmGbmBuffer *sb = dynamic_cast<DrmGbmBuffer*>(b)) {
return hasBo() != sb->hasBo();
} else {
return true;
}
}
void releaseGbm() override;
bool hasBo() const {
return m_bo != nullptr;
}
private:
2021-03-06 15:24:52 +00:00
void initialize();
};
}
#endif