Index: tests/ImageFilterCacheTest.cpp |
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp |
index c7b2170c0ff699c2dccf117cd90bb42cc0549eb8..938c04838610f59b0c0b5b450b2e307057361d6f 100644 |
--- a/tests/ImageFilterCacheTest.cpp |
+++ b/tests/ImageFilterCacheTest.cpp |
@@ -27,8 +27,8 @@ static SkBitmap create_bm() { |
// Ensure the cache can return a cached image |
static void test_find_existing(skiatest::Reporter* reporter, |
- SkSpecialImage* image, |
- SkSpecialImage* subset) { |
+ const sk_sp<SkSpecialImage>& image, |
+ const sk_sp<SkSpecialImage>& subset) { |
static const size_t kCacheSize = 1000000; |
SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCacheSize)); |
@@ -37,7 +37,7 @@ static void test_find_existing(skiatest::Reporter* reporter, |
SkImageFilter::Cache::Key key2(0, SkMatrix::I(), clip, subset->uniqueID(), subset->subset()); |
SkIPoint offset = SkIPoint::Make(3, 4); |
- cache->set(key1, image, offset); |
+ cache->set(key1, image.get(), offset); |
SkIPoint foundOffset; |
@@ -51,8 +51,8 @@ static void test_find_existing(skiatest::Reporter* reporter, |
// If either id is different or the clip or the matrix are different the |
// cached image won't be found. Even if it is caching the same bitmap. |
static void test_dont_find_if_diff_key(skiatest::Reporter* reporter, |
- SkSpecialImage* image, |
- SkSpecialImage* subset) { |
+ const sk_sp<SkSpecialImage>& image, |
+ const sk_sp<SkSpecialImage>& subset) { |
static const size_t kCacheSize = 1000000; |
SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCacheSize)); |
@@ -66,7 +66,7 @@ static void test_dont_find_if_diff_key(skiatest::Reporter* reporter, |
SkImageFilter::Cache::Key key4(0, SkMatrix::I(), clip1, subset->uniqueID(), subset->subset()); |
SkIPoint offset = SkIPoint::Make(3, 4); |
- cache->set(key0, image, offset); |
+ cache->set(key0, image.get(), offset); |
SkIPoint foundOffset; |
REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); |
@@ -76,7 +76,7 @@ static void test_dont_find_if_diff_key(skiatest::Reporter* reporter, |
} |
// Test purging when the max cache size is exceeded |
-static void test_internal_purge(skiatest::Reporter* reporter, SkSpecialImage* image) { |
+static void test_internal_purge(skiatest::Reporter* reporter, const sk_sp<SkSpecialImage>& image) { |
SkASSERT(image->getSize()); |
const size_t kCacheSize = image->getSize() + 10; |
SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCacheSize)); |
@@ -86,14 +86,14 @@ static void test_internal_purge(skiatest::Reporter* reporter, SkSpecialImage* im |
SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, image->uniqueID(), image->subset()); |
SkIPoint offset = SkIPoint::Make(3, 4); |
- cache->set(key1, image, offset); |
+ cache->set(key1, image.get(), offset); |
SkIPoint foundOffset; |
REPORTER_ASSERT(reporter, cache->get(key1, &foundOffset)); |
// This should knock the first one out of the cache |
- cache->set(key2, image, offset); |
+ cache->set(key2, image.get(), offset); |
REPORTER_ASSERT(reporter, cache->get(key2, &foundOffset)); |
REPORTER_ASSERT(reporter, !cache->get(key1, &foundOffset)); |
@@ -101,8 +101,8 @@ static void test_internal_purge(skiatest::Reporter* reporter, SkSpecialImage* im |
// Exercise the purgeByKeys and purge methods |
static void test_explicit_purging(skiatest::Reporter* reporter, |
- SkSpecialImage* image, |
- SkSpecialImage* subset) { |
+ const sk_sp<SkSpecialImage>& image, |
+ const sk_sp<SkSpecialImage>& subset) { |
static const size_t kCacheSize = 1000000; |
SkAutoTUnref<SkImageFilter::Cache> cache(SkImageFilter::Cache::Create(kCacheSize)); |
@@ -111,8 +111,8 @@ static void test_explicit_purging(skiatest::Reporter* reporter, |
SkImageFilter::Cache::Key key2(1, SkMatrix::I(), clip, subset->uniqueID(), image->subset()); |
SkIPoint offset = SkIPoint::Make(3, 4); |
- cache->set(key1, image, offset); |
- cache->set(key2, image, offset); |
+ cache->set(key1, image.get(), offset); |
+ cache->set(key2, image.get(), offset); |
SkIPoint foundOffset; |
@@ -135,11 +135,11 @@ DEF_TEST(ImageFilterCache_RasterBacked, reporter) { |
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
- SkAutoTUnref<SkSpecialImage> fullImg(SkSpecialImage::NewFromRaster(nullptr, full, srcBM)); |
+ sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromRaster(nullptr, full, srcBM)); |
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
- SkAutoTUnref<SkSpecialImage> subsetImg(SkSpecialImage::NewFromRaster(nullptr, subset, srcBM)); |
+ sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromRaster(nullptr, subset, srcBM)); |
test_find_existing(reporter, fullImg, subsetImg); |
test_dont_find_if_diff_key(reporter, fullImg, subsetImg); |
@@ -149,16 +149,14 @@ DEF_TEST(ImageFilterCache_RasterBacked, reporter) { |
// Shared test code for both the raster and gpu-backed image cases |
-static void test_image_backed(skiatest::Reporter* reporter, SkImage* srcImage) { |
+static void test_image_backed(skiatest::Reporter* reporter, const sk_sp<SkImage>& srcImage) { |
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
- SkAutoTUnref<SkSpecialImage> fullImg(SkSpecialImage::NewFromImage(nullptr, full, srcImage)); |
+ sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromImage(nullptr, full, srcImage)); |
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
- SkAutoTUnref<SkSpecialImage> subsetImg(SkSpecialImage::NewFromImage(nullptr, |
- subset, |
- srcImage)); |
+ sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromImage(nullptr, subset, srcImage)); |
test_find_existing(reporter, fullImg, subsetImg); |
test_dont_find_if_diff_key(reporter, fullImg, subsetImg); |
@@ -171,7 +169,7 @@ DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) { |
sk_sp<SkImage> srcImage(SkImage::MakeFromBitmap(srcBM)); |
- test_image_backed(reporter, srcImage.get()); |
+ test_image_backed(reporter, srcImage); |
} |
#if SK_SUPPORT_GPU |
@@ -207,7 +205,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, co |
return; |
} |
- test_image_backed(reporter, srcImage.get()); |
+ test_image_backed(reporter, srcImage); |
} |
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, context) { |
@@ -219,15 +217,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_GPUBacked, reporter, context |
const SkIRect& full = SkIRect::MakeWH(kFullSize, kFullSize); |
- SkAutoTUnref<SkSpecialImage> fullImg(SkSpecialImage::NewFromGpu( |
- nullptr, full, |
- kNeedNewImageUniqueID_SpecialImage, |
- srcTexture)); |
+ sk_sp<SkSpecialImage> fullImg(SkSpecialImage::MakeFromGpu(nullptr, full, |
+ kNeedNewImageUniqueID_SpecialImage, |
+ srcTexture)); |
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize); |
- SkAutoTUnref<SkSpecialImage> subsetImg(SkSpecialImage::NewFromGpu( |
- nullptr, subset, |
+ sk_sp<SkSpecialImage> subsetImg(SkSpecialImage::MakeFromGpu(nullptr, subset, |
kNeedNewImageUniqueID_SpecialImage, |
srcTexture)); |