Commit 75e5efb6 authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Add PQ, HLG SkTransferFns and BT.2020 YUV to gfx::ColorSpace.

Skia added support for these recently, so lets expose them in
gfx::ColorSpace. This will allow us to correct our YUV conversions for
BT.2020 content in GpuMemoryBuffer upload and PaintCanvasVideoRenderer.

BUG=960620
TEST=unittests pass
R=ccameron

Change-Id: I6a659de0da7f21070857b855796d65bdce227a2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894770
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711964}
parent 9fb9ee6d
......@@ -66,14 +66,29 @@ ColorSpace::ColorSpace(const SkColorSpace& sk_color_space)
TransferID::INVALID,
MatrixID::RGB,
RangeID::FULL) {
// Special case the HDR transfer functions since they're not numerical
auto transfer_eq = [](skcms_TransferFunction x, skcms_TransferFunction y) {
return x.g == y.g && x.a == y.a && x.b == y.b && x.c == y.c && x.d == y.d &&
x.e == y.e && x.f == y.f;
};
skcms_TransferFunction fn;
if (sk_color_space.isNumericalTransferFn(&fn)) {
SetCustomTransferFunction(fn);
} else if (transfer_eq(fn, SkNamedTransferFn::kHLG)) {
transfer_ = TransferID::ARIB_STD_B67;
} else if (transfer_eq(fn, SkNamedTransferFn::kPQ)) {
transfer_ = TransferID::SMPTEST2084;
} else {
// Construct an invalid result: Unable to extract necessary parameters
return;
}
skcms_Matrix3x3 to_XYZD50;
if (!sk_color_space.isNumericalTransferFn(&fn) ||
!sk_color_space.toXYZD50(&to_XYZD50)) {
if (!sk_color_space.toXYZD50(&to_XYZD50)) {
// Construct an invalid result: Unable to extract necessary parameters
return;
}
SetCustomTransferFunction(fn);
SetCustomPrimaries(to_XYZD50);
}
......@@ -460,6 +475,12 @@ sk_sp<SkColorSpace> ColorSpace::ToSkColorSpace() const {
case TransferID::LINEAR_HDR:
transfer_fn = SkNamedTransferFn::kLinear;
break;
case TransferID::ARIB_STD_B67:
transfer_fn = SkNamedTransferFn::kHLG;
break;
case TransferID::SMPTEST2084:
transfer_fn = SkNamedTransferFn::kPQ;
break;
default:
if (!GetTransferFunction(&transfer_fn)) {
DLOG(ERROR) << "Failed to transfer function for SkColorSpace";
......@@ -939,6 +960,10 @@ bool ColorSpace::ToSkYUVColorSpace(SkYUVColorSpace* out) const {
*out = kRec601_SkYUVColorSpace;
return true;
case MatrixID::BT2020_NCL:
*out = kBT2020_SkYUVColorSpace;
return true;
default:
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment