Changeset 272498 in webkit


Ignore:
Timestamp:
Feb 8, 2021 9:37:13 AM (18 months ago)
Author:
weinig@apple.com
Message:

Update sRGB <-> XYZ conversion matrix values to match values in latest spec
https://bugs.webkit.org/show_bug.cgi?id=221533

Reviewed by Alex Christensen.

Source/WebCore:

Update values to keep in sync with https://github.com/w3c/csswg-drafts/issues/5922.

Updates ExtendedColor API test.

  • platform/graphics/ColorConversion.cpp:

Update values to keep in sync with the values used in the CSS Color 4 spec. This
doesn't have any user visible effect, but would reduce errors if round tripping
through this ever became necessary.

Tools:

  • TestWebKitAPI/Tests/WebCore/ExtendedColorTests.cpp:

(TestWebKitAPI::TEST):
Update values to values in P3 <-> sRGB conversion test and update to
use EXPECT_FLOAT_EQ so the values can be seen in the output when thigs
fail.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r272497 r272498  
     12021-02-08  Sam Weinig  <weinig@apple.com>
     2
     3        Update sRGB <-> XYZ conversion matrix values to match values in latest spec
     4        https://bugs.webkit.org/show_bug.cgi?id=221533
     5
     6        Reviewed by Alex Christensen.
     7
     8        Update values to keep in sync with https://github.com/w3c/csswg-drafts/issues/5922.
     9
     10        Updates ExtendedColor API test.
     11
     12        * platform/graphics/ColorConversion.cpp:
     13        Update values to keep in sync with the values used in the CSS Color 4 spec. This
     14        doesn't have any user visible effect, but would reduce errors if round tripping
     15        through this ever became necessary.
     16
    1172021-02-08  Rob Buis  <rbuis@igalia.com>
    218
  • trunk/Source/WebCore/platform/graphics/ColorConversion.cpp

    r272474 r272498  
    100100// sRGB Matrices.
    101101
    102 // https://en.wikipedia.org/wiki/SRGB
    103 // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
     102// https://drafts.csswg.org/css-color/#color-conversion-code
    104103static constexpr ColorMatrix<3, 3> xyzToLinearSRGBMatrix {
    105      3.2404542f, -1.5371385f, -0.4985314f,
    106     -0.9692660f,  1.8760108f,  0.0415560f,
    107      0.0556434f, -0.2040259f,  1.0572252f
    108 };
    109 
    110 // https://en.wikipedia.org/wiki/SRGB
    111 // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
     104     3.2409699419045226f,  -1.537383177570094f,   -0.4986107602930034f,
     105    -0.9692436362808796f,   1.8759675015077202f,   0.04155505740717559f,
     106     0.05563007969699366f, -0.20397695888897652f,  1.0569715142428786f
     107};
     108
     109// https://drafts.csswg.org/css-color/#color-conversion-code
    112110static constexpr ColorMatrix<3, 3> linearSRGBToXYZMatrix {
    113     0.4124564f,  0.3575761f,  0.1804375f,
    114     0.2126729f,  0.7151522f,  0.0721750f,
    115     0.0193339f,  0.1191920f,  0.9503041f
     111    0.41239079926595934f, 0.357584339383878f,   0.1804807884018343f,
     112    0.21263900587151027f, 0.715168678767756f,   0.07219231536073371f,
     113    0.01933081871559182f, 0.11919477979462598f, 0.9505321522496607f
    116114};
    117115
  • trunk/Tools/ChangeLog

    r272493 r272498  
     12021-02-08  Sam Weinig  <weinig@apple.com>
     2
     3        Update sRGB <-> XYZ conversion matrix values to match values in latest spec
     4        https://bugs.webkit.org/show_bug.cgi?id=221533
     5
     6        Reviewed by Alex Christensen.
     7
     8        * TestWebKitAPI/Tests/WebCore/ExtendedColorTests.cpp:
     9        (TestWebKitAPI::TEST):
     10        Update values to values in P3 <-> sRGB conversion test and update to
     11        use EXPECT_FLOAT_EQ so the values can be seen in the output when thigs
     12        fail.
     13
    1142021-02-08  Lauro Moura  <lmoura@igalia.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/ExtendedColorTests.cpp

    r272474 r272498  
    238238
    239239    auto sRGBAColor = p3Color.toSRGBALossy<float>();
    240     EXPECT_TRUE(WTF::areEssentiallyEqual(sRGBAColor.red, 1.0f));
    241     EXPECT_TRUE(WTF::areEssentiallyEqual(sRGBAColor.green, 0.462537885f));
    242     EXPECT_TRUE(WTF::areEssentiallyEqual(sRGBAColor.blue, 0.149147838f));
    243     EXPECT_TRUE(WTF::areEssentiallyEqual(sRGBAColor.alpha, 0.75f));
     240    EXPECT_FLOAT_EQ(sRGBAColor.red, 1.0f);
     241    EXPECT_FLOAT_EQ(sRGBAColor.green, 0.46253282f);
     242    EXPECT_FLOAT_EQ(sRGBAColor.blue, 0.14912748f);
     243    EXPECT_FLOAT_EQ(sRGBAColor.alpha, 0.75f);
    244244}
    245245
     
    250250
    251251    auto sRGBAColor = linearSRGBAColor.toSRGBALossy<float>();
    252     EXPECT_TRUE(WTF::areEssentiallyEqual(sRGBAColor.red, 1.0f));
    253     EXPECT_TRUE(WTF::areEssentiallyEqual(sRGBAColor.green, 0.735356927f));
    254     EXPECT_TRUE(WTF::areEssentiallyEqual(sRGBAColor.blue, 0.537098706f));
    255     EXPECT_TRUE(WTF::areEssentiallyEqual(sRGBAColor.alpha, 0.75f));
     252    EXPECT_FLOAT_EQ(sRGBAColor.red, 1.0f);
     253    EXPECT_FLOAT_EQ(sRGBAColor.green, 0.735356927f);
     254    EXPECT_FLOAT_EQ(sRGBAColor.blue, 0.537098706f);
     255    EXPECT_FLOAT_EQ(sRGBAColor.alpha, 0.75f);
    256256}
    257257
Note: See TracChangeset for help on using the changeset viewer.