Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: src/core/SkResourceCache.cpp

Issue 668223002: SkResourceCache::Key namespace support. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unused SkPictureShader headers Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkResourceCache.h ('k') | tests/ImageCacheTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkResourceCache.cpp
diff --git a/src/core/SkResourceCache.cpp b/src/core/SkResourceCache.cpp
index f7a810ec87a05027af859bb071f00a2be86324b8..1eb53cd8c6b4b504cdb7fb4674f9c7d4666cbb1c 100644
--- a/src/core/SkResourceCache.cpp
+++ b/src/core/SkResourceCache.cpp
@@ -10,6 +10,8 @@
#include "SkMipMap.h"
#include "SkPixelRef.h"
+#include <stddef.h>
+
// This can be defined by the caller's build system
//#define SK_USE_DISCARDABLE_SCALEDIMAGECACHE
@@ -21,12 +23,22 @@
#define SK_DEFAULT_IMAGE_CACHE_LIMIT (2 * 1024 * 1024)
#endif
-void SkResourceCache::Key::init(size_t length) {
+void SkResourceCache::Key::init(void* nameSpace, size_t length) {
SkASSERT(SkAlign4(length) == length);
- // 2 is fCount32 and fHash
- fCount32 = SkToS32(2 + (length >> 2));
- // skip both of our fields whe computing the murmur
- fHash = SkChecksum::Murmur3(this->as32() + 2, (fCount32 - 2) << 2);
+
+ // fCount32 and fHash are not hashed
+ static const int kUnhashedLocal32s = 2;
+ static const int kLocal32s = kUnhashedLocal32s + (sizeof(fNamespace) >> 2);
+
+ SK_COMPILE_ASSERT(sizeof(Key) == (kLocal32s << 2), unaccounted_key_locals);
+ SK_COMPILE_ASSERT(sizeof(Key) == offsetof(Key, fNamespace) + sizeof(fNamespace),
+ namespace_field_must_be_last);
+
+ fCount32 = SkToS32(kLocal32s + (length >> 2));
+ fNamespace = nameSpace;
+ // skip unhashed fields when computing the murmur
+ fHash = SkChecksum::Murmur3(this->as32() + kUnhashedLocal32s,
+ (fCount32 - kUnhashedLocal32s) << 2);
}
#include "SkTDynamicHash.h"
« no previous file with comments | « src/core/SkResourceCache.h ('k') | tests/ImageCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698