From 35e00a4a9dc35a44a3031b6f8f219a96f46e6451 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Fri, 19 Jul 2024 11:29:50 +0200 Subject: [PATCH] buffer: add backendLock --- include/aquamarine/buffer/Buffer.hpp | 4 +++- src/backend/drm/DRM.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/aquamarine/buffer/Buffer.hpp b/include/aquamarine/buffer/Buffer.hpp index c21b708..99c21bf 100644 --- a/include/aquamarine/buffer/Buffer.hpp +++ b/include/aquamarine/buffer/Buffer.hpp @@ -62,12 +62,14 @@ namespace Aquamarine { virtual bool locked(); Hyprutils::Math::Vector2D size; - bool opaque = false; + bool opaque = false; + bool lockedByBackend = false; CAttachmentManager attachments; struct { Hyprutils::Signal::CSignal destroy; + Hyprutils::Signal::CSignal backendRelease; } events; private: diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 9196956..e853d85 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -1236,6 +1236,11 @@ void Aquamarine::SDRMConnector::applyCommit(const SDRMConnectorCommitData& data) if (crtc->cursor && data.cursorFB) crtc->cursor->back = data.cursorFB; + if (data.mainFB) + data.mainFB->buffer->lockedByBackend = true; + if (crtc->cursor && data.cursorFB) + data.cursorFB->buffer->lockedByBackend = true; + pendingCursorFB.reset(); if (output->state->state().committed & COutputState::AQ_OUTPUT_STATE_MODE) @@ -1253,9 +1258,18 @@ void Aquamarine::SDRMConnector::rollbackCommit(const SDRMConnectorCommitData& da void Aquamarine::SDRMConnector::onPresent() { crtc->primary->last = crtc->primary->front; crtc->primary->front = crtc->primary->back; + if (crtc->primary->last && crtc->primary->last->buffer) { + crtc->primary->last->buffer->lockedByBackend = false; + crtc->primary->last->buffer->events.backendRelease.emit(); + } + if (crtc->cursor) { crtc->cursor->last = crtc->cursor->front; crtc->cursor->front = crtc->cursor->back; + if (crtc->cursor->last && crtc->cursor->last->buffer) { + crtc->cursor->last->buffer->lockedByBackend = false; + crtc->cursor->last->buffer->events.backendRelease.emit(); + } } }