summaryrefslogtreecommitdiff
path: root/src/helpers/Monitor.cpp
diff options
context:
space:
mode:
authorDominick DiMaggio <ddimaggio324@gmail.com>2025-10-29 08:53:42 -0400
committerGitHub <noreply@github.com>2025-10-29 12:53:42 +0000
commitff50dc36e912b6ad764802d51be838bc7f6ed323 (patch)
treea51a09b12e89b9ee3c5ceb2f082c09e49ff146ea /src/helpers/Monitor.cpp
parentce9787b3f47ce550027274a1aa25e74b6fb1c74a (diff)
renderer/cm: allow gamma 2.2 instead of sRGB EOTF (#12094)
Diffstat (limited to 'src/helpers/Monitor.cpp')
-rw-r--r--src/helpers/Monitor.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index e12a4bff..08dbdaea 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -465,32 +465,41 @@ void CMonitor::onDisconnect(bool destroy) {
std::erase_if(g_pCompositor->m_monitors, [&](PHLMONITOR& el) { return el.get() == this; });
}
-void CMonitor::applyCMType(NCMType::eCMType cmType) {
- auto oldImageDescription = m_imageDescription;
+void CMonitor::applyCMType(NCMType::eCMType cmType, int cmSdrEotf) {
+ auto oldImageDescription = m_imageDescription;
+ static auto PSDREOTF = CConfigValue<Hyprlang::INT>("render:cm_sdr_eotf");
+ auto chosenSdrEotf = cmSdrEotf == 0 ? (*PSDREOTF > 0 ? NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22 : NColorManagement::CM_TRANSFER_FUNCTION_SRGB) :
+ (cmSdrEotf == 1 ? NColorManagement::CM_TRANSFER_FUNCTION_SRGB : NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22);
+
switch (cmType) {
- case NCMType::CM_SRGB: m_imageDescription = {}; break; // assumes SImageDescirption defaults to sRGB
+ case NCMType::CM_SRGB: m_imageDescription = {.transferFunction = chosenSdrEotf}; break; // assumes SImageDescription defaults to sRGB
case NCMType::CM_WIDE:
- m_imageDescription = {.primariesNameSet = true,
+ m_imageDescription = {.transferFunction = chosenSdrEotf,
+ .primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020)};
break;
case NCMType::CM_DCIP3:
- m_imageDescription = {.primariesNameSet = true,
+ m_imageDescription = {.transferFunction = chosenSdrEotf,
+ .primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_DCI_P3,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_DCI_P3)};
break;
case NCMType::CM_DP3:
- m_imageDescription = {.primariesNameSet = true,
+ m_imageDescription = {.transferFunction = chosenSdrEotf,
+ .primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_DISPLAY_P3,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_DISPLAY_P3)};
break;
case NCMType::CM_ADOBE:
- m_imageDescription = {.primariesNameSet = true,
+ m_imageDescription = {.transferFunction = chosenSdrEotf,
+ .primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_ADOBE_RGB,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_ADOBE_RGB)};
break;
case NCMType::CM_EDID:
- m_imageDescription = {.primariesNameSet = false,
+ m_imageDescription = {.transferFunction = chosenSdrEotf,
+ .primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = {
.red = {.x = m_output->parsedEDID.chromaticityCoords->red.x, .y = m_output->parsedEDID.chromaticityCoords->red.y},
@@ -868,6 +877,8 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
default: break;
}
+ m_sdrEotf = RULE->sdrEotf;
+
m_sdrMinLuminance = RULE->sdrMinLuminance;
m_sdrMaxLuminance = RULE->sdrMaxLuminance;
@@ -875,7 +886,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
m_maxLuminance = RULE->maxLuminance;
m_maxAvgLuminance = RULE->maxAvgLuminance;
- applyCMType(m_cmType);
+ applyCMType(m_cmType, m_sdrEotf);
m_sdrSaturation = RULE->sdrSaturation;
m_sdrBrightness = RULE->sdrBrightness;