Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | List of all members
Sniffer Struct Reference

Public Member Functions

 Sniffer (std::string name)
 
void sniff (const void *ptr, size_t len)
 

Public Attributes

std::string skpName
 

Detailed Description

Definition at line 48 of file get_images_from_skps.cpp.

Constructor & Destructor Documentation

◆ Sniffer()

Sniffer::Sniffer ( std::string  name)
inline

Definition at line 52 of file get_images_from_skps.cpp.

52 {
53 skpName = name;
54 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
std::string skpName

Member Function Documentation

◆ sniff()

void Sniffer::sniff ( const void *  ptr,
size_t  len 
)
inline

Definition at line 56 of file get_images_from_skps.cpp.

56 {
57 SkMD5 md5;
58 md5.write(ptr, len);
59 SkMD5::Digest digest = md5.finish();
60
61 if (gSeen.contains(digest)) {
62 return;
63 }
64 gSeen.add(digest);
65
67 std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(data);
68 if (!codec) {
69 // FIXME: This code is currently unreachable because we create an empty generator when
70 // we fail to create a codec.
71 SkDebugf("Codec could not be created for %s\n", skpName.c_str());
73 return;
74 }
76 switch (codec->getEncodedFormat()) {
77 case SkEncodedImageFormat::kBMP: ext = "bmp"; break;
78 case SkEncodedImageFormat::kGIF: ext = "gif"; break;
79 case SkEncodedImageFormat::kICO: ext = "ico"; break;
80 case SkEncodedImageFormat::kJPEG: ext = "jpg"; break;
81 case SkEncodedImageFormat::kPNG: ext = "png"; break;
82 case SkEncodedImageFormat::kDNG: ext = "dng"; break;
83 case SkEncodedImageFormat::kWBMP: ext = "wbmp"; break;
84 case SkEncodedImageFormat::kWEBP: ext = "webp"; break;
85 default:
86 // This should be unreachable because we cannot create a codec if we do not know
87 // the image type.
88 SkASSERT(false);
89 }
90
91 auto writeImage = [&] (const char* name, int num) {
93 path.appendf("%s/%s%d.%s", gOutputDir, name, num, ext.c_str());
94
95 SkFILEWStream file(path.c_str());
96 file.write(ptr, len);
97
98 SkDebugf("%s\n", path.c_str());
99 };
100
101 if (FLAGS_testDecode) {
103 SkImageInfo info = codec->getInfo().makeColorType(kN32_SkColorType);
104 bitmap.allocPixels(info);
105 const SkCodec::Result result = codec->getPixels(
106 info, bitmap.getPixels(), bitmap.rowBytes());
107 switch (result) {
111 break;
112 default:
113 SkDebugf("Decoding failed for %s\n", skpName.c_str());
114 if (FLAGS_writeFailedImages) {
115 writeImage("unknown", gSkpToUnknownCount[skpName]);
116 }
118 return;
119 }
120 }
121
122 if (FLAGS_writeImages) {
123 writeImage("", gKnown);
124 }
125
126 gKnown++;
127 }
static SkMD5::Digest md5(const SkBitmap &bm)
Definition: CodecTest.cpp:77
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static std::unique_ptr< SkCodec > MakeFromData(sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
Definition: SkCodec.cpp:241
Result
Definition: SkCodec.h:76
@ kIncompleteInput
Definition: SkCodec.h:84
@ kSuccess
Definition: SkCodec.h:80
@ kErrorInInput
Definition: SkCodec.h:91
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
Definition: SkData.h:116
Definition: SkMD5.h:19
GAsyncResult * result
static std::map< std::string, unsigned int > gSkpToUnknownCount
static int gKnown
static THashSet< SkMD5::Digest > gSeen
static const char * gOutputDir
Definition: bitmap.py:1
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

Member Data Documentation

◆ skpName

std::string Sniffer::skpName

Definition at line 50 of file get_images_from_skps.cpp.


The documentation for this struct was generated from the following file: