19#define LOG_MEMORY_CACHE 0
26 static constexpr size_t kMaxLength = 60;
27 static constexpr char kTail[] =
"...";
28 static const size_t kTailLen = strlen(kTail);
29 bool overlength = encodeLength > kMaxLength;
41 if (
result == fMap.end()) {
52 result->second.fHitCount++;
53 return result->second.fData;
62 fMap[Key(
key)] = Value(data, description);
70 for (
auto it = fMap.begin(); it != fMap.end(); ++it) {
72 size_t bytesToHash = it->first.fKey->size();
80 SkASSERT(bytesToHash >=
sizeof(vkKeyType));
81 bytesToHash -=
sizeof(vkKeyType);
82 memcpy(&vkKeyType, it->first.fKey->bytes() + bytesToHash,
sizeof(vkKeyType));
88 hash.write(it->first.fKey->bytes(), bytesToHash);
94 const SkData* data = it->second.fData.get();
95 const SkString& description = it->second.fDescription;
119 const char* ext =
"key";
122 file.write(description.
c_str(), description.
size());
static SkMD5::Digest md5(const SkBitmap &bm)
static const int kGrShaderTypeCount
static SkString data_to_str(const SkData &data)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static uint32_t hash(const SkShaderBase::GradientInfo &v)
SK_API SkString static SkString SkStringPrintf()
@ kShader_PersistentCacheKeyType
const char * data() const
void append(const char text[])
const char * c_str() const
void writeShadersToDisk(const char *path, GrBackendApi backend)
void store(const SkData &key, const SkData &data, const SkString &description) override
sk_sp< SkData > load(const SkData &key) override
bool UnpackCachedShaders(SkReadBuffer *reader, std::string shaders[], SkSL::Program::Interface interfaces[], int numInterfaces, ShaderMetadata *meta)
SkFourByteTag GetType(SkReadBuffer *reader)
static size_t EncodedSize(size_t srcDataLength)
static size_t Encode(const void *src, size_t length, void *dst, const char *encode=nullptr)
SkString toLowercaseHexString() const