Flutter Engine
The Flutter Engine
Functions
SkChecksum Namespace Reference

Functions

uint32_t Hash32 (const void *data, size_t bytes, uint32_t seed)
 
uint64_t Hash64 (const void *data, size_t bytes, uint64_t seed)
 
static uint32_t Mix (uint32_t hash)
 
static uint32_t CheapMix (uint32_t hash)
 

Detailed Description

Our hash functions are exposed as SK_SPI (e.g. SkParagraph)

Function Documentation

◆ CheapMix()

static uint32_t SkChecksum::CheapMix ( uint32_t  hash)
inlinestatic

uint32_t -> uint32_t hash, useful for when you're about to truncate this hash but you suspect its low bits aren't well mixed.

This version is 2-lines cheaper than Mix, but seems to be sufficient for the font cache.

Definition at line 45 of file SkChecksum.h.

45 {
46 hash ^= hash >> 16;
47 hash *= 0x85ebca6b;
48 hash ^= hash >> 16;
49 return hash;
50 }
static uint32_t hash(const SkShaderBase::GradientInfo &v)

◆ Hash32()

uint32_t SK_SPI SkChecksum::Hash32 ( const void *  data,
size_t  bytes,
uint32_t  seed = 0 
)

This is a fast, high-quality 32-bit hash. We make no guarantees about this remaining stable over time, or being consistent across devices.

For now, this is a 64-bit wyhash, truncated to 32-bits. See: https://github.com/wangyi-fudan/wyhash

Definition at line 113 of file SkChecksum.cpp.

113 {
114 return static_cast<uint32_t>(wyhash(data, bytes, seed, _wyp));
115}
static const uint64_t _wyp[4]
Definition: SkChecksum.cpp:108
static uint64_t wyhash(const void *key, size_t len, uint64_t seed, const uint64_t *secret)
Definition: SkChecksum.cpp:67
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ Hash64()

uint64_t SK_SPI SkChecksum::Hash64 ( const void *  data,
size_t  bytes,
uint64_t  seed = 0 
)

This is a fast, high-quality 64-bit hash. We make no guarantees about this remaining stable over time, or being consistent across devices.

For now, this is a 64-bit wyhash. See: https://github.com/wangyi-fudan/wyhash

Definition at line 117 of file SkChecksum.cpp.

117 {
118 return wyhash(data, bytes, seed, _wyp);
119}

◆ Mix()

static uint32_t SkChecksum::Mix ( uint32_t  hash)
inlinestatic

uint32_t -> uint32_t hash, useful for when you're about to truncate this hash but you suspect its low bits aren't well mixed.

This is the Murmur3 finalizer.

Definition at line 30 of file SkChecksum.h.

30 {
31 hash ^= hash >> 16;
32 hash *= 0x85ebca6b;
33 hash ^= hash >> 13;
34 hash *= 0xc2b2ae35;
35 hash ^= hash >> 16;
36 return hash;
37 }