From b5433bb75324a95dd27eb5492141565466c2cdd6 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Thu, 10 Jul 2025 13:11:07 +0200 Subject: [PATCH] singlepixel: move to unique ptrs less refcounting, move by rvalue. --- src/protocols/SinglePixel.cpp | 8 ++++---- src/protocols/SinglePixel.hpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/protocols/SinglePixel.cpp b/src/protocols/SinglePixel.cpp index 42c4f8ed4..a04cb481c 100644 --- a/src/protocols/SinglePixel.cpp +++ b/src/protocols/SinglePixel.cpp @@ -79,7 +79,7 @@ bool CSinglePixelBufferResource::good() { return m_buffer->good(); } -CSinglePixelBufferManagerResource::CSinglePixelBufferManagerResource(SP resource_) : m_resource(resource_) { +CSinglePixelBufferManagerResource::CSinglePixelBufferManagerResource(UP&& resource_) : m_resource(std::move(resource_)) { if UNLIKELY (!good()) return; @@ -87,9 +87,9 @@ CSinglePixelBufferManagerResource::CSinglePixelBufferManagerResource(SPsetOnDestroy([this](CWpSinglePixelBufferManagerV1* r) { PROTO::singlePixel->destroyResource(this); }); m_resource->setCreateU32RgbaBuffer([this](CWpSinglePixelBufferManagerV1* res, uint32_t id, uint32_t r, uint32_t g, uint32_t b, uint32_t a) { - CHyprColor color{r / (float)std::numeric_limits::max(), g / (float)std::numeric_limits::max(), b / (float)std::numeric_limits::max(), + CHyprColor color{r / (float)std::numeric_limits::max(), g / (float)std::numeric_limits::max(), b / (float)std::numeric_limits::max(), a / (float)std::numeric_limits::max()}; - const auto RESOURCE = PROTO::singlePixel->m_buffers.emplace_back(makeShared(id, m_resource->client(), color)); + const auto& RESOURCE = PROTO::singlePixel->m_buffers.emplace_back(makeUnique(id, m_resource->client(), color)); if UNLIKELY (!RESOURCE->good()) { res->noMemory(); @@ -108,7 +108,7 @@ CSinglePixelProtocol::CSinglePixelProtocol(const wl_interface* iface, const int& } void CSinglePixelProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto& RESOURCE = m_managers.emplace_back(makeUnique(makeUnique(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); diff --git a/src/protocols/SinglePixel.hpp b/src/protocols/SinglePixel.hpp index 4f613de86..f8bbfba9f 100644 --- a/src/protocols/SinglePixel.hpp +++ b/src/protocols/SinglePixel.hpp @@ -43,12 +43,12 @@ class CSinglePixelBufferResource { class CSinglePixelBufferManagerResource { public: - CSinglePixelBufferManagerResource(SP resource_); + CSinglePixelBufferManagerResource(UP&& resource_); bool good(); private: - SP m_resource; + UP m_resource; }; class CSinglePixelProtocol : public IWaylandProtocol { @@ -62,8 +62,8 @@ class CSinglePixelProtocol : public IWaylandProtocol { void destroyResource(CSinglePixelBufferResource* resource); // - std::vector> m_managers; - std::vector> m_buffers; + std::vector> m_managers; + std::vector> m_buffers; friend class CSinglePixelBufferManagerResource; friend class CSinglePixelBufferResource;