OLD | NEW |
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 | 9 |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #endif | 22 #endif |
23 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 23 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
24 " hwui" | 24 " hwui" |
25 #endif | 25 #endif |
26 ; | 26 ; |
27 | 27 |
28 static const char configHelp[] = | 28 static const char configHelp[] = |
29 "Options: 565 8888 debug gpu gl gpudebug gpudft gpunull " | 29 "Options: 565 8888 debug gpu gl gpudebug gpudft gpunull " |
30 "msaa16 msaa4 glmsaa4 gpuf16 gpusrgb glsrgb nonrendering null nullgpu " | 30 "msaa16 msaa4 glmsaa4 gpuf16 gpusrgb glsrgb nonrendering null nullgpu " |
31 "nvpr16 nvpr4 nvprdit16 nvprdit4 glnvpr4 glnvprdit4 pdf skp svg xps" | 31 "nvpr16 nvpr4 nvprdit16 nvprdit4 glnvpr4 glnvprdit4 pdf skp svg xps" |
| 32 "glinst glinst4 glinstdit4 glinst16 glinstdit16 esinst esinst4 esinsdit4" |
32 #if SK_ANGLE | 33 #if SK_ANGLE |
33 #ifdef SK_BUILD_FOR_WIN | 34 #ifdef SK_BUILD_FOR_WIN |
34 " angle" | 35 " angle" |
35 #endif | 36 #endif |
36 " angle-gl" | 37 " angle-gl" |
37 #endif | 38 #endif |
38 #if SK_COMMAND_BUFFER | 39 #if SK_COMMAND_BUFFER |
39 " commandbuffer" | 40 " commandbuffer" |
40 #endif | 41 #endif |
41 #if SK_MESA | 42 #if SK_MESA |
42 " mesa" | 43 " mesa" |
43 #endif | 44 #endif |
44 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 45 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
45 " hwui" | 46 " hwui" |
46 #endif | 47 #endif |
47 #ifdef SK_VULKAN | 48 #ifdef SK_VULKAN |
48 " vk vksrgb" | 49 " vk vksrgb" |
49 #endif | 50 #endif |
50 " or use extended form 'backend(option=value,...)'.\n"; | 51 " or use extended form 'backend(option=value,...)'.\n"; |
51 | 52 |
52 static const char configExtendedHelp[] = | 53 static const char configExtendedHelp[] = |
53 "Extended form: 'backend(option=value,...)'\n\n" | 54 "Extended form: 'backend(option=value,...)'\n\n" |
54 "Possible backends and options:\n" | 55 "Possible backends and options:\n" |
55 #if SK_SUPPORT_GPU | 56 #if SK_SUPPORT_GPU |
56 "\n" | 57 "\n" |
57 "gpu(api=string,color=string,dit=bool,nvpr=bool,samples=int)\tGPU backend\n" | 58 "gpu(api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int)\tGPU
backend\n" |
58 "\tapi\ttype: string\tdefault: native.\n" | 59 "\tapi\ttype: string\tdefault: native.\n" |
59 "\t Select graphics API to use with gpu backend.\n" | 60 "\t Select graphics API to use with gpu backend.\n" |
60 "\t Options:\n" | 61 "\t Options:\n" |
61 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n" | 62 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n" |
62 "\t\tgl \t\t\tUse OpenGL.\n" | 63 "\t\tgl \t\t\tUse OpenGL.\n" |
63 "\t\tgles \t\t\tUse OpenGL ES.\n" | 64 "\t\tgles \t\t\tUse OpenGL ES.\n" |
64 "\t\tdebug \t\t\tUse debug OpenGL.\n" | 65 "\t\tdebug \t\t\tUse debug OpenGL.\n" |
65 "\t\tnull \t\t\tUse null OpenGL.\n" | 66 "\t\tnull \t\t\tUse null OpenGL.\n" |
66 #if SK_ANGLE | 67 #if SK_ANGLE |
67 #ifdef SK_BUILD_FOR_WIN | 68 #ifdef SK_BUILD_FOR_WIN |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 ; | 132 ; |
132 | 133 |
133 DEFINE_extended_string(config, defaultConfigs, configHelp, configExtendedHelp); | 134 DEFINE_extended_string(config, defaultConfigs, configHelp, configExtendedHelp); |
134 | 135 |
135 static const struct { | 136 static const struct { |
136 const char* predefinedConfig; | 137 const char* predefinedConfig; |
137 const char* backend; | 138 const char* backend; |
138 const char* options; | 139 const char* options; |
139 } gPredefinedConfigs[] = { | 140 } gPredefinedConfigs[] = { |
140 #if SK_SUPPORT_GPU | 141 #if SK_SUPPORT_GPU |
141 { "gpu", "gpu", "" }, | 142 { "gpu", "gpu", "" }, |
142 { "gl", "gpu", "api=gl" }, | 143 { "gl", "gpu", "api=gl" }, |
143 { "msaa4", "gpu", "samples=4" }, | 144 { "msaa4", "gpu", "samples=4" }, |
144 { "glmsaa4", "gpu", "api=gl,samples=4" }, | 145 { "glmsaa4", "gpu", "api=gl,samples=4" }, |
145 { "msaa16", "gpu", "samples=16" }, | 146 { "msaa16", "gpu", "samples=16" }, |
146 { "nvpr4", "gpu", "nvpr=true,samples=4" }, | 147 { "nvpr4", "gpu", "nvpr=true,samples=4" }, |
147 { "glnvpr4", "gpu", "api=gl,nvpr=true,samples=4" }, | 148 { "glnvpr4", "gpu", "api=gl,nvpr=true,samples=4" }, |
148 { "nvpr16", "gpu", "nvpr=true,samples=16" }, | 149 { "nvpr16", "gpu", "nvpr=true,samples=16" }, |
149 { "nvprdit4", "gpu", "nvpr=true,samples=4,dit=true" }, | 150 { "nvprdit4", "gpu", "nvpr=true,samples=4,dit=true" }, |
150 { "glnvprdit4", "gpu", "api=gl,nvpr=true,samples=4,dit=true" }, | 151 { "glnvprdit4", "gpu", "api=gl,nvpr=true,samples=4,dit=true" }, |
151 { "nvprdit16", "gpu", "nvpr=true,samples=16,dit=true" }, | 152 { "nvprdit16", "gpu", "nvpr=true,samples=16,dit=true" }, |
152 { "gpuf16", "gpu", "color=f16" }, | 153 { "glinst", "gpu", "api=gl,inst=true" }, |
153 { "gpusrgb", "gpu", "color=srgb" }, | 154 { "glinst4", "gpu", "api=gl,inst=true,samples=4" }, |
154 { "glsrgb", "gpu", "api=gl,color=srgb" }, | 155 { "glinstdit4", "gpu", "api=gl,inst=true,samples=4,dit=true" }, |
155 { "gpudft", "gpu", "dit=true" }, | 156 { "glinst16", "gpu", "api=gl,inst=true,samples=16" }, |
156 { "gpudebug", "gpu", "api=debug" }, | 157 { "glinstdit16", "gpu", "api=gl,inst=true,samples=16,dit=true" }, |
157 { "gpunull", "gpu", "api=null" }, | 158 { "esinst", "gpu", "api=gles,inst=true" }, |
158 { "debug", "gpu", "api=debug" }, | 159 { "esinst4", "gpu", "api=gles,inst=true,samples=4" }, |
159 { "nullgpu", "gpu", "api=null" } | 160 { "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" }, |
| 161 { "gpuf16", "gpu", "color=f16" }, |
| 162 { "gpusrgb", "gpu", "color=srgb" }, |
| 163 { "glsrgb", "gpu", "api=gl,color=srgb" }, |
| 164 { "gpudft", "gpu", "dit=true" }, |
| 165 { "gpudebug", "gpu", "api=debug" }, |
| 166 { "gpunull", "gpu", "api=null" }, |
| 167 { "debug", "gpu", "api=debug" }, |
| 168 { "nullgpu", "gpu", "api=null" } |
160 #if SK_ANGLE | 169 #if SK_ANGLE |
161 #ifdef SK_BUILD_FOR_WIN | 170 #ifdef SK_BUILD_FOR_WIN |
162 , { "angle", "gpu", "api=angle" } | 171 , { "angle", "gpu", "api=angle" } |
163 #endif | 172 #endif |
164 , { "angle-gl", "gpu", "api=angle-gl" } | 173 , { "angle-gl", "gpu", "api=angle-gl" } |
165 #endif | 174 #endif |
166 #if SK_COMMAND_BUFFER | 175 #if SK_COMMAND_BUFFER |
167 , { "commandbuffer", "gpu", "api=commandbuffer" } | 176 , { "commandbuffer", "gpu", "api=commandbuffer" } |
168 #endif | 177 #endif |
169 #if SK_MESA | 178 #if SK_MESA |
(...skipping 13 matching lines...) Expand all Loading... |
183 const SkTArray<SkString>& viaParts) | 192 const SkTArray<SkString>& viaParts) |
184 : fTag(tag) | 193 : fTag(tag) |
185 , fBackend(backend) | 194 , fBackend(backend) |
186 , fViaParts(viaParts) { | 195 , fViaParts(viaParts) { |
187 } | 196 } |
188 SkCommandLineConfig::~SkCommandLineConfig() { | 197 SkCommandLineConfig::~SkCommandLineConfig() { |
189 } | 198 } |
190 | 199 |
191 #if SK_SUPPORT_GPU | 200 #if SK_SUPPORT_GPU |
192 SkCommandLineConfigGpu::SkCommandLineConfigGpu( | 201 SkCommandLineConfigGpu::SkCommandLineConfigGpu( |
193 const SkString& tag, const SkTArray<SkString>& viaParts, | 202 const SkString& tag, const SkTArray<SkString>& viaParts, ContextType context
Type, bool useNVPR, |
194 ContextType contextType, bool useNVPR, bool useDIText, int samples, | 203 bool useInstanced, bool useDIText, int samples, SkColorType colorType, |
195 SkColorType colorType, sk_sp<SkColorSpace> colorSpace) | 204 sk_sp<SkColorSpace> colorSpace) |
196 : SkCommandLineConfig(tag, SkString("gpu"), viaParts) | 205 : SkCommandLineConfig(tag, SkString("gpu"), viaParts) |
197 , fContextType(contextType) | 206 , fContextType(contextType) |
198 , fUseNVPR(useNVPR) | 207 , fUseNVPR(useNVPR) |
| 208 , fUseInstanced(useInstanced) |
199 , fUseDIText(useDIText) | 209 , fUseDIText(useDIText) |
200 , fSamples(samples) | 210 , fSamples(samples) |
201 , fColorType(colorType) | 211 , fColorType(colorType) |
202 , fColorSpace(std::move(colorSpace)) { | 212 , fColorSpace(std::move(colorSpace)) { |
203 } | 213 } |
204 static bool parse_option_int(const SkString& value, int* outInt) { | 214 static bool parse_option_int(const SkString& value, int* outInt) { |
205 if (value.isEmpty()) { | 215 if (value.isEmpty()) { |
206 return false; | 216 return false; |
207 } | 217 } |
208 char* endptr = nullptr; | 218 char* endptr = nullptr; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } | 306 } |
297 | 307 |
298 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, | 308 SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag, |
299 const SkTArray<SkString>&
vias, | 309 const SkTArray<SkString>&
vias, |
300 const SkString& options) { | 310 const SkString& options) { |
301 // Defaults for GPU backend. | 311 // Defaults for GPU backend. |
302 bool seenAPI = false; | 312 bool seenAPI = false; |
303 SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNativeG
L_ContextType; | 313 SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNativeG
L_ContextType; |
304 bool seenUseNVPR = false; | 314 bool seenUseNVPR = false; |
305 bool useNVPR = false; | 315 bool useNVPR = false; |
| 316 bool seenUseInstanced = false; |
| 317 bool useInstanced = false; |
306 bool seenUseDIText =false; | 318 bool seenUseDIText =false; |
307 bool useDIText = false; | 319 bool useDIText = false; |
308 bool seenSamples = false; | 320 bool seenSamples = false; |
309 int samples = 0; | 321 int samples = 0; |
310 bool seenColor = false; | 322 bool seenColor = false; |
311 SkColorType colorType = kN32_SkColorType; | 323 SkColorType colorType = kN32_SkColorType; |
312 sk_sp<SkColorSpace> colorSpace = nullptr; | 324 sk_sp<SkColorSpace> colorSpace = nullptr; |
313 | 325 |
314 SkTArray<SkString> optionParts; | 326 SkTArray<SkString> optionParts; |
315 SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts); | 327 SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts); |
316 for (int i = 0; i < optionParts.count(); ++i) { | 328 for (int i = 0; i < optionParts.count(); ++i) { |
317 SkTArray<SkString> keyValueParts; | 329 SkTArray<SkString> keyValueParts; |
318 SkStrSplit(optionParts[i].c_str(), "=", kStrict_SkStrSplitMode, &keyValu
eParts); | 330 SkStrSplit(optionParts[i].c_str(), "=", kStrict_SkStrSplitMode, &keyValu
eParts); |
319 if (keyValueParts.count() != 2) { | 331 if (keyValueParts.count() != 2) { |
320 return nullptr; | 332 return nullptr; |
321 } | 333 } |
322 const SkString& key = keyValueParts[0]; | 334 const SkString& key = keyValueParts[0]; |
323 const SkString& value = keyValueParts[1]; | 335 const SkString& value = keyValueParts[1]; |
324 bool valueOk = false; | 336 bool valueOk = false; |
325 if (key.equals("api") && !seenAPI) { | 337 if (key.equals("api") && !seenAPI) { |
326 valueOk = parse_option_gpu_api(value, &contextType); | 338 valueOk = parse_option_gpu_api(value, &contextType); |
327 seenAPI = true; | 339 seenAPI = true; |
328 } else if (key.equals("nvpr") && !seenUseNVPR) { | 340 } else if (key.equals("nvpr") && !seenUseNVPR) { |
329 valueOk = parse_option_bool(value, &useNVPR); | 341 valueOk = parse_option_bool(value, &useNVPR); |
330 seenUseNVPR = true; | 342 seenUseNVPR = true; |
| 343 } else if (key.equals("inst") && !seenUseInstanced) { |
| 344 valueOk = parse_option_bool(value, &useInstanced); |
| 345 seenUseInstanced = true; |
331 } else if (key.equals("dit") && !seenUseDIText) { | 346 } else if (key.equals("dit") && !seenUseDIText) { |
332 valueOk = parse_option_bool(value, &useDIText); | 347 valueOk = parse_option_bool(value, &useDIText); |
333 seenUseDIText = true; | 348 seenUseDIText = true; |
334 } else if (key.equals("samples") && !seenSamples) { | 349 } else if (key.equals("samples") && !seenSamples) { |
335 valueOk = parse_option_int(value, &samples); | 350 valueOk = parse_option_int(value, &samples); |
336 seenSamples = true; | 351 seenSamples = true; |
337 } else if (key.equals("color") && !seenColor) { | 352 } else if (key.equals("color") && !seenColor) { |
338 valueOk = parse_option_gpu_color(value, &colorType, &colorSpace); | 353 valueOk = parse_option_gpu_color(value, &colorType, &colorSpace); |
339 seenColor = true; | 354 seenColor = true; |
340 } | 355 } |
341 if (!valueOk) { | 356 if (!valueOk) { |
342 return nullptr; | 357 return nullptr; |
343 } | 358 } |
344 } | 359 } |
345 return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText
, samples, | 360 return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useInstan
ced, useDIText, |
346 colorType, colorSpace); | 361 samples, colorType, colorSpace); |
347 } | 362 } |
348 #endif | 363 #endif |
349 | 364 |
350 void ParseConfigs(const SkCommandLineFlags::StringArray& configs, | 365 void ParseConfigs(const SkCommandLineFlags::StringArray& configs, |
351 SkCommandLineConfigArray* outResult) { | 366 SkCommandLineConfigArray* outResult) { |
352 outResult->reset(); | 367 outResult->reset(); |
353 for (int i = 0; i < configs.count(); ++i) { | 368 for (int i = 0; i < configs.count(); ++i) { |
354 SkString extendedBackend; | 369 SkString extendedBackend; |
355 SkString extendedOptions; | 370 SkString extendedOptions; |
356 SkString simpleBackend; | 371 SkString simpleBackend; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 if (extendedBackend.equals("gpu")) { | 417 if (extendedBackend.equals("gpu")) { |
403 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti
ons); | 418 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti
ons); |
404 } | 419 } |
405 #endif | 420 #endif |
406 if (!parsedConfig) { | 421 if (!parsedConfig) { |
407 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); | 422 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); |
408 } | 423 } |
409 outResult->emplace_back(parsedConfig); | 424 outResult->emplace_back(parsedConfig); |
410 } | 425 } |
411 } | 426 } |
OLD | NEW |