allocator: add missing virtual destructor (#3)

add missing virtual destructor to base class and free gbm device on
destruction of CGBMAllocator
This commit is contained in:
Tom Englund 2024-07-06 14:57:27 +02:00 committed by GitHub
parent 29c415a4f5
commit 263cb161da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View File

@ -16,6 +16,7 @@ namespace Aquamarine {
class IAllocator {
public:
virtual ~IAllocator() = default;
virtual Hyprutils::Memory::CSharedPointer<IBuffer> acquire(const SAllocatorBufferParams& params, Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain) = 0;
virtual Hyprutils::Memory::CSharedPointer<CBackend> getBackend() = 0;
};

View File

@ -35,6 +35,7 @@ namespace Aquamarine {
class CGBMAllocator : public IAllocator {
public:
~CGBMAllocator();
static Hyprutils::Memory::CSharedPointer<CGBMAllocator> create(int drmfd_, Hyprutils::Memory::CWeakPointer<CBackend> backend_);
virtual Hyprutils::Memory::CSharedPointer<IBuffer> acquire(const SAllocatorBufferParams& params, Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain_);

View File

@ -183,6 +183,11 @@ SDMABUFAttrs Aquamarine::CGBMBuffer::dmabuf() {
return attrs;
}
CGBMAllocator::~CGBMAllocator() {
if (gbmDevice)
gbm_device_destroy(gbmDevice);
}
SP<CGBMAllocator> Aquamarine::CGBMAllocator::create(int drmfd_, Hyprutils::Memory::CWeakPointer<CBackend> backend_) {
uint64_t capabilities = 0;
if (drmGetCap(drmfd_, DRM_CAP_PRIME, &capabilities) || !(capabilities & DRM_PRIME_CAP_EXPORT)) {