aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBrian Osman <brianosman@google.com>2019-01-04 17:03:00 -0500
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2019-01-05 20:06:51 +0000
commit82ebe04caff2d7a0b47772ed44c4e3d2318e8aff (patch)
tree8df975dadbf4f8a63be20b9e6d2edddcaf282672 /tools
parentb282e1f622f62df3cdf6b9c2ad67ce7b2e9364e0 (diff)
downloadplatform_external_skqp-82ebe04caff2d7a0b47772ed44c4e3d2318e8aff.tar.gz
platform_external_skqp-82ebe04caff2d7a0b47772ed44c4e3d2318e8aff.tar.bz2
platform_external_skqp-82ebe04caff2d7a0b47772ed44c4e3d2318e8aff.zip
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/flags/SkCommonFlagsConfig.cpp7
-rw-r--r--tools/viewer/Viewer.cpp8
-rw-r--r--tools/viewer/Viewer.h2
3 files changed, 7 insertions, 10 deletions
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index 66a5b2a7ba..44e79ac513 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -309,16 +309,13 @@ static bool parse_option_gpu_color(const SkString& value,
*outColorSpace = SkColorSpace::MakeSRGB();
} else if (value.equals("p3")) {
*outColorType = kRGBA_8888_SkColorType;
- *outColorSpace = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
- SkColorSpace::kDCIP3_D65_Gamut);
+ *outColorSpace = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB, SkNamedGamut::kDCIP3);
} else if (value.equals("esrgb")) {
*outColorType = kRGBA_F16_SkColorType;
*outColorSpace = SkColorSpace::MakeSRGB();
} else if (value.equals("narrow") || value.equals("enarrow")) {
- SkMatrix44 narrow_gamut;
- narrow_gamut.set3x3RowMajorf(gNarrow_toXYZD50);
*outColorType = value.equals("narrow") ? kRGBA_8888_SkColorType : kRGBA_F16_SkColorType;
- *outColorSpace = SkColorSpace::MakeRGB(k2Dot2Curve_SkGammaNamed, narrow_gamut);
+ *outColorSpace = SkColorSpace::MakeRGB(SkNamedTransferFn::k2Dot2, gNarrow_toXYZD50);
} else if (value.equals("f16")) {
*outColorType = kRGBA_F16_SkColorType;
*outColorSpace = SkColorSpace::MakeSRGBLinear();
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index fcae406db7..7ec001bac0 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -185,7 +185,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
, 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 @@ void Viewer::updateTitle() {
}
title.appendf(" %s Gamma %f",
curPrimaries >= 0 ? gNamedPrimaries[curPrimaries].fName : "Custom",
- fColorSpaceTransferFn.fG);
+ fColorSpaceTransferFn.g);
}
const DisplayParams& params = fWindow->getRequestedDisplayParams();
@@ -1091,7 +1091,7 @@ void Viewer::drawSlide(SkCanvas* canvas) {
// 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 @@ void Viewer::drawImGui() {
}
// 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")) {
diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h
index e140eb4537..2cff48676c 100644
--- a/tools/viewer/Viewer.h
+++ b/tools/viewer/Viewer.h
@@ -138,7 +138,7 @@ private:
// Color properties for slide rendering
ColorMode fColorMode;
SkColorSpacePrimaries fColorSpacePrimaries;
- SkColorSpaceTransferFn fColorSpaceTransferFn;
+ skcms_TransferFunction fColorSpaceTransferFn;
// transform data
SkScalar fZoomLevel;