Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
CommonFlagsImages.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3
4#include "src/core/SkOSFile.h"
7
8using namespace skia_private;
9
10namespace CommonFlags {
12 SkASSERT(output);
13
14 static const char* const exts[] = {
15 "bmp",
16 "gif",
17 "jpg",
18 "jpeg",
19 "png",
20 "webp",
21 "ktx",
22 "astc",
23 "wbmp",
24 "ico",
25#if !defined(SK_BUILD_FOR_WIN)
26 "BMP",
27 "GIF",
28 "JPG",
29 "JPEG",
30 "PNG",
31 "WEBP",
32 "KTX",
33 "ASTC",
34 "WBMP",
35 "ICO",
36#endif
37#ifdef SK_HAS_HEIF_LIBRARY
38 "heic",
39#if !defined(SK_BUILD_FOR_WIN)
40 "HEIC",
41#endif
42#endif
43#ifdef SK_CODEC_DECODES_RAW
44 "arw",
45 "cr2",
46 "dng",
47 "nef",
48 "nrw",
49 "orf",
50 "raf",
51 "rw2",
52 "pef",
53 "srw",
54#if !defined(SK_BUILD_FOR_WIN)
55 "ARW",
56 "CR2",
57 "DNG",
58 "NEF",
59 "NRW",
60 "ORF",
61 "RAF",
62 "RW2",
63 "PEF",
64 "SRW",
65#endif
66#endif
67 };
68
69 for (int i = 0; i < images.size(); ++i) {
70 const char* flag = images[i];
71 if (!sk_exists(flag)) {
72 SkDebugf("%s does not exist!\n", flag);
73 return false;
74 }
75
76 if (sk_isdir(flag)) {
77 // If the value passed in is a directory, add all the images
78 bool foundAnImage = false;
79 for (const char* ext : exts) {
80 SkOSFile::Iter it(flag, ext);
81 SkString file;
82 while (it.next(&file)) {
83 foundAnImage = true;
84 output->push_back() = SkOSPath::Join(flag, file.c_str());
85 }
86 }
87 if (!foundAnImage) {
88 SkDebugf("No supported images found in %s!\n", flag);
89 return false;
90 }
91 } else {
92 // Also add the value if it is a single image
93 output->push_back() = flag;
94 }
95 }
96 return true;
97}
98
99} // namespace CommonFlags
#define SkASSERT(cond)
Definition SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
bool sk_exists(const char *path, SkFILE_Flags=(SkFILE_Flags) 0)
bool sk_isdir(const char *path)
SK_SPI bool next(SkString *name, bool getDir=false)
static SkString Join(const char *rootPath, const char *relativePath)
Definition SkOSPath.cpp:14
FlutterSemanticsFlag flag
std::array< MockImage, 3 > images
bool CollectImages(const CommandLineFlags::StringArray &dir, skia_private::TArray< SkString > *output)