From 46ac115bd19ee3aff5c816033de0b1d55a74e33f Mon Sep 17 00:00:00 2001 From: davc0n Date: Sat, 3 May 2025 18:54:50 +0200 Subject: [PATCH] protocols: refactor class member vars (types) (#10261) --- src/helpers/Monitor.cpp | 6 +-- src/managers/SeatManager.cpp | 4 +- src/protocols/DataDeviceWlr.cpp | 6 +-- src/protocols/LinuxDMABUF.cpp | 12 ++--- src/protocols/MesaDRM.cpp | 12 ++--- src/protocols/PrimarySelection.cpp | 6 +-- src/protocols/Screencopy.cpp | 10 ++--- src/protocols/SinglePixel.cpp | 16 +++---- src/protocols/ToplevelExport.cpp | 10 ++--- src/protocols/core/Compositor.cpp | 12 ++--- src/protocols/core/DataDevice.cpp | 6 +-- src/protocols/core/Shm.cpp | 10 ++--- src/protocols/types/Buffer.cpp | 72 +++++++++++++++--------------- src/protocols/types/Buffer.hpp | 14 +++--- src/protocols/types/DMABuffer.cpp | 46 +++++++++---------- src/protocols/types/DMABuffer.hpp | 6 +-- src/protocols/types/DataDevice.cpp | 4 +- src/protocols/types/DataDevice.hpp | 4 +- src/protocols/types/WLBuffer.cpp | 28 ++++++------ src/protocols/types/WLBuffer.hpp | 6 +-- src/render/Renderer.cpp | 4 +- 21 files changed, 147 insertions(+), 147 deletions(-) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index c8bafa88..5b76e390 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -1379,9 +1379,9 @@ bool CMonitor::attemptDirectScanout() { if (!params.success || !PSURFACE->m_current.texture->m_pEglImage /* dmabuf */) return false; - Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {}", (uintptr_t)PSURFACE.get(), (uintptr_t)PSURFACE->m_current.buffer.buffer.get()); + Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt, buffer {}", (uintptr_t)PSURFACE.get(), (uintptr_t)PSURFACE->m_current.buffer.m_buffer.get()); - auto PBUFFER = PSURFACE->m_current.buffer.buffer; + auto PBUFFER = PSURFACE->m_current.buffer.m_buffer; if (PBUFFER == m_output->state->state().buffer) { PSURFACE->presentFeedback(Time::steadyNow(), m_self.lock()); @@ -1447,7 +1447,7 @@ bool CMonitor::attemptDirectScanout() { m_scanoutNeedsCursorUpdate = false; - if (!PBUFFER->lockedByBackend || PBUFFER->hlEvents.backendRelease) + if (!PBUFFER->lockedByBackend || PBUFFER->m_hlEvents.backendRelease) return true; // lock buffer while DRM/KMS is using it, then release it when page flip happens since DRM/KMS should be done by then diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp index f910598d..419e8bf4 100644 --- a/src/managers/SeatManager.cpp +++ b/src/managers/SeatManager.cpp @@ -559,7 +559,7 @@ void CSeatManager::setCurrentSelection(SP source) { m_selection.currentSelection = source; if (source) { - m_selection.destroySelection = source->events.destroy.registerListener([this](std::any d) { setCurrentSelection(nullptr); }); + m_selection.destroySelection = source->m_events.destroy.registerListener([this](std::any d) { setCurrentSelection(nullptr); }); PROTO::data->setSelection(source); PROTO::dataWlr->setSelection(source, false); } @@ -584,7 +584,7 @@ void CSeatManager::setCurrentPrimarySelection(SP source) { m_selection.currentPrimarySelection = source; if (source) { - m_selection.destroyPrimarySelection = source->events.destroy.registerListener([this](std::any d) { setCurrentPrimarySelection(nullptr); }); + m_selection.destroyPrimarySelection = source->m_events.destroy.registerListener([this](std::any d) { setCurrentPrimarySelection(nullptr); }); PROTO::primarySelection->setSelection(source); PROTO::dataWlr->setSelection(source, true); } diff --git a/src/protocols/DataDeviceWlr.cpp b/src/protocols/DataDeviceWlr.cpp index 680840da..a79e71af 100644 --- a/src/protocols/DataDeviceWlr.cpp +++ b/src/protocols/DataDeviceWlr.cpp @@ -49,11 +49,11 @@ CWLRDataSource::CWLRDataSource(SP resource_, SPsetData(this); resource->setDestroy([this](CZwlrDataControlSourceV1* r) { - events.destroy.emit(); + m_events.destroy.emit(); PROTO::dataWlr->destroyResource(this); }); resource->setOnDestroy([this](CZwlrDataControlSourceV1* r) { - events.destroy.emit(); + m_events.destroy.emit(); PROTO::dataWlr->destroyResource(this); }); @@ -61,7 +61,7 @@ CWLRDataSource::CWLRDataSource(SP resource_, SP CWLRDataSource::fromResource(wl_resource* res) { diff --git a/src/protocols/LinuxDMABUF.cpp b/src/protocols/LinuxDMABUF.cpp index 2a067bf7..189a2555 100644 --- a/src/protocols/LinuxDMABUF.cpp +++ b/src/protocols/LinuxDMABUF.cpp @@ -99,20 +99,20 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec CLinuxDMABuffer::CLinuxDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs attrs) { buffer = makeShared(id, client, attrs); - buffer->resource->buffer = buffer; + buffer->m_resource->m_buffer = buffer; listeners.bufferResourceDestroy = buffer->events.destroy.registerListener([this](std::any d) { listeners.bufferResourceDestroy.reset(); PROTO::linuxDma->destroyResource(this); }); - if (!buffer->success) + if (!buffer->m_success) LOGM(ERR, "Possibly compositor bug: buffer failed to create"); } CLinuxDMABuffer::~CLinuxDMABuffer() { - if (buffer && buffer->resource) - buffer->resource->sendRelease(); + if (buffer && buffer->m_resource) + buffer->m_resource->sendRelease(); buffer.reset(); listeners.bufferResourceDestroy.reset(); @@ -219,14 +219,14 @@ void CLinuxDMABUFParamsResource::create(uint32_t id) { auto buf = PROTO::linuxDma->m_vBuffers.emplace_back(makeShared(id, resource->client(), *attrs)); - if UNLIKELY (!buf->good() || !buf->buffer->success) { + if UNLIKELY (!buf->good() || !buf->buffer->m_success) { resource->sendFailed(); PROTO::linuxDma->m_vBuffers.pop_back(); return; } if (!id) - resource->sendCreated(PROTO::linuxDma->m_vBuffers.back()->buffer->resource->getResource()); + resource->sendCreated(PROTO::linuxDma->m_vBuffers.back()->buffer->m_resource->getResource()); createdBuffer = buf; } diff --git a/src/protocols/MesaDRM.cpp b/src/protocols/MesaDRM.cpp index 41c34d89..be5a02cd 100644 --- a/src/protocols/MesaDRM.cpp +++ b/src/protocols/MesaDRM.cpp @@ -11,21 +11,21 @@ CMesaDRMBufferResource::CMesaDRMBufferResource(uint32_t id, wl_client* client, A LOGM(LOG, " | plane {}: mod {} fd {} stride {} offset {}", i, attrs_.modifier, attrs_.fds[i], attrs_.strides[i], attrs_.offsets[i]); } - buffer = makeShared(id, client, attrs_); - buffer->resource->buffer = buffer; + buffer = makeShared(id, client, attrs_); + buffer->m_resource->m_buffer = buffer; listeners.bufferResourceDestroy = buffer->events.destroy.registerListener([this](std::any d) { listeners.bufferResourceDestroy.reset(); PROTO::mesaDRM->destroyResource(this); }); - if (!buffer->success) + if (!buffer->m_success) LOGM(ERR, "Possibly compositor bug: buffer failed to create"); } CMesaDRMBufferResource::~CMesaDRMBufferResource() { - if (buffer && buffer->resource) - buffer->resource->sendRelease(); + if (buffer && buffer->m_resource) + buffer->m_resource->sendRelease(); buffer.reset(); listeners.bufferResourceDestroy.reset(); } @@ -94,7 +94,7 @@ CMesaDRMResource::CMesaDRMResource(SP resource_) : resource(resource_) { } // append instance so that buffer knows its owner - RESOURCE->buffer->resource->buffer = RESOURCE->buffer; + RESOURCE->buffer->m_resource->m_buffer = RESOURCE->buffer; }); resource->sendDevice(PROTO::mesaDRM->nodeName.c_str()); diff --git a/src/protocols/PrimarySelection.cpp b/src/protocols/PrimarySelection.cpp index 2cd610ec..d6eb5165 100644 --- a/src/protocols/PrimarySelection.cpp +++ b/src/protocols/PrimarySelection.cpp @@ -50,11 +50,11 @@ CPrimarySelectionSource::CPrimarySelectionSource(SPsetData(this); resource->setDestroy([this](CZwpPrimarySelectionSourceV1* r) { - events.destroy.emit(); + m_events.destroy.emit(); PROTO::primarySelection->destroyResource(this); }); resource->setOnDestroy([this](CZwpPrimarySelectionSourceV1* r) { - events.destroy.emit(); + m_events.destroy.emit(); PROTO::primarySelection->destroyResource(this); }); @@ -62,7 +62,7 @@ CPrimarySelectionSource::CPrimarySelectionSource(SP CPrimarySelectionSource::fromResource(wl_resource* res) { diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index 4539a463..391d13e7 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -100,7 +100,7 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_ return; } - if UNLIKELY (PBUFFER->buffer->size != box.size()) { + if UNLIKELY (PBUFFER->m_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"); PROTO::screencopy->destroyResource(this); @@ -114,7 +114,7 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_ return; } - if (auto attrs = PBUFFER->buffer->dmabuf(); attrs.success) { + if (auto attrs = PBUFFER->m_buffer->dmabuf(); attrs.success) { bufferDMA = true; if (attrs.format != dmabufFormat) { @@ -123,7 +123,7 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_ PROTO::screencopy->destroyResource(this); return; } - } else if (auto attrs = PBUFFER->buffer->shm(); attrs.success) { + } else if (auto attrs = PBUFFER->m_buffer->shm(); attrs.success) { if (attrs.format != shmFormat) { LOGM(ERR, "Invalid buffer shm format in {:x}", (uintptr_t)pFrame); resource->error(ZWLR_SCREENCOPY_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format"); @@ -142,7 +142,7 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_ return; } - buffer = CHLBufferReference(PBUFFER->buffer.lock()); + buffer = CHLBufferReference(PBUFFER->m_buffer.lock()); PROTO::screencopy->m_vFramesAwaitingWrite.emplace_back(self); @@ -193,7 +193,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.buffer, nullptr, true)) { + if (!g_pHyprRenderer->beginRender(pMonitor.lock(), fakeDamage, RENDER_MODE_TO_BUFFER, buffer.m_buffer, nullptr, true)) { LOGM(ERR, "Can't copy: failed to begin rendering to dma frame"); callback(false); return; diff --git a/src/protocols/SinglePixel.cpp b/src/protocols/SinglePixel.cpp index c383dbb3..1104ab42 100644 --- a/src/protocols/SinglePixel.cpp +++ b/src/protocols/SinglePixel.cpp @@ -10,13 +10,13 @@ CSinglePixelBuffer::CSinglePixelBuffer(uint32_t id, wl_client* client, CHyprColo g_pHyprRenderer->makeEGLCurrent(); - opaque = col_.a >= 1.F; + m_opaque = col_.a >= 1.F; - texture = makeShared(DRM_FORMAT_ARGB8888, (uint8_t*)&color, 4, Vector2D{1, 1}); + m_texture = makeShared(DRM_FORMAT_ARGB8888, (uint8_t*)&color, 4, Vector2D{1, 1}); - resource = CWLBufferResource::create(makeShared(client, 1, id)); + m_resource = CWLBufferResource::create(makeShared(client, 1, id)); - success = texture->m_iTexID; + success = m_texture->m_iTexID; size = {1, 1}; @@ -25,8 +25,8 @@ CSinglePixelBuffer::CSinglePixelBuffer(uint32_t id, wl_client* client, CHyprColo } CSinglePixelBuffer::~CSinglePixelBuffer() { - if (resource) - resource->sendRelease(); + if (m_resource) + m_resource->sendRelease(); } Aquamarine::eBufferCapability CSinglePixelBuffer::caps() { @@ -58,7 +58,7 @@ void CSinglePixelBuffer::endDataPtr() { } bool CSinglePixelBuffer::good() { - return resource->good(); + return m_resource->good(); } CSinglePixelBufferResource::CSinglePixelBufferResource(uint32_t id, wl_client* client, CHyprColor color) { @@ -67,7 +67,7 @@ CSinglePixelBufferResource::CSinglePixelBufferResource(uint32_t id, wl_client* c if UNLIKELY (!buffer->good()) return; - buffer->resource->buffer = buffer; + buffer->m_resource->m_buffer = buffer; listeners.bufferResourceDestroy = buffer->events.destroy.registerListener([this](std::any d) { listeners.bufferResourceDestroy.reset(); diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp index 57fc415e..fd5d0b27 100644 --- a/src/protocols/ToplevelExport.cpp +++ b/src/protocols/ToplevelExport.cpp @@ -155,7 +155,7 @@ void CToplevelExportFrame::copy(CHyprlandToplevelExportFrameV1* pFrame, wl_resou return; } - if UNLIKELY (PBUFFER->buffer->size != box.size()) { + if UNLIKELY (PBUFFER->m_buffer->size != box.size()) { resource->error(HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer dimensions"); PROTO::toplevelExport->destroyResource(this); return; @@ -167,7 +167,7 @@ void CToplevelExportFrame::copy(CHyprlandToplevelExportFrameV1* pFrame, wl_resou return; } - if (auto attrs = PBUFFER->buffer->dmabuf(); attrs.success) { + if (auto attrs = PBUFFER->m_buffer->dmabuf(); attrs.success) { bufferDMA = true; if (attrs.format != dmabufFormat) { @@ -175,7 +175,7 @@ void CToplevelExportFrame::copy(CHyprlandToplevelExportFrameV1* pFrame, wl_resou PROTO::toplevelExport->destroyResource(this); return; } - } else if (auto attrs = PBUFFER->buffer->shm(); attrs.success) { + } else if (auto attrs = PBUFFER->m_buffer->shm(); attrs.success) { if (attrs.format != shmFormat) { resource->error(HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format"); PROTO::toplevelExport->destroyResource(this); @@ -191,7 +191,7 @@ void CToplevelExportFrame::copy(CHyprlandToplevelExportFrameV1* pFrame, wl_resou return; } - buffer = CHLBufferReference(PBUFFER->buffer.lock()); + buffer = CHLBufferReference(PBUFFER->m_buffer.lock()); m_ignoreDamage = ignoreDamage; @@ -340,7 +340,7 @@ bool CToplevelExportFrame::copyDmabuf(const Time::steady_tp& now) { g_pPointerManager->damageCursor(PMONITOR->m_self.lock()); } - if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_TO_BUFFER, buffer.buffer)) + if (!g_pHyprRenderer->beginRender(PMONITOR, fakeDamage, RENDER_MODE_TO_BUFFER, buffer.m_buffer)) return false; g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 1.0)); diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index df1916ef..e6390dbf 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -82,11 +82,11 @@ CWLSurfaceResource::CWLSurfaceResource(SP resource_) : m_resource(re auto buf = buffer ? CWLBufferResource::fromResource(buffer) : nullptr; - if (buf && buf->buffer) { - m_pending.buffer = CHLBufferReference(buf->buffer.lock()); - m_pending.texture = buf->buffer->texture; - m_pending.size = buf->buffer->size; - m_pending.bufferSize = buf->buffer->size; + if (buf && buf->m_buffer) { + m_pending.buffer = CHLBufferReference(buf->m_buffer.lock()); + m_pending.texture = buf->m_buffer->m_texture; + m_pending.size = buf->m_buffer->size; + m_pending.bufferSize = buf->m_buffer->size; } else { m_pending.buffer = {}; m_pending.texture.reset(); @@ -157,7 +157,7 @@ CWLSurfaceResource::CWLSurfaceResource(SP resource_) : m_resource(re whenReadable(); } else if (state->buffer->type() == Aquamarine::BUFFER_TYPE_DMABUF && state->buffer->dmabuf().success) { // async buffer and is dmabuf, then we can wait on implicit fences - auto syncFd = dynamic_cast(state->buffer.buffer.get())->exportSyncFile(); + auto syncFd = dynamic_cast(state->buffer.m_buffer.get())->exportSyncFile(); if (syncFd.isValid()) g_pEventLoopManager->doOnReadable(std::move(syncFd), whenReadable); diff --git a/src/protocols/core/DataDevice.cpp b/src/protocols/core/DataDevice.cpp index a54ae7e1..63523cd9 100644 --- a/src/protocols/core/DataDevice.cpp +++ b/src/protocols/core/DataDevice.cpp @@ -134,12 +134,12 @@ CWLDataSourceResource::CWLDataSourceResource(SP resource_, SPsetData(this); m_resource->setDestroy([this](CWlDataSource* r) { - events.destroy.emit(); + m_events.destroy.emit(); PROTO::data->onDestroyDataSource(m_self); PROTO::data->destroyResource(this); }); m_resource->setOnDestroy([this](CWlDataSource* r) { - events.destroy.emit(); + m_events.destroy.emit(); PROTO::data->onDestroyDataSource(m_self); PROTO::data->destroyResource(this); }); @@ -152,7 +152,7 @@ CWLDataSourceResource::CWLDataSourceResource(SP resource_, SPonDestroyDataSource(m_self); } diff --git a/src/protocols/core/Shm.cpp b/src/protocols/core/Shm.cpp index 6ebfa64f..228884b9 100644 --- a/src/protocols/core/Shm.cpp +++ b/src/protocols/core/Shm.cpp @@ -20,9 +20,9 @@ CWLSHMBuffer::CWLSHMBuffer(SP pool_, uint32_t id, int32_t of m_stride = stride_; m_fmt = fmt_; m_offset = offset_; - opaque = NFormatUtils::isFormatOpaque(NFormatUtils::shmToDRM(fmt_)); + m_opaque = NFormatUtils::isFormatOpaque(NFormatUtils::shmToDRM(fmt_)); - resource = CWLBufferResource::create(makeShared(pool_->m_resource->client(), 1, id)); + m_resource = CWLBufferResource::create(makeShared(pool_->m_resource->client(), 1, id)); m_listeners.bufferResourceDestroy = events.destroy.registerListener([this](std::any d) { m_listeners.bufferResourceDestroy.reset(); @@ -31,8 +31,8 @@ CWLSHMBuffer::CWLSHMBuffer(SP pool_, uint32_t id, int32_t of } CWLSHMBuffer::~CWLSHMBuffer() { - if (resource) - resource->sendRelease(); + if (m_resource) + m_resource->sendRelease(); } Aquamarine::eBufferCapability CWLSHMBuffer::caps() { @@ -156,7 +156,7 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP resource_, CFileDescriptor } // append instance so that buffer knows its owner - RESOURCE->resource->buffer = RESOURCE; + RESOURCE->m_resource->m_buffer = RESOURCE; }); if UNLIKELY (m_pool->m_data == MAP_FAILED) diff --git a/src/protocols/types/Buffer.cpp b/src/protocols/types/Buffer.cpp index 73155c29..179a1b0e 100644 --- a/src/protocols/types/Buffer.cpp +++ b/src/protocols/types/Buffer.cpp @@ -1,104 +1,104 @@ #include "Buffer.hpp" IHLBuffer::~IHLBuffer() { - if (locked() && resource) + if (locked() && m_resource) sendRelease(); } void IHLBuffer::sendRelease() { - resource->sendRelease(); - syncReleasers.clear(); + m_resource->sendRelease(); + m_syncReleasers.clear(); } void IHLBuffer::lock() { - nLocks++; + m_locks++; } void IHLBuffer::unlock() { - nLocks--; + m_locks--; - ASSERT(nLocks >= 0); + ASSERT(m_locks >= 0); - if (nLocks == 0) + if (m_locks == 0) sendRelease(); } bool IHLBuffer::locked() { - return nLocks > 0; + return m_locks > 0; } void IHLBuffer::onBackendRelease(const std::function& fn) { - if (hlEvents.backendRelease) { - hlEvents.backendRelease->emit(nullptr); + if (m_hlEvents.backendRelease) { + m_hlEvents.backendRelease->emit(nullptr); Debug::log(LOG, "backendRelease emitted early"); } - hlEvents.backendRelease = events.backendRelease.registerListener([this, fn](std::any) { + m_hlEvents.backendRelease = events.backendRelease.registerListener([this, fn](std::any) { fn(); - hlEvents.backendRelease.reset(); + m_hlEvents.backendRelease.reset(); }); } void IHLBuffer::addReleasePoint(CDRMSyncPointState& point) { ASSERT(locked()); if (point) - syncReleasers.emplace_back(point.createSyncRelease()); + m_syncReleasers.emplace_back(point.createSyncRelease()); } -CHLBufferReference::CHLBufferReference() : buffer(nullptr) { +CHLBufferReference::CHLBufferReference() : m_buffer(nullptr) { ; } -CHLBufferReference::CHLBufferReference(const CHLBufferReference& other) : buffer(other.buffer) { - if (buffer) - buffer->lock(); +CHLBufferReference::CHLBufferReference(const CHLBufferReference& other) : m_buffer(other.m_buffer) { + if (m_buffer) + m_buffer->lock(); } -CHLBufferReference::CHLBufferReference(SP buffer_) : buffer(buffer_) { - if (buffer) - buffer->lock(); +CHLBufferReference::CHLBufferReference(SP buffer_) : m_buffer(buffer_) { + if (m_buffer) + m_buffer->lock(); } CHLBufferReference::~CHLBufferReference() { - if (buffer) - buffer->unlock(); + if (m_buffer) + m_buffer->unlock(); } CHLBufferReference& CHLBufferReference::operator=(const CHLBufferReference& other) { - if (other.buffer) - other.buffer->lock(); - if (buffer) - buffer->unlock(); - buffer = other.buffer; + if (other.m_buffer) + other.m_buffer->lock(); + if (m_buffer) + m_buffer->unlock(); + m_buffer = other.m_buffer; return *this; } bool CHLBufferReference::operator==(const CHLBufferReference& other) const { - return buffer == other.buffer; + return m_buffer == other.m_buffer; } bool CHLBufferReference::operator==(const SP& other) const { - return buffer == other; + return m_buffer == other; } bool CHLBufferReference::operator==(const SP& other) const { - return buffer == other; + return m_buffer == other; } SP CHLBufferReference::operator->() const { - return buffer; + return m_buffer; } CHLBufferReference::operator bool() const { - return buffer; + return m_buffer; } void CHLBufferReference::drop() { - if (!buffer) + if (!m_buffer) return; - buffer->nLocks--; - ASSERT(buffer->nLocks >= 0); + m_buffer->m_locks--; + ASSERT(m_buffer->m_locks >= 0); - buffer = nullptr; + m_buffer = nullptr; } diff --git a/src/protocols/types/Buffer.hpp b/src/protocols/types/Buffer.hpp index e4821ac0..692cb97c 100644 --- a/src/protocols/types/Buffer.hpp +++ b/src/protocols/types/Buffer.hpp @@ -26,18 +26,18 @@ class IHLBuffer : public Aquamarine::IBuffer { void onBackendRelease(const std::function& fn); void addReleasePoint(CDRMSyncPointState& point); - SP texture; - bool opaque = false; - SP resource; - std::vector> syncReleasers; + SP m_texture; + bool m_opaque = false; + SP m_resource; + std::vector> m_syncReleasers; struct { CHyprSignalListener backendRelease; CHyprSignalListener backendRelease2; // for explicit ds - } hlEvents; + } m_hlEvents; private: - int nLocks = 0; + int m_locks = 0; friend class CHLBufferReference; }; @@ -60,5 +60,5 @@ class CHLBufferReference { // unlock and drop the buffer without sending release void drop(); - SP buffer; + SP m_buffer; }; diff --git a/src/protocols/types/DMABuffer.cpp b/src/protocols/types/DMABuffer.cpp index d08925ff..d8e41959 100644 --- a/src/protocols/types/DMABuffer.cpp +++ b/src/protocols/types/DMABuffer.cpp @@ -12,40 +12,40 @@ using namespace Hyprutils::OS; -CDMABuffer::CDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs const& attrs_) : attrs(attrs_) { +CDMABuffer::CDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs const& attrs_) : m_attrs(attrs_) { g_pHyprRenderer->makeEGLCurrent(); - listeners.resourceDestroy = events.destroy.registerListener([this](std::any d) { + m_listeners.resourceDestroy = events.destroy.registerListener([this](std::any d) { closeFDs(); - listeners.resourceDestroy.reset(); + m_listeners.resourceDestroy.reset(); }); - size = attrs.size; - resource = CWLBufferResource::create(makeShared(client, 1, id)); + size = m_attrs.size; + m_resource = CWLBufferResource::create(makeShared(client, 1, id)); - auto eglImage = g_pHyprOpenGL->createEGLImage(attrs); + auto eglImage = g_pHyprOpenGL->createEGLImage(m_attrs); if UNLIKELY (!eglImage) { Debug::log(ERR, "CDMABuffer: failed to import EGLImage, retrying as implicit"); - attrs.modifier = DRM_FORMAT_MOD_INVALID; - eglImage = g_pHyprOpenGL->createEGLImage(attrs); + m_attrs.modifier = DRM_FORMAT_MOD_INVALID; + eglImage = g_pHyprOpenGL->createEGLImage(m_attrs); if UNLIKELY (!eglImage) { Debug::log(ERR, "CDMABuffer: failed to import EGLImage"); return; } } - texture = makeShared(attrs, eglImage); // texture takes ownership of the eglImage - opaque = NFormatUtils::isFormatOpaque(attrs.format); - success = texture->m_iTexID; + m_texture = makeShared(m_attrs, eglImage); // texture takes ownership of the eglImage + m_opaque = NFormatUtils::isFormatOpaque(m_attrs.format); + m_success = m_texture->m_iTexID; - if UNLIKELY (!success) + if UNLIKELY (!m_success) Debug::log(ERR, "Failed to create a dmabuf: texture is null"); } CDMABuffer::~CDMABuffer() { - if (resource) - resource->sendRelease(); + if (m_resource) + m_resource->sendRelease(); closeFDs(); } @@ -67,7 +67,7 @@ bool CDMABuffer::isSynchronous() { } Aquamarine::SDMABUFAttrs CDMABuffer::dmabuf() { - return attrs; + return m_attrs; } std::tuple CDMABuffer::beginDataPtr(uint32_t flags) { @@ -80,17 +80,17 @@ void CDMABuffer::endDataPtr() { } bool CDMABuffer::good() { - return success; + return m_success; } void CDMABuffer::closeFDs() { - for (int i = 0; i < attrs.planes; ++i) { - if (attrs.fds[i] == -1) + for (int i = 0; i < m_attrs.planes; ++i) { + if (m_attrs.fds[i] == -1) continue; - close(attrs.fds[i]); - attrs.fds[i] = -1; + close(m_attrs.fds[i]); + m_attrs.fds[i] = -1; } - attrs.planes = 0; + m_attrs.planes = 0; } static int doIoctl(int fd, unsigned long request, void* arg) { @@ -111,8 +111,8 @@ CFileDescriptor CDMABuffer::exportSyncFile() { #if !defined(__linux__) return {}; #else - std::vector syncFds(attrs.fds.size()); - for (const auto& fd : attrs.fds) { + std::vector syncFds(m_attrs.fds.size()); + for (const auto& fd : m_attrs.fds) { if (fd == -1) continue; diff --git a/src/protocols/types/DMABuffer.hpp b/src/protocols/types/DMABuffer.hpp index 5ebf7581..19f2ddf7 100644 --- a/src/protocols/types/DMABuffer.hpp +++ b/src/protocols/types/DMABuffer.hpp @@ -19,12 +19,12 @@ class CDMABuffer : public IHLBuffer { void closeFDs(); Hyprutils::OS::CFileDescriptor exportSyncFile(); - bool success = false; + bool m_success = false; private: - Aquamarine::SDMABUFAttrs attrs; + Aquamarine::SDMABUFAttrs m_attrs; struct { CHyprSignalListener resourceDestroy; - } listeners; + } m_listeners; }; diff --git a/src/protocols/types/DataDevice.cpp b/src/protocols/types/DataDevice.cpp index fef11b64..8c94b5b1 100644 --- a/src/protocols/types/DataDevice.cpp +++ b/src/protocols/types/DataDevice.cpp @@ -9,11 +9,11 @@ bool IDataSource::dndDone() { } bool IDataSource::used() { - return wasUsed; + return m_wasUsed; } void IDataSource::markUsed() { - wasUsed = true; + m_wasUsed = true; } eDataSourceType IDataSource::type() { diff --git a/src/protocols/types/DataDevice.hpp b/src/protocols/types/DataDevice.hpp index cbb4b271..857d818d 100644 --- a/src/protocols/types/DataDevice.hpp +++ b/src/protocols/types/DataDevice.hpp @@ -42,10 +42,10 @@ class IDataSource { struct { CSignal destroy; - } events; + } m_events; private: - bool wasUsed = false; + bool m_wasUsed = false; }; class IDataOffer { diff --git a/src/protocols/types/WLBuffer.cpp b/src/protocols/types/WLBuffer.cpp index f2b81c00..8e2f2b5f 100644 --- a/src/protocols/types/WLBuffer.cpp +++ b/src/protocols/types/WLBuffer.cpp @@ -5,43 +5,43 @@ #include "../../helpers/sync/SyncTimeline.hpp" #include -CWLBufferResource::CWLBufferResource(WP resource_) : resource(resource_.lock()) { +CWLBufferResource::CWLBufferResource(WP resource_) : m_resource(resource_.lock()) { if UNLIKELY (!good()) return; - resource->setOnDestroy([this](CWlBuffer* r) { - if (buffer.expired()) + m_resource->setOnDestroy([this](CWlBuffer* r) { + if (m_buffer.expired()) return; - buffer->events.destroy.emit(); + m_buffer->events.destroy.emit(); }); - resource->setDestroy([this](CWlBuffer* r) { - if (buffer.expired()) + m_resource->setDestroy([this](CWlBuffer* r) { + if (m_buffer.expired()) return; - buffer->events.destroy.emit(); + m_buffer->events.destroy.emit(); }); - resource->setData(this); + m_resource->setData(this); } bool CWLBufferResource::good() { - return resource->resource(); + return m_resource->resource(); } void CWLBufferResource::sendRelease() { - resource->sendRelease(); + m_resource->sendRelease(); } wl_resource* CWLBufferResource::getResource() { - return resource->resource(); + return m_resource->resource(); } SP CWLBufferResource::fromResource(wl_resource* res) { auto data = (CWLBufferResource*)(((CWlBuffer*)wl_resource_get_user_data(res))->data()); - return data ? data->self.lock() : nullptr; + return data ? data->m_self.lock() : nullptr; } SP CWLBufferResource::create(WP resource) { - auto p = SP(new CWLBufferResource(resource)); - p->self = p; + auto p = SP(new CWLBufferResource(resource)); + p->m_self = p; return p; } diff --git a/src/protocols/types/WLBuffer.hpp b/src/protocols/types/WLBuffer.hpp index c7e21d4c..2e823c5e 100644 --- a/src/protocols/types/WLBuffer.hpp +++ b/src/protocols/types/WLBuffer.hpp @@ -18,14 +18,14 @@ class CWLBufferResource { void sendRelease(); wl_resource* getResource(); - WP buffer; + WP m_buffer; - WP self; + WP m_self; private: CWLBufferResource(WP resource_); - SP resource; + SP m_resource; friend class IHLBuffer; }; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 1b861f7a..cddc8c95 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -2290,13 +2290,13 @@ void CHyprRenderer::endRender(const std::function& renderingDoneCallback UP eglSync = CEGLSync::create(); if (eglSync && eglSync->isValid()) { for (auto const& buf : usedAsyncBuffers) { - for (const auto& releaser : buf->syncReleasers) { + for (const auto& releaser : buf->m_syncReleasers) { releaser->addSyncFileFd(eglSync->fd()); } } // release buffer refs with release points now, since syncReleaser handles actual buffer release based on EGLSync - std::erase_if(usedAsyncBuffers, [](const auto& buf) { return !buf->syncReleasers.empty(); }); + std::erase_if(usedAsyncBuffers, [](const auto& buf) { return !buf->m_syncReleasers.empty(); }); // release buffer refs without release points when EGLSync sync_file/fence is signalled g_pEventLoopManager->doOnReadable(eglSync->fd().duplicate(), [renderingDoneCallback, prevbfs = std::move(usedAsyncBuffers)]() mutable {