Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3110,6 +3110,27 @@ SImageDescription CCompositor::getPreferredImageDescription() {
return m_monitors.size() == 1 ? m_monitors[0]->m_imageDescription : SImageDescription{.primaries = NColorPrimaries::BT709};
}

SImageDescription CCompositor::getHDRImageDescription() {
if (!PROTO::colorManagement) {
Debug::log(ERR, "FIXME: color management protocol is not enabled, returning empty image description");
return SImageDescription{};
}

return m_monitors.size() == 1 && m_monitors[0]->m_output && m_monitors[0]->m_output->parsedEDID.hdrMetadata.has_value() ?
SImageDescription{.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020),
.luminances = {.min = m_monitors[0]->m_output->parsedEDID.hdrMetadata->desiredContentMinLuminance,
.max = m_monitors[0]->m_output->parsedEDID.hdrMetadata->desiredContentMaxLuminance,
.reference = m_monitors[0]->m_output->parsedEDID.hdrMetadata->desiredMaxFrameAverageLuminance}} :
SImageDescription{.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
.primariesNameSet = true,
.primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
.primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020),
.luminances = {.min = 0, .max = 10000, .reference = 203}};
}

bool CCompositor::shouldChangePreferredImageDescription() {
Debug::log(WARN, "FIXME: color management protocol is enabled and outputs changed, check preferred image description changes");
return false;
Expand Down
1 change: 1 addition & 0 deletions src/Compositor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class CCompositor {
std::optional<unsigned int> getVTNr();

NColorManagement::SImageDescription getPreferredImageDescription();
NColorManagement::SImageDescription getHDRImageDescription();
bool shouldChangePreferredImageDescription();

bool supportsDrmSyncobjTimeline() const;
Expand Down
12 changes: 12 additions & 0 deletions src/config/ConfigDescriptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1999,4 +1999,16 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{false},
},

/*
* Quirks
*/

SConfigOptionDescription{
.value = "quirks:prefer_hdr",
.description = "Prefer HDR mode. 0 - off, 1 - always, 2 - gamescope only",
.type = CONFIG_OPTION_INT,
.data = SConfigOptionDescription::SRangeData{.value = 0, .min = 0, .max = 2},
},

};
2 changes: 2 additions & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ CConfigManager::CConfigManager() {

registerConfigVar("experimental:xx_color_management_v4", Hyprlang::INT{0});

registerConfigVar("quirks:prefer_hdr", Hyprlang::INT{0});

// devices
m_config->addSpecialCategory("device", {"name"});
m_config->addSpecialConfigValue("device", "sensitivity", {0.F});
Expand Down
4 changes: 4 additions & 0 deletions src/protocols/core/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,10 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
}

SImageDescription CWLSurfaceResource::getPreferredImageDescription() {
static const auto PFORCE_HDR = CConfigValue<Hyprlang::INT>("quirks:prefer_hdr");
if (*PFORCE_HDR == 1 || (*PFORCE_HDR == 2 && m_hlSurface && m_hlSurface->getWindow() && m_hlSurface->getWindow()->m_class == "gamescope"))
return g_pCompositor->getHDRImageDescription();

auto parent = m_self;
if (parent->m_role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = sc<CSubsurfaceRole*>(parent->m_role.get())->m_subsurface.lock();
Expand Down
Loading