diff --git a/src/backends/drm/drm_buffer.cpp b/src/backends/drm/drm_buffer.cpp index 55aeff877f..4220ceca52 100644 --- a/src/backends/drm/drm_buffer.cpp +++ b/src/backends/drm/drm_buffer.cpp @@ -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; +} + } diff --git a/src/backends/drm/drm_buffer.h b/src/backends/drm/drm_buffer.h index ea22babcf8..02bc8b13c3 100644 --- a/src/backends/drm/drm_buffer.h +++ b/src/backends/drm/drm_buffer.h @@ -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; diff --git a/src/backends/drm/drm_buffer_gbm.cpp b/src/backends/drm/drm_buffer_gbm.cpp index 15c832b902..280a5414f4 100644 --- a/src/backends/drm/drm_buffer_gbm.cpp +++ b/src/backends/drm/drm_buffer_gbm.cpp @@ -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(b)) { + return hasBo() != sb->hasBo(); + } else { + return true; + } +} + +bool DrmGbmBuffer::hasBo() const +{ + return m_bo != nullptr; +} + } diff --git a/src/backends/drm/drm_buffer_gbm.h b/src/backends/drm/drm_buffer_gbm.h index 1e3ae8a022..ee7c0149e1 100644 --- a/src/backends/drm/drm_buffer_gbm.h +++ b/src/backends/drm/drm_buffer_gbm.h @@ -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(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(); diff --git a/src/backends/drm/drm_lease_output.cpp b/src/backends/drm/drm_lease_output.cpp index 766c3add23..a2858824bf 100644 --- a/src/backends/drm/drm_lease_output.cpp +++ b/src/backends/drm/drm_lease_output.cpp @@ -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; +} + } diff --git a/src/backends/drm/drm_lease_output.h b/src/backends/drm/drm_lease_output.h index 1b992b6fb9..ae8db03128 100644 --- a/src/backends/drm/drm_lease_output.h +++ b/src/backends/drm/drm_lease_output.h @@ -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; diff --git a/src/backends/drm/drm_virtual_output.cpp b/src/backends/drm/drm_virtual_output.cpp index dd98723266..0deccfd264 100644 --- a/src/backends/drm/drm_virtual_output.cpp +++ b/src/backends/drm/drm_virtual_output.cpp @@ -93,4 +93,20 @@ QVector 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; +} + } diff --git a/src/backends/drm/drm_virtual_output.h b/src/backends/drm/drm_virtual_output.h index 160999bb6d..8fb665adba 100644 --- a/src/backends/drm/drm_virtual_output.h +++ b/src/backends/drm/drm_virtual_output.h @@ -34,16 +34,9 @@ public: bool isFormatSupported(uint32_t drmFormat) const override; QVector 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); diff --git a/src/backends/drm/dumb_swapchain.cpp b/src/backends/drm/dumb_swapchain.cpp index 4b20e332c6..5af8bd4187 100644 --- a/src/backends/drm/dumb_swapchain.cpp +++ b/src/backends/drm/dumb_swapchain.cpp @@ -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(); +} + } diff --git a/src/backends/drm/dumb_swapchain.h b/src/backends/drm/dumb_swapchain.h index 917a27a2c7..faa6672aed 100644 --- a/src/backends/drm/dumb_swapchain.h +++ b/src/backends/drm/dumb_swapchain.h @@ -29,17 +29,9 @@ public: QSharedPointer currentBuffer() const; void releaseBuffer(QSharedPointer 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: diff --git a/src/backends/drm/gbm_dmabuf.cpp b/src/backends/drm/gbm_dmabuf.cpp index 2bc53a6a00..3a23d647b6 100644 --- a/src/backends/drm/gbm_dmabuf.cpp +++ b/src/backends/drm/gbm_dmabuf.cpp @@ -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; diff --git a/src/backends/drm/gbm_dmabuf.h b/src/backends/drm/gbm_dmabuf.h index bd3c203561..57ebf2ac26 100644 --- a/src/backends/drm/gbm_dmabuf.h +++ b/src/backends/drm/gbm_dmabuf.h @@ -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); diff --git a/src/backends/drm/gbm_surface.cpp b/src/backends/drm/gbm_surface.cpp index d998f74301..94278ea493 100644 --- a/src/backends/drm/gbm_surface.cpp +++ b/src/backends/drm/gbm_surface.cpp @@ -116,4 +116,19 @@ QSharedPointer 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; +} + } diff --git a/src/backends/drm/gbm_surface.h b/src/backends/drm/gbm_surface.h index e76a722e13..f7bca28394 100644 --- a/src/backends/drm/gbm_surface.h +++ b/src/backends/drm/gbm_surface.h @@ -36,17 +36,9 @@ public: QSharedPointer currentBuffer() const; QSharedPointer 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;