Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: tools/flags/SkCommonFlagsConfig.cpp

Issue 2350003003: Add ability to pick a different gamut in GPU f16 or sRGB configs (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/TestConfigParsing.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/flags/SkCommonFlagsConfig.cpp
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index cbacd5bf67fcfa900821ff17f91f2324811d8e3a..f2041bb56999c90eef92fe3c824fce77a77e510b 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -28,8 +28,8 @@ static const char defaultConfigs[] =
static const char configHelp[] =
"Options: 565 8888 debug gpu gl gpudebug gpudft gpunull "
- "msaa16 msaa4 glmsaa4 gpuf16 gpusrgb glsrgb nonrendering null nullgpu "
- "nvpr16 nvpr4 nvprdit16 nvprdit4 glnvpr4 glnvprdit4 pdf skp svg xps"
+ "msaa16 msaa4 glmsaa4 gpuf16 gpusrgb gpuwide glsrgb nonrendering null nullgpu "
+ "nvpr16 nvpr4 nvprdit16 nvprdit4 glnvpr4 glnvprdit4 pdf skp svg xps "
"glinst glinst4 glinstdit4 glinst16 glinstdit16 esinst esinst4 esinsdit4"
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
@@ -84,8 +84,13 @@ static const char configExtendedHelp[] =
"\t Select framebuffer color format.\n"
"\t Options:\n"
"\t\t8888\t\t\tLinear 8888.\n"
- "\t\tf16 \t\t\tLinear 16-bit floating point.\n"
- "\t\tsrgb\t\t\tsRGB 8888.\n"
+ "\t\tf16{_gamut}\t\tLinear 16-bit floating point.\n"
+ "\t\tsrgb{_gamut}\t\tsRGB 8888.\n"
+ "\t gamut\ttype: string\tdefault: srgb.\n"
+ "\t Select color gamut for f16 or sRGB format buffers.\n"
+ "\t Options:\n"
+ "\t\tsrgb\t\t\tsRGB gamut.\n"
+ "\t\twide\t\t\tWide Gamut RGB.\n"
"\tdit\ttype: bool\tdefault: false.\n"
"\t Use device independent text.\n"
"\tnvpr\ttype: bool\tdefault: false.\n"
@@ -107,6 +112,7 @@ static const char configExtendedHelp[] =
"\tnvprdit16 \t= gpu(nvpr=true,samples=16,dit=true)\n"
"\tgpuf16 \t= gpu(color=f16)\n"
"\tgpusrgb \t= gpu(color=srgb)\n"
+ "\tgpuwide \t= gpu(color=f16_wide)\n"
"\tglsrgb \t= gpu(api=gl,color=srgb)\n"
"\tgpudft \t= gpu(dit=true)\n"
"\tgpudebug \t= gpu(api=debug)\n"
@@ -163,6 +169,7 @@ static const struct {
{ "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" },
{ "gpuf16", "gpu", "color=f16" },
{ "gpusrgb", "gpu", "color=srgb" },
+ { "gpuwide", "gpu", "color=f16_wide" },
{ "glsrgb", "gpu", "api=gl,color=srgb" },
{ "gpudft", "gpu", "dit=true" },
{ "gpudebug", "gpu", "api=debug" },
@@ -305,14 +312,44 @@ static bool parse_option_gpu_color(const SkString& value,
*outColorSpace = nullptr;
return true;
}
- if (value.equals("f16")) {
+
+ SkTArray<SkString> commands;
+ SkStrSplit(value.c_str(), "_", &commands);
Brian Osman 2016/09/19 19:39:19 I realize this is unfortunate (introducing a new m
+ if (commands.count() < 1 || commands.count() > 2) {
+ return false;
+ }
+
+ // First, figure out color gamut that we'll work in (default to sRGB)
+ sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+ if (commands.count() == 2) {
+ if (commands[1].equals("srgb")) {
+ // sRGB gamut (which is our default)
+ } else if (commands[1].equals("wide")) {
+ // WideGamut RGB
+ const float gWideGamutRGB_toXYZD50[]{
+ 0.7161046f, 0.1009296f, 0.1471858f, // -> X
+ 0.2581874f, 0.7249378f, 0.0168748f, // -> Y
+ 0.0000000f, 0.0517813f, 0.7734287f, // -> Z
+ };
+ SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor);
+ wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50);
+ colorSpace = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma,
+ wideGamutRGBMatrix);
+ } else {
+ // Unknown color gamut
+ return false;
+ }
+ }
+
+ // Now pick a color type
+ if (commands[0].equals("f16")) {
*outColorType = kRGBA_F16_SkColorType;
- *outColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)->makeLinearGamma();
+ *outColorSpace = colorSpace->makeLinearGamma();
return true;
}
- if (value.equals("srgb")) {
+ if (commands[0].equals("srgb")) {
*outColorType = kN32_SkColorType;
- *outColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+ *outColorSpace = colorSpace;
return true;
}
return false;
« no previous file with comments | « tests/TestConfigParsing.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698