diff options
| author | UjinT34 <41110182+UjinT34@users.noreply.github.com> | 2026-02-26 15:01:59 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-26 12:01:59 +0000 |
| commit | c71fbd854dfdedaae011f4b8b1fdb81f8054b309 (patch) | |
| tree | 89d600037ab206f800acca1b2567eb60af67c7e9 /src/helpers/TransferFunction.cpp | |
| parent | 0e9196867b4f602e1e5a599d4f3565faff615b3c (diff) | |
renderer: better sdr eotf settings (#12812)
Diffstat (limited to 'src/helpers/TransferFunction.cpp')
| -rw-r--r-- | src/helpers/TransferFunction.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/helpers/TransferFunction.cpp b/src/helpers/TransferFunction.cpp new file mode 100644 index 00000000..935f77fe --- /dev/null +++ b/src/helpers/TransferFunction.cpp @@ -0,0 +1,35 @@ +#include "TransferFunction.hpp" +#include "../config/ConfigValue.hpp" +#include "../event/EventBus.hpp" +#include <string> +#include <unordered_map> +#include <hyprlang.hpp> + +using namespace NTransferFunction; + +static std::unordered_map<std::string, eTF> const table = {{"default", TF_DEFAULT}, {"0", TF_DEFAULT}, {"auto", TF_AUTO}, {"srgb", TF_SRGB}, + {"3", TF_SRGB}, {"gamma22", TF_GAMMA22}, {"1", TF_GAMMA22}, {"gamma22force", TF_FORCED_GAMMA22}, + {"2", TF_FORCED_GAMMA22}}; + +eTF NTransferFunction::fromString(const std::string tfName) { + auto it = table.find(tfName); + if (it == table.end()) + return TF_DEFAULT; + return it->second; +} + +std::string NTransferFunction::toString(eTF tf) { + for (const auto& [key, value] : table) { + if (value == tf) + return key; + } + return ""; +} + +eTF NTransferFunction::fromConfig() { + static auto PSDREOTF = CConfigValue<Hyprlang::STRING>("render:cm_sdr_eotf"); + static auto sdrEOTF = NTransferFunction::fromString(*PSDREOTF); + static auto P = Event::bus()->m_events.config.reloaded.listen([]() { sdrEOTF = NTransferFunction::fromString(*PSDREOTF); }); + + return sdrEOTF; +} |
