summaryrefslogtreecommitdiff
path: root/src/protocols/Screencopy.cpp
diff options
context:
space:
mode:
authorIkalco <73481042+ikalco@users.noreply.github.com>2025-04-07 14:03:27 -0500
committerGitHub <noreply@github.com>2025-04-07 21:03:27 +0200
commitda86db43d47141b9d7332d3cb756ff7c05dbb39a (patch)
tree7b187bc96aedceda108b51eff034ba75e33fb510 /src/protocols/Screencopy.cpp
parent70ae99f52162a0ed2723d45c63adfb2e61f4e2f5 (diff)
core: refactor and improve surface commit (#9805)
* make CHLBufferReference not a SP anymore * copy over release and acquire points in CHLBufferReference * use CHLBufferReference in screencopy and toplevel export TODO: use CHLBufferReference in direct scanout properly the only problem is the scanout buffer release timing, specifically the onBackendRelease mechanism * cleanup SSurfaceState and surface pending commit tracking * move surface code from DRMSyncobj, and move acquire to SSurfaceState * use queue for comitted pending surface states like proto says "The content update is placed in a queue until it becomes active." - wl_surface::commit * drop, not release, prev buffer if 2nd buffer wl_surface.attach is sent "A wl_buffer that has been attached and then replaced by another attach instead of committed will not receive a release event, and is not used by the compositor." - wl_surface::attach
Diffstat (limited to 'src/protocols/Screencopy.cpp')
-rw-r--r--src/protocols/Screencopy.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp
index 3fd9b9f2..c124e6d2 100644
--- a/src/protocols/Screencopy.cpp
+++ b/src/protocols/Screencopy.cpp
@@ -14,11 +14,6 @@
#include <algorithm>
#include <functional>
-CScreencopyFrame::~CScreencopyFrame() {
- if (buffer && buffer->locked())
- buffer->unlock();
-}
-
CScreencopyFrame::CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource_, int32_t overlay_cursor, wl_resource* output, CBox box_) : resource(resource_) {
if UNLIKELY (!good())
return;
@@ -102,8 +97,6 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_
return;
}
- PBUFFER->buffer->lock();
-
if UNLIKELY (PBUFFER->buffer->size != box.size()) {
LOGM(ERR, "Invalid dimensions in {:x}", (uintptr_t)this);
resource->error(ZWLR_SCREENCOPY_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer dimensions");
@@ -146,7 +139,7 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_
return;
}
- buffer = PBUFFER->buffer;
+ buffer = CHLBufferReference(PBUFFER->buffer.lock());
PROTO::screencopy->m_vFramesAwaitingWrite.emplace_back(self);
@@ -207,7 +200,7 @@ void CScreencopyFrame::copyDmabuf(std::function<void(bool)> callback) {
CRegion fakeDamage = {0, 0, INT16_MAX, INT16_MAX};
- if (!g_pHyprRenderer->beginRender(pMonitor.lock(), fakeDamage, RENDER_MODE_TO_BUFFER, buffer.lock(), nullptr, true)) {
+ if (!g_pHyprRenderer->beginRender(pMonitor.lock(), fakeDamage, RENDER_MODE_TO_BUFFER, buffer.buffer, nullptr, true)) {
LOGM(ERR, "Can't copy: failed to begin rendering to dma frame");
callback(false);
return;