Core: Move to aquamarine (#6608)

Moves Hyprland from wlroots to aquamarine for the backend.

---------

Signed-off-by: Vaxry <vaxry@vaxry.net>
Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
Co-authored-by: Jan Beich <jbeich@FreeBSD.org>
Co-authored-by: vaxerski <vaxerski@users.noreply.github.com>
Co-authored-by: UjinT34 <41110182+UjinT34@users.noreply.github.com>
Co-authored-by: Tom Englund <tomenglund26@gmail.com>
Co-authored-by: Ikalco <73481042+ikalco@users.noreply.github.com>
Co-authored-by: diniamo <diniamo53@gmail.com>
This commit is contained in:
Vaxry 2024-07-21 13:09:54 +02:00 committed by GitHub
parent f642fb97df
commit 016da234d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
131 changed files with 4755 additions and 3460 deletions

View file

@ -1,41 +1,10 @@
#include "Buffer.hpp"
#include "WLBuffer.hpp"
SDMABUFAttrs IWLBuffer::dmabuf() {
return SDMABUFAttrs{};
void IHLBuffer::sendRelease() {
resource->sendRelease();
}
SSHMAttrs IWLBuffer::shm() {
return SSHMAttrs{};
}
std::tuple<uint8_t*, uint32_t, size_t> IWLBuffer::beginDataPtr(uint32_t flags) {
return {nullptr, 0, 0};
}
void IWLBuffer::endDataPtr() {
; // empty
}
void IWLBuffer::sendRelease() {
if (!resource || !resource->resource)
return;
resource->resource->sendRelease();
}
void IWLBuffer::lock() {
locks++;
}
void IWLBuffer::unlock() {
locks--;
ASSERT(locks >= 0);
if (locks <= 0)
sendRelease();
}
bool IWLBuffer::locked() {
return locks;
void IHLBuffer::sendReleaseWithSurface(SP<CWLSurfaceResource> surf) {
if (resource && resource->good())
resource->sendReleaseWithSurface(surf);
}

View file

@ -1,75 +1,29 @@
#pragma once
#include "../../defines.hpp"
#include "../../helpers/signal/Signal.hpp"
#include "../../render/Texture.hpp"
#include "./WLBuffer.hpp"
#include <array>
#include <tuple>
#include <aquamarine/buffer/Buffer.hpp>
enum eBufferCapability {
BUFFER_CAPABILITY_DATAPTR = (1 << 0),
};
enum eBufferType {
BUFFER_TYPE_DMABUF = 0,
BUFFER_TYPE_SHM,
BUFFER_TYPE_MISC,
};
class CWLBufferResource;
struct SDMABUFAttrs {
bool success = false;
Vector2D size;
uint32_t format = 0; // fourcc
uint64_t modifier = 0;
int planes = 1;
std::array<uint32_t, 4> offsets = {0};
std::array<uint32_t, 4> strides = {0};
std::array<int, 4> fds = {-1, -1, -1, -1};
};
struct SSHMAttrs {
bool success = false;
int fd = 0;
uint32_t format = 0;
Vector2D size;
int stride = 0;
int64_t offset = 0;
};
class IWLBuffer {
class IHLBuffer : public Aquamarine::IBuffer {
public:
virtual ~IWLBuffer() {
virtual ~IHLBuffer() {
;
};
}
virtual Aquamarine::eBufferCapability caps() = 0;
virtual Aquamarine::eBufferType type() = 0;
virtual void update(const CRegion& damage) = 0;
virtual bool isSynchronous() = 0; // whether the updates to this buffer are synchronous, aka happen over cpu
virtual bool good() = 0;
virtual void sendRelease();
virtual void sendReleaseWithSurface(SP<CWLSurfaceResource>);
virtual eBufferCapability caps() = 0;
virtual eBufferType type() = 0;
virtual void update(const CRegion& damage) = 0;
virtual bool isSynchronous() = 0; // whether the updates to this buffer are synchronous, aka happen over cpu
virtual SDMABUFAttrs dmabuf();
virtual SSHMAttrs shm();
virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
virtual void endDataPtr();
virtual void sendRelease();
virtual void lock();
virtual void unlock();
virtual bool locked();
Vector2D size;
bool opaque = false;
SP<CWLBufferResource> resource;
SP<CTexture> texture;
SP<CTexture> texture;
bool opaque = false;
SP<CWLBufferResource> resource;
struct {
CSignal destroy;
} events;
private:
int locks = 0;
CHyprSignalListener backendRelease;
} hlEvents;
};

View file

@ -3,7 +3,7 @@
#include "../../render/Renderer.hpp"
#include "../../helpers/Format.hpp"
CDMABuffer::CDMABuffer(uint32_t id, wl_client* client, SDMABUFAttrs const& attrs_) : attrs(attrs_) {
CDMABuffer::CDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs const& attrs_) : attrs(attrs_) {
g_pHyprRenderer->makeEGLCurrent();
listeners.resourceDestroy = events.destroy.registerListener([this](std::any d) {
@ -31,12 +31,12 @@ CDMABuffer::~CDMABuffer() {
closeFDs();
}
eBufferCapability CDMABuffer::caps() {
return BUFFER_CAPABILITY_DATAPTR;
Aquamarine::eBufferCapability CDMABuffer::caps() {
return Aquamarine::eBufferCapability::BUFFER_CAPABILITY_DATAPTR;
}
eBufferType CDMABuffer::type() {
return BUFFER_TYPE_DMABUF;
Aquamarine::eBufferType CDMABuffer::type() {
return Aquamarine::eBufferType::BUFFER_TYPE_DMABUF;
}
void CDMABuffer::update(const CRegion& damage) {
@ -47,7 +47,7 @@ bool CDMABuffer::isSynchronous() {
return false;
}
SDMABUFAttrs CDMABuffer::dmabuf() {
Aquamarine::SDMABUFAttrs CDMABuffer::dmabuf() {
return attrs;
}

View file

@ -2,16 +2,16 @@
#include "Buffer.hpp"
class CDMABuffer : public IWLBuffer {
class CDMABuffer : public IHLBuffer {
public:
CDMABuffer(uint32_t id, wl_client* client, SDMABUFAttrs const& attrs_);
CDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs const& attrs_);
virtual ~CDMABuffer();
virtual eBufferCapability caps();
virtual eBufferType type();
virtual Aquamarine::eBufferCapability caps();
virtual Aquamarine::eBufferType type();
virtual bool isSynchronous();
virtual void update(const CRegion& damage);
virtual SDMABUFAttrs dmabuf();
virtual Aquamarine::SDMABUFAttrs dmabuf();
virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
virtual void endDataPtr();
bool good();
@ -21,7 +21,7 @@ class CDMABuffer : public IWLBuffer {
bool success = false;
private:
SDMABUFAttrs attrs;
Aquamarine::SDMABUFAttrs attrs;
struct {
CHyprSignalListener resourceDestroy;

View file

@ -1,5 +1,10 @@
#include "WLBuffer.hpp"
#include "Buffer.hpp"
#include "../core/Compositor.hpp"
#include "../DRMSyncobj.hpp"
#include "../../helpers/sync/SyncTimeline.hpp"
#include "../../Compositor.hpp"
#include <xf86drm.h>
CWLBufferResource::CWLBufferResource(SP<CWlBuffer> resource_) : resource(resource_) {
if (!good())
@ -27,6 +32,16 @@ void CWLBufferResource::sendRelease() {
resource->sendRelease();
}
void CWLBufferResource::sendReleaseWithSurface(SP<CWLSurfaceResource> surf) {
sendRelease();
if (!surf || !surf->syncobj)
return;
if (drmSyncobjTimelineSignal(g_pCompositor->m_iDRMFD, &surf->syncobj->releaseTimeline->timeline->handle, &surf->syncobj->releasePoint, 1))
Debug::log(ERR, "sendReleaseWithSurface: drmSyncobjTimelineSignal failed");
}
wl_resource* CWLBufferResource::getResource() {
return resource->resource();
}

View file

@ -7,7 +7,8 @@
#include "wayland.hpp"
#include "../../helpers/signal/Signal.hpp"
class IWLBuffer;
class IHLBuffer;
class CWLSurfaceResource;
class CWLBufferResource {
public:
@ -16,9 +17,10 @@ class CWLBufferResource {
bool good();
void sendRelease();
void sendReleaseWithSurface(SP<CWLSurfaceResource>);
wl_resource* getResource();
WP<IWLBuffer> buffer;
WP<IHLBuffer> buffer;
WP<CWLBufferResource> self;
@ -27,5 +29,5 @@ class CWLBufferResource {
SP<CWlBuffer> resource;
friend class IWLBuffer;
friend class IHLBuffer;
};