diff --git a/src/backends/drm/drm_buffer_gbm.cpp b/src/backends/drm/drm_buffer_gbm.cpp index 73a8297251..5333b6f5ff 100644 --- a/src/backends/drm/drm_buffer_gbm.cpp +++ b/src/backends/drm/drm_buffer_gbm.cpp @@ -72,19 +72,22 @@ GbmBuffer::GbmBuffer(DrmGpu *gpu, gbm_bo *bo, const std::shared_ptr : DrmGpuBuffer(gpu, QSize(gbm_bo_get_width(bo), gbm_bo_get_height(bo)), gbm_bo_get_format(bo), gbm_bo_get_modifier(bo), getHandles(bo), getStrides(bo), getOffsets(bo), gbm_bo_get_plane_count(bo)) , m_bo(bo) , m_surface(surface) + , m_flags(surface->flags()) { } -GbmBuffer::GbmBuffer(DrmGpu *gpu, gbm_bo *bo) +GbmBuffer::GbmBuffer(DrmGpu *gpu, gbm_bo *bo, uint32_t flags) : DrmGpuBuffer(gpu, QSize(gbm_bo_get_width(bo), gbm_bo_get_height(bo)), gbm_bo_get_format(bo), gbm_bo_get_modifier(bo), getHandles(bo), getStrides(bo), getOffsets(bo), gbm_bo_get_plane_count(bo)) , m_bo(bo) + , m_flags(flags) { } -GbmBuffer::GbmBuffer(DrmGpu *gpu, gbm_bo *bo, KWaylandServer::LinuxDmaBufV1ClientBuffer *clientBuffer) +GbmBuffer::GbmBuffer(DrmGpu *gpu, gbm_bo *bo, KWaylandServer::LinuxDmaBufV1ClientBuffer *clientBuffer, uint32_t flags) : DrmGpuBuffer(gpu, QSize(gbm_bo_get_width(bo), gbm_bo_get_height(bo)), gbm_bo_get_format(bo), gbm_bo_get_modifier(bo), getHandles(bo), getStrides(bo), getOffsets(bo), gbm_bo_get_plane_count(bo)) , m_bo(bo) , m_clientBuffer(clientBuffer) + , m_flags(flags) { m_clientBuffer->ref(); } @@ -119,6 +122,11 @@ KWaylandServer::ClientBuffer *GbmBuffer::clientBuffer() const return m_clientBuffer; } +uint32_t GbmBuffer::flags() const +{ + return m_flags; +} + bool GbmBuffer::map(uint32_t flags) { if (m_data) { @@ -175,7 +183,7 @@ std::shared_ptr GbmBuffer::importBuffer(DrmGpu *gpu, KWaylandServer:: bo = gbm_bo_import(gpu->gbmDevice(), GBM_BO_IMPORT_FD, &data, GBM_BO_USE_SCANOUT); } if (bo) { - return std::make_shared(gpu, bo, clientBuffer); + return std::make_shared(gpu, bo, clientBuffer, GBM_BO_USE_SCANOUT); } else { return nullptr; } @@ -206,7 +214,7 @@ std::shared_ptr GbmBuffer::importBuffer(DrmGpu *gpu, GbmBuffer *buffe } gbm_bo *bo = gbm_bo_import(gpu->gbmDevice(), GBM_BO_IMPORT_FD_MODIFIER, &data, flags); if (bo) { - return std::make_shared(gpu, bo); + return std::make_shared(gpu, bo, flags); } else { return nullptr; } diff --git a/src/backends/drm/drm_buffer_gbm.h b/src/backends/drm/drm_buffer_gbm.h index 112225a883..54912bca67 100644 --- a/src/backends/drm/drm_buffer_gbm.h +++ b/src/backends/drm/drm_buffer_gbm.h @@ -32,14 +32,15 @@ class GLTexture; class GbmBuffer : public DrmGpuBuffer { public: - GbmBuffer(DrmGpu *gpu, gbm_bo *bo); + GbmBuffer(DrmGpu *gpu, gbm_bo *bo, uint32_t flags); GbmBuffer(DrmGpu *gpu, gbm_bo *bo, const std::shared_ptr &surface); - GbmBuffer(DrmGpu *gpu, gbm_bo *bo, KWaylandServer::LinuxDmaBufV1ClientBuffer *clientBuffer); + GbmBuffer(DrmGpu *gpu, gbm_bo *bo, KWaylandServer::LinuxDmaBufV1ClientBuffer *clientBuffer, uint32_t flags); ~GbmBuffer() override; gbm_bo *bo() const; void *mappedData() const; KWaylandServer::ClientBuffer *clientBuffer() const; + uint32_t flags() const; bool map(uint32_t flags); @@ -52,6 +53,7 @@ private: gbm_bo *const m_bo; const std::shared_ptr m_surface; KWaylandServer::ClientBuffer *const m_clientBuffer = nullptr; + const uint32_t m_flags; void *m_data = nullptr; void *m_mapping = nullptr; };