diff options
| author | davc0n <dconti.dev@gmail.com> | 2025-05-04 23:39:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-04 23:39:00 +0200 |
| commit | 9cd5b257459a6b4c5d5d4d1026df85f0ecbe5a93 (patch) | |
| tree | c1ec209a122a10ab637ba62da5eabb0fea0d1568 /src/protocols/XXColorManagement.cpp | |
| parent | 78ff20ddf03166c7fa769419b7c2861db89f412b (diff) | |
protocols: refactor class member vars (u-z) (#10282)
* protocols: refactor class member vars (u-z)
* protocols: fix clang format
Diffstat (limited to 'src/protocols/XXColorManagement.cpp')
| -rw-r--r-- | src/protocols/XXColorManagement.cpp | 351 |
1 files changed, 176 insertions, 175 deletions
diff --git a/src/protocols/XXColorManagement.cpp b/src/protocols/XXColorManagement.cpp index e0a9b61d..5a345f40 100644 --- a/src/protocols/XXColorManagement.cpp +++ b/src/protocols/XXColorManagement.cpp @@ -31,54 +31,54 @@ static wpColorManagerV1Primaries getWPPrimaries(xxColorManagerV4Primaries primar return (wpColorManagerV1Primaries)(primaries + 1); } -CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(resource_) { +CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC); - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_EXTENDED_TARGET_VOLUME); - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES); - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_PRIMARIES); - resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES); - - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_SRGB); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_NTSC); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_GENERIC_FILM); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_BT2020); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_EXTENDED_TARGET_VOLUME); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_PRIMARIES); + m_resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_SET_LUMINANCES); + + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_SRGB); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL_M); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_PAL); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_NTSC); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_GENERIC_FILM); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_BT2020); // resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_CIE1931_XYZ); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3); - resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB); - - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_HLG); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ); - resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR); - - resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3); + m_resource->sendSupportedPrimariesNamed(XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB); + + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA28); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_HLG); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ); + m_resource->sendSupportedTfNamed(XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR); + + m_resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL); // resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE); // resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_ABSOLUTE); // resource->sendSupportedIntent(XX_COLOR_MANAGER_V4_RENDER_INTENT_RELATIVE_BPC); - resource->setDestroy([](CXxColorManagerV4* r) { LOGM(TRACE, "Destroy xx_color_manager at {:x} (generated default)", (uintptr_t)r); }); - resource->setGetOutput([](CXxColorManagerV4* r, uint32_t id, wl_resource* output) { + m_resource->setDestroy([](CXxColorManagerV4* r) { LOGM(TRACE, "Destroy xx_color_manager at {:x} (generated default)", (uintptr_t)r); }); + m_resource->setGetOutput([](CXxColorManagerV4* r, uint32_t id, wl_resource* output) { LOGM(TRACE, "Get output for id={}, output={}", id, (uintptr_t)output); const auto RESOURCE = - PROTO::xxColorManagement->m_vOutputs.emplace_back(makeShared<CXXColorManagementOutput>(makeShared<CXxColorManagementOutputV4>(r->client(), r->version(), id))); + PROTO::xxColorManagement->m_outputs.emplace_back(makeShared<CXXColorManagementOutput>(makeShared<CXxColorManagementOutputV4>(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vOutputs.pop_back(); + PROTO::xxColorManagement->m_outputs.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); - resource->setGetSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) { + m_resource->setGetSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) { LOGM(TRACE, "Get surface for id={}, surface={}", id, (uintptr_t)surface); auto SURF = CWLSurfaceResource::fromResource(surface); @@ -94,16 +94,16 @@ CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(res } const auto RESOURCE = - PROTO::xxColorManagement->m_vSurfaces.emplace_back(makeShared<CXXColorManagementSurface>(makeShared<CXxColorManagementSurfaceV4>(r->client(), r->version(), id), SURF)); + PROTO::xxColorManagement->m_surfaces.emplace_back(makeShared<CXXColorManagementSurface>(makeShared<CXxColorManagementSurfaceV4>(r->client(), r->version(), id), SURF)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vSurfaces.pop_back(); + PROTO::xxColorManagement->m_surfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); - resource->setGetFeedbackSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) { + m_resource->setGetFeedbackSurface([](CXxColorManagerV4* r, uint32_t id, wl_resource* surface) { LOGM(TRACE, "Get feedback surface for id={}, surface={}", id, (uintptr_t)surface); auto SURF = CWLSurfaceResource::fromResource(surface); @@ -113,118 +113,118 @@ CXXColorManager::CXXColorManager(SP<CXxColorManagerV4> resource_) : resource(res return; } - const auto RESOURCE = PROTO::xxColorManagement->m_vFeedbackSurfaces.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_feedbackSurfaces.emplace_back( makeShared<CXXColorManagementFeedbackSurface>(makeShared<CXxColorManagementFeedbackSurfaceV4>(r->client(), r->version(), id), SURF)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vFeedbackSurfaces.pop_back(); + PROTO::xxColorManagement->m_feedbackSurfaces.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); - resource->setNewIccCreator([](CXxColorManagerV4* r, uint32_t id) { + m_resource->setNewIccCreator([](CXxColorManagerV4* r, uint32_t id) { LOGM(WARN, "New ICC creator for id={} (unsupported)", id); r->error(XX_COLOR_MANAGER_V4_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported"); }); - resource->setNewParametricCreator([](CXxColorManagerV4* r, uint32_t id) { + m_resource->setNewParametricCreator([](CXxColorManagerV4* r, uint32_t id) { LOGM(TRACE, "New parametric creator for id={}", id); - const auto RESOURCE = PROTO::xxColorManagement->m_vParametricCreators.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_parametricCreators.emplace_back( makeShared<CXXColorManagementParametricCreator>(makeShared<CXxImageDescriptionCreatorParamsV4>(r->client(), r->version(), id))); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vParametricCreators.pop_back(); + PROTO::xxColorManagement->m_parametricCreators.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); - resource->setOnDestroy([this](CXxColorManagerV4* r) { PROTO::xxColorManagement->destroyResource(this); }); + m_resource->setOnDestroy([this](CXxColorManagerV4* r) { PROTO::xxColorManagement->destroyResource(this); }); } bool CXXColorManager::good() { - return resource->resource(); + return m_resource->resource(); } -CXXColorManagementOutput::CXXColorManagementOutput(SP<CXxColorManagementOutputV4> resource_) : resource(resource_) { +CXXColorManagementOutput::CXXColorManagementOutput(SP<CXxColorManagementOutputV4> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - resource->setDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); }); - resource->setOnDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); }); + m_resource->setDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); }); + m_resource->setOnDestroy([this](CXxColorManagementOutputV4* r) { PROTO::xxColorManagement->destroyResource(this); }); - resource->setGetImageDescription([this](CXxColorManagementOutputV4* r, uint32_t id) { + m_resource->setGetImageDescription([this](CXxColorManagementOutputV4* r, uint32_t id) { LOGM(TRACE, "Get image description for output={}, id={}", (uintptr_t)r, id); - if (imageDescription.valid()) - PROTO::xxColorManagement->destroyResource(imageDescription.get()); + if (m_imageDescription.valid()) + PROTO::xxColorManagement->destroyResource(m_imageDescription.get()); - const auto RESOURCE = PROTO::xxColorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_imageDescriptions.emplace_back( makeShared<CXXColorManagementImageDescription>(makeShared<CXxImageDescriptionV4>(r->client(), r->version(), id), true)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vImageDescriptions.pop_back(); + PROTO::xxColorManagement->m_imageDescriptions.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; }); } bool CXXColorManagementOutput::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CXXColorManagementOutput::client() { - return pClient; + return m_client; } -CXXColorManagementSurface::CXXColorManagementSurface(SP<CWLSurfaceResource> surface_) : surface(surface_) { +CXXColorManagementSurface::CXXColorManagementSurface(SP<CWLSurfaceResource> surface_) : m_surface(surface_) { // only for frog cm untill wayland cm is adopted } -CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) { +CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - if (!surface->m_colorManagement.valid()) { + if (!m_surface->m_colorManagement.valid()) { const auto RESOURCE = PROTO::colorManagement->m_surfaces.emplace_back(makeShared<CColorManagementSurface>(surface_)); if UNLIKELY (!RESOURCE) { - resource->noMemory(); + m_resource->noMemory(); PROTO::colorManagement->m_surfaces.pop_back(); return; } RESOURCE->m_self = RESOURCE; - surface->m_colorManagement = RESOURCE; + m_surface->m_colorManagement = RESOURCE; - resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { - LOGM(TRACE, "Destroy wp cm and xx cm for surface {}", (uintptr_t)surface); - if (surface.valid()) - PROTO::colorManagement->destroyResource(surface->m_colorManagement.get()); + m_resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { + LOGM(TRACE, "Destroy wp cm and xx cm for surface {}", (uintptr_t)m_surface); + if (m_surface.valid()) + PROTO::colorManagement->destroyResource(m_surface->m_colorManagement.get()); PROTO::xxColorManagement->destroyResource(this); }); } else - resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { - LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface); + m_resource->setOnDestroy([this](CXxColorManagementSurfaceV4* r) { + LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface); PROTO::xxColorManagement->destroyResource(this); }); - resource->setDestroy([this](CXxColorManagementSurfaceV4* r) { - LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)surface); + m_resource->setDestroy([this](CXxColorManagementSurfaceV4* r) { + LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface); PROTO::xxColorManagement->destroyResource(this); }); - resource->setSetImageDescription([this](CXxColorManagementSurfaceV4* r, wl_resource* image_description, uint32_t render_intent) { + m_resource->setSetImageDescription([this](CXxColorManagementSurfaceV4* r, wl_resource* image_description, uint32_t render_intent) { LOGM(TRACE, "Set image description for surface={}, desc={}, intent={}", (uintptr_t)r, (uintptr_t)image_description, render_intent); const auto PO = (CXxImageDescriptionV4*)wl_resource_get_user_data(image_description); @@ -237,35 +237,35 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac return; } - const auto imageDescription = std::find_if(PROTO::xxColorManagement->m_vImageDescriptions.begin(), PROTO::xxColorManagement->m_vImageDescriptions.end(), + const auto imageDescription = std::find_if(PROTO::xxColorManagement->m_imageDescriptions.begin(), PROTO::xxColorManagement->m_imageDescriptions.end(), [&](const auto& other) { return other->resource()->resource() == image_description; }); - if (imageDescription == PROTO::xxColorManagement->m_vImageDescriptions.end()) { + if (imageDescription == PROTO::xxColorManagement->m_imageDescriptions.end()) { r->error(XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, "Image description not found"); return; } - if (surface.valid()) { - surface->m_colorManagement->m_imageDescription = imageDescription->get()->settings; - surface->m_colorManagement->setHasImageDescription(true); + if (m_surface.valid()) { + m_surface->m_colorManagement->m_imageDescription = imageDescription->get()->m_settings; + m_surface->m_colorManagement->setHasImageDescription(true); } else LOGM(ERR, "Set image description for invalid surface"); }); - resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) { + m_resource->setUnsetImageDescription([this](CXxColorManagementSurfaceV4* r) { LOGM(TRACE, "Unset image description for surface={}", (uintptr_t)r); - if (surface.valid()) { - surface->m_colorManagement->m_imageDescription = SImageDescription{}; - surface->m_colorManagement->setHasImageDescription(false); + if (m_surface.valid()) { + m_surface->m_colorManagement->m_imageDescription = SImageDescription{}; + m_surface->m_colorManagement->setHasImageDescription(false); } else LOGM(ERR, "Unset image description for invalid surface"); }); } bool CXXColorManagementSurface::good() { - return resource && resource->resource(); + return m_resource && m_resource->resource(); } wl_client* CXXColorManagementSurface::client() { - return pClient; + return m_client; } const SImageDescription& CXXColorManagementSurface::imageDescription() { @@ -297,104 +297,104 @@ bool CXXColorManagementSurface::needsHdrMetadataUpdate() { } CXXColorManagementFeedbackSurface::CXXColorManagementFeedbackSurface(SP<CXxColorManagementFeedbackSurfaceV4> resource_, SP<CWLSurfaceResource> surface_) : - surface(surface_), resource(resource_) { + m_surface(surface_), m_resource(resource_) { if UNLIKELY (!good()) return; - pClient = resource->client(); + m_client = m_resource->client(); - resource->setDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) { - LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface); + m_resource->setDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) { + LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface); if (m_currentPreferred.valid()) PROTO::xxColorManagement->destroyResource(m_currentPreferred.get()); PROTO::xxColorManagement->destroyResource(this); }); - resource->setOnDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) { - LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)surface); + m_resource->setOnDestroy([this](CXxColorManagementFeedbackSurfaceV4* r) { + LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface); if (m_currentPreferred.valid()) PROTO::xxColorManagement->destroyResource(m_currentPreferred.get()); PROTO::xxColorManagement->destroyResource(this); }); - resource->setGetPreferred([this](CXxColorManagementFeedbackSurfaceV4* r, uint32_t id) { + m_resource->setGetPreferred([this](CXxColorManagementFeedbackSurfaceV4* r, uint32_t id) { LOGM(TRACE, "Get preferred for id {}", id); if (m_currentPreferred.valid()) PROTO::xxColorManagement->destroyResource(m_currentPreferred.get()); - const auto RESOURCE = PROTO::xxColorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_imageDescriptions.emplace_back( makeShared<CXXColorManagementImageDescription>(makeShared<CXxImageDescriptionV4>(r->client(), r->version(), id), true)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vImageDescriptions.pop_back(); + PROTO::xxColorManagement->m_imageDescriptions.pop_back(); return; } - RESOURCE->self = RESOURCE; + RESOURCE->m_self = RESOURCE; m_currentPreferred = RESOURCE; - m_currentPreferred->settings = g_pCompositor->getPreferredImageDescription(); + m_currentPreferred->m_settings = g_pCompositor->getPreferredImageDescription(); RESOURCE->resource()->sendReady(id); }); } bool CXXColorManagementFeedbackSurface::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CXXColorManagementFeedbackSurface::client() { - return pClient; + return m_client; } -CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxImageDescriptionCreatorParamsV4> resource_) : resource(resource_) { +CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxImageDescriptionCreatorParamsV4> resource_) : m_resource(resource_) { if UNLIKELY (!good()) return; // - pClient = resource->client(); + m_client = m_resource->client(); - resource->setOnDestroy([this](CXxImageDescriptionCreatorParamsV4* r) { PROTO::xxColorManagement->destroyResource(this); }); + m_resource->setOnDestroy([this](CXxImageDescriptionCreatorParamsV4* r) { PROTO::xxColorManagement->destroyResource(this); }); - resource->setCreate([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t id) { + m_resource->setCreate([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t id) { LOGM(TRACE, "Create image description from params for id {}", id); // FIXME actually check completeness - if (!valuesSet) { + if (!m_valuesSet) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INCOMPLETE_SET, "Missing required settings"); return; } // FIXME actually check consistency - if (!valuesSet) { + if (!m_valuesSet) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INCONSISTENT_SET, "Set is not consistent"); return; } - const auto RESOURCE = PROTO::xxColorManagement->m_vImageDescriptions.emplace_back( + const auto RESOURCE = PROTO::xxColorManagement->m_imageDescriptions.emplace_back( makeShared<CXXColorManagementImageDescription>(makeShared<CXxImageDescriptionV4>(r->client(), r->version(), id), false)); if UNLIKELY (!RESOURCE->good()) { r->noMemory(); - PROTO::xxColorManagement->m_vImageDescriptions.pop_back(); + PROTO::xxColorManagement->m_imageDescriptions.pop_back(); return; } // FIXME actually check support - if (!valuesSet) { + if (!m_valuesSet) { RESOURCE->resource()->sendFailed(XX_IMAGE_DESCRIPTION_V4_CAUSE_UNSUPPORTED, "unsupported"); return; } - RESOURCE->self = RESOURCE; - RESOURCE->settings = settings; + RESOURCE->m_self = RESOURCE; + RESOURCE->m_settings = m_settings; RESOURCE->resource()->sendReady(id); PROTO::xxColorManagement->destroyResource(this); }); - resource->setSetTfNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t tf) { + m_resource->setSetTfNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t tf) { LOGM(TRACE, "Set image description transfer function to {}", tf); - if (valuesSet & PC_TF) { + if (m_valuesSet & PC_TF) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Transfer function already set"); return; } @@ -409,21 +409,21 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI default: r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_TF, "Unsupported transfer function"); return; } - settings.transferFunction = convertTransferFunction(getWPTransferFunction((xxColorManagerV4TransferFunction)tf)); - valuesSet |= PC_TF; + m_settings.transferFunction = convertTransferFunction(getWPTransferFunction((xxColorManagerV4TransferFunction)tf)); + m_valuesSet |= PC_TF; }); - resource->setSetTfPower([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t eexp) { + m_resource->setSetTfPower([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t eexp) { LOGM(TRACE, "Set image description tf power to {}", eexp); - if (valuesSet & PC_TF_POWER) { + if (m_valuesSet & PC_TF_POWER) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Transfer function power already set"); return; } - settings.transferFunctionPower = eexp / 10000.0f; - valuesSet |= PC_TF_POWER; + m_settings.transferFunctionPower = eexp / 10000.0f; + m_valuesSet |= PC_TF_POWER; }); - resource->setSetPrimariesNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t primaries) { + m_resource->setSetPrimariesNamed([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t primaries) { LOGM(TRACE, "Set image description primaries by name {}", primaries); - if (valuesSet & PC_PRIMARIES) { + if (m_valuesSet & PC_PRIMARIES) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Primaries already set"); return; } @@ -438,29 +438,29 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI case XX_COLOR_MANAGER_V4_PRIMARIES_DCI_P3: case XX_COLOR_MANAGER_V4_PRIMARIES_DISPLAY_P3: case XX_COLOR_MANAGER_V4_PRIMARIES_ADOBE_RGB: - settings.primariesNameSet = true; - settings.primariesNamed = convertPrimaries(getWPPrimaries((xxColorManagerV4Primaries)primaries)); - settings.primaries = getPrimaries(settings.primariesNamed); - valuesSet |= PC_PRIMARIES; + m_settings.primariesNameSet = true; + m_settings.primariesNamed = convertPrimaries(getWPPrimaries((xxColorManagerV4Primaries)primaries)); + m_settings.primaries = getPrimaries(m_settings.primariesNamed); + m_valuesSet |= PC_PRIMARIES; break; default: r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_PRIMARIES, "Unsupported primaries"); } }); - resource->setSetPrimaries( + m_resource->setSetPrimaries( [this](CXxImageDescriptionCreatorParamsV4* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { LOGM(TRACE, "Set image description primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); - if (valuesSet & PC_PRIMARIES) { + if (m_valuesSet & PC_PRIMARIES) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Primaries already set"); return; } - settings.primariesNameSet = false; - settings.primaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}}; - valuesSet |= PC_PRIMARIES; + m_settings.primariesNameSet = false; + m_settings.primaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}}; + m_valuesSet |= PC_PRIMARIES; }); - resource->setSetLuminances([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) { + m_resource->setSetLuminances([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) { auto min = min_lum / 10000.0f; LOGM(TRACE, "Set image description luminances to {} - {} ({})", min, max_lum, reference_lum); - if (valuesSet & PC_LUMINANCES) { + if (m_valuesSet & PC_LUMINANCES) { r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Luminances already set"); return; } @@ -468,20 +468,20 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, "Invalid luminances"); return; } - settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum}; - valuesSet |= PC_LUMINANCES; + m_settings.luminances = SImageDescription::SPCLuminances{.min = min, .max = max_lum, .reference = reference_lum}; + m_valuesSet |= PC_LUMINANCES; }); - resource->setSetMasteringDisplayPrimaries( + m_resource->setSetMasteringDisplayPrimaries( [this](CXxImageDescriptionCreatorParamsV4* r, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) { LOGM(TRACE, "Set image description mastering primaries by values r:{},{} g:{},{} b:{},{} w:{},{}", r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y); // if (valuesSet & PC_MASTERING_PRIMARIES) { // r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Mastering primaries already set"); // return; // } - settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}}; - valuesSet |= PC_MASTERING_PRIMARIES; + m_settings.masteringPrimaries = SPCPRimaries{.red = {.x = r_x, .y = r_y}, .green = {.x = g_x, .y = g_y}, .blue = {.x = b_x, .y = b_y}, .white = {.x = w_x, .y = w_y}}; + m_valuesSet |= PC_MASTERING_PRIMARIES; }); - resource->setSetMasteringLuminance([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum) { + m_resource->setSetMasteringLuminance([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t min_lum, uint32_t max_lum) { auto min = min_lum / 10000.0f; LOGM(TRACE, "Set image description mastering luminances to {} - {}", min, max_lum); // if (valuesSet & PC_MASTERING_LUMINANCES) { @@ -492,35 +492,35 @@ CXXColorManagementParametricCreator::CXXColorManagementParametricCreator(SP<CXxI r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_INVALID_LUMINANCE, "Invalid luminances"); return; } - settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum}; - valuesSet |= PC_MASTERING_LUMINANCES; + m_settings.masteringLuminances = SImageDescription::SPCMasteringLuminances{.min = min, .max = max_lum}; + m_valuesSet |= PC_MASTERING_LUMINANCES; }); - resource->setSetMaxCll([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_cll) { + m_resource->setSetMaxCll([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_cll) { LOGM(TRACE, "Set image description max content light level to {}", max_cll); // if (valuesSet & PC_CLL) { // r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Max CLL already set"); // return; // } - settings.maxCLL = max_cll; - valuesSet |= PC_CLL; + m_settings.maxCLL = max_cll; + m_valuesSet |= PC_CLL; }); - resource->setSetMaxFall([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_fall) { + m_resource->setSetMaxFall([this](CXxImageDescriptionCreatorParamsV4* r, uint32_t max_fall) { LOGM(TRACE, "Set image description max frame-average light level to {}", max_fall); // if (valuesSet & PC_FALL) { // r->error(XX_IMAGE_DESCRIPTION_CREATOR_PARAMS_V4_ERROR_ALREADY_SET, "Max FALL already set"); // return; // } - settings.maxFALL = max_fall; - valuesSet |= PC_FALL; + m_settings.maxFALL = max_fall; + m_valuesSet |= PC_FALL; }); } bool CXXColorManagementParametricCreator::good() { - return resource->resource(); + return m_resource->resource(); } wl_client* CXXColorManagementParametricCreator::client() { - return pClient; + return m_client; } CXXColorManagementImageDescription::CXXColorManagementImageDescription(SP<CXxImageDescriptionV4> resource_, bool allowGetInformation) : @@ -528,7 +528,7 @@ CXXColorManagementImageDescription::CXXColorManagementImageDescription(SP<CXxIma if UNLIKELY (!good()) return; - pClient = m_resource->client(); + m_client = m_resource->client(); m_resource->setDestroy([this](CXxImageDescriptionV4* r) { PROTO::xxColorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CXxImageDescriptionV4* r) { PROTO::xxColorManagement->destroyResource(this); }); @@ -540,7 +540,7 @@ CXXColorManagementImageDescription::CXXColorManagementImageDescription(SP<CXxIma return; } - auto RESOURCE = makeShared<CXXColorManagementImageDescriptionInfo>(makeShared<CXxImageDescriptionInfoV4>(r->client(), r->version(), id), settings); + auto RESOURCE = makeShared<CXXColorManagementImageDescriptionInfo>(makeShared<CXxImageDescriptionInfoV4>(r->client(), r->version(), id), m_settings); if UNLIKELY (!RESOURCE->good()) r->noMemory(); @@ -555,7 +555,7 @@ bool CXXColorManagementImageDescription::good() { } wl_client* CXXColorManagementImageDescription::client() { - return pClient; + return m_client; } SP<CXxImageDescriptionV4> CXXColorManagementImageDescription::resource() { @@ -563,33 +563,34 @@ SP<CXxImageDescriptionV4> CXXColorManagementImageDescription::resource() { } CXXColorManagementImageDescriptionInfo::CXXColorManagementImageDescriptionInfo(SP<CXxImageDescriptionInfoV4> resource_, const SImageDescription& settings_) : - m_resource(resource_), settings(settings_) { + m_resource(resource_), m_settings(settings_) { if UNLIKELY (!good()) return; - pClient = m_resource->client(); + m_client = m_resource->client(); const auto toProto = [](float value) { return int32_t(std::round(value * 10000)); }; - if (settings.icc.fd >= 0) - m_resource->sendIccFile(settings.icc.fd, settings.icc.length); + if (m_settings.icc.fd >= 0) + m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length); // send preferred client paramateres - m_resource->sendPrimaries(toProto(settings.primaries.red.x), toProto(settings.primaries.red.y), toProto(settings.primaries.green.x), toProto(settings.primaries.green.y), - toProto(settings.primaries.blue.x), toProto(settings.primaries.blue.y), toProto(settings.primaries.white.x), toProto(settings.primaries.white.y)); - if (settings.primariesNameSet) - m_resource->sendPrimariesNamed(settings.primariesNamed); - m_resource->sendTfPower(std::round(settings.transferFunctionPower * 10000)); - m_resource->sendTfNamed(settings.transferFunction); - m_resource->sendLuminances(std::round(settings.luminances.min * 10000), settings.luminances.max, settings.luminances.reference); + m_resource->sendPrimaries(toProto(m_settings.primaries.red.x), toProto(m_settings.primaries.red.y), toProto(m_settings.primaries.green.x), + toProto(m_settings.primaries.green.y), toProto(m_settings.primaries.blue.x), toProto(m_settings.primaries.blue.y), + toProto(m_settings.primaries.white.x), toProto(m_settings.primaries.white.y)); + if (m_settings.primariesNameSet) + m_resource->sendPrimariesNamed(m_settings.primariesNamed); + m_resource->sendTfPower(std::round(m_settings.transferFunctionPower * 10000)); + m_resource->sendTfNamed(m_settings.transferFunction); + m_resource->sendLuminances(std::round(m_settings.luminances.min * 10000), m_settings.luminances.max, m_settings.luminances.reference); // send expexted display paramateres - m_resource->sendTargetPrimaries(toProto(settings.masteringPrimaries.red.x), toProto(settings.masteringPrimaries.red.y), toProto(settings.masteringPrimaries.green.x), - toProto(settings.masteringPrimaries.green.y), toProto(settings.masteringPrimaries.blue.x), toProto(settings.masteringPrimaries.blue.y), - toProto(settings.masteringPrimaries.white.x), toProto(settings.masteringPrimaries.white.y)); - m_resource->sendTargetLuminance(std::round(settings.masteringLuminances.min * 10000), settings.masteringLuminances.max); - m_resource->sendTargetMaxCll(settings.maxCLL); - m_resource->sendTargetMaxFall(settings.maxFALL); + m_resource->sendTargetPrimaries(toProto(m_settings.masteringPrimaries.red.x), toProto(m_settings.masteringPrimaries.red.y), toProto(m_settings.masteringPrimaries.green.x), + toProto(m_settings.masteringPrimaries.green.y), toProto(m_settings.masteringPrimaries.blue.x), toProto(m_settings.masteringPrimaries.blue.y), + toProto(m_settings.masteringPrimaries.white.x), toProto(m_settings.masteringPrimaries.white.y)); + m_resource->sendTargetLuminance(std::round(m_settings.masteringLuminances.min * 10000), m_settings.masteringLuminances.max); + m_resource->sendTargetMaxCll(m_settings.maxCLL); + m_resource->sendTargetMaxFall(m_settings.maxFALL); m_resource->sendDone(); } @@ -599,7 +600,7 @@ bool CXXColorManagementImageDescriptionInfo::good() { } wl_client* CXXColorManagementImageDescriptionInfo::client() { - return pClient; + return m_client; } CXXColorManagementProtocol::CXXColorManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -607,11 +608,11 @@ CXXColorManagementProtocol::CXXColorManagementProtocol(const wl_interface* iface } void CXXColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { - const auto RESOURCE = m_vManagers.emplace_back(makeShared<CXXColorManager>(makeShared<CXxColorManagerV4>(client, ver, id))); + const auto RESOURCE = m_managers.emplace_back(makeShared<CXXColorManager>(makeShared<CXxColorManagerV4>(client, ver, id))); if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); - m_vManagers.pop_back(); + m_managers.pop_back(); return; } @@ -619,31 +620,31 @@ void CXXColorManagementProtocol::bindManager(wl_client* client, void* data, uint } void CXXColorManagementProtocol::onImagePreferredChanged() { - for (auto const& feedback : m_vFeedbackSurfaces) { - feedback->resource->sendPreferredChanged(); + for (auto const& feedback : m_feedbackSurfaces) { + feedback->m_resource->sendPreferredChanged(); } } void CXXColorManagementProtocol::destroyResource(CXXColorManager* 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 CXXColorManagementProtocol::destroyResource(CXXColorManagementOutput* resource) { - std::erase_if(m_vOutputs, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_outputs, [&](const auto& other) { return other.get() == resource; }); } void CXXColorManagementProtocol::destroyResource(CXXColorManagementSurface* 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; }); } void CXXColorManagementProtocol::destroyResource(CXXColorManagementFeedbackSurface* resource) { - std::erase_if(m_vFeedbackSurfaces, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_feedbackSurfaces, [&](const auto& other) { return other.get() == resource; }); } void CXXColorManagementProtocol::destroyResource(CXXColorManagementParametricCreator* resource) { - std::erase_if(m_vParametricCreators, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_parametricCreators, [&](const auto& other) { return other.get() == resource; }); } void CXXColorManagementProtocol::destroyResource(CXXColorManagementImageDescription* resource) { - std::erase_if(m_vImageDescriptions, [&](const auto& other) { return other.get() == resource; }); + std::erase_if(m_imageDescriptions, [&](const auto& other) { return other.get() == resource; }); } |
