cache workbuffer descriptions

This commit is contained in:
UjinT34 2026-04-26 10:59:07 +03:00
parent 3f77bf25d1
commit e249b381bf
2 changed files with 21 additions and 8 deletions

View file

@ -2558,15 +2558,25 @@ PImageDescription CMonitor::workBufferImageDescription() {
const bool isHDRLikeTF =
value.transferFunction == CM_TRANSFER_FUNCTION_ST2084_PQ || value.transferFunction == CM_TRANSFER_FUNCTION_HLG || value.transferFunction == CM_TRANSFER_FUNCTION_EXT_LINEAR;
if (isHDRLikeTF || value.windowsScRGB)
return LINEAR_IMAGE_DESCRIPTION;
const auto& cached = m_cachedInternalDescription->value();
return CImageDescription::from(SImageDescription{
.transferFunction = chooseTF(m_sdrEotf),
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = NColorPrimaries::BT2020,
});
// HDR
if (isHDRLikeTF || value.windowsScRGB) {
if (cached.primariesNamed != NColorManagement::CM_PRIMARIES_SRGB || cached.luminances != value.luminances)
m_cachedInternalDescription = LINEAR_IMAGE_DESCRIPTION->with(value.luminances);
return m_cachedInternalDescription;
}
// SDR
if (cached.primariesNamed != NColorManagement::CM_PRIMARIES_BT2020 || cached.transferFunction != chooseTF(m_sdrEotf))
m_cachedInternalDescription = CImageDescription::from(SImageDescription{
.transferFunction = chooseTF(m_sdrEotf),
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = NColorPrimaries::BT2020,
});
return m_cachedInternalDescription;
}
WP<CMonitorResources> CMonitor::resources() {

View file

@ -415,6 +415,9 @@ class CMonitor {
// Resources
UP<Monitor::CMonitorResources> m_resources;
// cached should contain one of predefined descriptions: BT2020 primaries with variable TF and SDR luminances or SRGB primaries with linear TF and variable luminances.
// avoids lookup for an id when ::from is used
NColorManagement::PImageDescription m_cachedInternalDescription = NColorManagement::CImageDescription::from(NColorManagement::SImageDescription{});
struct {
CHyprSignalListener frame;