/** * @param A list of directories or a skp files. * @returns an alphabetical list of skp files. */ static void process_input_files( const SkCommandLineFlags::StringArray& inputs, SkTArray<SkString>* files) { for (int i = 0; i < inputs.count(); i ++) { const char* input = inputs[i]; if (sk_isdir(input)) { SkOSFile::Iter iter(input, SKP_FILE_EXTENSION); SkString inputFilename; while (iter.next(&inputFilename)) { if (!SkCommandLineFlags::ShouldSkip( FLAGS_match, inputFilename.c_str())) { files->push_back( SkOSPath::Join(input, inputFilename.c_str())); } } } else { if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, input)) { files->push_back(SkString(input)); } } } if (files->count() > 0) { SkTQSort<SkString>(files->begin(), files->end() - 1); } }
bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* output) { SkASSERT(output); static const char* const exts[] = { "bmp", "gif", "jpg", "jpeg", "png", "webp", "ktx", "astc", "wbmp", "ico", "BMP", "GIF", "JPG", "JPEG", "PNG", "WEBP", "KTX", "ASTC", "WBMP", "ICO", #ifdef SK_CODEC_DECODES_RAW "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw", "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW", #endif }; for (int i = 0; i < images.count(); ++i) { const char* flag = images[i]; if (!sk_exists(flag)) { SkDebugf("%s does not exist!\n", flag); return false; } if (sk_isdir(flag)) { // If the value passed in is a directory, add all the images bool foundAnImage = false; for (const char* ext : exts) { SkOSFile::Iter it(flag, ext); SkString file; while (it.next(&file)) { foundAnImage = true; output->push_back() = SkOSPath::Join(flag, file.c_str()); } } if (!foundAnImage) { SkDebugf("No supported images found in %s!\n", flag); return false; } } else { // Also add the value if it is a single image output->push_back() = flag; } } return true; }
void ParseConfigs(const SkCommandLineFlags::StringArray& configs, SkCommandLineConfigArray* outResult) { outResult->reset(); for (int i = 0; i < configs.count(); ++i) { SkString extendedBackend; SkString extendedOptions; SkString simpleBackend; SkTArray<SkString> vias; SkString tag(configs[i]); SkTArray<SkString> parts; SkStrSplit(tag.c_str(), "(", kStrict_SkStrSplitMode, &parts); if (parts.count() == 2) { SkTArray<SkString> parts2; SkStrSplit(parts[1].c_str(), ")", kStrict_SkStrSplitMode, &parts2); if (parts2.count() == 2 && parts2[1].isEmpty()) { SkStrSplit(parts[0].c_str(), "-", kStrict_SkStrSplitMode, &vias); if (vias.count()) { extendedBackend = vias[vias.count() - 1]; vias.pop_back(); } else { extendedBackend = parts[0]; } extendedOptions = parts2[0]; simpleBackend.printf("%s(%s)", extendedBackend.c_str(), extendedOptions.c_str()); } } if (extendedBackend.isEmpty()) { simpleBackend = tag; SkStrSplit(tag.c_str(), "-", kStrict_SkStrSplitMode, &vias); if (vias.count()) { simpleBackend = vias[vias.count() - 1]; vias.pop_back(); } // Note: no #if SK_ANGLE: this is a special rule in the via-tag grammar. if (vias.count() && simpleBackend.equals("gl") && vias[vias.count() - 1].equals("angle")) { simpleBackend = "angle-gl"; vias.pop_back(); } for (auto& predefinedConfig : gPredefinedConfigs) { if (simpleBackend.equals(predefinedConfig.predefinedConfig)) { extendedBackend = predefinedConfig.backend; extendedOptions = predefinedConfig.options; break; } } } SkCommandLineConfig* parsedConfig = nullptr; #if SK_SUPPORT_GPU if (extendedBackend.equals("gpu")) { parsedConfig = parse_command_line_config_gpu(tag, vias, extendedOptions); } #endif if (!parsedConfig) { parsedConfig = new SkCommandLineConfig(tag, simpleBackend, vias); } outResult->emplace_back(parsedConfig); } }