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 #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 defined(SK_BUILD_FOR_WIN) |
20 #ifdef SK_BUILD_FOR_WIN | 20 " angle_d3d11_es2" |
21 " angle" | |
22 #endif | |
23 #endif | 21 #endif |
24 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 22 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
25 " hwui" | 23 " hwui" |
26 #endif | 24 #endif |
27 ; | 25 ; |
28 | 26 |
29 static const struct { | 27 static const struct { |
30 const char* predefinedConfig; | 28 const char* predefinedConfig; |
31 const char* backend; | 29 const char* backend; |
32 const char* options; | 30 const char* options; |
33 } gPredefinedConfigs[] ={ | 31 } gPredefinedConfigs[] ={ |
34 #if SK_SUPPORT_GPU | 32 #if SK_SUPPORT_GPU |
35 { "gpu", "gpu", "" }, | 33 { "gpu", "gpu", "" }, |
36 { "gl", "gpu", "api=gl" }, | 34 { "gl", "gpu", "api=gl" }, |
37 { "msaa4", "gpu", "samples=4" }, | 35 { "msaa4", "gpu", "samples=4" }, |
38 { "glmsaa4", "gpu", "api=gl,samples=4" }, | 36 { "glmsaa4", "gpu", "api=gl,samples=4" }, |
39 { "msaa16", "gpu", "samples=16" }, | 37 { "msaa16", "gpu", "samples=16" }, |
40 { "nvpr4", "gpu", "nvpr=true,samples=4" }, | 38 { "nvpr4", "gpu", "nvpr=true,samples=4" }, |
41 { "glnvpr4", "gpu", "api=gl,nvpr=true,samples=4" }, | 39 { "glnvpr4", "gpu", "api=gl,nvpr=true,samples=4" }, |
42 { "nvpr16", "gpu", "nvpr=true,samples=16" }, | 40 { "nvpr16", "gpu", "nvpr=true,samples=16" }, |
43 { "nvprdit4", "gpu", "nvpr=true,samples=4,dit=true" }, | 41 { "nvprdit4", "gpu", "nvpr=true,samples=4,dit=true" }, |
44 { "glnvprdit4", "gpu", "api=gl,nvpr=true,samples=4,dit=true" }, | 42 { "glnvprdit4", "gpu", "api=gl,nvpr=true,samples=4,dit=true" }, |
45 { "nvprdit16", "gpu", "nvpr=true,samples=16,dit=true" }, | 43 { "nvprdit16", "gpu", "nvpr=true,samples=16,dit=true" }, |
46 { "glinst", "gpu", "api=gl,inst=true" }, | 44 { "glinst", "gpu", "api=gl,inst=true" }, |
47 { "glinst4", "gpu", "api=gl,inst=true,samples=4" }, | 45 { "glinst4", "gpu", "api=gl,inst=true,samples=4" }, |
48 { "glinstdit4", "gpu", "api=gl,inst=true,samples=4,dit=true" }, | 46 { "glinstdit4", "gpu", "api=gl,inst=true,samples=4,dit=true" }, |
49 { "glinst16", "gpu", "api=gl,inst=true,samples=16" }, | 47 { "glinst16", "gpu", "api=gl,inst=true,samples=16" }, |
50 { "glinstdit16", "gpu", "api=gl,inst=true,samples=16,dit=true" }, | 48 { "glinstdit16", "gpu", "api=gl,inst=true,samples=16,dit=true" }, |
51 { "esinst", "gpu", "api=gles,inst=true" }, | 49 { "esinst", "gpu", "api=gles,inst=true" }, |
52 { "esinst4", "gpu", "api=gles,inst=true,samples=4" }, | 50 { "esinst4", "gpu", "api=gles,inst=true,samples=4" }, |
53 { "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" }, | 51 { "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" }, |
54 { "gpuf16", "gpu", "color=f16" }, | 52 { "gpuf16", "gpu", "color=f16" }, |
55 { "gpusrgb", "gpu", "color=srgb" }, | 53 { "gpusrgb", "gpu", "color=srgb" }, |
56 { "glsrgb", "gpu", "api=gl,color=srgb" }, | 54 { "glsrgb", "gpu", "api=gl,color=srgb" }, |
57 { "glwide", "gpu", "api=gl,color=f16_wide" }, | 55 { "glwide", "gpu", "api=gl,color=f16_wide" }, |
58 { "gpudft", "gpu", "dit=true" }, | 56 { "gpudft", "gpu", "dit=true" }, |
59 { "gpudebug", "gpu", "api=debug" }, | 57 { "gpudebug", "gpu", "api=debug" }, |
60 { "gpunull", "gpu", "api=null" }, | 58 { "gpunull", "gpu", "api=null" }, |
61 { "debug", "gpu", "api=debug" }, | 59 { "debug", "gpu", "api=debug" }, |
62 { "nullgpu", "gpu", "api=null" } | 60 { "nullgpu", "gpu", "api=null" }, |
63 #if SK_ANGLE | 61 { "angle_d3d11_es2", "gpu", "api=angle_d3d11_es2" }, |
64 #ifdef SK_BUILD_FOR_WIN | 62 { "angle_gl_es2", "gpu", "api=angle_gl_es2" }, |
65 ,{ "angle", "gpu", "api=angle" } | 63 { "commandbuffer", "gpu", "api=commandbuffer" } |
66 #endif | |
67 ,{ "angle-gl", "gpu", "api=angle-gl" } | |
68 #endif | |
69 ,{ "commandbuffer", "gpu", "api=commandbuffer" } | |
70 #if SK_MESA | 64 #if SK_MESA |
71 ,{ "mesa", "gpu", "api=mesa" } | 65 ,{ "mesa", "gpu", "api=mesa" } |
72 #endif | 66 #endif |
73 #ifdef SK_VULKAN | 67 #ifdef SK_VULKAN |
74 ,{ "vk", "gpu", "api=vulkan" } | 68 ,{ "vk", "gpu", "api=vulkan" } |
75 ,{ "vksrgb", "gpu", "api=vulkan,color=srgb" } | 69 ,{ "vksrgb", "gpu", "api=vulkan,color=srgb" } |
76 ,{ "vkwide", "gpu", "api=vulkan,color=f16_wide" } | 70 ,{ "vkwide", "gpu", "api=vulkan,color=f16_wide" } |
77 ,{ "vkmsaa4", "gpu", "api=vulkan,samples=4" } | 71 ,{ "vkmsaa4", "gpu", "api=vulkan,samples=4" } |
78 ,{ "vkmsaa16", "gpu", "api=vulkan,samples=16" } | 72 ,{ "vkmsaa16", "gpu", "api=vulkan,samples=16" } |
79 #endif | 73 #endif |
80 | 74 |
81 #else | 75 #else |
82 { "", "", "" } | 76 { "", "", "" } |
83 #endif | 77 #endif |
84 }; | 78 }; |
85 | 79 |
86 static const char configHelp[] = | 80 static const char configHelp[] = |
87 "Options: 565 8888 srgb f16 nonrendering null pdf pdfa skp pipe svg xps" | 81 "Options: 565 8888 srgb f16 nonrendering null pdf pdfa skp pipe svg xps" |
88 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | 82 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK |
(...skipping 18 matching lines...) Expand all Loading... | |
107 "\n" | 101 "\n" |
108 "gpu[api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int]\n" | 102 "gpu[api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int]\n" |
109 "\tapi\ttype: string\tdefault: native.\n" | 103 "\tapi\ttype: string\tdefault: native.\n" |
110 "\t Select graphics API to use with gpu backend.\n" | 104 "\t Select graphics API to use with gpu backend.\n" |
111 "\t Options:\n" | 105 "\t Options:\n" |
112 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n" | 106 "\t\tnative\t\t\tUse platform default OpenGL or OpenGL ES backend.\n" |
113 "\t\tgl \t\t\tUse OpenGL.\n" | 107 "\t\tgl \t\t\tUse OpenGL.\n" |
114 "\t\tgles \t\t\tUse OpenGL ES.\n" | 108 "\t\tgles \t\t\tUse OpenGL ES.\n" |
115 "\t\tdebug \t\t\tUse debug OpenGL.\n" | 109 "\t\tdebug \t\t\tUse debug OpenGL.\n" |
116 "\t\tnull \t\t\tUse null OpenGL.\n" | 110 "\t\tnull \t\t\tUse null OpenGL.\n" |
117 #if SK_ANGLE | 111 "\t\tangle_d3d9_es2\t\t\tUse OpenGL ES2 on the ANGLE Direct3D9 backend.\n" |
118 #ifdef SK_BUILD_FOR_WIN | 112 "\t\tangle_d3d11_es2\t\t\tUse OpenGL ES2 on the ANGLE Direct3D11 backend.\n" |
119 "\t\tangle\t\t\tUse ANGLE DirectX.\n" | 113 "\t\tangle_d3d11_es3\t\t\tUse OpenGL ES3 on the ANGLE Direct3D11 backend.\n" |
120 #endif | 114 "\t\tangle_gl_es2\t\t\tUse OpenGL ES2 on the ANGLE OpenGL backend.\n" |
121 "\t\tangle-gl\t\t\tUse ANGLE OpenGL.\n" | 115 "\t\tangle_gl_es3\t\t\tUse OpenGL ES3 on the ANGLE OpenGL backend.\n" |
122 #endif | |
123 "\t\tcommandbuffer\t\tUse command buffer.\n" | 116 "\t\tcommandbuffer\t\tUse command buffer.\n" |
124 #if SK_MESA | 117 #if SK_MESA |
125 "\t\tmesa\t\t\tUse MESA.\n" | 118 "\t\tmesa\t\t\tUse MESA.\n" |
126 #endif | 119 #endif |
127 #ifdef SK_VULKAN | 120 #ifdef SK_VULKAN |
128 "\t\tvulkan\t\t\tUse Vulkan.\n" | 121 "\t\tvulkan\t\t\tUse Vulkan.\n" |
129 #endif | 122 #endif |
130 "\tcolor\ttype: string\tdefault: 8888.\n" | 123 "\tcolor\ttype: string\tdefault: 8888.\n" |
131 "\t Select framebuffer color format.\n" | 124 "\t Select framebuffer color format.\n" |
132 "\t Options:\n" | 125 "\t Options:\n" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 return true; | 219 return true; |
227 } | 220 } |
228 if (value.equals("debug")) { | 221 if (value.equals("debug")) { |
229 *outContextType = GrContextFactory::kDebugGL_ContextType; | 222 *outContextType = GrContextFactory::kDebugGL_ContextType; |
230 return true; | 223 return true; |
231 } | 224 } |
232 if (value.equals("null")) { | 225 if (value.equals("null")) { |
233 *outContextType = GrContextFactory::kNullGL_ContextType; | 226 *outContextType = GrContextFactory::kNullGL_ContextType; |
234 return true; | 227 return true; |
235 } | 228 } |
236 #if SK_ANGLE | 229 if (value.equals("angle_d3d9_es2")) { |
237 #ifdef SK_BUILD_FOR_WIN | 230 *outContextType = GrContextFactory::kANGLE_D3D9_ES2_ContextType; |
238 if (value.equals("angle")) { | |
239 *outContextType = GrContextFactory::kANGLE_ContextType; | |
240 return true; | 231 return true; |
241 } | 232 } |
242 #endif | 233 if (value.equals("angle_d3d11_es2")) { |
243 if (value.equals("angle-gl")) { | 234 *outContextType = GrContextFactory::kANGLE_D3D11_ES2_ContextType; |
244 *outContextType = GrContextFactory::kANGLE_GL_ContextType; | |
245 return true; | 235 return true; |
246 } | 236 } |
247 #endif | 237 if (value.equals("angle_d3d11_es3")) { |
238 *outContextType = GrContextFactory::kANGLE_D3D11_ES3_ContextType; | |
239 return true; | |
240 } | |
241 if (value.equals("angle_gl_es2")) { | |
242 *outContextType = GrContextFactory::kANGLE_GL_ES2_ContextType; | |
243 return true; | |
244 } | |
245 if (value.equals("angle_gl_es3")) { | |
246 *outContextType = GrContextFactory::kANGLE_GL_ES3_ContextType; | |
247 return true; | |
248 } | |
Brian Osman
2016/09/29 14:58:22
nit: indentation
bsalomon
2016/09/29 16:48:10
Done.
| |
248 if (value.equals("commandbuffer")) { | 249 if (value.equals("commandbuffer")) { |
249 *outContextType = GrContextFactory::kCommandBuffer_ContextType; | 250 *outContextType = GrContextFactory::kCommandBuffer_ContextType; |
250 return true; | 251 return true; |
251 } | 252 } |
252 #if SK_MESA | 253 #if SK_MESA |
253 if (value.equals("mesa")) { | 254 if (value.equals("mesa")) { |
254 *outContextType = GrContextFactory::kMESA_ContextType; | 255 *outContextType = GrContextFactory::kMESA_ContextType; |
255 return true; | 256 return true; |
256 } | 257 } |
257 #endif | 258 #endif |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 } | 400 } |
400 } | 401 } |
401 | 402 |
402 if (extendedBackend.isEmpty()) { | 403 if (extendedBackend.isEmpty()) { |
403 simpleBackend = tag; | 404 simpleBackend = tag; |
404 SkStrSplit(tag.c_str(), "-", kStrict_SkStrSplitMode, &vias); | 405 SkStrSplit(tag.c_str(), "-", kStrict_SkStrSplitMode, &vias); |
405 if (vias.count()) { | 406 if (vias.count()) { |
406 simpleBackend = vias[vias.count() - 1]; | 407 simpleBackend = vias[vias.count() - 1]; |
407 vias.pop_back(); | 408 vias.pop_back(); |
408 } | 409 } |
409 // Note: no #if SK_ANGLE: this is a special rule in the via-tag gram mar. | |
410 if (vias.count() && simpleBackend.equals("gl") && | |
411 vias[vias.count() - 1].equals("angle")) { | |
412 simpleBackend = "angle-gl"; | |
413 vias.pop_back(); | |
414 } | |
415 | |
416 for (auto& predefinedConfig : gPredefinedConfigs) { | 410 for (auto& predefinedConfig : gPredefinedConfigs) { |
417 if (simpleBackend.equals(predefinedConfig.predefinedConfig)) { | 411 if (simpleBackend.equals(predefinedConfig.predefinedConfig)) { |
418 extendedBackend = predefinedConfig.backend; | 412 extendedBackend = predefinedConfig.backend; |
419 extendedOptions = predefinedConfig.options; | 413 extendedOptions = predefinedConfig.options; |
420 break; | 414 break; |
421 } | 415 } |
422 } | 416 } |
423 } | 417 } |
424 SkCommandLineConfig* parsedConfig = nullptr; | 418 SkCommandLineConfig* parsedConfig = nullptr; |
425 #if SK_SUPPORT_GPU | 419 #if SK_SUPPORT_GPU |
426 if (extendedBackend.equals("gpu")) { | 420 if (extendedBackend.equals("gpu")) { |
427 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons); | 421 parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOpti ons); |
428 } | 422 } |
429 #endif | 423 #endif |
430 if (!parsedConfig) { | 424 if (!parsedConfig) { |
431 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); | 425 parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); |
432 } | 426 } |
433 outResult->emplace_back(parsedConfig); | 427 outResult->emplace_back(parsedConfig); |
434 } | 428 } |
435 } | 429 } |
OLD | NEW |