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/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);