blob: abd8bdb78dc3f1ffc854366243c31c7b03182046 [file] [log] [blame]
kkinnunen3e980c32015-12-23 01:33:00 -08001/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
raftias7c602de2016-10-13 10:45:44 -07008#include "SkColorSpace_Base.h"
kkinnunen3e980c32015-12-23 01:33:00 -08009#include "SkCommonFlagsConfig.h"
csmartdalton6270e552016-09-13 10:41:49 -070010#include "SkImageInfo.h"
kkinnunen3e980c32015-12-23 01:33:00 -080011
12#include <stdlib.h>
13
bsalomon3724e572016-03-30 18:56:19 -070014#if SK_SUPPORT_GPU
15using sk_gpu_test::GrContextFactory;
16#endif
17
kkinnunen3e980c32015-12-23 01:33:00 -080018static const char defaultConfigs[] =
mtklein896ddb72016-09-14 10:33:12 -070019 "8888 gpu nonrendering"
bsalomon11abd8d2016-10-14 08:13:48 -070020#if defined(SK_BUILD_FOR_WIN)
21 " angle_d3d11_es2"
kkinnunen3e980c32015-12-23 01:33:00 -080022#endif
23#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
24 " hwui"
25#endif
26 ;
27
brianosman37e23342016-09-20 08:06:30 -070028static const struct {
29 const char* predefinedConfig;
30 const char* backend;
31 const char* options;
32} gPredefinedConfigs[] ={
33#if SK_SUPPORT_GPU
Brian Salomon002c1202016-10-18 11:28:20 -040034 { "gpu", "gpu", "" },
35 { "gl", "gpu", "api=gl" },
36 { "msaa4", "gpu", "samples=4" },
37 { "glmsaa4", "gpu", "api=gl,samples=4" },
38 { "msaa16", "gpu", "samples=16" },
39 { "nvpr4", "gpu", "nvpr=true,samples=4" },
40 { "glnvpr4", "gpu", "api=gl,nvpr=true,samples=4" },
41 { "nvpr16", "gpu", "nvpr=true,samples=16" },
42 { "nvprdit4", "gpu", "nvpr=true,samples=4,dit=true" },
43 { "glnvprdit4", "gpu", "api=gl,nvpr=true,samples=4,dit=true" },
44 { "nvprdit16", "gpu", "nvpr=true,samples=16,dit=true" },
45 { "glinst", "gpu", "api=gl,inst=true" },
46 { "glinst4", "gpu", "api=gl,inst=true,samples=4" },
47 { "glinstdit4", "gpu", "api=gl,inst=true,samples=4,dit=true" },
48 { "glinst16", "gpu", "api=gl,inst=true,samples=16" },
49 { "glinstdit16", "gpu", "api=gl,inst=true,samples=16,dit=true" },
50 { "esinst", "gpu", "api=gles,inst=true" },
51 { "esinst4", "gpu", "api=gles,inst=true,samples=4" },
52 { "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" },
53 { "gpuf16", "gpu", "color=f16" },
54 { "gpusrgb", "gpu", "color=srgb" },
55 { "glsrgb", "gpu", "api=gl,color=srgb" },
56 { "glwide", "gpu", "api=gl,color=f16_wide" },
57 { "glnarrow", "gpu", "api=gl,color=f16_narrow" },
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" },
63 { "angle_d3d11_es2", "gpu", "api=angle_d3d11_es2" },
64 { "angle_d3d9_es2", "gpu", "api=angle_d3d9_es2" },
65 { "angle_d3d11_es2_msaa4", "gpu", "api=angle_d3d11_es2,samples=4" },
66 { "angle_gl_es2", "gpu", "api=angle_gl_es2" },
Brian Salomon002c1202016-10-18 11:28:20 -040067 { "commandbuffer", "gpu", "api=commandbuffer" }
kkinnunen3e980c32015-12-23 01:33:00 -080068#if SK_MESA
Brian Salomon002c1202016-10-18 11:28:20 -040069 ,{ "mesa", "gpu", "api=mesa" }
kkinnunen3e980c32015-12-23 01:33:00 -080070#endif
brianosman37e23342016-09-20 08:06:30 -070071#ifdef SK_VULKAN
Brian Salomon002c1202016-10-18 11:28:20 -040072 ,{ "vk", "gpu", "api=vulkan" }
73 ,{ "vksrgb", "gpu", "api=vulkan,color=srgb" }
74 ,{ "vkwide", "gpu", "api=vulkan,color=f16_wide" }
75 ,{ "vkmsaa4", "gpu", "api=vulkan,samples=4" }
76 ,{ "vkmsaa16", "gpu", "api=vulkan,samples=16" }
brianosman37e23342016-09-20 08:06:30 -070077#endif
78
79#else
80{ "", "", "" }
81#endif
82};
83
84static const char configHelp[] =
85 "Options: 565 8888 srgb f16 nonrendering null pdf pdfa skp pipe svg xps"
kkinnunen3e980c32015-12-23 01:33:00 -080086#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
87 " hwui"
88#endif
brianosman37e23342016-09-20 08:06:30 -070089 ;
90
91static const char* config_help_fn() {
92 static SkString helpString;
93 helpString.set(configHelp);
94 for (const auto& config : gPredefinedConfigs) {
95 helpString.appendf(" %s", config.predefinedConfig);
96 }
bsalomon808ecbb2016-09-28 12:40:22 -070097 helpString.append(" or use extended form 'backend[option=value,...]'.\n");
brianosman37e23342016-09-20 08:06:30 -070098 return helpString.c_str();
99}
kkinnunen3e980c32015-12-23 01:33:00 -0800100
101static const char configExtendedHelp[] =
102 "Extended form: 'backend(option=value,...)'\n\n"
103 "Possible backends and options:\n"
104#if SK_SUPPORT_GPU
105 "\n"
bsalomon808ecbb2016-09-28 12:40:22 -0700106 "gpu[api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int]\n"
kkinnunen3e980c32015-12-23 01:33:00 -0800107 "\tapi\ttype: string\tdefault: native.\n"
108 "\t Select graphics API to use with gpu backend.\n"
109 "\t Options:\n"
110 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n"
111 "\t\tgl \t\t\tUse OpenGL.\n"
112 "\t\tgles \t\t\tUse OpenGL ES.\n"
113 "\t\tdebug \t\t\tUse debug OpenGL.\n"
114 "\t\tnull \t\t\tUse null OpenGL.\n"
bsalomon11abd8d2016-10-14 08:13:48 -0700115 "\t\tangle_d3d9_es2\t\t\tUse OpenGL ES2 on the ANGLE Direct3D9 backend.\n"
116 "\t\tangle_d3d11_es2\t\t\tUse OpenGL ES2 on the ANGLE Direct3D11 backend.\n"
117 "\t\tangle_d3d11_es3\t\t\tUse OpenGL ES3 on the ANGLE Direct3D11 backend.\n"
118 "\t\tangle_gl_es2\t\t\tUse OpenGL ES2 on the ANGLE OpenGL backend.\n"
119 "\t\tangle_gl_es3\t\t\tUse OpenGL ES3 on the ANGLE OpenGL backend.\n"
kkinnunen3e980c32015-12-23 01:33:00 -0800120 "\t\tcommandbuffer\t\tUse command buffer.\n"
kkinnunen3e980c32015-12-23 01:33:00 -0800121#if SK_MESA
122 "\t\tmesa\t\t\tUse MESA.\n"
123#endif
bsalomondc0fcd42016-04-11 14:21:33 -0700124#ifdef SK_VULKAN
125 "\t\tvulkan\t\t\tUse Vulkan.\n"
126#endif
brianosmand93c1202016-03-10 07:49:08 -0800127 "\tcolor\ttype: string\tdefault: 8888.\n"
128 "\t Select framebuffer color format.\n"
129 "\t Options:\n"
130 "\t\t8888\t\t\tLinear 8888.\n"
brianosman4562f6e2016-09-19 14:42:04 -0700131 "\t\tf16{_gamut}\t\tLinear 16-bit floating point.\n"
132 "\t\tsrgb{_gamut}\t\tsRGB 8888.\n"
133 "\t gamut\ttype: string\tdefault: srgb.\n"
134 "\t Select color gamut for f16 or sRGB format buffers.\n"
135 "\t Options:\n"
136 "\t\tsrgb\t\t\tsRGB gamut.\n"
137 "\t\twide\t\t\tWide Gamut RGB.\n"
kkinnunen3e980c32015-12-23 01:33:00 -0800138 "\tdit\ttype: bool\tdefault: false.\n"
139 "\t Use device independent text.\n"
140 "\tnvpr\ttype: bool\tdefault: false.\n"
141 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n"
142 "\tsamples\ttype: int\tdefault: 0.\n"
143 "\t Use multisampling with N samples.\n"
144 "\n"
145 "Predefined configs:\n\n"
brianosman37e23342016-09-20 08:06:30 -0700146 // Help text for pre-defined configs is auto-generated from gPredefinedConfigs
kkinnunen3e980c32015-12-23 01:33:00 -0800147#endif
148 ;
149
brianosman37e23342016-09-20 08:06:30 -0700150static const char* config_extended_help_fn() {
151 static SkString helpString;
152 helpString.set(configExtendedHelp);
153 for (const auto& config : gPredefinedConfigs) {
154 helpString.appendf("\t%-10s\t= gpu(%s)\n", config.predefinedConfig, config.options);
155 }
156 return helpString.c_str();
157}
kkinnunen3e980c32015-12-23 01:33:00 -0800158
brianosman37e23342016-09-20 08:06:30 -0700159DEFINE_extended_string(config, defaultConfigs, config_help_fn(), config_extended_help_fn());
kkinnunen3e980c32015-12-23 01:33:00 -0800160
161SkCommandLineConfig::SkCommandLineConfig(const SkString& tag, const SkString& backend,
162 const SkTArray<SkString>& viaParts)
163 : fTag(tag)
164 , fBackend(backend)
165 , fViaParts(viaParts) {
166}
167SkCommandLineConfig::~SkCommandLineConfig() {
168}
169
170#if SK_SUPPORT_GPU
171SkCommandLineConfigGpu::SkCommandLineConfigGpu(
csmartdaltone0d36292016-07-29 08:14:20 -0700172 const SkString& tag, const SkTArray<SkString>& viaParts, ContextType contextType, bool useNVPR,
173 bool useInstanced, bool useDIText, int samples, SkColorType colorType,
174 sk_sp<SkColorSpace> colorSpace)
kkinnunen3e980c32015-12-23 01:33:00 -0800175 : SkCommandLineConfig(tag, SkString("gpu"), viaParts)
176 , fContextType(contextType)
csmartdalton6270e552016-09-13 10:41:49 -0700177 , fContextOptions(ContextOptions::kNone)
kkinnunen3e980c32015-12-23 01:33:00 -0800178 , fUseDIText(useDIText)
brianosmand93c1202016-03-10 07:49:08 -0800179 , fSamples(samples)
180 , fColorType(colorType)
brianosmanb109b8c2016-06-16 13:03:24 -0700181 , fColorSpace(std::move(colorSpace)) {
csmartdalton6270e552016-09-13 10:41:49 -0700182 if (useNVPR) {
183 fContextOptions |= ContextOptions::kEnableNVPR;
184 }
185 if (useInstanced) {
186 fContextOptions |= ContextOptions::kUseInstanced;
187 }
Brian Osman7039f742016-11-01 15:56:16 -0400188 if (fColorSpace) {
csmartdalton6270e552016-09-13 10:41:49 -0700189 fContextOptions |= ContextOptions::kRequireSRGBSupport;
190 }
kkinnunen3e980c32015-12-23 01:33:00 -0800191}
192static bool parse_option_int(const SkString& value, int* outInt) {
193 if (value.isEmpty()) {
194 return false;
195 }
196 char* endptr = nullptr;
197 long intValue = strtol(value.c_str(), &endptr, 10);
198 if (*endptr != '\0') {
199 return false;
200 }
201 *outInt = static_cast<int>(intValue);
202 return true;
203}
204static bool parse_option_bool(const SkString& value, bool* outBool) {
205 if (value.equals("true")) {
206 *outBool = true;
207 return true;
208 }
209 if (value.equals("false")) {
210 *outBool = false;
211 return true;
212 }
213 return false;
214}
215static bool parse_option_gpu_api(const SkString& value,
216 SkCommandLineConfigGpu::ContextType* outContextType) {
kkinnunen3e980c32015-12-23 01:33:00 -0800217 if (value.equals("gl")) {
bsalomon85b4b532016-04-05 11:06:27 -0700218 *outContextType = GrContextFactory::kGL_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800219 return true;
220 }
221 if (value.equals("gles")) {
bsalomon85b4b532016-04-05 11:06:27 -0700222 *outContextType = GrContextFactory::kGLES_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800223 return true;
224 }
225 if (value.equals("debug")) {
bsalomon85b4b532016-04-05 11:06:27 -0700226 *outContextType = GrContextFactory::kDebugGL_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800227 return true;
228 }
229 if (value.equals("null")) {
bsalomon85b4b532016-04-05 11:06:27 -0700230 *outContextType = GrContextFactory::kNullGL_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800231 return true;
232 }
bsalomon11abd8d2016-10-14 08:13:48 -0700233 if (value.equals("angle_d3d9_es2")) {
234 *outContextType = GrContextFactory::kANGLE_D3D9_ES2_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800235 return true;
236 }
bsalomon11abd8d2016-10-14 08:13:48 -0700237 if (value.equals("angle_d3d11_es2")) {
238 *outContextType = GrContextFactory::kANGLE_D3D11_ES2_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800239 return true;
240 }
bsalomon11abd8d2016-10-14 08:13:48 -0700241 if (value.equals("angle_d3d11_es3")) {
242 *outContextType = GrContextFactory::kANGLE_D3D11_ES3_ContextType;
243 return true;
244 }
245 if (value.equals("angle_gl_es2")) {
246 *outContextType = GrContextFactory::kANGLE_GL_ES2_ContextType;
247 return true;
248 }
249 if (value.equals("angle_gl_es3")) {
250 *outContextType = GrContextFactory::kANGLE_GL_ES3_ContextType;
251 return true;
252 }
kkinnunen3e980c32015-12-23 01:33:00 -0800253 if (value.equals("commandbuffer")) {
bsalomon85b4b532016-04-05 11:06:27 -0700254 *outContextType = GrContextFactory::kCommandBuffer_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800255 return true;
256 }
kkinnunen3e980c32015-12-23 01:33:00 -0800257#if SK_MESA
258 if (value.equals("mesa")) {
bsalomon85b4b532016-04-05 11:06:27 -0700259 *outContextType = GrContextFactory::kMESA_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800260 return true;
261 }
262#endif
bsalomondc0fcd42016-04-11 14:21:33 -0700263#ifdef SK_VULKAN
264 if (value.equals("vulkan")) {
265 *outContextType = GrContextFactory::kVulkan_ContextType;
266 return true;
267 }
268#endif
kkinnunen3e980c32015-12-23 01:33:00 -0800269 return false;
270}
brianosmand93c1202016-03-10 07:49:08 -0800271static bool parse_option_gpu_color(const SkString& value,
272 SkColorType* outColorType,
brianosmanb109b8c2016-06-16 13:03:24 -0700273 sk_sp<SkColorSpace>* outColorSpace) {
brianosmand93c1202016-03-10 07:49:08 -0800274 if (value.equals("8888")) {
bsalomon33069252016-09-28 08:49:53 -0700275 *outColorType = kRGBA_8888_SkColorType;
brianosmanb109b8c2016-06-16 13:03:24 -0700276 *outColorSpace = nullptr;
brianosmand93c1202016-03-10 07:49:08 -0800277 return true;
278 }
brianosman4562f6e2016-09-19 14:42:04 -0700279
280 SkTArray<SkString> commands;
281 SkStrSplit(value.c_str(), "_", &commands);
282 if (commands.count() < 1 || commands.count() > 2) {
283 return false;
284 }
285
286 // First, figure out color gamut that we'll work in (default to sRGB)
raftias94888332016-10-18 10:02:51 -0700287 const bool linearGamma = commands[0].equals("f16");
Brian Osman526972e2016-10-24 09:24:02 -0400288 *outColorSpace = SkColorSpace::MakeNamed(linearGamma ? SkColorSpace::kSRGBLinear_Named
289 : SkColorSpace::kSRGB_Named);
brianosman4562f6e2016-09-19 14:42:04 -0700290 if (commands.count() == 2) {
291 if (commands[1].equals("srgb")) {
292 // sRGB gamut (which is our default)
293 } else if (commands[1].equals("wide")) {
294 // WideGamut RGB
295 const float gWideGamutRGB_toXYZD50[]{
296 0.7161046f, 0.1009296f, 0.1471858f, // -> X
297 0.2581874f, 0.7249378f, 0.0168748f, // -> Y
298 0.0000000f, 0.0517813f, 0.7734287f, // -> Z
299 };
300 SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor);
301 wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50);
Brian Osman526972e2016-10-24 09:24:02 -0400302 *outColorSpace = SkColorSpace::MakeRGB(linearGamma
raftias94888332016-10-18 10:02:51 -0700303 ? SkColorSpace::kLinear_RenderTargetGamma
304 : SkColorSpace::kSRGB_RenderTargetGamma,
Brian Osman526972e2016-10-24 09:24:02 -0400305 wideGamutRGBMatrix);
Brian Osman4a6b28e2016-10-17 11:14:02 -0400306 } else if (commands[1].equals("narrow")) {
307 // NarrowGamut RGB (an artifically smaller than sRGB gamut)
308 SkColorSpacePrimaries primaries ={
309 0.54f, 0.33f, // Rx, Ry
310 0.33f, 0.50f, // Gx, Gy
311 0.25f, 0.20f, // Bx, By
312 0.3127f, 0.3290f, // Wx, Wy
313 };
314 SkMatrix44 narrowGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor);
315 primaries.toXYZD50(&narrowGamutRGBMatrix);
Brian Osman526972e2016-10-24 09:24:02 -0400316 *outColorSpace = SkColorSpace::MakeRGB(linearGamma
raftias94888332016-10-18 10:02:51 -0700317 ? SkColorSpace::kLinear_RenderTargetGamma
318 : SkColorSpace::kSRGB_RenderTargetGamma,
Brian Osman526972e2016-10-24 09:24:02 -0400319 narrowGamutRGBMatrix);
brianosman4562f6e2016-09-19 14:42:04 -0700320 } else {
321 // Unknown color gamut
322 return false;
323 }
324 }
325
326 // Now pick a color type
327 if (commands[0].equals("f16")) {
brianosmand93c1202016-03-10 07:49:08 -0800328 *outColorType = kRGBA_F16_SkColorType;
brianosmand93c1202016-03-10 07:49:08 -0800329 return true;
330 }
brianosman4562f6e2016-09-19 14:42:04 -0700331 if (commands[0].equals("srgb")) {
bsalomon33069252016-09-28 08:49:53 -0700332 *outColorType = kRGBA_8888_SkColorType;
brianosmand93c1202016-03-10 07:49:08 -0800333 return true;
334 }
335 return false;
336}
kkinnunen3e980c32015-12-23 01:33:00 -0800337
338SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
339 const SkTArray<SkString>& vias,
340 const SkString& options) {
341 // Defaults for GPU backend.
342 bool seenAPI = false;
bsalomon85b4b532016-04-05 11:06:27 -0700343 SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNativeGL_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800344 bool seenUseNVPR = false;
345 bool useNVPR = false;
csmartdaltone0d36292016-07-29 08:14:20 -0700346 bool seenUseInstanced = false;
347 bool useInstanced = false;
kkinnunen3e980c32015-12-23 01:33:00 -0800348 bool seenUseDIText =false;
349 bool useDIText = false;
350 bool seenSamples = false;
351 int samples = 0;
brianosmand93c1202016-03-10 07:49:08 -0800352 bool seenColor = false;
bsalomon33069252016-09-28 08:49:53 -0700353 SkColorType colorType = kRGBA_8888_SkColorType;
brianosmanb109b8c2016-06-16 13:03:24 -0700354 sk_sp<SkColorSpace> colorSpace = nullptr;
kkinnunen3e980c32015-12-23 01:33:00 -0800355
356 SkTArray<SkString> optionParts;
357 SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts);
358 for (int i = 0; i < optionParts.count(); ++i) {
359 SkTArray<SkString> keyValueParts;
360 SkStrSplit(optionParts[i].c_str(), "=", kStrict_SkStrSplitMode, &keyValueParts);
361 if (keyValueParts.count() != 2) {
362 return nullptr;
363 }
364 const SkString& key = keyValueParts[0];
365 const SkString& value = keyValueParts[1];
366 bool valueOk = false;
367 if (key.equals("api") && !seenAPI) {
368 valueOk = parse_option_gpu_api(value, &contextType);
369 seenAPI = true;
370 } else if (key.equals("nvpr") && !seenUseNVPR) {
371 valueOk = parse_option_bool(value, &useNVPR);
372 seenUseNVPR = true;
csmartdaltone0d36292016-07-29 08:14:20 -0700373 } else if (key.equals("inst") && !seenUseInstanced) {
374 valueOk = parse_option_bool(value, &useInstanced);
375 seenUseInstanced = true;
kkinnunen3e980c32015-12-23 01:33:00 -0800376 } else if (key.equals("dit") && !seenUseDIText) {
377 valueOk = parse_option_bool(value, &useDIText);
378 seenUseDIText = true;
379 } else if (key.equals("samples") && !seenSamples) {
380 valueOk = parse_option_int(value, &samples);
381 seenSamples = true;
brianosmand93c1202016-03-10 07:49:08 -0800382 } else if (key.equals("color") && !seenColor) {
brianosmanb109b8c2016-06-16 13:03:24 -0700383 valueOk = parse_option_gpu_color(value, &colorType, &colorSpace);
brianosmand93c1202016-03-10 07:49:08 -0800384 seenColor = true;
kkinnunen3e980c32015-12-23 01:33:00 -0800385 }
386 if (!valueOk) {
387 return nullptr;
388 }
389 }
csmartdaltone0d36292016-07-29 08:14:20 -0700390 return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useInstanced, useDIText,
391 samples, colorType, colorSpace);
kkinnunen3e980c32015-12-23 01:33:00 -0800392}
393#endif
394
395void ParseConfigs(const SkCommandLineFlags::StringArray& configs,
396 SkCommandLineConfigArray* outResult) {
397 outResult->reset();
398 for (int i = 0; i < configs.count(); ++i) {
399 SkString extendedBackend;
400 SkString extendedOptions;
401 SkString simpleBackend;
402 SkTArray<SkString> vias;
403
404 SkString tag(configs[i]);
405 SkTArray<SkString> parts;
bsalomon808ecbb2016-09-28 12:40:22 -0700406 SkStrSplit(tag.c_str(), "[", kStrict_SkStrSplitMode, &parts);
kkinnunen3e980c32015-12-23 01:33:00 -0800407 if (parts.count() == 2) {
408 SkTArray<SkString> parts2;
bsalomon808ecbb2016-09-28 12:40:22 -0700409 SkStrSplit(parts[1].c_str(), "]", kStrict_SkStrSplitMode, &parts2);
kkinnunen3e980c32015-12-23 01:33:00 -0800410 if (parts2.count() == 2 && parts2[1].isEmpty()) {
411 SkStrSplit(parts[0].c_str(), "-", kStrict_SkStrSplitMode, &vias);
412 if (vias.count()) {
413 extendedBackend = vias[vias.count() - 1];
414 vias.pop_back();
415 } else {
416 extendedBackend = parts[0];
417 }
418 extendedOptions = parts2[0];
bsalomon808ecbb2016-09-28 12:40:22 -0700419 simpleBackend.printf("%s[%s]", extendedBackend.c_str(), extendedOptions.c_str());
kkinnunen3e980c32015-12-23 01:33:00 -0800420 }
421 }
422
423 if (extendedBackend.isEmpty()) {
424 simpleBackend = tag;
425 SkStrSplit(tag.c_str(), "-", kStrict_SkStrSplitMode, &vias);
426 if (vias.count()) {
427 simpleBackend = vias[vias.count() - 1];
428 vias.pop_back();
429 }
kkinnunen3e980c32015-12-23 01:33:00 -0800430 for (auto& predefinedConfig : gPredefinedConfigs) {
431 if (simpleBackend.equals(predefinedConfig.predefinedConfig)) {
432 extendedBackend = predefinedConfig.backend;
433 extendedOptions = predefinedConfig.options;
434 break;
435 }
436 }
437 }
438 SkCommandLineConfig* parsedConfig = nullptr;
439#if SK_SUPPORT_GPU
440 if (extendedBackend.equals("gpu")) {
441 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOptions);
442 }
443#endif
444 if (!parsedConfig) {
445 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias);
446 }
447 outResult->emplace_back(parsedConfig);
448 }
449}