diff options
| -rw-r--r-- | libs/ui/ColorSpace.cpp | 4 | ||||
| -rw-r--r-- | libs/ui/tests/colorspace_test.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/libs/ui/ColorSpace.cpp b/libs/ui/ColorSpace.cpp index 4ea3b9639d..a8fe4e383a 100644 --- a/libs/ui/ColorSpace.cpp +++ b/libs/ui/ColorSpace.cpp @@ -97,7 +97,7 @@ constexpr mat3 ColorSpace::computeXYZMatrix( } static constexpr float rcpResponse(float x, float g,float a, float b, float c, float d) { - return x >= d * c ? std::pow(x / a, 1.0f / g) - b / a : x / c; + return x >= d * c ? (std::pow(x, 1.0f / g) - b) / a : x / c; } static constexpr float response(float x, float g, float a, float b, float c, float d) { @@ -216,7 +216,7 @@ const ColorSpace ColorSpace::DCIP3() { return { "SMPTE RP 431-2-2007 DCI (P3)", {{float2{0.680f, 0.320f}, {0.265f, 0.690f}, {0.150f, 0.060f}}}, - {0.3127f, 0.3290f}, + {0.314f, 0.351f}, std::bind(powf, _1, 1.0f / 2.6f), std::bind(powf, _1, 2.6f) }; diff --git a/libs/ui/tests/colorspace_test.cpp b/libs/ui/tests/colorspace_test.cpp index b5a06e6ea6..e5c263331d 100644 --- a/libs/ui/tests/colorspace_test.cpp +++ b/libs/ui/tests/colorspace_test.cpp @@ -106,6 +106,11 @@ TEST_F(ColorSpaceTest, XYZFromPrimaries) { TEST_F(ColorSpaceTest, TransferFunctions) { ColorSpace sRGB = ColorSpace::sRGB(); + EXPECT_NEAR(0.0f, sRGB.getEOTF()(0.0f), 1e-6f); + EXPECT_NEAR(0.0f, sRGB.getOETF()(0.0f), 1e-6f); + EXPECT_NEAR(1.0f, sRGB.getEOTF()(1.0f), 1e-6f); + EXPECT_NEAR(1.0f, sRGB.getOETF()(1.0f), 1e-6f); + for (float v = 0.0f; v <= 0.5f; v += 1e-3f) { ASSERT_TRUE(v >= sRGB.getEOTF()(v)); ASSERT_TRUE(v <= sRGB.getOETF()(v)); |