Switch SkSpecialImage & SkSpecialSurface classes over to smart pointers
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1812023002
Review URL: https://codereview.chromium.org/1812023002
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp
index c7b2170..938c048 100644
--- a/tests/ImageFilterCacheTest.cpp
+++ b/tests/ImageFilterCacheTest.cpp
@@ -27,8 +27,8 @@
// 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 @@
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 @@
// 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 @@
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 @@
}
// 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 @@
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 @@
// 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 @@
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 @@
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 @@
// 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 @@
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 @@
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 @@
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));
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 0c2f124..a648cb0 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -158,27 +158,27 @@
return SkColorFilterImageFilter::Create(filter, input, cropRect);
}
-static SkSpecialSurface* create_empty_special_surface(GrContext* context,
- SkImageFilter::Proxy* proxy,
- int widthHeight) {
+static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context,
+ SkImageFilter::Proxy* proxy,
+ int widthHeight) {
if (context) {
GrSurfaceDesc desc;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = widthHeight;
desc.fHeight = widthHeight;
- return SkSpecialSurface::NewRenderTarget(proxy, context, desc);
+ return SkSpecialSurface::MakeRenderTarget(proxy, context, desc);
} else {
const SkImageInfo info = SkImageInfo::MakeN32(widthHeight, widthHeight,
kOpaque_SkAlphaType);
- return SkSpecialSurface::NewRaster(proxy, info);
+ return SkSpecialSurface::MakeRaster(proxy, info);
}
}
-static SkSpecialImage* create_empty_special_image(GrContext* context,
- SkImageFilter::Proxy* proxy,
- int widthHeight) {
- SkAutoTUnref<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, widthHeight));
+static sk_sp<SkSpecialImage> create_empty_special_image(GrContext* context,
+ SkImageFilter::Proxy* proxy,
+ int widthHeight) {
+ sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, widthHeight));
SkASSERT(surf);
@@ -187,7 +187,7 @@
canvas->clear(0x0);
- return surf->newImageSnapshot();
+ return surf->makeImageSnapshot();
}
@@ -313,7 +313,7 @@
// Check that all filters offset to their absolute crop rect,
// unaffected by the input crop rect.
// Tests pass by not asserting.
- SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
SkASSERT(srcImg);
SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80));
@@ -357,7 +357,7 @@
SkString str;
str.printf("filter %d", static_cast<int>(i));
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr);
- SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset));
+ SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
REPORTER_ASSERT_MESSAGE(reporter, resultImg, str.c_str());
REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, str.c_str());
}
@@ -399,30 +399,31 @@
SkAutoTUnref<SkImageFilter> negativeFilter(SkBlurImageFilter::Create(-five, five));
SkBitmap gradient = make_gradient_circle(width, height);
- SkAutoTUnref<SkSpecialImage> imgSrc(SkSpecialImage::NewFromRaster(proxy,
- SkIRect::MakeWH(width,
- height),
- gradient));
+ sk_sp<SkSpecialImage> imgSrc(SkSpecialImage::MakeFromRaster(proxy,
+ SkIRect::MakeWH(width, height),
+ gradient));
SkIPoint offset;
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr);
- SkAutoTUnref<SkSpecialImage> positiveResult1(positiveFilter->filterImage(imgSrc, ctx, &offset));
+ SkAutoTUnref<SkSpecialImage> positiveResult1(positiveFilter->filterImage(imgSrc.get(),
+ ctx, &offset));
REPORTER_ASSERT(reporter, positiveResult1);
- SkAutoTUnref<SkSpecialImage> negativeResult1(negativeFilter->filterImage(imgSrc, ctx, &offset));
+ SkAutoTUnref<SkSpecialImage> negativeResult1(negativeFilter->filterImage(imgSrc.get(),
+ ctx, &offset));
REPORTER_ASSERT(reporter, negativeResult1);
SkMatrix negativeScale;
negativeScale.setScale(-SK_Scalar1, SK_Scalar1);
SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeWH(32, 32), nullptr);
- SkAutoTUnref<SkSpecialImage> negativeResult2(positiveFilter->filterImage(imgSrc,
+ SkAutoTUnref<SkSpecialImage> negativeResult2(positiveFilter->filterImage(imgSrc.get(),
negativeCTX,
&offset));
REPORTER_ASSERT(reporter, negativeResult2);
- SkAutoTUnref<SkSpecialImage> positiveResult2(negativeFilter->filterImage(imgSrc,
+ SkAutoTUnref<SkSpecialImage> positiveResult2(negativeFilter->filterImage(imgSrc.get(),
negativeCTX,
&offset));
REPORTER_ASSERT(reporter, positiveResult2);
@@ -520,14 +521,14 @@
SkAutoTUnref<SkImageFilter> input(SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect));
SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(0, 0, input, &cropRect));
- SkAutoTUnref<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, 10));
+ sk_sp<SkSpecialSurface> surf(create_empty_special_surface(context, proxy, 10));
surf->getCanvas()->clear(SK_ColorGREEN);
- SkAutoTUnref<SkSpecialImage> image(surf->newImageSnapshot());
+ sk_sp<SkSpecialImage> image(surf->makeImageSnapshot());
SkIPoint offset;
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr);
- SkAutoTUnref<SkSpecialImage> result(filter->filterImage(image, ctx, &offset));
+ SkAutoTUnref<SkSpecialImage> result(filter->filterImage(image.get(), ctx, &offset));
REPORTER_ASSERT(reporter, offset.fX == 5 && offset.fY == 0);
REPORTER_ASSERT(reporter, result);
REPORTER_ASSERT(reporter, result->width() == 5 && result->height() == 10);
@@ -828,12 +829,12 @@
SkAutoTUnref<SkImageFilter> source(SkImageSource::Create(greenImage.get()));
SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(source.get(), source.get()));
- SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 1));
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 1));
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 100, 100), nullptr);
SkIPoint offset;
- SkAutoTUnref<SkSpecialImage> resultImg(merge->filterImage(srcImg, ctx, &offset));
+ SkAutoTUnref<SkSpecialImage> resultImg(merge->filterImage(srcImg.get(), ctx, &offset));
REPORTER_ASSERT(reporter, resultImg);
REPORTER_ASSERT(reporter, resultImg->width() == 20 && resultImg->height() == 20);
@@ -1091,14 +1092,14 @@
picture.reset(recorder.endRecording());
}
- SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 2));
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 2));
SkAutoTUnref<SkImageFilter> imageFilter(SkPictureImageFilter::Create(picture.get()));
SkIPoint offset;
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), nullptr);
- SkAutoTUnref<SkSpecialImage> resultImage(imageFilter->filterImage(srcImg, ctx, &offset));
+ SkAutoTUnref<SkSpecialImage> resultImage(imageFilter->filterImage(srcImg.get(), ctx, &offset));
REPORTER_ASSERT(reporter, !resultImage);
}
@@ -1343,7 +1344,7 @@
static void test_composed_imagefilter_offset(SkImageFilter::Proxy* proxy,
skiatest::Reporter* reporter,
GrContext* context) {
- SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20));
SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, nullptr, &cropRect));
@@ -1354,7 +1355,7 @@
SkIPoint offset;
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr);
- SkAutoTUnref<SkSpecialImage> resultImg(composedFilter->filterImage(srcImg, ctx, &offset));
+ SkAutoTUnref<SkSpecialImage> resultImg(composedFilter->filterImage(srcImg.get(), ctx, &offset));
REPORTER_ASSERT(reporter, resultImg);
REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0);
}
@@ -1372,7 +1373,7 @@
static void test_partial_crop_rect(SkImageFilter::Proxy* proxy,
skiatest::Reporter* reporter,
GrContext* context) {
- SkAutoTUnref<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
+ sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 100));
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30),
SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::kHasHeight_CropEdge);
@@ -1380,7 +1381,7 @@
SkIPoint offset;
SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr);
- SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset));
+ SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
REPORTER_ASSERT(reporter, resultImg);
REPORTER_ASSERT(reporter, offset.fX == 0);
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index 03a496d..233ce2c 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -49,22 +49,23 @@
}
// Basic test of the SkSpecialImage public API (e.g., peekTexture, peekPixels & draw)
-static void test_image(SkSpecialImage* img, skiatest::Reporter* reporter,
+static void test_image(const sk_sp<SkSpecialImage>& img, skiatest::Reporter* reporter,
bool peekPixelsSucceeds, bool peekTextureSucceeds,
int offset, int size) {
- const SkIRect subset = TestingSpecialImageAccess::Subset(img);
+ const SkIRect subset = TestingSpecialImageAccess::Subset(img.get());
REPORTER_ASSERT(reporter, offset == subset.left());
REPORTER_ASSERT(reporter, offset == subset.top());
REPORTER_ASSERT(reporter, kSmallerSize == subset.width());
REPORTER_ASSERT(reporter, kSmallerSize == subset.height());
//--------------
- REPORTER_ASSERT(reporter, peekTextureSucceeds == !!TestingSpecialImageAccess::PeekTexture(img));
+ REPORTER_ASSERT(reporter, peekTextureSucceeds ==
+ !!TestingSpecialImageAccess::PeekTexture(img.get()));
//--------------
SkPixmap pixmap;
REPORTER_ASSERT(reporter, peekPixelsSucceeds ==
- !!TestingSpecialImageAccess::PeekPixels(img, &pixmap));
+ !!TestingSpecialImageAccess::PeekPixels(img.get(), &pixmap));
if (peekPixelsSucceeds) {
REPORTER_ASSERT(reporter, size == pixmap.width());
REPORTER_ASSERT(reporter, size == pixmap.height());
@@ -73,7 +74,7 @@
//--------------
SkImageInfo info = SkImageInfo::MakeN32(kFullSize, kFullSize, kOpaque_SkAlphaType);
- SkAutoTUnref<SkSpecialSurface> surf(img->newSurface(info));
+ sk_sp<SkSpecialSurface> surf(img->makeSurface(info));
SkCanvas* canvas = surf->getCanvas();
@@ -98,7 +99,7 @@
DEF_TEST(SpecialImage_Raster, reporter) {
SkBitmap bm = create_bm();
- SkAutoTUnref<SkSpecialImage> fullSImage(SkSpecialImage::NewFromRaster(
+ sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromRaster(
nullptr,
SkIRect::MakeWH(kFullSize, kFullSize),
bm));
@@ -106,12 +107,12 @@
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
{
- SkAutoTUnref<SkSpecialImage> subSImg1(SkSpecialImage::NewFromRaster(nullptr, subset, bm));
+ sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromRaster(nullptr, subset, bm));
test_image(subSImg1, reporter, true, false, kPad, kFullSize);
}
{
- SkAutoTUnref<SkSpecialImage> subSImg2(fullSImage->extractSubset(subset));
+ sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset));
test_image(subSImg2, reporter, true, false, 0, kSmallerSize);
}
}
@@ -121,22 +122,21 @@
sk_sp<SkImage> fullImage(SkImage::MakeFromBitmap(bm));
- SkAutoTUnref<SkSpecialImage> fullSImage(SkSpecialImage::NewFromImage(
+ sk_sp<SkSpecialImage> fullSImage(SkSpecialImage::MakeFromImage(
nullptr,
SkIRect::MakeWH(kFullSize, kFullSize),
- fullImage.get()));
+ fullImage));
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
{
- SkAutoTUnref<SkSpecialImage> subSImg1(SkSpecialImage::NewFromImage(nullptr,
- subset,
- fullImage.get()));
+ sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromImage(nullptr, subset,
+ fullImage));
test_image(subSImg1, reporter, true, false, kPad, kFullSize);
}
{
- SkAutoTUnref<SkSpecialImage> subSImg2(fullSImage->extractSubset(subset));
+ sk_sp<SkSpecialImage> subSImg2(fullSImage->makeSubset(subset));
test_image(subSImg2, reporter, true, false, 0, kSmallerSize);
}
}
@@ -154,16 +154,18 @@
{
// The SkAutoPixmapStorage keeps hold of the memory
- SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromPixmap(nullptr, subset, pixmap,
- nullptr, nullptr));
+ sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(nullptr, subset, pixmap,
+ nullptr, nullptr));
test_image(img, reporter, true, false, kPad, kFullSize);
}
{
// The image takes ownership of the memory
- SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromPixmap(
+ sk_sp<SkSpecialImage> img(SkSpecialImage::MakeFromPixmap(
nullptr, subset, pixmap,
- [] (void* addr, void*) -> void { sk_free(addr); },
+ [] (void* addr, void*) -> void {
+ sk_free(addr);
+ },
nullptr));
pixmap.release();
test_image(img, reporter, true, false, kPad, kFullSize);
@@ -187,7 +189,7 @@
return;
}
- SkAutoTUnref<SkSpecialImage> fullSImg(SkSpecialImage::NewFromGpu(
+ sk_sp<SkSpecialImage> fullSImg(SkSpecialImage::MakeFromGpu(
nullptr,
SkIRect::MakeWH(kFullSize, kFullSize),
kNeedNewImageUniqueID_SpecialImage,
@@ -196,7 +198,7 @@
const SkIRect& subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
{
- SkAutoTUnref<SkSpecialImage> subSImg1(SkSpecialImage::NewFromGpu(
+ sk_sp<SkSpecialImage> subSImg1(SkSpecialImage::MakeFromGpu(
nullptr, subset,
kNeedNewImageUniqueID_SpecialImage,
texture));
@@ -204,7 +206,7 @@
}
{
- SkAutoTUnref<SkSpecialImage> subSImg2(fullSImg->extractSubset(subset));
+ sk_sp<SkSpecialImage> subSImg2(fullSImg->makeSubset(subset));
test_image(subSImg2, reporter, false, true, kPad, kFullSize);
}
}
diff --git a/tests/SpecialSurfaceTest.cpp b/tests/SpecialSurfaceTest.cpp
index 580d2dd..cd4f0ae 100644
--- a/tests/SpecialSurfaceTest.cpp
+++ b/tests/SpecialSurfaceTest.cpp
@@ -33,9 +33,11 @@
static const int kFullSize = kSmallerSize + 2 * kPad;
// Exercise the public API of SkSpecialSurface (e.g., getCanvas, newImageSnapshot)
-static void test_surface(SkSpecialSurface* surf, skiatest::Reporter* reporter, int offset) {
+static void test_surface(const sk_sp<SkSpecialSurface>& surf,
+ skiatest::Reporter* reporter,
+ int offset) {
- const SkIRect surfSubset = TestingSpecialSurfaceAccess::Subset(surf);
+ const SkIRect surfSubset = TestingSpecialSurfaceAccess::Subset(surf.get());
REPORTER_ASSERT(reporter, offset == surfSubset.fLeft);
REPORTER_ASSERT(reporter, offset == surfSubset.fTop);
REPORTER_ASSERT(reporter, kSmallerSize == surfSubset.width());
@@ -46,10 +48,10 @@
canvas->clear(SK_ColorRED);
- SkAutoTUnref<SkSpecialImage> img(surf->newImageSnapshot());
+ sk_sp<SkSpecialImage> img(surf->makeImageSnapshot());
REPORTER_ASSERT(reporter, img);
- const SkIRect imgSubset = TestingSpecialSurfaceAccess::Subset(img);
+ const SkIRect imgSubset = TestingSpecialSurfaceAccess::Subset(img.get());
REPORTER_ASSERT(reporter, surfSubset == imgSubset);
// the canvas was invalidated by the newImageSnapshot call
@@ -59,7 +61,7 @@
DEF_TEST(SpecialSurface_Raster, reporter) {
SkImageInfo info = SkImageInfo::MakeN32(kSmallerSize, kSmallerSize, kOpaque_SkAlphaType);
- SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewRaster(nullptr, info));
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRaster(nullptr, info));
test_surface(surf, reporter, 0);
}
@@ -71,7 +73,7 @@
const SkIRect subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewFromBitmap(nullptr, subset, bm));
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeFromBitmap(nullptr, subset, bm));
test_surface(surf, reporter, kPad);
@@ -87,7 +89,7 @@
desc.fWidth = kSmallerSize;
desc.fHeight = kSmallerSize;
- SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewRenderTarget(nullptr, context, desc));
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(nullptr, context, desc));
test_surface(surf, reporter, 0);
}
@@ -105,7 +107,7 @@
const SkIRect subset = SkIRect::MakeXYWH(kPad, kPad, kSmallerSize, kSmallerSize);
- SkAutoTUnref<SkSpecialSurface> surf(SkSpecialSurface::NewFromTexture(nullptr, subset, temp));
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeFromTexture(nullptr, subset, temp));
test_surface(surf, reporter, kPad);