fix hl tf -> wp tf

This commit is contained in:
UjinT34 2026-04-26 09:54:15 +03:00
parent 19175706eb
commit 3f77bf25d1
2 changed files with 10 additions and 3 deletions

View file

@ -5,6 +5,7 @@
#include <hyprgraphics/color/Color.hpp>
#include "../../helpers/memory/Memory.hpp"
#include "../../helpers/math/Math.hpp"
#include "../../debug/log/Logger.hpp"
#include <filesystem>
#include <string>
@ -45,6 +46,7 @@ namespace NColorManagement {
};
enum eTransferFunction : uint8_t {
CM_TRANSFER_FUNCTION_LINEAR = 0,
CM_TRANSFER_FUNCTION_BT1886 = 1,
CM_TRANSFER_FUNCTION_GAMMA22 = 2,
CM_TRANSFER_FUNCTION_GAMMA28 = 3,
@ -68,9 +70,14 @@ namespace NColorManagement {
inline ePrimaries convertPrimaries(wpColorManagerV1Primaries primaries) {
return sc<ePrimaries>(primaries);
}
inline wpColorManagerV1TransferFunction convertTransferFunction(eTransferFunction tf) {
inline wpColorManagerV1TransferFunction convertTransferFunction(eTransferFunction tf, bool useV1SRGB = true) {
switch (tf) {
case CM_TRANSFER_FUNCTION_SRGB: return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4;
case CM_TRANSFER_FUNCTION_LINEAR:
Log::logger->log(Log::TRACE,
"CM_TRANSFER_FUNCTION_LINEAR is internal and buffers with this TF shouldn't go outside. Returning "
"WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR for preferred description instead");
return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR;
case CM_TRANSFER_FUNCTION_SRGB: return useV1SRGB ? WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB : WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4;
default: return sc<wpColorManagerV1TransferFunction>(tf);
}
}

View file

@ -807,7 +807,7 @@ CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP<CW
if (m_settings.primariesNameSet)
m_resource->sendPrimariesNamed(m_settings.primariesNamed);
m_resource->sendTfNamed(m_settings.transferFunction);
m_resource->sendTfNamed(convertTransferFunction(m_settings.transferFunction, m_resource->version() == 1));
if (m_settings.transferFunctionPower != 1.0f)
m_resource->sendTfPower(std::round(m_settings.transferFunctionPower * 10000));