blob: 20dc26600abf64e3886bccedd9820b77bf4457a5 [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
bsalomon11abd8d2016-10-14 08:13:48 -070034 { "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" },
Brian Osman4a6b28e2016-10-17 11:14:02 -040057 { "glnarrow", "gpu", "api=gl,color=f16_narrow" },
bsalomon11abd8d2016-10-14 08:13:48 -070058 { "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_gl_es2", "gpu", "api=angle_gl_es2" },
65 { "commandbuffer", "gpu", "api=commandbuffer" }
kkinnunen3e980c32015-12-23 01:33:00 -080066#if SK_MESA
bsalomon11abd8d2016-10-14 08:13:48 -070067 ,{ "mesa", "gpu", "api=mesa" }
kkinnunen3e980c32015-12-23 01:33:00 -080068#endif
brianosman37e23342016-09-20 08:06:30 -070069#ifdef SK_VULKAN
bsalomon11abd8d2016-10-14 08:13:48 -070070 ,{ "vk", "gpu", "api=vulkan" }
71 ,{ "vksrgb", "gpu", "api=vulkan,color=srgb" }
72 ,{ "vkwide", "gpu", "api=vulkan,color=f16_wide" }
73 ,{ "vkmsaa4", "gpu", "api=vulkan,samples=4" }
74 ,{ "vkmsaa16", "gpu", "api=vulkan,samples=16" }
brianosman37e23342016-09-20 08:06:30 -070075#endif
76
77#else
78{ "", "", "" }
79#endif
80};
81
82static const char configHelp[] =
83 "Options: 565 8888 srgb f16 nonrendering null pdf pdfa skp pipe svg xps"
kkinnunen3e980c32015-12-23 01:33:00 -080084#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
85 " hwui"
86#endif
brianosman37e23342016-09-20 08:06:30 -070087 ;
88
89static const char* config_help_fn() {
90 static SkString helpString;
91 helpString.set(configHelp);
92 for (const auto& config : gPredefinedConfigs) {
93 helpString.appendf(" %s", config.predefinedConfig);
94 }
bsalomon808ecbb2016-09-28 12:40:22 -070095 helpString.append(" or use extended form 'backend[option=value,...]'.\n");
brianosman37e23342016-09-20 08:06:30 -070096 return helpString.c_str();
97}
kkinnunen3e980c32015-12-23 01:33:00 -080098
99static const char configExtendedHelp[] =
100 "Extended form: 'backend(option=value,...)'\n\n"
101 "Possible backends and options:\n"
102#if SK_SUPPORT_GPU
103 "\n"
bsalomon808ecbb2016-09-28 12:40:22 -0700104 "gpu[api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int]\n"
kkinnunen3e980c32015-12-23 01:33:00 -0800105 "\tapi\ttype: string\tdefault: native.\n"
106 "\t Select graphics API to use with gpu backend.\n"
107 "\t Options:\n"
108 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n"
109 "\t\tgl \t\t\tUse OpenGL.\n"
110 "\t\tgles \t\t\tUse OpenGL ES.\n"
111 "\t\tdebug \t\t\tUse debug OpenGL.\n"
112 "\t\tnull \t\t\tUse null OpenGL.\n"
bsalomon11abd8d2016-10-14 08:13:48 -0700113 "\t\tangle_d3d9_es2\t\t\tUse OpenGL ES2 on the ANGLE Direct3D9 backend.\n"
114 "\t\tangle_d3d11_es2\t\t\tUse OpenGL ES2 on the ANGLE Direct3D11 backend.\n"
115 "\t\tangle_d3d11_es3\t\t\tUse OpenGL ES3 on the ANGLE Direct3D11 backend.\n"
116 "\t\tangle_gl_es2\t\t\tUse OpenGL ES2 on the ANGLE OpenGL backend.\n"
117 "\t\tangle_gl_es3\t\t\tUse OpenGL ES3 on the ANGLE OpenGL backend.\n"
kkinnunen3e980c32015-12-23 01:33:00 -0800118 "\t\tcommandbuffer\t\tUse command buffer.\n"
kkinnunen3e980c32015-12-23 01:33:00 -0800119#if SK_MESA
120 "\t\tmesa\t\t\tUse MESA.\n"
121#endif
bsalomondc0fcd42016-04-11 14:21:33 -0700122#ifdef SK_VULKAN
123 "\t\tvulkan\t\t\tUse Vulkan.\n"
124#endif
brianosmand93c1202016-03-10 07:49:08 -0800125 "\tcolor\ttype: string\tdefault: 8888.\n"
126 "\t Select framebuffer color format.\n"
127 "\t Options:\n"
128 "\t\t8888\t\t\tLinear 8888.\n"
brianosman4562f6e2016-09-19 14:42:04 -0700129 "\t\tf16{_gamut}\t\tLinear 16-bit floating point.\n"
130 "\t\tsrgb{_gamut}\t\tsRGB 8888.\n"
131 "\t gamut\ttype: string\tdefault: srgb.\n"
132 "\t Select color gamut for f16 or sRGB format buffers.\n"
133 "\t Options:\n"
134 "\t\tsrgb\t\t\tsRGB gamut.\n"
135 "\t\twide\t\t\tWide Gamut RGB.\n"
Brian Osman4a6b28e2016-10-17 11:14:02 -0400136 "\t\tnarrow\t\t\tNarrow Gamut RGB.\n"
kkinnunen3e980c32015-12-23 01:33:00 -0800137 "\tdit\ttype: bool\tdefault: false.\n"
138 "\t Use device independent text.\n"
139 "\tnvpr\ttype: bool\tdefault: false.\n"
140 "\t Use NV_path_rendering OpenGL and OpenGL ES extension.\n"
141 "\tsamples\ttype: int\tdefault: 0.\n"
142 "\t Use multisampling with N samples.\n"
143 "\n"
144 "Predefined configs:\n\n"
brianosman37e23342016-09-20 08:06:30 -0700145 // Help text for pre-defined configs is auto-generated from gPredefinedConfigs
kkinnunen3e980c32015-12-23 01:33:00 -0800146#endif
147 ;
148
brianosman37e23342016-09-20 08:06:30 -0700149static const char* config_extended_help_fn() {
150 static SkString helpString;
151 helpString.set(configExtendedHelp);
152 for (const auto& config : gPredefinedConfigs) {
153 helpString.appendf("\t%-10s\t= gpu(%s)\n", config.predefinedConfig, config.options);
154 }
155 return helpString.c_str();
156}
kkinnunen3e980c32015-12-23 01:33:00 -0800157
brianosman37e23342016-09-20 08:06:30 -0700158DEFINE_extended_string(config, defaultConfigs, config_help_fn(), config_extended_help_fn());
kkinnunen3e980c32015-12-23 01:33:00 -0800159
160SkCommandLineConfig::SkCommandLineConfig(const SkString& tag, const SkString& backend,
161 const SkTArray<SkString>& viaParts)
162 : fTag(tag)
163 , fBackend(backend)
164 , fViaParts(viaParts) {
165}
166SkCommandLineConfig::~SkCommandLineConfig() {
167}
168
169#if SK_SUPPORT_GPU
170SkCommandLineConfigGpu::SkCommandLineConfigGpu(
csmartdaltone0d36292016-07-29 08:14:20 -0700171 const SkString& tag, const SkTArray<SkString>& viaParts, ContextType contextType, bool useNVPR,
172 bool useInstanced, bool useDIText, int samples, SkColorType colorType,
173 sk_sp<SkColorSpace> colorSpace)
kkinnunen3e980c32015-12-23 01:33:00 -0800174 : SkCommandLineConfig(tag, SkString("gpu"), viaParts)
175 , fContextType(contextType)
csmartdalton6270e552016-09-13 10:41:49 -0700176 , fContextOptions(ContextOptions::kNone)
kkinnunen3e980c32015-12-23 01:33:00 -0800177 , fUseDIText(useDIText)
brianosmand93c1202016-03-10 07:49:08 -0800178 , fSamples(samples)
179 , fColorType(colorType)
brianosmanb109b8c2016-06-16 13:03:24 -0700180 , fColorSpace(std::move(colorSpace)) {
csmartdalton6270e552016-09-13 10:41:49 -0700181 if (useNVPR) {
182 fContextOptions |= ContextOptions::kEnableNVPR;
183 }
184 if (useInstanced) {
185 fContextOptions |= ContextOptions::kUseInstanced;
186 }
187 if (SkColorAndColorSpaceAreGammaCorrect(colorType, colorSpace.get())) {
188 fContextOptions |= ContextOptions::kRequireSRGBSupport;
189 }
kkinnunen3e980c32015-12-23 01:33:00 -0800190}
191static bool parse_option_int(const SkString& value, int* outInt) {
192 if (value.isEmpty()) {
193 return false;
194 }
195 char* endptr = nullptr;
196 long intValue = strtol(value.c_str(), &endptr, 10);
197 if (*endptr != '\0') {
198 return false;
199 }
200 *outInt = static_cast<int>(intValue);
201 return true;
202}
203static bool parse_option_bool(const SkString& value, bool* outBool) {
204 if (value.equals("true")) {
205 *outBool = true;
206 return true;
207 }
208 if (value.equals("false")) {
209 *outBool = false;
210 return true;
211 }
212 return false;
213}
214static bool parse_option_gpu_api(const SkString& value,
215 SkCommandLineConfigGpu::ContextType* outContextType) {
kkinnunen3e980c32015-12-23 01:33:00 -0800216 if (value.equals("gl")) {
bsalomon85b4b532016-04-05 11:06:27 -0700217 *outContextType = GrContextFactory::kGL_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800218 return true;
219 }
220 if (value.equals("gles")) {
bsalomon85b4b532016-04-05 11:06:27 -0700221 *outContextType = GrContextFactory::kGLES_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800222 return true;
223 }
224 if (value.equals("debug")) {
bsalomon85b4b532016-04-05 11:06:27 -0700225 *outContextType = GrContextFactory::kDebugGL_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800226 return true;
227 }
228 if (value.equals("null")) {
bsalomon85b4b532016-04-05 11:06:27 -0700229 *outContextType = GrContextFactory::kNullGL_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800230 return true;
231 }
bsalomon11abd8d2016-10-14 08:13:48 -0700232 if (value.equals("angle_d3d9_es2")) {
233 *outContextType = GrContextFactory::kANGLE_D3D9_ES2_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800234 return true;
235 }
bsalomon11abd8d2016-10-14 08:13:48 -0700236 if (value.equals("angle_d3d11_es2")) {
237 *outContextType = GrContextFactory::kANGLE_D3D11_ES2_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800238 return true;
239 }
bsalomon11abd8d2016-10-14 08:13:48 -0700240 if (value.equals("angle_d3d11_es3")) {
241 *outContextType = GrContextFactory::kANGLE_D3D11_ES3_ContextType;
242 return true;
243 }
244 if (value.equals("angle_gl_es2")) {
245 *outContextType = GrContextFactory::kANGLE_GL_ES2_ContextType;
246 return true;
247 }
248 if (value.equals("angle_gl_es3")) {
249 *outContextType = GrContextFactory::kANGLE_GL_ES3_ContextType;
250 return true;
251 }
kkinnunen3e980c32015-12-23 01:33:00 -0800252 if (value.equals("commandbuffer")) {
bsalomon85b4b532016-04-05 11:06:27 -0700253 *outContextType = GrContextFactory::kCommandBuffer_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800254 return true;
255 }
kkinnunen3e980c32015-12-23 01:33:00 -0800256#if SK_MESA
257 if (value.equals("mesa")) {
bsalomon85b4b532016-04-05 11:06:27 -0700258 *outContextType = GrContextFactory::kMESA_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800259 return true;
260 }
261#endif
bsalomondc0fcd42016-04-11 14:21:33 -0700262#ifdef SK_VULKAN
263 if (value.equals("vulkan")) {
264 *outContextType = GrContextFactory::kVulkan_ContextType;
265 return true;
266 }
267#endif
kkinnunen3e980c32015-12-23 01:33:00 -0800268 return false;
269}
brianosmand93c1202016-03-10 07:49:08 -0800270static bool parse_option_gpu_color(const SkString& value,
271 SkColorType* outColorType,
brianosmanb109b8c2016-06-16 13:03:24 -0700272 sk_sp<SkColorSpace>* outColorSpace) {
brianosmand93c1202016-03-10 07:49:08 -0800273 if (value.equals("8888")) {
bsalomon33069252016-09-28 08:49:53 -0700274 *outColorType = kRGBA_8888_SkColorType;
brianosmanb109b8c2016-06-16 13:03:24 -0700275 *outColorSpace = nullptr;
brianosmand93c1202016-03-10 07:49:08 -0800276 return true;
277 }
brianosman4562f6e2016-09-19 14:42:04 -0700278
279 SkTArray<SkString> commands;
280 SkStrSplit(value.c_str(), "_", &commands);
281 if (commands.count() < 1 || commands.count() > 2) {
282 return false;
283 }
284
285 // First, figure out color gamut that we'll work in (default to sRGB)
286 sk_sp<SkColorSpace> colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
287 if (commands.count() == 2) {
288 if (commands[1].equals("srgb")) {
289 // sRGB gamut (which is our default)
290 } else if (commands[1].equals("wide")) {
291 // WideGamut RGB
292 const float gWideGamutRGB_toXYZD50[]{
293 0.7161046f, 0.1009296f, 0.1471858f, // -> X
294 0.2581874f, 0.7249378f, 0.0168748f, // -> Y
295 0.0000000f, 0.0517813f, 0.7734287f, // -> Z
296 };
297 SkMatrix44 wideGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor);
298 wideGamutRGBMatrix.set3x3RowMajorf(gWideGamutRGB_toXYZD50);
299 colorSpace = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma,
300 wideGamutRGBMatrix);
Brian Osman4a6b28e2016-10-17 11:14:02 -0400301 } else if (commands[1].equals("narrow")) {
302 // NarrowGamut RGB (an artifically smaller than sRGB gamut)
303 SkColorSpacePrimaries primaries ={
304 0.54f, 0.33f, // Rx, Ry
305 0.33f, 0.50f, // Gx, Gy
306 0.25f, 0.20f, // Bx, By
307 0.3127f, 0.3290f, // Wx, Wy
308 };
309 SkMatrix44 narrowGamutRGBMatrix(SkMatrix44::kUninitialized_Constructor);
310 primaries.toXYZD50(&narrowGamutRGBMatrix);
311 colorSpace = SkColorSpace::NewRGB(SkColorSpace::kSRGB_RenderTargetGamma,
312 narrowGamutRGBMatrix);
brianosman4562f6e2016-09-19 14:42:04 -0700313 } else {
314 // Unknown color gamut
315 return false;
316 }
317 }
318
319 // Now pick a color type
320 if (commands[0].equals("f16")) {
brianosmand93c1202016-03-10 07:49:08 -0800321 *outColorType = kRGBA_F16_SkColorType;
raftias7c602de2016-10-13 10:45:44 -0700322 *outColorSpace = as_CSB(colorSpace)->makeLinearGamma();
brianosmand93c1202016-03-10 07:49:08 -0800323 return true;
324 }
brianosman4562f6e2016-09-19 14:42:04 -0700325 if (commands[0].equals("srgb")) {
bsalomon33069252016-09-28 08:49:53 -0700326 *outColorType = kRGBA_8888_SkColorType;
brianosman4562f6e2016-09-19 14:42:04 -0700327 *outColorSpace = colorSpace;
brianosmand93c1202016-03-10 07:49:08 -0800328 return true;
329 }
330 return false;
331}
kkinnunen3e980c32015-12-23 01:33:00 -0800332
333SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
334 const SkTArray<SkString>& vias,
335 const SkString& options) {
336 // Defaults for GPU backend.
337 bool seenAPI = false;
bsalomon85b4b532016-04-05 11:06:27 -0700338 SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNativeGL_ContextType;
kkinnunen3e980c32015-12-23 01:33:00 -0800339 bool seenUseNVPR = false;
340 bool useNVPR = false;
csmartdaltone0d36292016-07-29 08:14:20 -0700341 bool seenUseInstanced = false;
342 bool useInstanced = false;
kkinnunen3e980c32015-12-23 01:33:00 -0800343 bool seenUseDIText =false;
344 bool useDIText = false;
345 bool seenSamples = false;
346 int samples = 0;
brianosmand93c1202016-03-10 07:49:08 -0800347 bool seenColor = false;
bsalomon33069252016-09-28 08:49:53 -0700348 SkColorType colorType = kRGBA_8888_SkColorType;
brianosmanb109b8c2016-06-16 13:03:24 -0700349 sk_sp<SkColorSpace> colorSpace = nullptr;
kkinnunen3e980c32015-12-23 01:33:00 -0800350
351 SkTArray<SkString> optionParts;
352 SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts);
353 for (int i = 0; i < optionParts.count(); ++i) {
354 SkTArray<SkString> keyValueParts;
355 SkStrSplit(optionParts[i].c_str(), "=", kStrict_SkStrSplitMode, &keyValueParts);
356 if (keyValueParts.count() != 2) {
357 return nullptr;
358 }
359 const SkString& key = keyValueParts[0];
360 const SkString& value = keyValueParts[1];
361 bool valueOk = false;
362 if (key.equals("api") && !seenAPI) {
363 valueOk = parse_option_gpu_api(value, &contextType);
364 seenAPI = true;
365 } else if (key.equals("nvpr") && !seenUseNVPR) {
366 valueOk = parse_option_bool(value, &useNVPR);
367 seenUseNVPR = true;
csmartdaltone0d36292016-07-29 08:14:20 -0700368 } else if (key.equals("inst") && !seenUseInstanced) {
369 valueOk = parse_option_bool(value, &useInstanced);
370 seenUseInstanced = true;
kkinnunen3e980c32015-12-23 01:33:00 -0800371 } else if (key.equals("dit") && !seenUseDIText) {
372 valueOk = parse_option_bool(value, &useDIText);
373 seenUseDIText = true;
374 } else if (key.equals("samples") && !seenSamples) {
375 valueOk = parse_option_int(value, &samples);
376 seenSamples = true;
brianosmand93c1202016-03-10 07:49:08 -0800377 } else if (key.equals("color") && !seenColor) {
brianosmanb109b8c2016-06-16 13:03:24 -0700378 valueOk = parse_option_gpu_color(value, &colorType, &colorSpace);
brianosmand93c1202016-03-10 07:49:08 -0800379 seenColor = true;
kkinnunen3e980c32015-12-23 01:33:00 -0800380 }
381 if (!valueOk) {
382 return nullptr;
383 }
384 }
csmartdaltone0d36292016-07-29 08:14:20 -0700385 return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useInstanced, useDIText,
386 samples, colorType, colorSpace);
kkinnunen3e980c32015-12-23 01:33:00 -0800387}
388#endif
389
390void ParseConfigs(const SkCommandLineFlags::StringArray& configs,
391 SkCommandLineConfigArray* outResult) {
392 outResult->reset();
393 for (int i = 0; i < configs.count(); ++i) {
394 SkString extendedBackend;
395 SkString extendedOptions;
396 SkString simpleBackend;
397 SkTArray<SkString> vias;
398
399 SkString tag(configs[i]);
400 SkTArray<SkString> parts;
bsalomon808ecbb2016-09-28 12:40:22 -0700401 SkStrSplit(tag.c_str(), "[", kStrict_SkStrSplitMode, &parts);
kkinnunen3e980c32015-12-23 01:33:00 -0800402 if (parts.count() == 2) {
403 SkTArray<SkString> parts2;
bsalomon808ecbb2016-09-28 12:40:22 -0700404 SkStrSplit(parts[1].c_str(), "]", kStrict_SkStrSplitMode, &parts2);
kkinnunen3e980c32015-12-23 01:33:00 -0800405 if (parts2.count() == 2 && parts2[1].isEmpty()) {
406 SkStrSplit(parts[0].c_str(), "-", kStrict_SkStrSplitMode, &vias);
407 if (vias.count()) {
408 extendedBackend = vias[vias.count() - 1];
409 vias.pop_back();
410 } else {
411 extendedBackend = parts[0];
412 }
413 extendedOptions = parts2[0];
bsalomon808ecbb2016-09-28 12:40:22 -0700414 simpleBackend.printf("%s[%s]", extendedBackend.c_str(), extendedOptions.c_str());
kkinnunen3e980c32015-12-23 01:33:00 -0800415 }
416 }
417
418 if (extendedBackend.isEmpty()) {
419 simpleBackend = tag;
420 SkStrSplit(tag.c_str(), "-", kStrict_SkStrSplitMode, &vias);
421 if (vias.count()) {
422 simpleBackend = vias[vias.count() - 1];
423 vias.pop_back();
424 }
kkinnunen3e980c32015-12-23 01:33:00 -0800425 for (auto& predefinedConfig : gPredefinedConfigs) {
426 if (simpleBackend.equals(predefinedConfig.predefinedConfig)) {
427 extendedBackend = predefinedConfig.backend;
428 extendedOptions = predefinedConfig.options;
429 break;
430 }
431 }
432 }
433 SkCommandLineConfig* parsedConfig = nullptr;
434#if SK_SUPPORT_GPU
435 if (extendedBackend.equals("gpu")) {
436 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOptions);
437 }
438#endif
439 if (!parsedConfig) {
440 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias);
441 }
442 outResult->emplace_back(parsedConfig);
443 }
444}