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

Unified Diff: bench/ImageCacheBench.cpp

Issue 483493003: expose generalized imagecache key (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove more dead code Created 6 years, 4 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 | « no previous file | gyp/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/ImageCacheBench.cpp
diff --git a/bench/ImageCacheBench.cpp b/bench/ImageCacheBench.cpp
index e65d1fc3e860d86f44175b8b1d3fd34817456c87..07f332baa22d5cb5e923ac625ce086a9e0c158fc 100644
--- a/bench/ImageCacheBench.cpp
+++ b/bench/ImageCacheBench.cpp
@@ -8,6 +8,19 @@
#include "Benchmark.h"
#include "SkScaledImageCache.h"
+namespace {
+static void* gGlobalAddress;
+class TestKey : public SkScaledImageCache::Key {
+public:
+ void* fPtr;
+ intptr_t fValue;
+
+ TestKey(intptr_t value) : fPtr(&gGlobalAddress), fValue(value) {
+ this->init(sizeof(fPtr) + sizeof(fValue));
+ }
+};
+}
+
class ImageCacheBench : public Benchmark {
SkScaledImageCache fCache;
SkBitmap fBM;
@@ -22,12 +35,11 @@ public:
}
void populateCache() {
- SkScalar scale = 1;
for (int i = 0; i < CACHE_COUNT; ++i) {
+ TestKey key(i);
SkBitmap tmp;
tmp.allocN32Pixels(1, 1);
- fCache.unlock(fCache.addAndLock(fBM, scale, scale, tmp));
- scale += 1;
+ fCache.unlock(fCache.addAndLock(key, tmp));
}
}
@@ -41,10 +53,12 @@ protected:
this->populateCache();
}
+ TestKey key(-1);
SkBitmap tmp;
// search for a miss (-1 scale)
for (int i = 0; i < loops; ++i) {
- (void)fCache.findAndLock(fBM, -1, -1, &tmp);
+ SkDEBUGCODE(SkScaledImageCache::ID* id =) fCache.findAndLock(key, &tmp);
+ SkASSERT(NULL == id);
}
}
« no previous file with comments | « no previous file | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698