Commit 46a2fc94 authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Use new skia isPQish and isHLGish functions where applicable.

PaintImage::GetContentColorUsage() and gfx::ColorSpace construction
both use ad hoc methods for determining if the transfer function is
PQ or HLG, instead use the new sanctioned Skia methods.

R=ccameron

Fixed: 1106417e
Change-Id: Ia515c60d92d1733e4edfba369071050dd6805ccc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2311123
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790644}
parent 8f63ed8f
...@@ -100,6 +100,7 @@ cc_component("paint") { ...@@ -100,6 +100,7 @@ cc_component("paint") {
"//cc/base", "//cc/base",
"//cc/debug", "//cc/debug",
"//skia", "//skia",
"//skia:skcms",
"//ui/gfx:color_space", "//ui/gfx:color_space",
"//ui/gfx:geometry_skia", "//ui/gfx:geometry_skia",
"//ui/gfx/geometry", "//ui/gfx/geometry",
......
...@@ -293,10 +293,12 @@ gfx::ContentColorUsage PaintImage::GetContentColorUsage() const { ...@@ -293,10 +293,12 @@ gfx::ContentColorUsage PaintImage::GetContentColorUsage() const {
if (!color_space || color_space->isSRGB()) if (!color_space || color_space->isSRGB())
return gfx::ContentColorUsage::kSRGB; return gfx::ContentColorUsage::kSRGB;
// TODO(crbug.com/1106417): Use SkColorSpace::isHDR() when available.
skcms_TransferFunction fn; skcms_TransferFunction fn;
if (!color_space->isNumericalTransferFn(&fn) && fn.g < 0) if (!color_space->isNumericalTransferFn(&fn) &&
(skcms_TransferFunction_isPQish(&fn) ||
skcms_TransferFunction_isHLGish(&fn))) {
return gfx::ContentColorUsage::kHDR; return gfx::ContentColorUsage::kHDR;
}
// If it's not HDR and not SRGB, report it as WCG. // If it's not HDR and not SRGB, report it as WCG.
return gfx::ContentColorUsage::kWideColorGamut; return gfx::ContentColorUsage::kWideColorGamut;
......
...@@ -97,19 +97,13 @@ ColorSpace::ColorSpace(const SkColorSpace& sk_color_space) ...@@ -97,19 +97,13 @@ ColorSpace::ColorSpace(const SkColorSpace& sk_color_space)
TransferID::INVALID, TransferID::INVALID,
MatrixID::RGB, MatrixID::RGB,
RangeID::FULL) { 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; skcms_TransferFunction fn;
if (sk_color_space.isNumericalTransferFn(&fn)) { if (sk_color_space.isNumericalTransferFn(&fn)) {
transfer_ = TransferID::CUSTOM; transfer_ = TransferID::CUSTOM;
SetCustomTransferFunction(fn); SetCustomTransferFunction(fn);
} else if (transfer_eq(fn, SkNamedTransferFn::kHLG)) { } else if (skcms_TransferFunction_isHLGish(&fn)) {
transfer_ = TransferID::ARIB_STD_B67; transfer_ = TransferID::ARIB_STD_B67;
} else if (fn.g == SkNamedTransferFn::kPQ.g) { } else if (skcms_TransferFunction_isPQish(&fn)) {
transfer_ = TransferID::SMPTEST2084; transfer_ = TransferID::SMPTEST2084;
transfer_params_[0] = GetSDRWhiteLevelFromPQSkTransferFunction(fn); transfer_params_[0] = GetSDRWhiteLevelFromPQSkTransferFunction(fn);
} else { } else {
......
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