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

Side by Side Diff: tools/flags/SkCommonFlagsConfig.cpp

Issue 2350003003: Add ability to pick a different gamut in GPU f16 or sRGB configs (Closed)
Patch Set: Switched to glwide and vkwide as new configs 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 unified diff | Download patch
« no previous file with comments | « tests/TestConfigParsing.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCommonFlagsConfig.h" 8 #include "SkCommonFlagsConfig.h"
9 #include "SkImageInfo.h" 9 #include "SkImageInfo.h"
10 10
(...skipping 10 matching lines...) Expand all
21 " angle" 21 " angle"
22 #endif 22 #endif
23 #endif 23 #endif
24 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 24 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
25 " hwui" 25 " hwui"
26 #endif 26 #endif
27 ; 27 ;
28 28
29 static const char configHelp[] = 29 static const char configHelp[] =
30 "Options: 565 8888 debug gpu gl gpudebug gpudft gpunull " 30 "Options: 565 8888 debug gpu gl gpudebug gpudft gpunull "
31 "msaa16 msaa4 glmsaa4 gpuf16 gpusrgb glsrgb nonrendering null nullgpu " 31 "msaa16 msaa4 glmsaa4 gpuf16 gpusrgb glsrgb glwide nonrendering null nullgpu "
32 "nvpr16 nvpr4 nvprdit16 nvprdit4 glnvpr4 glnvprdit4 pdf skp svg xps" 32 "nvpr16 nvpr4 nvprdit16 nvprdit4 glnvpr4 glnvprdit4 pdf skp svg xps "
33 "glinst glinst4 glinstdit4 glinst16 glinstdit16 esinst esinst4 esinsdit4" 33 "glinst glinst4 glinstdit4 glinst16 glinstdit16 esinst esinst4 esinsdit4"
34 #if SK_ANGLE 34 #if SK_ANGLE
35 #ifdef SK_BUILD_FOR_WIN 35 #ifdef SK_BUILD_FOR_WIN
36 " angle" 36 " angle"
37 #endif 37 #endif
38 " angle-gl" 38 " angle-gl"
39 #endif 39 #endif
40 #if SK_COMMAND_BUFFER 40 #if SK_COMMAND_BUFFER
41 " commandbuffer" 41 " commandbuffer"
42 #endif 42 #endif
43 #if SK_MESA 43 #if SK_MESA
44 " mesa" 44 " mesa"
45 #endif 45 #endif
46 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 46 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
47 " hwui" 47 " hwui"
48 #endif 48 #endif
49 #ifdef SK_VULKAN 49 #ifdef SK_VULKAN
50 " vk vksrgb" 50 " vk vksrgb vkwide"
51 #endif 51 #endif
52 " or use extended form 'backend(option=value,...)'.\n"; 52 " or use extended form 'backend(option=value,...)'.\n";
53 53
54 static const char configExtendedHelp[] = 54 static const char configExtendedHelp[] =
55 "Extended form: 'backend(option=value,...)'\n\n" 55 "Extended form: 'backend(option=value,...)'\n\n"
56 "Possible backends and options:\n" 56 "Possible backends and options:\n"
57 #if SK_SUPPORT_GPU 57 #if SK_SUPPORT_GPU
58 "\n" 58 "\n"
59 "gpu(api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int)\tGPU backend\n" 59 "gpu(api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int)\tGPU backend\n"
60 "\tapi\ttype: string\tdefault: native.\n" 60 "\tapi\ttype: string\tdefault: native.\n"
(...skipping 16 matching lines...) Expand all
77 #if SK_MESA 77 #if SK_MESA
78 "\t\tmesa\t\t\tUse MESA.\n" 78 "\t\tmesa\t\t\tUse MESA.\n"
79 #endif 79 #endif
80 #ifdef SK_VULKAN 80 #ifdef SK_VULKAN
81 "\t\tvulkan\t\t\tUse Vulkan.\n" 81 "\t\tvulkan\t\t\tUse Vulkan.\n"
82 #endif 82 #endif
83 "\tcolor\ttype: string\tdefault: 8888.\n" 83 "\tcolor\ttype: string\tdefault: 8888.\n"
84 "\t Select framebuffer color format.\n" 84 "\t Select framebuffer color format.\n"
85 "\t Options:\n" 85 "\t Options:\n"
86 "\t\t8888\t\t\tLinear 8888.\n" 86 "\t\t8888\t\t\tLinear 8888.\n"
87 "\t\tf16 \t\t\tLinear 16-bit floating point.\n" 87 "\t\tf16{_gamut}\t\tLinear 16-bit floating point.\n"
88 "\t\tsrgb\t\t\tsRGB 8888.\n" 88 "\t\tsrgb{_gamut}\t\tsRGB 8888.\n"
89 "\t gamut\ttype: string\tdefault: srgb.\n"
90 "\t Select color gamut for f16 or sRGB format buffers.\n"
91 "\t Options:\n"
92 "\t\tsrgb\t\t\tsRGB gamut.\n"
93 "\t\twide\t\t\tWide Gamut RGB.\n"
89 "\tdit\ttype: bool\tdefault: false.\n" 94 "\tdit\ttype: bool\tdefault: false.\n"
90 "\t Use device independent text.\n" 95 "\t Use device independent text.\n"
91 "\tnvpr\ttype: bool\tdefault: false.\n" 96 "\tnvpr\ttype: bool\tdefault: false.\n"
92 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n" 97 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n"
93 "\tsamples\ttype: int\tdefault: 0.\n" 98 "\tsamples\ttype: int\tdefault: 0.\n"
94 "\t Use multisampling with N samples.\n" 99 "\t Use multisampling with N samples.\n"
95 "\n" 100 "\n"
96 "Predefined configs:\n\n" 101 "Predefined configs:\n\n"
97 "\tgpu \t= gpu()\n" 102 "\tgpu \t= gpu()\n"
98 "\tgl \t= gpu(api=gl)\n" 103 "\tgl \t= gpu(api=gl)\n"
99 "\tmsaa4 \t= gpu(samples=4)\n" 104 "\tmsaa4 \t= gpu(samples=4)\n"
100 "\tglmsaa4 \t= gpu(api=gl,samples=4)\n" 105 "\tglmsaa4 \t= gpu(api=gl,samples=4)\n"
101 "\tmsaa16 \t= gpu(samples=16)\n" 106 "\tmsaa16 \t= gpu(samples=16)\n"
102 "\tnvpr4 \t= gpu(nvpr=true,samples=4)\n" 107 "\tnvpr4 \t= gpu(nvpr=true,samples=4)\n"
103 "\tglnvpr4 \t= gpu(api=gl,nvpr=true,samples=4)\n" 108 "\tglnvpr4 \t= gpu(api=gl,nvpr=true,samples=4)\n"
104 "\tnvpr16 \t= gpu(nvpr=true,samples=16)\n" 109 "\tnvpr16 \t= gpu(nvpr=true,samples=16)\n"
105 "\tnvprdit4 \t= gpu(nvpr=true,samples=4,dit=true)\n" 110 "\tnvprdit4 \t= gpu(nvpr=true,samples=4,dit=true)\n"
106 "\tglnvprdit4\t= gpu(api=gl,nvpr=true,samples=4,dit=true)\n" 111 "\tglnvprdit4\t= gpu(api=gl,nvpr=true,samples=4,dit=true)\n"
107 "\tnvprdit16 \t= gpu(nvpr=true,samples=16,dit=true)\n" 112 "\tnvprdit16 \t= gpu(nvpr=true,samples=16,dit=true)\n"
108 "\tgpuf16 \t= gpu(color=f16)\n" 113 "\tgpuf16 \t= gpu(color=f16)\n"
109 "\tgpusrgb \t= gpu(color=srgb)\n" 114 "\tgpusrgb \t= gpu(color=srgb)\n"
110 "\tglsrgb \t= gpu(api=gl,color=srgb)\n" 115 "\tglsrgb \t= gpu(api=gl,color=srgb)\n"
116 "\tglwide \t= gpu(api=gl,color=f16_wide)\n"
111 "\tgpudft \t= gpu(dit=true)\n" 117 "\tgpudft \t= gpu(dit=true)\n"
112 "\tgpudebug \t= gpu(api=debug)\n" 118 "\tgpudebug \t= gpu(api=debug)\n"
113 "\tgpunull \t= gpu(api=null)\n" 119 "\tgpunull \t= gpu(api=null)\n"
114 "\tdebug \t= gpu(api=debug)\n" 120 "\tdebug \t= gpu(api=debug)\n"
115 "\tnullgpu \t= gpu(api=null)\n" 121 "\tnullgpu \t= gpu(api=null)\n"
116 #if SK_ANGLE 122 #if SK_ANGLE
117 #ifdef SK_BUILD_FOR_WIN 123 #ifdef SK_BUILD_FOR_WIN
118 "\tangle \t= gpu(api=angle)\n" 124 "\tangle \t= gpu(api=angle)\n"
119 #endif 125 #endif
120 "\tangle-gl \t= gpu(api=angle-gl)\n" 126 "\tangle-gl \t= gpu(api=angle-gl)\n"
121 #endif 127 #endif
122 #if SK_COMMAND_BUFFER 128 #if SK_COMMAND_BUFFER
123 "\tcommandbuffer\t= gpu(api=commandbuffer)\n" 129 "\tcommandbuffer\t= gpu(api=commandbuffer)\n"
124 #endif 130 #endif
125 #if SK_MESA 131 #if SK_MESA
126 "\tmesa \t= gpu(api=mesa)\n" 132 "\tmesa \t= gpu(api=mesa)\n"
127 #endif 133 #endif
128 #ifdef SK_VULKAN 134 #ifdef SK_VULKAN
129 "\tvk \t= gpu(api=vulkan)\n" 135 "\tvk \t= gpu(api=vulkan)\n"
130 "\tvksrgb \t= gpu(api=vulkan,color=srgb)\n" 136 "\tvksrgb \t= gpu(api=vulkan,color=srgb)\n"
137 "\tvkwide \t= gpu(api=vulkan,color=f16_wide)\n"
131 "\tvkmsaa4 \t= gpu(api=gl,samples=4)\n" 138 "\tvkmsaa4 \t= gpu(api=gl,samples=4)\n"
132 "\tvkmsaa16 \t= gpu(api=gl,samples=16)\n" 139 "\tvkmsaa16 \t= gpu(api=gl,samples=16)\n"
133 #endif 140 #endif
134 #endif 141 #endif
135 ; 142 ;
136 143
137 DEFINE_extended_string(config, defaultConfigs, configHelp, configExtendedHelp); 144 DEFINE_extended_string(config, defaultConfigs, configHelp, configExtendedHelp);
138 145
139 static const struct { 146 static const struct {
140 const char* predefinedConfig; 147 const char* predefinedConfig;
(...skipping 16 matching lines...) Expand all
157 { "glinst4", "gpu", "api=gl,inst=true,samples=4" }, 164 { "glinst4", "gpu", "api=gl,inst=true,samples=4" },
158 { "glinstdit4", "gpu", "api=gl,inst=true,samples=4,dit=true" }, 165 { "glinstdit4", "gpu", "api=gl,inst=true,samples=4,dit=true" },
159 { "glinst16", "gpu", "api=gl,inst=true,samples=16" }, 166 { "glinst16", "gpu", "api=gl,inst=true,samples=16" },
160 { "glinstdit16", "gpu", "api=gl,inst=true,samples=16,dit=true" }, 167 { "glinstdit16", "gpu", "api=gl,inst=true,samples=16,dit=true" },
161 { "esinst", "gpu", "api=gles,inst=true" }, 168 { "esinst", "gpu", "api=gles,inst=true" },
162 { "esinst4", "gpu", "api=gles,inst=true,samples=4" }, 169 { "esinst4", "gpu", "api=gles,inst=true,samples=4" },
163 { "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" }, 170 { "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" },
164 { "gpuf16", "gpu", "color=f16" }, 171 { "gpuf16", "gpu", "color=f16" },
165 { "gpusrgb", "gpu", "color=srgb" }, 172 { "gpusrgb", "gpu", "color=srgb" },
166 { "glsrgb", "gpu", "api=gl,color=srgb" }, 173 { "glsrgb", "gpu", "api=gl,color=srgb" },
174 { "glwide", "gpu", "api=gl,color=f16_wide" },
167 { "gpudft", "gpu", "dit=true" }, 175 { "gpudft", "gpu", "dit=true" },
168 { "gpudebug", "gpu", "api=debug" }, 176 { "gpudebug", "gpu", "api=debug" },
169 { "gpunull", "gpu", "api=null" }, 177 { "gpunull", "gpu", "api=null" },
170 { "debug", "gpu", "api=debug" }, 178 { "debug", "gpu", "api=debug" },
171 { "nullgpu", "gpu", "api=null" } 179 { "nullgpu", "gpu", "api=null" }
172 #if SK_ANGLE 180 #if SK_ANGLE
173 #ifdef SK_BUILD_FOR_WIN 181 #ifdef SK_BUILD_FOR_WIN
174 , { "angle", "gpu", "api=angle" } 182 , { "angle", "gpu", "api=angle" }
175 #endif 183 #endif
176 , { "angle-gl", "gpu", "api=angle-gl" } 184 , { "angle-gl", "gpu", "api=angle-gl" }
177 #endif 185 #endif
178 #if SK_COMMAND_BUFFER 186 #if SK_COMMAND_BUFFER
179 , { "commandbuffer", "gpu", "api=commandbuffer" } 187 , { "commandbuffer", "gpu", "api=commandbuffer" }
180 #endif 188 #endif
181 #if SK_MESA 189 #if SK_MESA
182 , { "mesa", "gpu", "api=mesa" } 190 , { "mesa", "gpu", "api=mesa" }
183 #endif 191 #endif
184 #ifdef SK_VULKAN 192 #ifdef SK_VULKAN
185 , { "vk", "gpu", "api=vulkan" } 193 , { "vk", "gpu", "api=vulkan" }
186 , { "vksrgb", "gpu", "api=vulkan,color=srgb" } 194 , { "vksrgb", "gpu", "api=vulkan,color=srgb" }
195 , { "vkwide", "gpu", "api=vulkan,color=f16_wide" }
187 , { "vkmsaa4", "gpu", "api=vulkan,samples=4" } 196 , { "vkmsaa4", "gpu", "api=vulkan,samples=4" }
188 , { "vkmsaa16", "gpu", "api=vulkan,samples=16" } 197 , { "vkmsaa16", "gpu", "api=vulkan,samples=16" }
189 #endif 198 #endif
190 199
191 #else 200 #else
192 { "", "", "" } 201 { "", "", "" }
193 #endif 202 #endif
194 }; 203 };
195 204
196 SkCommandLineConfig::SkCommandLineConfig(const SkString& tag, const SkString& ba ckend, 205 SkCommandLineConfig::SkCommandLineConfig(const SkString& tag, const SkString& ba ckend,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return false; 307 return false;
299 } 308 }
300 static bool parse_option_gpu_color(const SkString& value, 309 static bool parse_option_gpu_color(const SkString& value,
301 SkColorType* outColorType, 310 SkColorType* outColorType,
302 sk_sp<SkColorSpace>* outColorSpace) { 311 sk_sp<SkColorSpace>* outColorSpace) {
303 if (value.equals("8888")) { 312 if (value.equals("8888")) {
304 *outColorType = kN32_SkColorType; 313 *outColorType = kN32_SkColorType;
305 *outColorSpace = nullptr; 314 *outColorSpace = nullptr;
306 return true; 315 return true;
307 } 316 }
308 if (value.equals("f16")) { 317
318 SkTArray<SkString> commands;
319 SkStrSplit(value.c_str(), "_", &commands);
320 if (commands.count() < 1 || commands.count() > 2) {
321 return false;
322 }
323
324 // First, figure out color gamut that we'll work in (default to sRGB)
325 sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_ Named);
326 if (commands.count() == 2) {
327 if (commands[1].equals("srgb")) {
328 // sRGB gamut (which is our default)
329 } else if (commands[1].equals("wide")) {
330 // WideGamut RGB
331 const float gWideGamutRGB_toXYZD50[]{
332 0.7161046f, 0.1009296f, 0.1471858f, // -> X
333 0.2581874f, 0.7249378f, 0.0168748f, // -> Y
334 0.0000000f, 0.0517813f, 0.7734287f, // -> Z
335 };
336 SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor );
337 wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50);
338 colorSpace = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGa mma,
339 wideGamutRGBMatrix);
340 } else {
341 // Unknown color gamut
342 return false;
343 }
344 }
345
346 // Now pick a color type
347 if (commands[0].equals("f16")) {
309 *outColorType = kRGBA_F16_SkColorType; 348 *outColorType = kRGBA_F16_SkColorType;
310 *outColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)->make LinearGamma(); 349 *outColorSpace = colorSpace->makeLinearGamma();
311 return true; 350 return true;
312 } 351 }
313 if (value.equals("srgb")) { 352 if (commands[0].equals("srgb")) {
314 *outColorType = kN32_SkColorType; 353 *outColorType = kN32_SkColorType;
315 *outColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); 354 *outColorSpace = colorSpace;
316 return true; 355 return true;
317 } 356 }
318 return false; 357 return false;
319 } 358 }
320 359
321 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, 360 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
322 const SkTArray<SkString>& vias, 361 const SkTArray<SkString>& vias,
323 const SkString& options) { 362 const SkString& options) {
324 // Defaults for GPU backend. 363 // Defaults for GPU backend.
325 bool seenAPI = false; 364 bool seenAPI = false;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (extendedBackend.equals("gpu")) { 469 if (extendedBackend.equals("gpu")) {
431 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons); 470 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons);
432 } 471 }
433 #endif 472 #endif
434 if (!parsedConfig) { 473 if (!parsedConfig) {
435 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); 474 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias);
436 } 475 }
437 outResult->emplace_back(parsedConfig); 476 outResult->emplace_back(parsedConfig);
438 } 477 }
439 } 478 }
OLDNEW
« 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