renderer: better sdr eotf settings (#12812)
This commit is contained in:
parent
0e9196867b
commit
c71fbd854d
9 changed files with 174 additions and 65 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "MiscFunctions.hpp"
|
||||
#include "../macros.hpp"
|
||||
#include "SharedDefs.hpp"
|
||||
#include "../helpers/TransferFunction.hpp"
|
||||
#include "math/Math.hpp"
|
||||
#include "../protocols/ColorManagement.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
|
|
@ -29,6 +30,7 @@
|
|||
#include "../hyprerror/HyprError.hpp"
|
||||
#include "../layout/LayoutManager.hpp"
|
||||
#include "../i18n/Engine.hpp"
|
||||
#include "../protocols/types/ColorManagement.hpp"
|
||||
#include "sync/SyncTimeline.hpp"
|
||||
#include "time/Time.hpp"
|
||||
#include "../desktop/view/LayerSurface.hpp"
|
||||
|
|
@ -480,20 +482,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, int cmSdrEotf) {
|
||||
auto oldImageDescription = m_imageDescription;
|
||||
static auto PSDREOTF = CConfigValue<Hyprlang::INT>("render:cm_sdr_eotf");
|
||||
auto chosenSdrEotf = cmSdrEotf == 0 ? (*PSDREOTF != 3 ? NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22 : NColorManagement::CM_TRANSFER_FUNCTION_SRGB) :
|
||||
(cmSdrEotf == 1 ? NColorManagement::CM_TRANSFER_FUNCTION_SRGB : NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22);
|
||||
static NColorManagement::eTransferFunction chooseTF(NTransferFunction::eTF tf) {
|
||||
const auto sdrEOTF = NTransferFunction::fromConfig();
|
||||
|
||||
const auto masteringPrimaries = getMasteringPrimaries();
|
||||
switch (tf) {
|
||||
case NTransferFunction::TF_DEFAULT:
|
||||
case NTransferFunction::TF_GAMMA22:
|
||||
case NTransferFunction::TF_FORCED_GAMMA22: return NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22;
|
||||
case NTransferFunction::TF_SRGB: return NColorManagement::CM_TRANSFER_FUNCTION_SRGB;
|
||||
|
||||
case NTransferFunction::TF_AUTO: // use global setting
|
||||
switch (sdrEOTF) {
|
||||
case NTransferFunction::TF_AUTO: return NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22;
|
||||
default: return chooseTF(sdrEOTF);
|
||||
}
|
||||
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void CMonitor::applyCMType(NCMType::eCMType cmType, NTransferFunction::eTF cmSdrEotf) {
|
||||
auto oldImageDescription = m_imageDescription;
|
||||
const auto chosenSdrEotf = chooseTF(cmSdrEotf);
|
||||
|
||||
const auto masteringPrimaries = getMasteringPrimaries();
|
||||
const NColorManagement::SImageDescription::SPCMasteringLuminances masteringLuminances = getMasteringLuminances();
|
||||
|
||||
const auto maxFALL = this->maxFALL();
|
||||
const auto maxCLL = this->maxCLL();
|
||||
|
||||
switch (cmType) {
|
||||
case NCMType::CM_SRGB: m_imageDescription = CImageDescription::from({.transferFunction = chosenSdrEotf}); break; // assumes SImageDescription defaults to sRGB
|
||||
case NCMType::CM_SRGB:
|
||||
m_imageDescription = CImageDescription::from({.transferFunction = chosenSdrEotf,
|
||||
.primariesNamed = NColorManagement::CM_PRIMARIES_SRGB,
|
||||
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_SRGB)});
|
||||
break; // assumes SImageDescription defaults to sRGB
|
||||
case NCMType::CM_WIDE:
|
||||
m_imageDescription = CImageDescription::from({.transferFunction = chosenSdrEotf,
|
||||
.primariesNameSet = true,
|
||||
|
|
@ -2152,11 +2175,11 @@ bool CMonitor::canNoShaderCM() {
|
|||
if (SRC_DESC_VALUE.icc.fd >= 0 || m_imageDescription->value().icc.fd >= 0)
|
||||
return false; // no ICC support
|
||||
|
||||
static auto PSDREOTF = CConfigValue<Hyprlang::INT>("render:cm_sdr_eotf");
|
||||
const auto sdrEOTF = NTransferFunction::fromConfig();
|
||||
// only primaries differ
|
||||
return (
|
||||
(SRC_DESC_VALUE.transferFunction == m_imageDescription->value().transferFunction ||
|
||||
(*PSDREOTF == 2 && SRC_DESC_VALUE.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_SRGB &&
|
||||
(sdrEOTF == NTransferFunction::TF_FORCED_GAMMA22 && SRC_DESC_VALUE.transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_SRGB &&
|
||||
m_imageDescription->value().transferFunction == NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22)) &&
|
||||
SRC_DESC_VALUE.transferFunctionPower == m_imageDescription->value().transferFunctionPower &&
|
||||
(!inHDR() || SRC_DESC_VALUE.luminances == m_imageDescription->value().luminances)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue