Reland "Add SkColorSpace factory from 3x3 row-major gamut and transfer function"
Moved named common transfer functions and gamuts to constexpr values in
SkColorSpace.h, in SkNamedTransferFn and SkNamedGamut namespaces.
Converted nearly all SkColorSpace::MakeRGB calls within Skia to use the
new factory with the named values. Multiple clients want a way to
extract named transfer function and gamut - this still doesn't provide
that, but this may be a better path forward for honestly advertising how
SkColorSpace works internally.
Originally landed as:
https://skia.googlesource.com/skia/+/a9549ab31630fc244094e6f1692371cbaf87f666
Re-landing with a new serialization format, but maintaining ability to
load old serialized color spaces, for SKP compatibility.
Bug: skia:
Change-Id: Ib84a6e1cd5d7d9816175773fdbaff2ca32658667
Reviewed-on: https://skia-review.googlesource.com/c/181176
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index fcae406..7ec001b 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -185,7 +185,7 @@
, fColorMode(ColorMode::kLegacy)
, fColorSpacePrimaries(gSrgbPrimaries)
// Our UI can only tweak gamma (currently), so start out gamma-only
- , fColorSpaceTransferFn(g2Dot2_TransferFn)
+ , fColorSpaceTransferFn(SkNamedTransferFn::k2Dot2)
, fZoomLevel(0.0f)
, fRotation(0.0f)
, fOffset{0.5f, 0.5f}
@@ -748,7 +748,7 @@
}
title.appendf(" %s Gamma %f",
curPrimaries >= 0 ? gNamedPrimaries[curPrimaries].fName : "Custom",
- fColorSpaceTransferFn.fG);
+ fColorSpaceTransferFn.g);
}
const DisplayParams& params = fWindow->getRequestedDisplayParams();
@@ -1091,7 +1091,7 @@
// If we're in any of the color managed modes, construct the color space we're going to use
sk_sp<SkColorSpace> colorSpace = nullptr;
if (ColorMode::kLegacy != fColorMode) {
- SkMatrix44 toXYZ;
+ skcms_Matrix3x3 toXYZ;
SkAssertResult(fColorSpacePrimaries.toXYZD50(&toXYZ));
colorSpace = SkColorSpace::MakeRGB(fColorSpaceTransferFn, toXYZ);
}
@@ -1835,7 +1835,7 @@
}
// Let user adjust the gamma
- ImGui::SliderFloat("Gamma", &fColorSpaceTransferFn.fG, 0.5f, 3.5f);
+ ImGui::SliderFloat("Gamma", &fColorSpaceTransferFn.g, 0.5f, 3.5f);
if (ImGui::Combo("Primaries", &primariesIdx,
"sRGB\0AdobeRGB\0P3\0Rec. 2020\0Custom\0\0")) {