From adbae0f74d951e06c575bad3c81a944027dfe413 Mon Sep 17 00:00:00 2001 From: davc0n Date: Sun, 4 May 2025 00:13:29 +0200 Subject: protocols: refactor class member vars (a-m) (#10265) --- src/protocols/FrogColorManagement.cpp | 116 +++++++++++++++++----------------- 1 file changed, 58 insertions(+), 58 deletions(-) (limited to 'src/protocols/FrogColorManagement.cpp') diff --git a/src/protocols/FrogColorManagement.cpp b/src/protocols/FrogColorManagement.cpp index 870b573f..42d3c496 100644 --- a/src/protocols/FrogColorManagement.cpp +++ b/src/protocols/FrogColorManagement.cpp @@ -22,14 +22,14 @@ static wpColorManagerV1Primaries getWPPrimaries(frogColorManagedSurfacePrimaries return (wpColorManagerV1Primaries)(primaries + 1); } -CFrogColorManager::CFrogColorManager(SP resource_) : resource(resource_) { +CFrogColorManager::CFrogColorManager(SP resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->setDestroy([](CFrogColorManagementFactoryV1* r) { LOGM(TRACE, "Destroy frog_color_management at {:x} (generated default)", (uintptr_t)r); }); - resource->setOnDestroy([this](CFrogColorManagementFactoryV1* r) { PROTO::frogColorManagement->destroyResource(this); }); + m_resource->setDestroy([](CFrogColorManagementFactoryV1* r) { LOGM(TRACE, "Destroy frog_color_management at {:x} (generated default)", (uintptr_t)r); }); + m_resource->setOnDestroy([this](CFrogColorManagementFactoryV1* r) { PROTO::frogColorManagement->destroyResource(this); }); - resource->setGetColorManagedSurface([](CFrogColorManagementFactoryV1* r, wl_resource* surface, uint32_t id) { + m_resource->setGetColorManagedSurface([](CFrogColorManagementFactoryV1* r, wl_resource* surface, uint32_t id) { LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); auto SURF = CWLSurfaceResource::fromResource(surface); @@ -39,70 +39,70 @@ CFrogColorManager::CFrogColorManager(SP resource_ return; } - const auto RESOURCE = PROTO::frogColorManagement->m_vSurfaces.emplace_back( - makeShared(makeShared(r->client(), r->version(), id), SURF)); + const auto RESOURCE = + PROTO::frogColorManagement->m_surfaces.emplace_back(makeShared(makeShared(r->client(), r->version(), id), SURF)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::frogColorManagement->m_vSurfaces.pop_back(); + PROTO::frogColorManagement->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); } bool CFrogColorManager::good() { - return resource->resource(); + return m_resource->resource(); } -CFrogColorManagementSurface::CFrogColorManagementSurface(SP resource_, SP surface_) : surface(surface_), resource(resource_) { +CFrogColorManagementSurface::CFrogColorManagementSurface(SP resource_, SP surface_) : m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - if (!surface->m_colorManagement.valid()) { - const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared(surface_)); + if (!m_surface->m_colorManagement.valid()) { + const auto RESOURCE = PROTO::colorManagement->m_surfaces.emplace_back(makeShared(surface_)); if UNLIKELY (!RESOURCE) { - resource->noMemory(); - PROTO::colorManagement->m_vSurfaces.pop_back(); + m_resource->noMemory(); + PROTO::colorManagement->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; - surface->m_colorManagement = RESOURCE; + m_surface->m_colorManagement = RESOURCE; - resource->setOnDestroy([this](CFrogColorManagedSurface* r) { - LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)surface); - if (surface.valid()) - PROTO::colorManagement->destroyResource(surface->m_colorManagement.get()); + m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) { + LOGM(TRACE, "Destroy frog cm and xx cm for surface {}", (uintptr_t)m_surface); + if (m_surface.valid()) + PROTO::colorManagement->destroyResource(m_surface->m_colorManagement.get()); PROTO::frogColorManagement->destroyResource(this); }); } else - resource->setOnDestroy([this](CFrogColorManagedSurface* r) { - LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)surface); + m_resource->setOnDestroy([this](CFrogColorManagedSurface* r) { + LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface); PROTO::frogColorManagement->destroyResource(this); }); - resource->setDestroy([this](CFrogColorManagedSurface* r) { - LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)surface); + m_resource->setDestroy([this](CFrogColorManagedSurface* r) { + LOGM(TRACE, "Destroy frog cm surface {}", (uintptr_t)m_surface); PROTO::frogColorManagement->destroyResource(this); }); - resource->setSetKnownTransferFunction([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceTransferFunction tf) { - LOGM(TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, surface->id()); + m_resource->setSetKnownTransferFunction([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceTransferFunction tf) { + LOGM(TRACE, "Set frog cm transfer function {} for {}", (uint32_t)tf, m_surface->id()); switch (tf) { case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ: - surface->m_colorManagement->m_imageDescription.transferFunction = + m_surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); break; ; case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22: - if (pqIntentSent) { + if (m_pqIntentSent) { LOGM(TRACE, "FIXME: assuming broken enum value 2 (FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22) referring to eotf value 2 (TRANSFER_FUNCTION_ST2084_PQ)"); - surface->m_colorManagement->m_imageDescription.transferFunction = + m_surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ)); break; }; @@ -110,49 +110,49 @@ CFrogColorManagementSurface::CFrogColorManagementSurface(SPm_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf)); + m_surface->m_colorManagement->m_imageDescription.transferFunction = convertTransferFunction(getWPTransferFunction(tf)); - surface->m_colorManagement->setHasImageDescription(true); + m_surface->m_colorManagement->setHasImageDescription(true); } }); - resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) { + m_resource->setSetKnownContainerColorVolume([this](CFrogColorManagedSurface* r, frogColorManagedSurfacePrimaries primariesName) { LOGM(TRACE, "Set frog cm primaries {}", (uint32_t)primariesName); switch (primariesName) { case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_UNDEFINED: - case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; break; - case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC2020: surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT2020; break; + case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC709: m_surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT709; break; + case FROG_COLOR_MANAGED_SURFACE_PRIMARIES_REC2020: m_surface->m_colorManagement->m_imageDescription.primaries = NColorPrimaries::BT2020; break; } - surface->m_colorManagement->m_imageDescription.primariesNamed = convertPrimaries(getWPPrimaries(primariesName)); + m_surface->m_colorManagement->m_imageDescription.primariesNamed = convertPrimaries(getWPPrimaries(primariesName)); - surface->m_colorManagement->setHasImageDescription(true); + m_surface->m_colorManagement->setHasImageDescription(true); }); - resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) { + m_resource->setSetRenderIntent([this](CFrogColorManagedSurface* r, frogColorManagedSurfaceRenderIntent intent) { LOGM(TRACE, "Set frog cm intent {}", (uint32_t)intent); - pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL; - surface->m_colorManagement->setHasImageDescription(true); + m_pqIntentSent = intent == FROG_COLOR_MANAGED_SURFACE_RENDER_INTENT_PERCEPTUAL; + m_surface->m_colorManagement->setHasImageDescription(true); }); - resource->setSetHdrMetadata([this](CFrogColorManagedSurface* r, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y, - uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) { + m_resource->setSetHdrMetadata([this](CFrogColorManagedSurface* r, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, + uint32_t w_y, uint32_t max_lum, uint32_t min_lum, uint32_t cll, uint32_t fall) { LOGM(TRACE, "Set frog primaries r:{},{} g:{},{} b:{},{} w:{},{} luminances {} - {} cll {} fall {}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y, min_lum, max_lum, cll, fall); - surface->m_colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f}, - .green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f}, - .blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f}, - .white = {.x = w_x / 50000.0f, .y = w_y / 50000.0f}}; - surface->m_colorManagement->m_imageDescription.masteringLuminances.min = min_lum / 10000.0f; - surface->m_colorManagement->m_imageDescription.masteringLuminances.max = max_lum; - surface->m_colorManagement->m_imageDescription.maxCLL = cll; - surface->m_colorManagement->m_imageDescription.maxFALL = fall; - - surface->m_colorManagement->setHasImageDescription(true); + m_surface->m_colorManagement->m_imageDescription.masteringPrimaries = SPCPRimaries{.red = {.x = r_x / 50000.0f, .y = r_y / 50000.0f}, + .green = {.x = g_x / 50000.0f, .y = g_y / 50000.0f}, + .blue = {.x = b_x / 50000.0f, .y = b_y / 50000.0f}, + .white = {.x = w_x / 50000.0f, .y = w_y / 50000.0f}}; + m_surface->m_colorManagement->m_imageDescription.masteringLuminances.min = min_lum / 10000.0f; + m_surface->m_colorManagement->m_imageDescription.masteringLuminances.max = max_lum; + m_surface->m_colorManagement->m_imageDescription.maxCLL = cll; + m_surface->m_colorManagement->m_imageDescription.maxFALL = fall; + + m_surface->m_colorManagement->setHasImageDescription(true); }); } bool CFrogColorManagementSurface::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CFrogColorManagementSurface::client() { - return pClient; + return m_client; } CFrogColorManagementProtocol::CFrogColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -160,11 +160,11 @@ CFrogColorManagementProtocol::CFrogColorManagementProtocol(const wl_interface* i } void CFrogColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared(makeShared(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } @@ -172,9 +172,9 @@ void CFrogColorManagementProtocol::bindManager(wl_client* client, void* data, ui } void CFrogColorManagementProtocol::destroyResource(CFrogColorManager* resource) { - std::erase_if(m_vManagers, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_managers, [&](const auto& other) { return other.get() == resource; }); } void CFrogColorManagementProtocol::destroyResource(CFrogColorManagementSurface* resource) { - std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_surfaces, [&](const auto& other) { return other.get() == resource; }); } -- cgit v1.2.3