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

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

Issue 2354943002: Auto-generate much of the help text for --config to reduce maintenance (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 unified diff | Download patch
« no previous file with comments | « no previous file | 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
11 #include <stdlib.h> 11 #include <stdlib.h>
12 12
13 #if SK_SUPPORT_GPU 13 #if SK_SUPPORT_GPU
14 using sk_gpu_test::GrContextFactory; 14 using sk_gpu_test::GrContextFactory;
15 #endif 15 #endif
16 16
17 static const char defaultConfigs[] = 17 static const char defaultConfigs[] =
18 "8888 gpu nonrendering" 18 "8888 gpu nonrendering"
19 #if SK_ANGLE 19 #if SK_ANGLE
20 #ifdef SK_BUILD_FOR_WIN 20 #ifdef SK_BUILD_FOR_WIN
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 struct {
30 "Options: 565 8888 debug gpu gl gpudebug gpudft gpunull " 30 const char* predefinedConfig;
31 "msaa16 msaa4 glmsaa4 gpuf16 gpusrgb glsrgb glwide nonrendering null nullgpu " 31 const char* backend;
32 "nvpr16 nvpr4 nvprdit16 nvprdit4 glnvpr4 glnvprdit4 pdf skp svg xps " 32 const char* options;
33 "glinst glinst4 glinstdit4 glinst16 glinstdit16 esinst esinst4 esinsdit4" 33 } gPredefinedConfigs[] ={
34 #if SK_SUPPORT_GPU
35 { "gpu", "gpu", "" },
36 { "gl", "gpu", "api=gl" },
37 { "msaa4", "gpu", "samples=4" },
38 { "glmsaa4", "gpu", "api=gl,samples=4" },
39 { "msaa16", "gpu", "samples=16" },
40 { "nvpr4", "gpu", "nvpr=true,samples=4" },
41 { "glnvpr4", "gpu", "api=gl,nvpr=true,samples=4" },
42 { "nvpr16", "gpu", "nvpr=true,samples=16" },
43 { "nvprdit4", "gpu", "nvpr=true,samples=4,dit=true" },
44 { "glnvprdit4", "gpu", "api=gl,nvpr=true,samples=4,dit=true" },
45 { "nvprdit16", "gpu", "nvpr=true,samples=16,dit=true" },
46 { "glinst", "gpu", "api=gl,inst=true" },
47 { "glinst4", "gpu", "api=gl,inst=true,samples=4" },
48 { "glinstdit4", "gpu", "api=gl,inst=true,samples=4,dit=true" },
49 { "glinst16", "gpu", "api=gl,inst=true,samples=16" },
50 { "glinstdit16", "gpu", "api=gl,inst=true,samples=16,dit=true" },
51 { "esinst", "gpu", "api=gles,inst=true" },
52 { "esinst4", "gpu", "api=gles,inst=true,samples=4" },
53 { "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" },
54 { "gpuf16", "gpu", "color=f16" },
55 { "gpusrgb", "gpu", "color=srgb" },
56 { "glsrgb", "gpu", "api=gl,color=srgb" },
57 { "glwide", "gpu", "api=gl,color=f16_wide" },
58 { "gpudft", "gpu", "dit=true" },
59 { "gpudebug", "gpu", "api=debug" },
60 { "gpunull", "gpu", "api=null" },
61 { "debug", "gpu", "api=debug" },
62 { "nullgpu", "gpu", "api=null" }
34 #if SK_ANGLE 63 #if SK_ANGLE
35 #ifdef SK_BUILD_FOR_WIN 64 #ifdef SK_BUILD_FOR_WIN
36 " angle" 65 ,{ "angle", "gpu", "api=angle" }
37 #endif 66 #endif
38 " angle-gl" 67 ,{ "angle-gl", "gpu", "api=angle-gl" }
39 #endif 68 #endif
40 #if SK_COMMAND_BUFFER 69 #if SK_COMMAND_BUFFER
41 " commandbuffer" 70 ,{ "commandbuffer", "gpu", "api=commandbuffer" }
42 #endif 71 #endif
43 #if SK_MESA 72 #if SK_MESA
44 " mesa" 73 ,{ "mesa", "gpu", "api=mesa" }
45 #endif 74 #endif
75 #ifdef SK_VULKAN
76 ,{ "vk", "gpu", "api=vulkan" }
77 ,{ "vksrgb", "gpu", "api=vulkan,color=srgb" }
78 ,{ "vkwide", "gpu", "api=vulkan,color=f16_wide" }
79 ,{ "vkmsaa4", "gpu", "api=vulkan,samples=4" }
80 ,{ "vkmsaa16", "gpu", "api=vulkan,samples=16" }
81 #endif
82
83 #else
84 { "", "", "" }
85 #endif
86 };
87
88 static const char configHelp[] =
89 "Options: 565 8888 srgb f16 nonrendering null pdf pdfa skp pipe svg xps"
46 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 90 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
47 " hwui" 91 " hwui"
48 #endif 92 #endif
49 #ifdef SK_VULKAN 93 ;
50 " vk vksrgb vkwide" 94
51 #endif 95 static const char* config_help_fn() {
52 " or use extended form 'backend(option=value,...)'.\n"; 96 static SkString helpString;
97 helpString.set(configHelp);
98 for (const auto& config : gPredefinedConfigs) {
99 helpString.appendf(" %s", config.predefinedConfig);
100 }
101 helpString.append(" or use extended form 'backend(option=value,...)'.\n");
102 return helpString.c_str();
103 }
53 104
54 static const char configExtendedHelp[] = 105 static const char configExtendedHelp[] =
55 "Extended form: 'backend(option=value,...)'\n\n" 106 "Extended form: 'backend(option=value,...)'\n\n"
56 "Possible backends and options:\n" 107 "Possible backends and options:\n"
57 #if SK_SUPPORT_GPU 108 #if SK_SUPPORT_GPU
58 "\n" 109 "\n"
59 "gpu(api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int)\tGPU backend\n" 110 "gpu(api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int)\n"
60 "\tapi\ttype: string\tdefault: native.\n" 111 "\tapi\ttype: string\tdefault: native.\n"
61 "\t Select graphics API to use with gpu backend.\n" 112 "\t Select graphics API to use with gpu backend.\n"
62 "\t Options:\n" 113 "\t Options:\n"
63 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n" 114 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n"
64 "\t\tgl \t\t\tUse OpenGL.\n" 115 "\t\tgl \t\t\tUse OpenGL.\n"
65 "\t\tgles \t\t\tUse OpenGL ES.\n" 116 "\t\tgles \t\t\tUse OpenGL ES.\n"
66 "\t\tdebug \t\t\tUse debug OpenGL.\n" 117 "\t\tdebug \t\t\tUse debug OpenGL.\n"
67 "\t\tnull \t\t\tUse null OpenGL.\n" 118 "\t\tnull \t\t\tUse null OpenGL.\n"
68 #if SK_ANGLE 119 #if SK_ANGLE
69 #ifdef SK_BUILD_FOR_WIN 120 #ifdef SK_BUILD_FOR_WIN
(...skipping 22 matching lines...) Expand all
92 "\t\tsrgb\t\t\tsRGB gamut.\n" 143 "\t\tsrgb\t\t\tsRGB gamut.\n"
93 "\t\twide\t\t\tWide Gamut RGB.\n" 144 "\t\twide\t\t\tWide Gamut RGB.\n"
94 "\tdit\ttype: bool\tdefault: false.\n" 145 "\tdit\ttype: bool\tdefault: false.\n"
95 "\t Use device independent text.\n" 146 "\t Use device independent text.\n"
96 "\tnvpr\ttype: bool\tdefault: false.\n" 147 "\tnvpr\ttype: bool\tdefault: false.\n"
97 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n" 148 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n"
98 "\tsamples\ttype: int\tdefault: 0.\n" 149 "\tsamples\ttype: int\tdefault: 0.\n"
99 "\t Use multisampling with N samples.\n" 150 "\t Use multisampling with N samples.\n"
100 "\n" 151 "\n"
101 "Predefined configs:\n\n" 152 "Predefined configs:\n\n"
102 "\tgpu \t= gpu()\n" 153 // Help text for pre-defined configs is auto-generated from gPredefinedConfi gs
103 "\tgl \t= gpu(api=gl)\n"
104 "\tmsaa4 \t= gpu(samples=4)\n"
105 "\tglmsaa4 \t= gpu(api=gl,samples=4)\n"
106 "\tmsaa16 \t= gpu(samples=16)\n"
107 "\tnvpr4 \t= gpu(nvpr=true,samples=4)\n"
108 "\tglnvpr4 \t= gpu(api=gl,nvpr=true,samples=4)\n"
109 "\tnvpr16 \t= gpu(nvpr=true,samples=16)\n"
110 "\tnvprdit4 \t= gpu(nvpr=true,samples=4,dit=true)\n"
111 "\tglnvprdit4\t= gpu(api=gl,nvpr=true,samples=4,dit=true)\n"
112 "\tnvprdit16 \t= gpu(nvpr=true,samples=16,dit=true)\n"
113 "\tgpuf16 \t= gpu(color=f16)\n"
114 "\tgpusrgb \t= gpu(color=srgb)\n"
115 "\tglsrgb \t= gpu(api=gl,color=srgb)\n"
116 "\tglwide \t= gpu(api=gl,color=f16_wide)\n"
117 "\tgpudft \t= gpu(dit=true)\n"
118 "\tgpudebug \t= gpu(api=debug)\n"
119 "\tgpunull \t= gpu(api=null)\n"
120 "\tdebug \t= gpu(api=debug)\n"
121 "\tnullgpu \t= gpu(api=null)\n"
122 #if SK_ANGLE
123 #ifdef SK_BUILD_FOR_WIN
124 "\tangle \t= gpu(api=angle)\n"
125 #endif
126 "\tangle-gl \t= gpu(api=angle-gl)\n"
127 #endif
128 #if SK_COMMAND_BUFFER
129 "\tcommandbuffer\t= gpu(api=commandbuffer)\n"
130 #endif
131 #if SK_MESA
132 "\tmesa \t= gpu(api=mesa)\n"
133 #endif
134 #ifdef SK_VULKAN
135 "\tvk \t= gpu(api=vulkan)\n"
136 "\tvksrgb \t= gpu(api=vulkan,color=srgb)\n"
137 "\tvkwide \t= gpu(api=vulkan,color=f16_wide)\n"
138 "\tvkmsaa4 \t= gpu(api=gl,samples=4)\n"
139 "\tvkmsaa16 \t= gpu(api=gl,samples=16)\n"
140 #endif
141 #endif 154 #endif
142 ; 155 ;
143 156
144 DEFINE_extended_string(config, defaultConfigs, configHelp, configExtendedHelp); 157 static const char* config_extended_help_fn() {
158 static SkString helpString;
159 helpString.set(configExtendedHelp);
160 for (const auto& config : gPredefinedConfigs) {
161 helpString.appendf("\t%-10s\t= gpu(%s)\n", config.predefinedConfig, conf ig.options);
162 }
163 return helpString.c_str();
164 }
145 165
146 static const struct { 166 DEFINE_extended_string(config, defaultConfigs, config_help_fn(), config_extended _help_fn());
147 const char* predefinedConfig;
148 const char* backend;
149 const char* options;
150 } gPredefinedConfigs[] = {
151 #if SK_SUPPORT_GPU
152 { "gpu", "gpu", "" },
153 { "gl", "gpu", "api=gl" },
154 { "msaa4", "gpu", "samples=4" },
155 { "glmsaa4", "gpu", "api=gl,samples=4" },
156 { "msaa16", "gpu", "samples=16" },
157 { "nvpr4", "gpu", "nvpr=true,samples=4" },
158 { "glnvpr4", "gpu", "api=gl,nvpr=true,samples=4" },
159 { "nvpr16", "gpu", "nvpr=true,samples=16" },
160 { "nvprdit4", "gpu", "nvpr=true,samples=4,dit=true" },
161 { "glnvprdit4", "gpu", "api=gl,nvpr=true,samples=4,dit=true" },
162 { "nvprdit16", "gpu", "nvpr=true,samples=16,dit=true" },
163 { "glinst", "gpu", "api=gl,inst=true" },
164 { "glinst4", "gpu", "api=gl,inst=true,samples=4" },
165 { "glinstdit4", "gpu", "api=gl,inst=true,samples=4,dit=true" },
166 { "glinst16", "gpu", "api=gl,inst=true,samples=16" },
167 { "glinstdit16", "gpu", "api=gl,inst=true,samples=16,dit=true" },
168 { "esinst", "gpu", "api=gles,inst=true" },
169 { "esinst4", "gpu", "api=gles,inst=true,samples=4" },
170 { "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" },
171 { "gpuf16", "gpu", "color=f16" },
172 { "gpusrgb", "gpu", "color=srgb" },
173 { "glsrgb", "gpu", "api=gl,color=srgb" },
174 { "glwide", "gpu", "api=gl,color=f16_wide" },
175 { "gpudft", "gpu", "dit=true" },
176 { "gpudebug", "gpu", "api=debug" },
177 { "gpunull", "gpu", "api=null" },
178 { "debug", "gpu", "api=debug" },
179 { "nullgpu", "gpu", "api=null" }
180 #if SK_ANGLE
181 #ifdef SK_BUILD_FOR_WIN
182 , { "angle", "gpu", "api=angle" }
183 #endif
184 , { "angle-gl", "gpu", "api=angle-gl" }
185 #endif
186 #if SK_COMMAND_BUFFER
187 , { "commandbuffer", "gpu", "api=commandbuffer" }
188 #endif
189 #if SK_MESA
190 , { "mesa", "gpu", "api=mesa" }
191 #endif
192 #ifdef SK_VULKAN
193 , { "vk", "gpu", "api=vulkan" }
194 , { "vksrgb", "gpu", "api=vulkan,color=srgb" }
195 , { "vkwide", "gpu", "api=vulkan,color=f16_wide" }
196 , { "vkmsaa4", "gpu", "api=vulkan,samples=4" }
197 , { "vkmsaa16", "gpu", "api=vulkan,samples=16" }
198 #endif
199
200 #else
201 { "", "", "" }
202 #endif
203 };
204 167
205 SkCommandLineConfig::SkCommandLineConfig(const SkString& tag, const SkString& ba ckend, 168 SkCommandLineConfig::SkCommandLineConfig(const SkString& tag, const SkString& ba ckend,
206 const SkTArray<SkString>& viaParts) 169 const SkTArray<SkString>& viaParts)
207 : fTag(tag) 170 : fTag(tag)
208 , fBackend(backend) 171 , fBackend(backend)
209 , fViaParts(viaParts) { 172 , fViaParts(viaParts) {
210 } 173 }
211 SkCommandLineConfig::~SkCommandLineConfig() { 174 SkCommandLineConfig::~SkCommandLineConfig() {
212 } 175 }
213 176
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 if (extendedBackend.equals("gpu")) { 432 if (extendedBackend.equals("gpu")) {
470 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons); 433 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons);
471 } 434 }
472 #endif 435 #endif
473 if (!parsedConfig) { 436 if (!parsedConfig) {
474 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); 437 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias);
475 } 438 }
476 outResult->emplace_back(parsedConfig); 439 outResult->emplace_back(parsedConfig);
477 } 440 }
478 } 441 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698