From da86db43d47141b9d7332d3cb756ff7c05dbb39a Mon Sep 17 00:00:00 2001 From: Ikalco <73481042+ikalco@users.noreply.github.com> Date: Mon, 7 Apr 2025 14:03:27 -0500 Subject: 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 --- src/protocols/Screencopy.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/protocols/Screencopy.cpp') 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 #include -CScreencopyFrame::~CScreencopyFrame() { - if (buffer && buffer->locked()) - buffer->unlock(); -} - CScreencopyFrame::CScreencopyFrame(SP 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 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; -- cgit v1.2.3