mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibGfx: Support more CICP configurations
This adds all parameters supported by skia by default. Supporting the other parameters would just be a matter of defining the constants, but that's work for another time.
This commit is contained in:
parent
d114f13029
commit
f78c5548fe
Notes:
github-actions[bot]
2025-02-26 15:16:10 +00:00
Author: https://github.com/LucasChollet Commit: https://github.com/LadybirdBrowser/ladybird/commit/f78c5548fed Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3697 Reviewed-by: https://github.com/gmta ✅
1 changed files with 20 additions and 1 deletions
|
@ -49,13 +49,23 @@ ColorSpace::ColorSpace(NonnullOwnPtr<Details::ColorSpaceImpl>&& color_space)
|
|||
|
||||
ErrorOr<ColorSpace> ColorSpace::from_cicp(Media::CodingIndependentCodePoints cicp)
|
||||
{
|
||||
// FIXME: Bail on invalid input
|
||||
if (cicp.matrix_coefficients() != Media::MatrixCoefficients::Identity)
|
||||
return Error::from_string_literal("Unsupported matrix coefficients for CICP");
|
||||
|
||||
if (cicp.video_full_range_flag() != Media::VideoFullRangeFlag::Full)
|
||||
return Error::from_string_literal("Unsupported matrix coefficients for CICP");
|
||||
|
||||
skcms_Matrix3x3 gamut = SkNamedGamut::kSRGB;
|
||||
switch (cicp.color_primaries()) {
|
||||
case Media::ColorPrimaries::BT709:
|
||||
gamut = SkNamedGamut::kSRGB;
|
||||
break;
|
||||
case Media::ColorPrimaries::BT2020:
|
||||
gamut = SkNamedGamut::kRec2020;
|
||||
break;
|
||||
case Media::ColorPrimaries::XYZ:
|
||||
gamut = SkNamedGamut::kXYZ;
|
||||
break;
|
||||
case Media::ColorPrimaries::SMPTE432:
|
||||
gamut = SkNamedGamut::kDisplayP3;
|
||||
break;
|
||||
|
@ -65,9 +75,18 @@ ErrorOr<ColorSpace> ColorSpace::from_cicp(Media::CodingIndependentCodePoints cic
|
|||
|
||||
skcms_TransferFunction transfer_function = SkNamedTransferFn::kSRGB;
|
||||
switch (cicp.transfer_characteristics()) {
|
||||
case Media::TransferCharacteristics::Linear:
|
||||
transfer_function = SkNamedTransferFn::kLinear;
|
||||
break;
|
||||
case Media::TransferCharacteristics::SRGB:
|
||||
transfer_function = SkNamedTransferFn::kSRGB;
|
||||
break;
|
||||
case Media::TransferCharacteristics::SMPTE2084:
|
||||
transfer_function = SkNamedTransferFn::kPQ;
|
||||
break;
|
||||
case Media::TransferCharacteristics::HLG:
|
||||
transfer_function = SkNamedTransferFn::kHLG;
|
||||
break;
|
||||
default:
|
||||
return Error::from_string_literal("FIXME: Unsupported transfer function");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue