backends/drm: move definitions into cpp file

This commit is contained in:
Xaver Hugl 2021-12-14 16:32:55 +01:00
parent ca79f11ede
commit 5d5bb2422c
14 changed files with 169 additions and 99 deletions

View file

@ -23,13 +23,38 @@
namespace KWin
{
DrmBuffer:: DrmBuffer(DrmGpu *gpu, uint32_t format, uint64_t modifier)
DrmBuffer::DrmBuffer(DrmGpu *gpu, uint32_t format, uint64_t modifier)
: m_gpu(gpu)
, m_format(format)
, m_modifier(modifier)
{
}
quint32 DrmBuffer::bufferId() const
{
return m_bufferId;
}
const QSize &DrmBuffer::size() const
{
return m_size;
}
DrmGpu *DrmBuffer::gpu() const
{
return m_gpu;
}
uint32_t DrmBuffer::format() const
{
return m_format;
}
uint64_t DrmBuffer::modifier() const
{
return m_modifier;
}
// DrmDumbBuffer
DrmDumbBuffer::DrmDumbBuffer(DrmGpu *gpu, const QSize &size, uint32_t drmFormat)
: DrmBuffer(gpu, drmFormat, DRM_FORMAT_MOD_LINEAR)
@ -105,4 +130,24 @@ bool DrmDumbBuffer::map(QImage::Format format)
return !m_image->isNull();
}
quint32 DrmDumbBuffer::handle() const
{
return m_handle;
}
QImage *DrmDumbBuffer::image() const
{
return m_image;
}
void *DrmDumbBuffer::data() const
{
return m_memory;
}
quint32 DrmDumbBuffer::stride() const
{
return m_stride;
}
}

View file

@ -25,23 +25,11 @@ public:
virtual bool needsModeChange(DrmBuffer *b) const {Q_UNUSED(b) return false;}
quint32 bufferId() const {
return m_bufferId;
}
const QSize &size() const {
return m_size;
}
DrmGpu *gpu() const {
return m_gpu;
}
uint32_t format() const {
return m_format;
}
uint64_t modifier() const {
return m_modifier;
}
quint32 bufferId() const;
const QSize &size() const;
DrmGpu *gpu() const;
uint32_t format() const;
uint64_t modifier() const;
protected:
quint32 m_bufferId = 0;
@ -60,18 +48,10 @@ public:
bool needsModeChange(DrmBuffer *b) const override;
bool map(QImage::Format format = QImage::Format_RGB32);
quint32 handle() const {
return m_handle;
}
QImage *image() const {
return m_image;
}
void *data() const {
return m_memory;
}
quint32 stride() const {
return m_stride;
}
quint32 handle() const;
QImage *image() const;
void *data() const;
quint32 stride() const;
private:
quint32 m_handle = 0;

View file

@ -88,6 +88,21 @@ KWaylandServer::ClientBuffer *GbmBuffer::clientBuffer() const
return m_clientBuffer;
}
gbm_bo* GbmBuffer::getBo() const
{
return m_bo;
}
void *GbmBuffer::mappedData() const
{
return m_data;
}
uint32_t GbmBuffer::stride() const
{
return m_stride;
}
DrmGbmBuffer::DrmGbmBuffer(DrmGpu *gpu, GbmSurface *surface, gbm_bo *bo)
: DrmBuffer(gpu, gbm_bo_get_format(bo), gbm_bo_get_modifier(bo)), GbmBuffer(surface, bo)
@ -151,4 +166,18 @@ void DrmGbmBuffer::initialize()
gbm_bo_set_user_data(m_bo, this, nullptr);
}
bool DrmGbmBuffer::needsModeChange(DrmBuffer *b) const
{
if (DrmGbmBuffer *sb = dynamic_cast<DrmGbmBuffer*>(b)) {
return hasBo() != sb->hasBo();
} else {
return true;
}
}
bool DrmGbmBuffer::hasBo() const
{
return m_bo != nullptr;
}
}

View file

@ -34,20 +34,13 @@ public:
GbmBuffer(gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer);
virtual ~GbmBuffer();
gbm_bo* getBo() const {
return m_bo;
}
void releaseBuffer();
bool map(uint32_t flags);
void *mappedData() const {
return m_data;
}
uint32_t stride() const {
return m_stride;
}
void *mappedData() const;
uint32_t stride() const;
KWaylandServer::ClientBuffer *clientBuffer() const;
gbm_bo* getBo() const;
protected:
GbmSurface *m_surface = nullptr;
@ -66,17 +59,8 @@ public:
DrmGbmBuffer(DrmGpu *gpu, gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer);
~DrmGbmBuffer() override;
bool needsModeChange(DrmBuffer *b) const override {
if (DrmGbmBuffer *sb = dynamic_cast<DrmGbmBuffer*>(b)) {
return hasBo() != sb->hasBo();
} else {
return true;
}
}
bool hasBo() const {
return m_bo != nullptr;
}
bool needsModeChange(DrmBuffer *b) const override;
bool hasBo() const;
private:
void initialize();

View file

@ -65,4 +65,14 @@ void DrmLeaseOutput::leaseEnded()
m_lease = nullptr;
}
KWaylandServer::DrmLeaseV1Interface *DrmLeaseOutput::lease() const
{
return m_lease;
}
DrmPipeline *DrmLeaseOutput::pipeline() const
{
return m_pipeline;
}
}

View file

@ -35,13 +35,8 @@ public:
void leased(KWaylandServer::DrmLeaseV1Interface *lease);
void leaseEnded();
KWaylandServer::DrmLeaseV1Interface *lease() const {
return m_lease;
}
DrmPipeline *pipeline() const {
return m_pipeline;
}
KWaylandServer::DrmLeaseV1Interface *lease() const;
DrmPipeline *pipeline() const;
private:
DrmPipeline *m_pipeline;

View file

@ -93,4 +93,20 @@ QVector<uint64_t> DrmVirtualOutput::supportedModifiers(uint32_t drmFormat) const
return {};
}
int DrmVirtualOutput::gammaRampSize() const
{
return 200;
}
bool DrmVirtualOutput::setGammaRamp(const GammaRamp &gamma)
{
Q_UNUSED(gamma);
return true;
}
bool DrmVirtualOutput::needsSoftwareTransformation() const
{
return false;
}
}

View file

@ -34,16 +34,9 @@ public:
bool isFormatSupported(uint32_t drmFormat) const override;
QVector<uint64_t> supportedModifiers(uint32_t drmFormat) const override;
int gammaRampSize() const override {
return 200;
}
bool setGammaRamp(const GammaRamp &gamma) override {
Q_UNUSED(gamma);
return true;
}
bool needsSoftwareTransformation() const override {
return false;
}
int gammaRampSize() const override;
bool setGammaRamp(const GammaRamp &gamma) override;
bool needsSoftwareTransformation() const override;
private:
void vblank(std::chrono::nanoseconds timestamp);

View file

@ -71,4 +71,19 @@ uint32_t DumbSwapchain::drmFormat() const
return m_format;
}
qsizetype DumbSwapchain::slotCount() const
{
return m_slots.count();
}
QSize DumbSwapchain::size() const
{
return m_size;
}
bool DumbSwapchain::isEmpty() const
{
return m_slots.isEmpty();
}
}

View file

@ -29,17 +29,9 @@ public:
QSharedPointer<DrmDumbBuffer> currentBuffer() const;
void releaseBuffer(QSharedPointer<DrmDumbBuffer> buffer);
qsizetype slotCount() const {
return m_slots.count();
}
QSize size() const {
return m_size;
}
bool isEmpty() const {
return m_slots.isEmpty();
}
qsizetype slotCount() const;
QSize size() const;
bool isEmpty() const;
uint32_t drmFormat() const;
private:

View file

@ -28,8 +28,17 @@ GbmDmaBuf::~GbmDmaBuf()
gbm_bo_destroy(m_bo);
}
int GbmDmaBuf::fd() const
{
return m_fd;
}
KWin::GbmDmaBuf *GbmDmaBuf::createBuffer(const QSize &size, gbm_device *device)
quint32 GbmDmaBuf::stride() const
{
return gbm_bo_get_stride(m_bo);
}
GbmDmaBuf *GbmDmaBuf::createBuffer(const QSize &size, gbm_device *device)
{
if (!device) {
return nullptr;

View file

@ -19,13 +19,8 @@ class GbmDmaBuf : public DmaBufTexture
public:
~GbmDmaBuf();
int fd() const override
{
return m_fd;
}
quint32 stride() const override {
return gbm_bo_get_stride(m_bo);
}
int fd() const override;
quint32 stride() const override;
static GbmDmaBuf *createBuffer(const QSize &size, gbm_device *device);

View file

@ -116,4 +116,19 @@ QSharedPointer<DrmGbmBuffer> GbmSurface::currentDrmBuffer() const
return m_currentDrmBuffer;
}
EGLSurface GbmSurface::eglSurface() const
{
return m_eglSurface;
}
QSize GbmSurface::size() const
{
return m_size;
}
bool GbmSurface::isValid() const
{
return m_surface != nullptr && m_eglSurface != EGL_NO_SURFACE;
}
}

View file

@ -36,17 +36,9 @@ public:
QSharedPointer<GbmBuffer> currentBuffer() const;
QSharedPointer<DrmGbmBuffer> currentDrmBuffer() const;
EGLSurface eglSurface() const {
return m_eglSurface;
}
QSize size() const {
return m_size;
}
bool isValid() const {
return m_surface != nullptr && m_eglSurface != EGL_NO_SURFACE;
}
EGLSurface eglSurface() const;
QSize size() const;
bool isValid() const;
private:
gbm_surface *m_surface;