diff --git a/src/libkwineffects/kwinglutils.cpp b/src/libkwineffects/kwinglutils.cpp index 55a3116f90..be8892242b 100644 --- a/src/libkwineffects/kwinglutils.cpp +++ b/src/libkwineffects/kwinglutils.cpp @@ -801,6 +801,10 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const stream << "uniform vec4 geometryColor;\n"; } if (traits & ShaderTrait::TransformColorspace) { + stream << "const int sRGB_EOTF = 0;\n"; + stream << "const int linear_EOTF = 1;\n"; + stream << "const int PQ_EOTF = 2;\n"; + stream << "\n"; stream << "uniform mat3 colorimetryTransform;\n"; stream << "uniform int sourceNamedTransferFunction;\n"; stream << "uniform int destinationNamedTransferFunction;\n"; @@ -851,8 +855,7 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const stream << " result = geometryColor;\n"; } if (traits & ShaderTrait::TransformColorspace) { - // sRGB -> output colorspace & linear - stream << " if (sourceNamedTransferFunction == 0) {\n"; + stream << " if (sourceNamedTransferFunction == sRGB_EOTF) {\n"; stream << " result.rgb = sdrBrightness * srgbToLinear(result.rgb);\n"; stream << " }\n"; stream << " result.rgb = doTonemapping(colorimetryTransform * result.rgb, maxHdrBrightness);\n"; @@ -867,11 +870,9 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const stream << " result *= modulation;\n"; } if (traits & ShaderTrait::TransformColorspace) { - // nits -> simple sRGB - stream << " if (destinationNamedTransferFunction == 0) {\n"; + stream << " if (destinationNamedTransferFunction == sRGB_EOTF) {\n"; stream << " result.rgb = linearToSrgb(doTonemapping(result.rgb, sdrBrightness) / sdrBrightness);\n"; - // nits -> PQ - stream << " } else if (destinationNamedTransferFunction == 2) {\n"; + stream << " } else if (destinationNamedTransferFunction == PQ_EOTF) {\n"; stream << " result.rgb = nitsToPq(result.rgb);\n"; stream << " }\n"; }