aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-03-24 17:00:17 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-24 21:40:33 +0000
commit9f4b0ae91e1875831cc11f0629b5db998ad85438 (patch)
treee7a969b5942bd5fac625403202f1f258d07a5bbf /tests
parent37b1d84436ccfbeafc2b321e469c462a2cfd4765 (diff)
simplify api to bitmapcache
Force all Find callers to make a bitmpacachedesc, which now has more rigid validation. Goal is to ensure we never make two desc (which turn into keys) that look different but represent the same image/transformation. BUG=skia: Change-Id: I8571837ee4754a69acc99e949bee9a465fa25f2b Reviewed-on: https://skia-review.googlesource.com/10114 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ImageTest.cpp7
-rw-r--r--tests/SkResourceCacheTest.cpp10
2 files changed, 9 insertions, 8 deletions
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index ab2215b17b..ba49000d9a 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -411,6 +411,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(c, reporter, ctxInfo) {
SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
sk_sp<SkImage> image(create_gpu_image(ctxInfo.grContext()));
const uint32_t uniqueID = image->uniqueID();
+ const auto desc = SkBitmapCacheDesc::Make(image.get());
auto surface(SkSurface::MakeRaster(info));
@@ -418,13 +419,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(c, reporter, ctxInfo) {
{
SkBitmap cachedBitmap;
- REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap));
+ REPORTER_ASSERT(reporter, !SkBitmapCache::Find(desc, &cachedBitmap));
}
surface->getCanvas()->drawImage(image, 0, 0);
{
SkBitmap cachedBitmap;
- if (SkBitmapCache::Find(uniqueID, &cachedBitmap)) {
+ if (SkBitmapCache::Find(desc, &cachedBitmap)) {
REPORTER_ASSERT(reporter, cachedBitmap.getGenerationID() == uniqueID);
REPORTER_ASSERT(reporter, cachedBitmap.isImmutable());
REPORTER_ASSERT(reporter, cachedBitmap.getPixels());
@@ -438,7 +439,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(c, reporter, ctxInfo) {
image.reset(nullptr);
{
SkBitmap cachedBitmap;
- REPORTER_ASSERT(reporter, !SkBitmapCache::Find(uniqueID, &cachedBitmap));
+ REPORTER_ASSERT(reporter, !SkBitmapCache::Find(desc, &cachedBitmap));
}
}
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp
index 542d80efff..b260d89503 100644
--- a/tests/SkResourceCacheTest.cpp
+++ b/tests/SkResourceCacheTest.cpp
@@ -89,8 +89,8 @@ static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* ca
}
for (int i = 0; i < N; ++i) {
- const SkMipMap* mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src[i]),
- colorMode, cache);
+ const auto desc = SkBitmapCacheDesc::Make(src[i]);
+ const SkMipMap* mipmap = SkMipMapCache::FindAndRef(desc, colorMode, cache);
if (cache) {
// if cache is null, we're working on the global cache, and other threads might purge
// it, making this check fragile.
@@ -100,7 +100,7 @@ static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* ca
src[i].reset(); // delete the underlying pixelref, which *should* remove us from the cache
- mipmap = SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(src[i]), colorMode, cache);
+ mipmap = SkMipMapCache::FindAndRef(desc, colorMode, cache);
REPORTER_ASSERT(reporter, !mipmap);
}
}
@@ -156,14 +156,14 @@ static void test_discarded_image(skiatest::Reporter* reporter, const SkMatrix& t
canvas->concat(transform);
canvas->drawImage(image, 0, 0, &paint);
- auto imageId = image->uniqueID();
+ const auto desc = SkBitmapCacheDesc::Make(image.get());
// delete the image
image.reset(nullptr);
// all resources should have been purged
SkBitmap result;
- REPORTER_ASSERT(reporter, !SkBitmapCache::Find(imageId, &result));
+ REPORTER_ASSERT(reporter, !SkBitmapCache::Find(desc, &result));
}
}