Index: src/core/SkRemote.cpp |
diff --git a/src/core/SkRemote.cpp b/src/core/SkRemote.cpp |
index 1e86044a544a42aae14ed8cbb287ba9b27b9cf6d..3966aaccc0318afba694f8775f00fdb6617d4eb4 100644 |
--- a/src/core/SkRemote.cpp |
+++ b/src/core/SkRemote.cpp |
@@ -35,6 +35,14 @@ namespace SkRemote { |
&& a.fDither == b.fDither; |
} |
+ // Misc carries 10 bytes of data in a 12 byte struct, so we need a custom hash. |
+ static_assert(sizeof(Misc) > offsetof(Misc, fDither) + sizeof(Misc().fDither), ""); |
+ struct MiscHash { |
+ uint32_t operator()(const Misc& misc) { |
+ return SkChecksum::Murmur3(&misc, offsetof(Misc, fDither) + sizeof(Misc().fDither)); |
+ } |
+ }; |
+ |
Stroke Stroke::CreateFrom(const SkPaint& paint) { |
Stroke stroke = { |
paint.getStrokeWidth(), |
@@ -59,6 +67,9 @@ namespace SkRemote { |
&& a.fJoin == b.fJoin; |
} |
+ // The default SkGoodHash works fine for Stroke, as it's dense. |
+ static_assert(sizeof(Stroke) == offsetof(Stroke, fJoin) + sizeof(Stroke().fJoin), ""); |
+ |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // |
class LookupScope { |
@@ -162,10 +173,10 @@ namespace SkRemote { |
return always_cache_helper(stroke, &fStroke, &fNextStroke, id); |
} |
- SkTHashMap<SkMatrix, ID> fMatrix; |
- SkTHashMap<Misc, ID> fMisc; |
- SkTHashMap<SkPath, ID> fPath; |
- SkTHashMap<Stroke, ID> fStroke; |
+ SkTHashMap<SkMatrix, ID> fMatrix; |
+ SkTHashMap<Misc, ID, MiscHash> fMisc; |
+ SkTHashMap<SkPath, ID> fPath; |
+ SkTHashMap<Stroke, ID> fStroke; |
ID fNextMatrix, |
fNextMisc, |
fNextPath, |