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

@ -30,6 +30,31 @@ DrmBuffer:: DrmBuffer(DrmGpu *gpu, uint32_t format, uint64_t 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::DrmDumbBuffer(DrmGpu *gpu, const QSize &size, uint32_t drmFormat) DrmDumbBuffer::DrmDumbBuffer(DrmGpu *gpu, const QSize &size, uint32_t drmFormat)
: DrmBuffer(gpu, drmFormat, DRM_FORMAT_MOD_LINEAR) : DrmBuffer(gpu, drmFormat, DRM_FORMAT_MOD_LINEAR)
@ -105,4 +130,24 @@ bool DrmDumbBuffer::map(QImage::Format format)
return !m_image->isNull(); 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;} virtual bool needsModeChange(DrmBuffer *b) const {Q_UNUSED(b) return false;}
quint32 bufferId() const { quint32 bufferId() const;
return m_bufferId; const QSize &size() const;
} DrmGpu *gpu() const;
uint32_t format() const;
const QSize &size() const { uint64_t modifier() const;
return m_size;
}
DrmGpu *gpu() const {
return m_gpu;
}
uint32_t format() const {
return m_format;
}
uint64_t modifier() const {
return m_modifier;
}
protected: protected:
quint32 m_bufferId = 0; quint32 m_bufferId = 0;
@ -60,18 +48,10 @@ public:
bool needsModeChange(DrmBuffer *b) const override; bool needsModeChange(DrmBuffer *b) const override;
bool map(QImage::Format format = QImage::Format_RGB32); bool map(QImage::Format format = QImage::Format_RGB32);
quint32 handle() const { quint32 handle() const;
return m_handle; QImage *image() const;
} void *data() const;
QImage *image() const { quint32 stride() const;
return m_image;
}
void *data() const {
return m_memory;
}
quint32 stride() const {
return m_stride;
}
private: private:
quint32 m_handle = 0; quint32 m_handle = 0;

View file

@ -88,6 +88,21 @@ KWaylandServer::ClientBuffer *GbmBuffer::clientBuffer() const
return m_clientBuffer; 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) DrmGbmBuffer::DrmGbmBuffer(DrmGpu *gpu, GbmSurface *surface, gbm_bo *bo)
: DrmBuffer(gpu, gbm_bo_get_format(bo), gbm_bo_get_modifier(bo)), GbmBuffer(surface, 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); 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); GbmBuffer(gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer);
virtual ~GbmBuffer(); virtual ~GbmBuffer();
gbm_bo* getBo() const {
return m_bo;
}
void releaseBuffer(); void releaseBuffer();
bool map(uint32_t flags); bool map(uint32_t flags);
void *mappedData() const {
return m_data; void *mappedData() const;
} uint32_t stride() const;
uint32_t stride() const {
return m_stride;
}
KWaylandServer::ClientBuffer *clientBuffer() const; KWaylandServer::ClientBuffer *clientBuffer() const;
gbm_bo* getBo() const;
protected: protected:
GbmSurface *m_surface = nullptr; GbmSurface *m_surface = nullptr;
@ -66,17 +59,8 @@ public:
DrmGbmBuffer(DrmGpu *gpu, gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer); DrmGbmBuffer(DrmGpu *gpu, gbm_bo *buffer, KWaylandServer::ClientBuffer *clientBuffer);
~DrmGbmBuffer() override; ~DrmGbmBuffer() override;
bool needsModeChange(DrmBuffer *b) const override { bool needsModeChange(DrmBuffer *b) const override;
if (DrmGbmBuffer *sb = dynamic_cast<DrmGbmBuffer*>(b)) { bool hasBo() const;
return hasBo() != sb->hasBo();
} else {
return true;
}
}
bool hasBo() const {
return m_bo != nullptr;
}
private: private:
void initialize(); void initialize();

View file

@ -65,4 +65,14 @@ void DrmLeaseOutput::leaseEnded()
m_lease = nullptr; 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 leased(KWaylandServer::DrmLeaseV1Interface *lease);
void leaseEnded(); void leaseEnded();
KWaylandServer::DrmLeaseV1Interface *lease() const { KWaylandServer::DrmLeaseV1Interface *lease() const;
return m_lease; DrmPipeline *pipeline() const;
}
DrmPipeline *pipeline() const {
return m_pipeline;
}
private: private:
DrmPipeline *m_pipeline; DrmPipeline *m_pipeline;

View file

@ -93,4 +93,20 @@ QVector<uint64_t> DrmVirtualOutput::supportedModifiers(uint32_t drmFormat) const
return {}; 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; bool isFormatSupported(uint32_t drmFormat) const override;
QVector<uint64_t> supportedModifiers(uint32_t drmFormat) const override; QVector<uint64_t> supportedModifiers(uint32_t drmFormat) const override;
int gammaRampSize() const override { int gammaRampSize() const override;
return 200; bool setGammaRamp(const GammaRamp &gamma) override;
} bool needsSoftwareTransformation() const override;
bool setGammaRamp(const GammaRamp &gamma) override {
Q_UNUSED(gamma);
return true;
}
bool needsSoftwareTransformation() const override {
return false;
}
private: private:
void vblank(std::chrono::nanoseconds timestamp); void vblank(std::chrono::nanoseconds timestamp);

View file

@ -71,4 +71,19 @@ uint32_t DumbSwapchain::drmFormat() const
return m_format; 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; QSharedPointer<DrmDumbBuffer> currentBuffer() const;
void releaseBuffer(QSharedPointer<DrmDumbBuffer> buffer); void releaseBuffer(QSharedPointer<DrmDumbBuffer> buffer);
qsizetype slotCount() const { qsizetype slotCount() const;
return m_slots.count(); QSize size() const;
} bool isEmpty() const;
QSize size() const {
return m_size;
}
bool isEmpty() const {
return m_slots.isEmpty();
}
uint32_t drmFormat() const; uint32_t drmFormat() const;
private: private:

View file

@ -28,8 +28,17 @@ GbmDmaBuf::~GbmDmaBuf()
gbm_bo_destroy(m_bo); 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) { if (!device) {
return nullptr; return nullptr;

View file

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

View file

@ -116,4 +116,19 @@ QSharedPointer<DrmGbmBuffer> GbmSurface::currentDrmBuffer() const
return m_currentDrmBuffer; 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<GbmBuffer> currentBuffer() const;
QSharedPointer<DrmGbmBuffer> currentDrmBuffer() const; QSharedPointer<DrmGbmBuffer> currentDrmBuffer() const;
EGLSurface eglSurface() const { EGLSurface eglSurface() const;
return m_eglSurface; QSize size() const;
} bool isValid() const;
QSize size() const {
return m_size;
}
bool isValid() const {
return m_surface != nullptr && m_eglSurface != EGL_NO_SURFACE;
}
private: private:
gbm_surface *m_surface; gbm_surface *m_surface;