Test sRGB with non-linear blending using new "srgbnl" sink
BUG=skia:
Change-Id: Ief7516c1505f8e447f83121ed4ba75b9fa9ba75b
Reviewed-on: https://skia-review.googlesource.com/8976
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 5e3185b..bec5dd3 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -866,19 +866,24 @@
if (FLAGS_cpu) {
auto srgbColorSpace = SkColorSpace::MakeSRGB();
+ auto srgbColorSpaceNonLinearBlending = SkColorSpace::MakeRGB(
+ SkColorSpace::kSRGB_RenderTargetGamma,
+ SkColorSpace::kSRGB_Gamut,
+ SkColorSpace::kNonLinearBlending_ColorSpaceFlag);
auto srgbLinearColorSpace = SkColorSpace::MakeSRGBLinear();
- SINK("565", RasterSink, kRGB_565_SkColorType);
- SINK("8888", RasterSink, kN32_SkColorType);
- SINK("srgb", RasterSink, kN32_SkColorType, srgbColorSpace);
- SINK("f16", RasterSink, kRGBA_F16_SkColorType, srgbLinearColorSpace);
- SINK("pdf", PDFSink);
- SINK("skp", SKPSink);
- SINK("pipe", PipeSink);
- SINK("svg", SVGSink);
- SINK("null", NullSink);
- SINK("xps", XPSSink);
- SINK("pdfa", PDFSink, true);
+ SINK("565", RasterSink, kRGB_565_SkColorType);
+ SINK("8888", RasterSink, kN32_SkColorType);
+ SINK("srgb", RasterSink, kN32_SkColorType, srgbColorSpace);
+ SINK("srgbnl", RasterSink, kN32_SkColorType, srgbColorSpaceNonLinearBlending);
+ SINK("f16", RasterSink, kRGBA_F16_SkColorType, srgbLinearColorSpace);
+ SINK("pdf", PDFSink);
+ SINK("skp", SKPSink);
+ SINK("pipe", PipeSink);
+ SINK("svg", SVGSink);
+ SINK("null", NullSink);
+ SINK("xps", XPSSink);
+ SINK("pdfa", PDFSink, true);
SINK("jsdebug", DebugSink);
}
#undef SINK
diff --git a/infra/bots/recipe_modules/sktest/api.py b/infra/bots/recipe_modules/sktest/api.py
index a9af719..e5fc92d 100644
--- a/infra/bots/recipe_modules/sktest/api.py
+++ b/infra/bots/recipe_modules/sktest/api.py
@@ -50,6 +50,7 @@
configs.extend(['f16'])
configs.extend(['sp-8888', '2ndpic-8888']) # Test niche uses of SkPicture.
configs.extend(['lite-8888']) # Experimental display list.
+ configs.extend(['srgbnl'])
if '-TSAN' not in bot:
if ('TegraK1' in bot or
diff --git a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug.json b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug.json
index a819257..a9a41f9 100644
--- a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug.json
+++ b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug.json
@@ -237,6 +237,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN.json b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN.json
index 4e4eae6..33f2c83 100644
--- a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN.json
+++ b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN.json
@@ -118,6 +118,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-MSAN.json b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-MSAN.json
index f5d48a4..ccc6ea3 100644
--- a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-MSAN.json
+++ b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-MSAN.json
@@ -118,6 +118,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug.json b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug.json
index e68873f..79e5734 100644
--- a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug.json
+++ b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug.json
@@ -235,6 +235,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared.json b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared.json
index 0e73d4a..cf14b17 100644
--- a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared.json
+++ b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Shared.json
@@ -237,6 +237,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-TSAN.json b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-TSAN.json
index cda4aa2..71b2098 100644
--- a/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-TSAN.json
+++ b/infra/bots/recipe_modules/sktest/example.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-TSAN.json
@@ -118,6 +118,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/infra/bots/recipe_modules/sktest/example.expected/failed_dm.json b/infra/bots/recipe_modules/sktest/example.expected/failed_dm.json
index 42d9c0f..3f82f04 100644
--- a/infra/bots/recipe_modules/sktest/example.expected/failed_dm.json
+++ b/infra/bots/recipe_modules/sktest/example.expected/failed_dm.json
@@ -235,6 +235,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/infra/bots/recipe_modules/sktest/example.expected/nobuildbot.json b/infra/bots/recipe_modules/sktest/example.expected/nobuildbot.json
index 064a0e7..e172521 100644
--- a/infra/bots/recipe_modules/sktest/example.expected/nobuildbot.json
+++ b/infra/bots/recipe_modules/sktest/example.expected/nobuildbot.json
@@ -275,6 +275,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/infra/bots/recipe_modules/sktest/example.expected/recipe_with_gerrit_patch.json b/infra/bots/recipe_modules/sktest/example.expected/recipe_with_gerrit_patch.json
index 9abab39..5fb195c 100644
--- a/infra/bots/recipe_modules/sktest/example.expected/recipe_with_gerrit_patch.json
+++ b/infra/bots/recipe_modules/sktest/example.expected/recipe_with_gerrit_patch.json
@@ -241,6 +241,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/infra/bots/recipes/swarm_test.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug.json b/infra/bots/recipes/swarm_test.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug.json
index 7281519..622155b 100644
--- a/infra/bots/recipes/swarm_test.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug.json
+++ b/infra/bots/recipes/swarm_test.expected/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Debug.json
@@ -237,6 +237,7 @@
"sp-8888",
"2ndpic-8888",
"lite-8888",
+ "srgbnl",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index 3e5e9b9..c9ac767 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -49,6 +49,7 @@
{ "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" },
{ "gpuf16", "gpu", "color=f16" },
{ "gpusrgb", "gpu", "color=srgb" },
+ { "gpusrgbnl", "gpu", "color=srgbnl" },
{ "glsrgb", "gpu", "api=gl,color=srgb" },
{ "glwide", "gpu", "api=gl,color=f16_wide" },
{ "glnarrow", "gpu", "api=gl,color=f16_narrow" },
@@ -290,10 +291,16 @@
return false;
}
- // First, figure out color gamut that we'll work in (default to sRGB)
const bool linearGamma = commands[0].equals("f16");
- *outColorSpace = linearGamma ? SkColorSpace::MakeSRGBLinear()
- : SkColorSpace::MakeSRGB();
+ const bool nonLinearBlending = commands[0].equals("srgbnl");
+ SkColorSpace::Gamut gamut = SkColorSpace::kSRGB_Gamut;
+ SkColorSpace::RenderTargetGamma gamma = linearGamma ? SkColorSpace::kLinear_RenderTargetGamma
+ : SkColorSpace::kSRGB_RenderTargetGamma;
+ SkColorSpace::ColorSpaceFlags flags =
+ nonLinearBlending ? SkColorSpace::kNonLinearBlending_ColorSpaceFlag
+ : (SkColorSpace::ColorSpaceFlags) 0;
+ *outColorSpace = SkColorSpace::MakeRGB(gamma, gamut, flags);
+
if (commands.count() == 2) {
if (commands[1].equals("srgb")) {
// sRGB gamut (which is our default)
@@ -306,10 +313,7 @@
};
SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor);
wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50);
- *outColorSpace = SkColorSpace::MakeRGB(linearGamma
- ? SkColorSpace::kLinear_RenderTargetGamma
- : SkColorSpace::kSRGB_RenderTargetGamma,
- wideGamutRGBMatrix);
+ *outColorSpace = SkColorSpace::MakeRGB(gamma, wideGamutRGBMatrix, flags);
} else if (commands[1].equals("narrow")) {
// NarrowGamut RGB (an artifically smaller than sRGB gamut)
SkColorSpacePrimaries primaries ={
@@ -320,10 +324,7 @@
};
SkMatrix44 narrowGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor);
primaries.toXYZD50(&narrowGamutRGBMatrix);
- *outColorSpace = SkColorSpace::MakeRGB(linearGamma
- ? SkColorSpace::kLinear_RenderTargetGamma
- : SkColorSpace::kSRGB_RenderTargetGamma,
- narrowGamutRGBMatrix);
+ *outColorSpace = SkColorSpace::MakeRGB(gamma, narrowGamutRGBMatrix, flags);
} else {
// Unknown color gamut
return false;
@@ -335,7 +336,7 @@
*outColorType = kRGBA_F16_SkColorType;
return true;
}
- if (commands[0].equals("srgb")) {
+ if (commands[0].equals("srgb") || commands[0].equals("srgbnl")) {
*outColorType = kRGBA_8888_SkColorType;
return true;
}