Index: bench/ImageCacheBench.cpp |
diff --git a/bench/ImageCacheBench.cpp b/bench/ImageCacheBench.cpp |
index 07f332baa22d5cb5e923ac625ce086a9e0c158fc..f4d88da0424d75a0c11f9f9495ee63f8dbbde59d 100644 |
--- a/bench/ImageCacheBench.cpp |
+++ b/bench/ImageCacheBench.cpp |
@@ -19,6 +19,15 @@ public: |
this->init(sizeof(fPtr) + sizeof(fValue)); |
} |
}; |
+struct TestRec : public SkScaledImageCache::Rec { |
+ TestKey fKey; |
+ intptr_t fValue; |
+ |
+ TestRec(const TestKey& key, intptr_t value) : fKey(key), fValue(value) {} |
+ |
+ virtual const Key& getKey() const SK_OVERRIDE { return fKey; } |
+ virtual size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + sizeof(fValue); } |
+}; |
} |
class ImageCacheBench : public Benchmark { |
@@ -36,10 +45,7 @@ public: |
void populateCache() { |
for (int i = 0; i < CACHE_COUNT; ++i) { |
- TestKey key(i); |
- SkBitmap tmp; |
- tmp.allocN32Pixels(1, 1); |
- fCache.unlock(fCache.addAndLock(key, tmp)); |
+ fCache.unlock(fCache.addAndLock(SkNEW_ARGS(TestRec, (TestKey(i), i)))); |
} |
} |
@@ -54,10 +60,9 @@ protected: |
} |
TestKey key(-1); |
- SkBitmap tmp; |
- // search for a miss (-1 scale) |
+ // search for a miss (-1) |
for (int i = 0; i < loops; ++i) { |
- SkDEBUGCODE(SkScaledImageCache::ID* id =) fCache.findAndLock(key, &tmp); |
+ SkDEBUGCODE(SkScaledImageCache::ID id =) fCache.findAndLock(key); |
SkASSERT(NULL == id); |
} |
} |