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/ToplevelExport.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/protocols/ToplevelExport.cpp') diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp index fb0bd9c7..66e74164 100644 --- a/src/protocols/ToplevelExport.cpp +++ b/src/protocols/ToplevelExport.cpp @@ -73,11 +73,6 @@ bool CToplevelExportClient::good() { return resource->resource(); } -CToplevelExportFrame::~CToplevelExportFrame() { - if (buffer && buffer->locked()) - buffer->unlock(); -} - CToplevelExportFrame::CToplevelExportFrame(SP resource_, int32_t overlayCursor_, PHLWINDOW pWindow_) : resource(resource_), pWindow(pWindow_) { if UNLIKELY (!good()) return; @@ -159,8 +154,6 @@ void CToplevelExportFrame::copy(CHyprlandToplevelExportFrameV1* pFrame, wl_resou return; } - PBUFFER->buffer->lock(); - if UNLIKELY (PBUFFER->buffer->size != box.size()) { resource->error(HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer dimensions"); PROTO::toplevelExport->destroyResource(this); @@ -197,7 +190,7 @@ void CToplevelExportFrame::copy(CHyprlandToplevelExportFrameV1* pFrame, wl_resou return; } - buffer = PBUFFER->buffer; + buffer = CHLBufferReference(PBUFFER->buffer.lock()); m_ignoreDamage = ignoreDamage; @@ -340,7 +333,7 @@ bool CToplevelExportFrame::copyDmabuf(timespec* now) { g_pPointerManager->damageCursor(PMONITOR->self.lock()); } - if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_TO_BUFFER, buffer.lock())) + if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_TO_BUFFER, buffer.buffer)) return false; g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 1.0)); -- cgit v1.2.3