29static DEFINE_string2(skps,
s,
"skps",
"A path to a directory of skps or a single skp.");
32 "Indicates if we want to test that the images decode successfully.");
34 "Indicates if we want to write out supported/decoded images.");
36 "Indicates if we want to write out unsupported/failed to decode images.");
38 "Dump SKP and count of unknown images to the specified JSON file. Will not be "
39 "written anywhere if empty.");
56 void sniff(
const void* ptr,
size_t len) {
61 if (
gSeen.contains(digest)) {
76 switch (codec->getEncodedFormat()) {
91 auto writeImage = [&] (
const char*
name,
int num) {
101 if (FLAGS_testDecode) {
114 if (FLAGS_writeFailedImages) {
122 if (FLAGS_writeImages) {
136 ((
Sniffer*)ctx)->sniff(data, size);
143int main(
int argc,
char** argv) {
145 "Usage: get_images_from_skps -s <dir of skps> -o <dir for output images> --testDecode "
146 "-j <output JSON path> --writeImages, --writeFailedImages\n");
149 const char* inputs = FLAGS_skps[0];
188 unsigned int totalFailures = 0,
189 totalUnsupported = 0;
197 SkDebugf(
"%s %u\n", failure.first.c_str(), failure.second);
198 totalFailures += failure.second;
199 writer.
appendU32(failure.first.c_str(), failure.second);
203 writer.
appendU32(
"totalFailures", totalFailures);
209 SkDebugf(
"%s %u\n", unsupported.first.c_str(), unsupported.second);
210 totalUnsupported += unsupported.second;
211 writer.
appendHexU32(unsupported.first.c_str(), unsupported.second);
215 writer.
appendU32(
"totalUnsupported", totalUnsupported);
219 SkDebugf(
"%d known, %u failures, %u unsupported\n",
220 gKnown, totalFailures, totalUnsupported);
225 if (totalFailures > 0 || totalUnsupported > 0) {
226 if (!FLAGS_failuresJsonPath.isEmpty()) {
227 SkDebugf(
"Writing failures to %s\n", FLAGS_failuresJsonPath[0]);
230 stream.writeStream(jsonStream.get(), jsonStream->getLength());
static SkMD5::Digest md5(const SkBitmap &bm)
#define DEFINE_bool(name, defaultValue, helpString)
#define DEFINE_string2(name, shortName, defaultValue, helpString)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
bool sk_isdir(const char *path)
static void Parse(int argc, const char *const *argv)
static void SetUsage(const char *usage)
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
std::unique_ptr< SkStreamAsset > detachAsStream()
void appendS32(int32_t value)
void appendU32(uint32_t value)
void beginObject(const char *name=nullptr, bool multiline=true)
void appendHexU32(uint32_t value)
SK_SPI bool next(SkString *name, bool getDir=false)
static SkString Join(const char *rootPath, const char *relativePath)
static sk_sp< SkPicture > MakeFromStream(SkStream *stream, const SkDeserialProcs *procs=nullptr)
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
static bool get_images_from_file(const SkString &file)
static std::map< std::string, unsigned int > gSkpToUnsupportedCount
static std::map< std::string, unsigned int > gSkpToUnknownCount
static THashSet< SkMD5::Digest > gSeen
static const char * gOutputDir
SkDeserialImageProc fImageProc
SkImageInfo makeColorType(SkColorType newColorType) const
Sniffer(std::string name)
void sniff(const void *ptr, size_t len)