Changeset 272125 in webkit
- Timestamp:
- Jan 31, 2021 12:24:46 PM (18 months ago)
- Location:
- trunk
- Files:
-
- 8 added
- 18 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/fast/css/parsing-color-function-expected.txt (modified) (1 diff)
-
LayoutTests/fast/css/parsing-color-function.html (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-001-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-001.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-002-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-002.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-003-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-003.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-004-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-004.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSValueKeywords.in (modified) (1 diff)
-
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (modified) (2 diffs)
-
Source/WebCore/platform/graphics/ColorConversion.cpp (modified) (7 diffs)
-
Source/WebCore/platform/graphics/ColorConversion.h (modified) (8 diffs)
-
Source/WebCore/platform/graphics/ColorSerialization.cpp (modified) (3 diffs)
-
Source/WebCore/platform/graphics/ColorSerialization.h (modified) (3 diffs)
-
Source/WebCore/platform/graphics/ColorSpace.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/ColorSpace.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/ColorTransferFunctions.h (modified) (3 diffs)
-
Source/WebCore/platform/graphics/ColorTypes.h (modified) (4 diffs)
-
Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp (modified) (2 diffs)
-
Source/WebCore/platform/graphics/cg/ColorSpaceCG.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r272123 r272125 1 2021-01-31 Sam Weinig <weinig@apple.com> 2 3 Add support for color(prophoto-rgb ...) as part of CSS Color 4 4 https://bugs.webkit.org/show_bug.cgi?id=221116 5 6 Reviewed by Antti Koivisto. 7 8 * TestExpectations: 9 Remove now passing prophoto-rgb tests. 10 11 * fast/css/parsing-color-function-expected.txt: 12 * fast/css/parsing-color-function.html: 13 Add prophoto-rgb as an rgb type so it gets tested with the 14 others. 15 1 16 2021-01-30 Sam Weinig <weinig@apple.com> 2 17 -
trunk/LayoutTests/TestExpectations
r272123 r272125 4605 4605 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-003.html [ ImageOnlyFailure ] # Invalid test, no colorspace specified 4606 4606 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-004.html [ ImageOnlyFailure ] # Invalid test, no colorspace specified 4607 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-009.html [ ImageOnlyFailure ] # Requires prophoto-rgb support4608 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-010.html [ ImageOnlyFailure ] # Requires prophoto-rgb support4609 4607 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-014.html [ ImageOnlyFailure ] # Requires fallback (at parse time) support 4610 4608 webkit.org/b/220928 imported/w3c/web-platform-tests/css/css-color/predefined-015.html [ ImageOnlyFailure ] # Requires fallback (at parse time) support (unclear if this makes sense) -
trunk/LayoutTests/fast/css/parsing-color-function-expected.txt
r272123 r272125 94 94 PASS computedStyle("background-color", "color(rec2020 0% 0% 0deg)") is "rgba(0, 0, 0, 0)" 95 95 PASS computedStyle("background-color", "color(rec2020 40% 0 0deg)") is "rgba(0, 0, 0, 0)" 96 97 Testing color(prophoto-rgb ...) 98 PASS computedStyle("background-color", "color(prophoto-rgb 0% 0% 0%)") is "color(prophoto-rgb 0 0 0)" 99 PASS computedStyle("background-color", "color(prophoto-rgb 10% 10% 10%)") is "color(prophoto-rgb 0.1 0.1 0.1)" 100 PASS computedStyle("background-color", "color(prophoto-rgb .2 .2 25%)") is "color(prophoto-rgb 0.2 0.2 0.25)" 101 PASS computedStyle("background-color", "color(prophoto-rgb 0 0 0 / 1)") is "color(prophoto-rgb 0 0 0)" 102 PASS computedStyle("background-color", "color(prophoto-rgb 0% 0 0 / 0.5)") is "color(prophoto-rgb 0 0 0 / 0.5)" 103 PASS computedStyle("background-color", "color(prophoto-rgb 20% 0 10/0.5)") is "color(prophoto-rgb 0.2 0 1 / 0.5)" 104 PASS computedStyle("background-color", "color(prophoto-rgb 20% 0 10/50%)") is "color(prophoto-rgb 0.2 0 1 / 0.5)" 105 PASS computedStyle("background-color", "color(prophoto-rgb 400% 0 10/50%)") is "color(prophoto-rgb 1 0 1 / 0.5)" 106 PASS computedStyle("background-color", "color(prophoto-rgb 50% -160 160)") is "color(prophoto-rgb 0.5 0 1)" 107 PASS computedStyle("background-color", "color(prophoto-rgb 50% -200 200)") is "color(prophoto-rgb 0.5 0 1)" 108 PASS computedStyle("background-color", "color(prophoto-rgb 0 0 0 / -10%)") is "color(prophoto-rgb 0 0 0 / 0)" 109 PASS computedStyle("background-color", "color(prophoto-rgb 0 0 0 / 110%)") is "color(prophoto-rgb 0 0 0)" 110 PASS computedStyle("background-color", "color(prophoto-rgb 0 0 0 / 300%)") is "color(prophoto-rgb 0 0 0)" 111 PASS computedStyle("background-color", "color(prophoto-rgb 50% -200)") is "color(prophoto-rgb 0.5 0 0)" 112 PASS computedStyle("background-color", "color(prophoto-rgb 50%)") is "color(prophoto-rgb 0.5 0 0)" 113 PASS computedStyle("background-color", "color(prophoto-rgb)") is "color(prophoto-rgb 0 0 0)" 114 PASS computedStyle("background-color", "color(prophoto-rgb 50% -200 / 0.5)") is "color(prophoto-rgb 0.5 0 0 / 0.5)" 115 PASS computedStyle("background-color", "color(prophoto-rgb 50% / 0.5)") is "color(prophoto-rgb 0.5 0 0 / 0.5)" 116 PASS computedStyle("background-color", "color(prophoto-rgb / 0.5)") is "color(prophoto-rgb 0 0 0 / 0.5)" 117 118 Test invalid values 119 PASS computedStyle("background-color", "color(prophoto-rgb 0 0 0 0)") is "rgba(0, 0, 0, 0)" 120 PASS computedStyle("background-color", "color(prophoto-rgb 0deg 0% 0)") is "rgba(0, 0, 0, 0)" 121 PASS computedStyle("background-color", "color(prophoto-rgb 0% 0 0 1)") is "rgba(0, 0, 0, 0)" 122 PASS computedStyle("background-color", "color(prophoto-rgb 0% 0 0 10%)") is "rgba(0, 0, 0, 0)" 123 PASS computedStyle("background-color", "color(prophoto-rgb 0% 0 0deg)") is "rgba(0, 0, 0, 0)" 124 PASS computedStyle("background-color", "color(prophoto-rgb 0% 0% 0deg)") is "rgba(0, 0, 0, 0)" 125 PASS computedStyle("background-color", "color(prophoto-rgb 40% 0 0deg)") is "rgba(0, 0, 0, 0)" 96 126 PASS successfullyParsed is true 97 127 -
trunk/LayoutTests/fast/css/parsing-color-function.html
r272123 r272125 35 35 } 36 36 37 for (const color of [ "srgb", "a98-rgb", "rec2020" ]) {37 for (const color of [ "srgb", "a98-rgb", "rec2020", "prophoto-rgb" ]) { 38 38 debug(''); 39 39 debug(`Testing color(${color} ...)`); -
trunk/LayoutTests/imported/w3c/ChangeLog
r272123 r272125 1 2021-01-31 Sam Weinig <weinig@apple.com> 2 3 Add support for color(prophoto-rgb ...) as part of CSS Color 4 4 https://bugs.webkit.org/show_bug.cgi?id=221116 5 6 Reviewed by Antti Koivisto. 7 8 Add some new WPT tests for color(prophoto-rgb ) that will be upstreamed shortly. 9 (see https://github.com/web-platform-tests/wpt/pull/27416). 10 11 * web-platform-tests/css/css-color/prophoto-rgb-001-expected.html: Added. 12 * web-platform-tests/css/css-color/prophoto-rgb-001.html: Added. 13 * web-platform-tests/css/css-color/prophoto-rgb-002-expected.html: Added. 14 * web-platform-tests/css/css-color/prophoto-rgb-002.html: Added. 15 * web-platform-tests/css/css-color/prophoto-rgb-003-expected.html: Added. 16 * web-platform-tests/css/css-color/prophoto-rgb-003.html: Added. 17 * web-platform-tests/css/css-color/prophoto-rgb-004-expected.html: Added. 18 * web-platform-tests/css/css-color/prophoto-rgb-004.html: Added. 19 1 20 2021-01-30 Sam Weinig <weinig@apple.com> 2 21 -
trunk/Source/WebCore/ChangeLog
r272124 r272125 1 2021-01-31 Sam Weinig <weinig@apple.com> 2 3 Add support for color(prophoto-rgb ...) as part of CSS Color 4 4 https://bugs.webkit.org/show_bug.cgi?id=221116 5 6 Reviewed by Antti Koivisto. 7 8 Tests: imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-001.html 9 imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-002.html 10 imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-003.html 11 imported/w3c/web-platform-tests/css/css-color/prophoto-rgb-004.html 12 13 * css/CSSValueKeywords.in: 14 Add prophoto-rgb keyword. 15 16 * css/parser/CSSPropertyParserHelpers.cpp: 17 (WebCore::CSSPropertyParserHelpers::parseColorFunctionForRGBTypes): 18 (WebCore::CSSPropertyParserHelpers::parseColorFunctionParameters): 19 Parse color(prophoto-rgb ) using the existing generic rgb type color function 20 parsing function. 21 22 * platform/graphics/ColorConversion.cpp: 23 (WebCore::convertFromD50WhitePointToD65WhitePoint): 24 (WebCore::convertFromD65WhitePointToD50WhitePoint): 25 Move these chromatic adaptation conversions up in the file so they can be reused by 26 toLinearProPhotoRGB(copnst XYZA&) and toXYZA(const LinearProPhotoRGB). 27 28 (WebCore::toLinearProPhotoRGB): 29 (WebCore::toProPhotoRGB): 30 (WebCore::toXYZA): 31 * platform/graphics/ColorConversion.h: 32 (WebCore::toLinearRec2020): 33 (WebCore::toProPhotoRGB): 34 (WebCore::toLinearProPhotoRGB): 35 (WebCore::callWithColorType): 36 Add conversion support for ProPhotoRGB, utilizing the ProPhotoRGBTransferFunction 37 for gamma correction. 38 39 * platform/graphics/ColorSerialization.cpp: 40 (WebCore::serialization): 41 (WebCore::serializationForCSS): 42 (WebCore::serializationForHTML): 43 (WebCore::serializationForRenderTreeAsText): 44 * platform/graphics/ColorSerialization.h: 45 Add serialization support, matching other rgb color() function 46 types. 47 48 * platform/graphics/ColorSpace.cpp: 49 (WebCore::operator<<): 50 * platform/graphics/ColorSpace.h: 51 Add ProPhotoRGB as a new ColorSpace. 52 53 * platform/graphics/ColorTransferFunctions.h: 54 (WebCore::mode>::toGammaEncoded): 55 (WebCore::mode>::toLinear): 56 Add transfer function for ProPhotoRGB. Both clamped and unclamped 57 are implemented, though for now, only the clamped variant is 58 being used. Also fix small bug in unclamped Rec2020TransferFunction 59 that I meant to land before where the sign wasn't getting applied 60 to the whole computation. 61 62 * platform/graphics/ColorTypes.h: 63 Add ProPhotoRGB and LinearProPhotoRGB types. Fix typo in forward 64 declaration of the XYZA type. 65 66 * platform/graphics/cg/ColorSpaceCG.cpp: 67 (WebCore::proPhotoRGBColorSpaceRef): 68 * platform/graphics/cg/ColorSpaceCG.h: 69 (WebCore::cachedCGColorSpace): 70 Add support for the ProPhotoRGB as a CoreGraphics color space, where 71 it is known as kCGColorSpaceROMMRGB (ROMM stands for Reference Output 72 Medium Metric, another name for ProPhoto). 73 1 74 2021-01-31 Zalan Bujtas <zalan@apple.com> 2 75 -
trunk/Source/WebCore/css/CSSValueKeywords.in
r272123 r272125 1407 1407 display-p3 1408 1408 // lab 1409 prophoto-rgb 1409 1410 // rec2020 1410 1411 // sRGB -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r272123 r272125 895 895 static Color parseColorFunctionForRGBTypes(CSSParserTokenRange& args) 896 896 { 897 ASSERT(args.peek().id() == CSSValueA98Rgb || args.peek().id() == CSSValueDisplayP3 || args.peek().id() == CSSValue Rec2020 || args.peek().id() == CSSValueSRGB);897 ASSERT(args.peek().id() == CSSValueA98Rgb || args.peek().id() == CSSValueDisplayP3 || args.peek().id() == CSSValueProphotoRgb || args.peek().id() == CSSValueRec2020 || args.peek().id() == CSSValueSRGB); 898 898 consumeIdentRaw(args); 899 899 … … 958 958 case CSSValueLab: 959 959 color = parseColorFunctionForLabParameters(args); 960 break; 961 case CSSValueProphotoRgb: 962 color = parseColorFunctionForRGBTypes<ProPhotoRGB<float>>(args); 960 963 break; 961 964 case CSSValueRec2020: -
trunk/Source/WebCore/platform/graphics/ColorConversion.cpp
r272123 r272125 1 1 /* 2 * Copyright (C) 2017 , 2020Apple Inc. All rights reserved.2 * Copyright (C) 2017-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 66 66 }; 67 67 68 // ProPhotoRGB Matrices. 69 70 // https://drafts.csswg.org/css-color/#color-conversion-code 71 static constexpr ColorMatrix<3, 3> xyzToLinearProPhotoRGBMatrix { 72 1.3457989731028281f, -0.25558010007997534f, -0.05110628506753401f, 73 -0.5446224939028347f, 1.5082327413132781f, 0.02053603239147973f, 74 0.0f, 0.0f, 1.2119675456389454f 75 }; 76 77 // https://drafts.csswg.org/css-color/#color-conversion-code 78 static constexpr ColorMatrix<3, 3> linearProPhotoRGBToXYZMatrix { 79 0.7977604896723027f, 0.13518583717574031f, 0.0313493495815248f, 80 0.2880711282292934f, 0.7118432178101014f, 0.00008565396060525902f, 81 0.0f, 0.0f, 0.8251046025104601f 82 }; 83 68 84 // Rec2020 Matrices. 69 85 … … 116 132 }; 117 133 134 // MARK: Chromatic Adaptation conversions. 135 136 static XYZA<float> convertFromD50WhitePointToD65WhitePoint(const XYZA<float>& color) 137 { 138 return makeFromComponentsClampingExceptAlpha<XYZA<float>>(D50ToD65Matrix.transformedColorComponents(asColorComponents(color))); 139 } 140 141 static XYZA<float> convertFromD65WhitePointToD50WhitePoint(const XYZA<float>& color) 142 { 143 return makeFromComponentsClampingExceptAlpha<XYZA<float>>(D65ToD50Matrix.transformedColorComponents(asColorComponents(color))); 144 } 145 118 146 // MARK: Gamma conversions. 119 147 … … 166 194 } 167 195 196 // ProPhotoRGB <-> LinearProPhotoRGB conversions. 197 198 LinearProPhotoRGB<float> toLinearProPhotoRGB(const ProPhotoRGB<float>& color) 199 { 200 return toLinear<ProPhotoRGBTransferFunction<float, TransferFunctionMode::Clamped>>(color); 201 } 202 203 ProPhotoRGB<float> toProPhotoRGB(const LinearProPhotoRGB<float>& color) 204 { 205 return toGammaEncoded<ProPhotoRGBTransferFunction<float, TransferFunctionMode::Clamped>>(color); 206 } 207 168 208 // Rec2020 <-> LinearRec2020 conversions. 169 209 … … 228 268 } 229 269 270 // - LinearProPhotoRGB matrix conversions. 271 272 LinearProPhotoRGB<float> toLinearProPhotoRGB(const XYZA<float>& color) 273 { 274 // We expect XYZA colors to be using the D65 white point, unlike ProPhotoRGB, which 275 // uses a D50 white point, so as a first step, use the Bradford transform to convert 276 // the incoming XYZA color to D50 white point. 277 auto xyzWithD50WhitePoint = convertFromD65WhitePointToD50WhitePoint(color); 278 return makeFromComponentsClampingExceptAlpha<LinearProPhotoRGB<float>>(xyzToLinearProPhotoRGBMatrix.transformedColorComponents(asColorComponents(xyzWithD50WhitePoint))); 279 } 280 281 XYZA<float> toXYZA(const LinearProPhotoRGB<float>& color) 282 { 283 auto xyzWithD50WhitePoint = makeFromComponentsClampingExceptAlpha<XYZA<float>>(linearProPhotoRGBToXYZMatrix.transformedColorComponents(asColorComponents(color))); 284 285 // We expect XYZA colors to be using the D65 white point, unlike ProPhotoRGB, which 286 // uses a D50 white point, so as a final step, use the Bradford transform to convert 287 // the resulting XYZA color to a D65 white point. 288 return convertFromD50WhitePointToD65WhitePoint(xyzWithD50WhitePoint); 289 } 290 230 291 // - LinearRec2020 matrix conversions. 231 292 … … 250 311 { 251 312 return makeFromComponentsClampingExceptAlpha<XYZA<float>>(linearSRGBToXYZMatrix.transformedColorComponents(asColorComponents(color))); 252 }253 254 // MARK: Chromatic Adaptation conversions.255 256 static XYZA<float> convertFromD50WhitePointToD65WhitePoint(const XYZA<float>& color)257 {258 return makeFromComponentsClampingExceptAlpha<XYZA<float>>(D50ToD65Matrix.transformedColorComponents(asColorComponents(color)));259 }260 261 static XYZA<float> convertFromD65WhitePointToD50WhitePoint(const XYZA<float>& color)262 {263 return makeFromComponentsClampingExceptAlpha<XYZA<float>>(D65ToD50Matrix.transformedColorComponents(asColorComponents(color)));264 313 } 265 314 … … 509 558 } 510 559 560 // - ProPhotoRGB combination functions. 561 562 XYZA<float> toXYZA(const ProPhotoRGB<float>& color) 563 { 564 return toXYZA(toLinearProPhotoRGB(color)); 565 } 566 567 ProPhotoRGB<float> toProPhotoRGB(const XYZA<float>& color) 568 { 569 return toProPhotoRGB(toLinearProPhotoRGB(color)); 570 } 571 511 572 // - Rec2020 combination functions. 512 573 -
trunk/Source/WebCore/platform/graphics/ColorConversion.h
r272123 r272125 1 1 /* 2 * Copyright (C) 2017 , 2020Apple Inc. All rights reserved.2 * Copyright (C) 2017-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 namespace WebCore { 31 31 32 // All color types must at least implement the following conversions to and from the XYZA color space: 33 // XYZA<float> toXYZA(const ColorType<float>&); 34 // ColorType<float> toColorType(const XYZA<float>&); 32 // All color types must at least implement the following conversions to and from the XYZA color space 33 // 34 // XYZA<float> toXYZA(const `ColorType`<float>&); 35 // `ColorType`<float> to`ColorType`(const XYZA<float>&); 36 // 37 // as well as an identity conversion 38 // 39 // constexpr `ColorType`<float> to`ColorType`(const `ColorType`<float>& color) { return color; } 40 // 41 // and a generic conversion utilizing a conversion the XYZ color space 42 // 43 // template<typename T> `ColorType`<float> to`ColorType`(const T& color) 35 44 // 36 45 // Any additional conversions can be thought of as optimizations, shortcutting unnecessary steps, though … … 92 101 WEBCORE_EXPORT ExtendedSRGBA<float> toExtendedSRGBA(const LinearExtendedSRGBA<float>&); 93 102 103 // LinearProPhotoRGB 104 WEBCORE_EXPORT XYZA<float> toXYZA(const LinearProPhotoRGB<float>&); 105 WEBCORE_EXPORT LinearProPhotoRGB<float> toLinearProPhotoRGB(const XYZA<float>&); 106 // Additions 107 WEBCORE_EXPORT ProPhotoRGB<float> toProPhotoRGB(const LinearProPhotoRGB<float>&); 108 94 109 // LinearRec2020 95 110 WEBCORE_EXPORT XYZA<float> toXYZA(const LinearRec2020<float>&); … … 103 118 // Additions 104 119 WEBCORE_EXPORT SRGBA<float> toSRGBA(const LinearSRGBA<float>&); 120 121 // ProPhotoRGB 122 WEBCORE_EXPORT XYZA<float> toXYZA(const ProPhotoRGB<float>&); 123 WEBCORE_EXPORT ProPhotoRGB<float> toProPhotoRGB(const XYZA<float>&); 124 // Additions 125 WEBCORE_EXPORT LinearProPhotoRGB<float> toLinearProPhotoRGB(const ProPhotoRGB<float>&); 105 126 106 127 // Rec2020 … … 129 150 constexpr LinearDisplayP3<float> toLinearDisplayP3(const LinearDisplayP3<float>& color) { return color; } 130 151 constexpr LinearExtendedSRGBA<float> toLinearExtendedSRGBA(const LinearExtendedSRGBA<float>& color) { return color; } 152 constexpr LinearProPhotoRGB<float> toLinearRec2020(const LinearProPhotoRGB<float>& color) { return color; } 131 153 constexpr LinearRec2020<float> toLinearRec2020(const LinearRec2020<float>& color) { return color; } 132 154 constexpr LinearSRGBA<float> toLinearSRGBA(const LinearSRGBA<float>& color) { return color; } 155 constexpr ProPhotoRGB<float> toProPhotoRGB(const ProPhotoRGB<float>& color) { return color; } 133 156 constexpr Rec2020<float> toRec2020(const Rec2020<float>& color) { return color; } 134 157 constexpr SRGBA<float> toSRGBA(const SRGBA<float>& color) { return color; } … … 186 209 } 187 210 211 template<typename T> LinearProPhotoRGB<float> toLinearProPhotoRGB(const T& color) 212 { 213 return toLinearProPhotoRGB(toXYZA(color)); 214 } 215 188 216 template<typename T> LinearRec2020<float> toLinearRec2020(const T& color) 189 217 { … … 194 222 { 195 223 return toLinearSRGBA(toXYZA(color)); 224 } 225 226 template<typename T> ProPhotoRGB<float> toProPhotoRGB(const T& color) 227 { 228 return toProPhotoRGB(toXYZA(color)); 196 229 } 197 230 … … 218 251 case ColorSpace::LinearRGB: 219 252 return std::invoke(std::forward<Functor>(functor), makeFromComponents<LinearSRGBA<T>>(components)); 253 case ColorSpace::ProPhotoRGB: 254 return std::invoke(std::forward<Functor>(functor), makeFromComponents<ProPhotoRGB<T>>(components)); 220 255 case ColorSpace::Rec2020: 221 256 return std::invoke(std::forward<Functor>(functor), makeFromComponents<Rec2020<T>>(components)); -
trunk/Source/WebCore/platform/graphics/ColorSerialization.cpp
r272123 r272125 1 1 /* 2 * Copyright (C) 2020 Apple Inc. All rights reserved.2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 69 69 case ColorSpace::LinearRGB: 70 70 return "linear-srgb"_s; 71 case ColorSpace::ProPhotoRGB: 72 return "prophoto-rgb"_s; 71 73 case ColorSpace::Rec2020: 72 74 return "rec2020"_s; … … 156 158 157 159 String serializationForRenderTreeAsText(const LinearSRGBA<float>& color) 160 { 161 return serialization(color); 162 } 163 164 // MARK: ProPhotoRGB<float> overloads 165 166 String serializationForCSS(const ProPhotoRGB<float>& color) 167 { 168 return serialization(color); 169 } 170 171 String serializationForHTML(const ProPhotoRGB<float>& color) 172 { 173 return serialization(color); 174 } 175 176 String serializationForRenderTreeAsText(const ProPhotoRGB<float>& color) 158 177 { 159 178 return serialization(color); -
trunk/Source/WebCore/platform/graphics/ColorSerialization.h
r272123 r272125 1 1 /* 2 * Copyright (C) 2020 Apple Inc. All rights reserved.2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 template<typename> struct Lab; 37 37 template<typename> struct LinearSRGBA; 38 template<typename> struct ProPhotoRGB; 38 39 template<typename> struct Rec2020; 39 40 template<typename> struct SRGBA; … … 65 66 WEBCORE_EXPORT String serializationForRenderTreeAsText(const LinearSRGBA<float>&); 66 67 68 WEBCORE_EXPORT String serializationForCSS(const ProPhotoRGB<float>&); 69 WEBCORE_EXPORT String serializationForHTML(const ProPhotoRGB<float>&); 70 WEBCORE_EXPORT String serializationForRenderTreeAsText(const ProPhotoRGB<float>&); 71 67 72 WEBCORE_EXPORT String serializationForCSS(const Rec2020<float>&); 68 73 WEBCORE_EXPORT String serializationForHTML(const Rec2020<float>&); -
trunk/Source/WebCore/platform/graphics/ColorSpace.cpp
r272123 r272125 46 46 ts << "LinearRGB"; 47 47 break; 48 case ColorSpace::ProPhotoRGB: 49 ts << "ProPhotoRGB"; 50 break; 48 51 case ColorSpace::Rec2020: 49 52 ts << "Rec2020"; -
trunk/Source/WebCore/platform/graphics/ColorSpace.h
r272123 r272125 37 37 Lab, 38 38 LinearRGB, 39 ProPhotoRGB, 39 40 Rec2020, 40 41 SRGB, -
trunk/Source/WebCore/platform/graphics/ColorTransferFunctions.h
r272123 r272125 44 44 45 45 template<typename T, TransferFunctionMode mode> 46 struct ProPhotoRGBTransferFunction { 47 static constexpr T gamma = 1.8; 48 49 static T toGammaEncoded(T); 50 static T toLinear(T); 51 }; 52 53 template<typename T, TransferFunctionMode mode> 46 54 struct Rec2020TransferFunction { 47 55 static constexpr T alpha = 1.09929682680944; … … 79 87 } 80 88 89 // MARK: ProPhotoRGBTransferFunction. 90 91 template<typename T, TransferFunctionMode mode> T ProPhotoRGBTransferFunction<T, mode>::toGammaEncoded(T c) 92 { 93 if constexpr (mode == TransferFunctionMode::Clamped) { 94 if (c < 1.0 / 512.0) 95 return 16.0 * c; 96 97 return clampTo<T>(std::pow(c, 1.0 / gamma), 0, 1); 98 } else { 99 if (std::abs(c) < 1.0 / 512.0) 100 return 16.0 * c; 101 102 float sign = std::signbit(c) ? -1.0 : 1.0; 103 return std::pow(c, 1.0 / gamma) * sign; 104 } 105 } 106 107 template<typename T, TransferFunctionMode mode> T ProPhotoRGBTransferFunction<T, mode>::toLinear(T c) 108 { 109 if constexpr (mode == TransferFunctionMode::Clamped) { 110 if (c <= 16.0 / 512.0) 111 return c / 16.0; 112 113 return clampTo<T>(std::pow(c, gamma), 0, 1); 114 } else { 115 if (std::abs(c) <= 16.0 / 512.0) 116 return c / 16.0; 117 118 float sign = std::signbit(c) ? -1.0 : 1.0; 119 return std::pow(c, gamma) * sign; 120 } 121 } 122 81 123 // MARK: Rec2020TransferFunction. 82 124 … … 93 135 94 136 float sign = std::signbit(c) ? -1.0 : 1.0; 95 return sign * alpha * std::pow(c, gamma) - (alpha - 1.0);137 return (alpha * std::pow(c, gamma) - (alpha - 1.0)) * sign; 96 138 } 97 139 } -
trunk/Source/WebCore/platform/graphics/ColorTypes.h
r272123 r272125 1 1 /* 2 * Copyright (C) 2020 Apple Inc. All rights reserved.2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 41 41 template<typename> struct LinearDisplayP3; 42 42 template<typename> struct LinearExtendedSRGBA; 43 template<typename> struct LinearProPhotoRGB; 43 44 template<typename> struct LinearRec2020; 44 45 template<typename> struct LinearSRGBA; 46 template<typename> struct ProPhotoRGB; 45 47 template<typename> struct Rec2020; 46 48 template<typename> struct SRGBA; 47 template<typename> struct XYZ ;49 template<typename> struct XYZA; 48 50 49 51 // MARK: Make functions. … … 259 261 template<typename T> LinearExtendedSRGBA(T, T, T, T) -> LinearExtendedSRGBA<T>; 260 262 263 template<typename T> struct LinearProPhotoRGB : RGBAType<LinearProPhotoRGB, T, RGBModel<T>> { 264 using RGBAType<LinearProPhotoRGB, T, RGBModel<T>>::RGBAType; 265 using GammaEncodedCounterpart = ProPhotoRGB<T>; 266 }; 267 template<typename T> LinearProPhotoRGB(T, T, T, T) -> LinearProPhotoRGB<T>; 268 261 269 template<typename T> struct LinearRec2020 : RGBAType<LinearRec2020, T, RGBModel<T>> { 262 270 using RGBAType<LinearRec2020, T, RGBModel<T>>::RGBAType; … … 271 279 }; 272 280 template<typename T> LinearSRGBA(T, T, T, T) -> LinearSRGBA<T>; 281 282 template<typename T> struct ProPhotoRGB : RGBAType<ProPhotoRGB, T, RGBModel<T>> { 283 using RGBAType<ProPhotoRGB, T, RGBModel<T>>::RGBAType; 284 using LinearCounterpart = LinearProPhotoRGB<T>; 285 static constexpr auto colorSpace = ColorSpace::ProPhotoRGB; 286 }; 287 template<typename T> ProPhotoRGB(T, T, T, T) -> ProPhotoRGB<T>; 273 288 274 289 template<typename T> struct Rec2020 : RGBAType<Rec2020, T, RGBModel<T>> { -
trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp
r272123 r272125 1 1 /* 2 * Copyright (C) 2020 Apple Inc. All rights reserved.2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 101 101 } 102 102 103 CGColorSpaceRef proPhotoRGBColorSpaceRef() 104 { 105 static CGColorSpaceRef proPhotoRGBColorSpace; 106 static std::once_flag onceFlag; 107 std::call_once(onceFlag, [] { 108 #if PLATFORM(COCOA) 109 proPhotoRGBColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceROMMRGB); 110 #else 111 proPhotoRGBColorSpace = sRGBColorSpaceRef(); 112 #endif 113 }); 114 return proPhotoRGBColorSpace; 115 } 116 103 117 CGColorSpaceRef rec2020ColorSpaceRef() 104 118 { -
trunk/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h
r272123 r272125 1 1 /* 2 * Copyright (C) 2020 Apple Inc. All rights reserved.2 * Copyright (C) 2020-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 WEBCORE_EXPORT CGColorSpaceRef labColorSpaceRef(); 38 38 WEBCORE_EXPORT CGColorSpaceRef linearRGBColorSpaceRef(); 39 WEBCORE_EXPORT CGColorSpaceRef proPhotoRGBColorSpaceRef(); 39 40 WEBCORE_EXPORT CGColorSpaceRef rec2020ColorSpaceRef(); 40 41 WEBCORE_EXPORT CGColorSpaceRef sRGBColorSpaceRef(); … … 51 52 case ColorSpace::LinearRGB: 52 53 return linearRGBColorSpaceRef(); 54 case ColorSpace::ProPhotoRGB: 55 return proPhotoRGBColorSpaceRef(); 53 56 case ColorSpace::Rec2020: 54 57 return rec2020ColorSpaceRef();
Note: See TracChangeset
for help on using the changeset viewer.