diff options
| author | UjinT34 <41110182+UjinT34@users.noreply.github.com> | 2025-08-22 13:13:55 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-22 11:13:55 +0100 |
| commit | 4e8875b5e9700c81ca4e169dc7b85bb5b3c8cb7a (patch) | |
| tree | bc3f021c02b7f9c0c452332627421f64ed7a2394 /src/protocols/ColorManagement.cpp | |
| parent | fdf1612f0f0c3a1ffc221a0d9d589a9b4a2af982 (diff) | |
hdr: scRGB, HLG and SDR -> HDR fixes (#11499)
Diffstat (limited to 'src/protocols/ColorManagement.cpp')
| -rw-r--r-- | src/protocols/ColorManagement.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/protocols/ColorManagement.cpp b/src/protocols/ColorManagement.cpp index 349a0b07..d126fea2 100644 --- a/src/protocols/ColorManagement.cpp +++ b/src/protocols/ColorManagement.cpp @@ -15,13 +15,13 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour m_resource->sendSupportedFeature(WP_COLOR_MANAGER_V1_FEATURE_PARAMETRIC); m_resource->sendSupportedFeature(WP_COLOR_MANAGER_V1_FEATURE_SET_PRIMARIES); m_resource->sendSupportedFeature(WP_COLOR_MANAGER_V1_FEATURE_SET_LUMINANCES); + m_resource->sendSupportedFeature(WP_COLOR_MANAGER_V1_FEATURE_WINDOWS_SCRGB); if (PROTO::colorManagement->m_debug) { m_resource->sendSupportedFeature(WP_COLOR_MANAGER_V1_FEATURE_ICC_V2_V4); m_resource->sendSupportedFeature(WP_COLOR_MANAGER_V1_FEATURE_SET_TF_POWER); m_resource->sendSupportedFeature(WP_COLOR_MANAGER_V1_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES); m_resource->sendSupportedFeature(WP_COLOR_MANAGER_V1_FEATURE_EXTENDED_TARGET_VOLUME); - m_resource->sendSupportedFeature(WP_COLOR_MANAGER_V1_FEATURE_WINDOWS_SCRGB); } m_resource->sendSupportedPrimariesNamed(WP_COLOR_MANAGER_V1_PRIMARIES_SRGB); @@ -170,11 +170,7 @@ CColorManager::CColorManager(SP<CWpColorManagerV1> resource) : m_resource(resour RESOURCE->m_self = RESOURCE; }); m_resource->setCreateWindowsScrgb([](CWpColorManagerV1* r, uint32_t id) { - LOGM(WARN, "New Windows scRGB description id={} (unsupported)", id); - if (!PROTO::colorManagement->m_debug) { - r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Windows scRGB profiles are not supported"); - return; - } + LOGM(WARN, "New Windows scRGB description id={}", id); const auto RESOURCE = PROTO::colorManagement->m_imageDescriptions.emplace_back( makeShared<CColorManagementImageDescription>(makeShared<CWpImageDescriptionV1>(r->client(), r->version(), id), false)); @@ -261,11 +257,11 @@ CColorManagementSurface::CColorManagementSurface(SP<CWpColorManagementSurfaceV1> m_client = m_resource->client(); m_resource->setDestroy([this](CWpColorManagementSurfaceV1* r) { - LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface); + LOGM(TRACE, "Destroy wp cm surface {}", (uintptr_t)m_surface); PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpColorManagementSurfaceV1* r) { - LOGM(TRACE, "Destroy xx cm surface {}", (uintptr_t)m_surface); + LOGM(TRACE, "Destroy wp cm surface {}", (uintptr_t)m_surface); PROTO::colorManagement->destroyResource(this); }); @@ -340,6 +336,16 @@ bool CColorManagementSurface::needsHdrMetadataUpdate() { return m_needsNewMetadata; } +bool CColorManagementSurface::isHDR() { + return m_imageDescription.transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ || m_imageDescription.transferFunction == CM_TRANSFER_FUNCTION_HLG || isWindowsScRGB(); +} + +bool CColorManagementSurface::isWindowsScRGB() { + return m_imageDescription.windowsScRGB || + // autodetect scRGB, might be incorrect + (m_imageDescription.primariesNamed == CM_PRIMARIES_SRGB && m_imageDescription.transferFunction == CM_TRANSFER_FUNCTION_EXT_LINEAR); +} + CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorManagementSurfaceFeedbackV1> resource, SP<CWLSurfaceResource> surface_) : m_surface(surface_), m_resource(resource) { if UNLIKELY (!good()) @@ -348,13 +354,13 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana m_client = m_resource->client(); m_resource->setDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) { - LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface); + LOGM(TRACE, "Destroy wp cm feedback surface {}", (uintptr_t)m_surface); if (m_currentPreferred.valid()) PROTO::colorManagement->destroyResource(m_currentPreferred.get()); PROTO::colorManagement->destroyResource(this); }); m_resource->setOnDestroy([this](CWpColorManagementSurfaceFeedbackV1* r) { - LOGM(TRACE, "Destroy xx cm feedback surface {}", (uintptr_t)m_surface); + LOGM(TRACE, "Destroy wp cm feedback surface {}", (uintptr_t)m_surface); if (m_currentPreferred.valid()) PROTO::colorManagement->destroyResource(m_currentPreferred.get()); PROTO::colorManagement->destroyResource(this); @@ -616,10 +622,6 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_ALREADY_SET, "Primaries already set"); return; } - if (!PROTO::colorManagement->m_debug) { - r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "Custom primaries aren't supported"); - return; - } m_settings.primariesNameSet = false; m_settings.primaries = SPCPRimaries{.red = {.x = r_x / 1000000.0f, .y = r_y / 1000000.0f}, .green = {.x = g_x / 1000000.0f, .y = g_y / 1000000.0f}, |
