aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-23 18:59:25 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-23 18:59:25 -0700
commite8f3062a36d3682f4019309a32b5b84dc9eddf8c (patch)
treeff5cd50c65edb6e3b77f77327165ad0162557137 /tests
parent041c870425eb0a3e2b0cbc46581b3da2f50571d9 (diff)
switch surface to sk_sp
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1817383002 CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot Review URL: https://codereview.chromium.org/1817383002
Diffstat (limited to 'tests')
-rw-r--r--tests/BlurTest.cpp2
-rw-r--r--tests/DrawBitmapRectTest.cpp2
-rw-r--r--tests/DrawFilterTest.cpp2
-rw-r--r--tests/DrawPathTest.cpp19
-rw-r--r--tests/GpuDrawPathTest.cpp5
-rw-r--r--tests/GrTextureMipMapInvalidationTest.cpp3
-rw-r--r--tests/GradientTest.cpp6
-rw-r--r--tests/ImageFilterTest.cpp11
-rw-r--r--tests/ImageIsOpaqueTest.cpp13
-rw-r--r--tests/ImageNewShaderTest.cpp20
-rw-r--r--tests/ImageTest.cpp13
-rw-r--r--tests/IndexedPngOverflowTest.cpp2
-rw-r--r--tests/PathTest.cpp12
-rw-r--r--tests/ReadPixelsTest.cpp14
-rw-r--r--tests/RecordDrawTest.cpp2
-rw-r--r--tests/RecorderTest.cpp2
-rw-r--r--tests/ResourceCacheTest.cpp3
-rw-r--r--tests/SkResourceCacheTest.cpp4
-rw-r--r--tests/SurfaceTest.cpp153
-rw-r--r--tests/TextBlobCacheTest.cpp5
-rw-r--r--tests/TextureStorageAllocator.cpp4
-rw-r--r--tests/WritePixelsTest.cpp11
22 files changed, 144 insertions, 164 deletions
diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp
index 39ef738288..dc3d6c76e3 100644
--- a/tests/BlurTest.cpp
+++ b/tests/BlurTest.cpp
@@ -564,7 +564,7 @@ DEF_TEST(BlurAsABlur, reporter) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SmallBoxBlurBug, reporter, ctx) {
SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::kNo, info));
+ auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
SkCanvas* canvas = surface->getCanvas();
SkRect r = SkRect::MakeXYWH(10, 10, 100, 100);
diff --git a/tests/DrawBitmapRectTest.cpp b/tests/DrawBitmapRectTest.cpp
index 8928d4c909..23fa2448a0 100644
--- a/tests/DrawBitmapRectTest.cpp
+++ b/tests/DrawBitmapRectTest.cpp
@@ -41,7 +41,7 @@ static void test_faulty_pixelref(skiatest::Reporter* reporter) {
bm.setPixelRef(new FailurePixelRef(info), 0, 0)->unref();
// now our bitmap has a pixelref, but we know it will fail to lock
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200));
+ auto surface(SkSurface::MakeRasterN32Premul(200, 200));
SkCanvas* canvas = surface->getCanvas();
const SkFilterQuality levels[] = {
diff --git a/tests/DrawFilterTest.cpp b/tests/DrawFilterTest.cpp
index f3e0a77306..ed23b701e5 100644
--- a/tests/DrawFilterTest.cpp
+++ b/tests/DrawFilterTest.cpp
@@ -27,7 +27,7 @@ public:
* it was before the save.
*/
static void test_saverestore(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10));
+ auto surface(SkSurface::MakeRasterN32Premul(10, 10));
SkCanvas* canvas = surface->getCanvas();
SkAutoTUnref<TestFilter> df(new TestFilter);
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index 8c46b100b3..9038406e13 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -18,7 +18,7 @@ static void test_big_aa_rect(skiatest::Reporter* reporter) {
SkPMColor pixel[1];
output.installPixels(SkImageInfo::MakeN32Premul(1, 1), pixel, 4);
- SkSurface* surf = SkSurface::NewRasterN32Premul(300, 33300);
+ auto surf = SkSurface::MakeRasterN32Premul(300, 33300);
SkCanvas* canvas = surf->getCanvas();
SkRect r = { 0, 33000, 300, 33300 };
@@ -46,7 +46,6 @@ static void test_big_aa_rect(skiatest::Reporter* reporter) {
} else {
REPORTER_ASSERT_MESSAGE(reporter, false, "readPixels failed");
}
- surf->unref();
}
///////////////////////////////////////////////////////////////////////////////
@@ -95,7 +94,7 @@ static void test_crbug131181() {
moveToH(&path, &data[0]);
cubicToH(&path, &data[2]);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
+ auto surface(SkSurface::MakeRasterN32Premul(640, 480));
SkPaint paint;
paint.setAntiAlias(true);
@@ -132,7 +131,7 @@ static void test_inversepathwithclip() {
SkPaint paint;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
+ auto surface(SkSurface::MakeRasterN32Premul(640, 480));
SkCanvas* canvas = surface->getCanvas();
canvas->save();
canvas->clipRect(SkRect::MakeWH(19, 11));
@@ -171,7 +170,7 @@ static void test_bug533() {
SkPaint paint;
paint.setAntiAlias(true);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
+ auto surface(SkSurface::MakeRasterN32Premul(640, 480));
surface->getCanvas()->drawPath(path, paint);
}
@@ -213,7 +212,7 @@ static void test_bigcubic() {
SkPaint paint;
paint.setAntiAlias(true);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
+ auto surface(SkSurface::MakeRasterN32Premul(640, 480));
surface->getCanvas()->drawPath(path, paint);
}
@@ -241,7 +240,7 @@ static void test_halfway() {
m.postTranslate(0.001f, 0.001f);
path.transform(m, &p2);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
+ auto surface(SkSurface::MakeRasterN32Premul(640, 480));
SkCanvas* canvas = surface->getCanvas();
canvas->translate(-16366, -1383);
canvas->drawPath(p2, paint);
@@ -262,7 +261,7 @@ static void test_halfway() {
static void test_giantaa() {
const int W = 400;
const int H = 400;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(33000, 10));
+ auto surface(SkSurface::MakeRasterN32Premul(33000, 10));
SkPaint paint;
paint.setAntiAlias(true);
@@ -316,7 +315,7 @@ static void test_crbug_165432(skiatest::Reporter* reporter) {
// http://crbug.com/472147
// This is a simplified version from the bug. RRect radii not properly scaled.
static void test_crbug_472147_simple(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(1000, 1000));
+ auto surface(SkSurface::MakeRasterN32Premul(1000, 1000));
SkCanvas* canvas = surface->getCanvas();
SkPaint p;
SkRect r = SkRect::MakeLTRB(-246.0f, 33.0f, 848.0f, 33554464.0f);
@@ -331,7 +330,7 @@ static void test_crbug_472147_simple(skiatest::Reporter* reporter) {
// http://crbug.com/472147
// RRect radii not properly scaled.
static void test_crbug_472147_actual(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(1000, 1000));
+ auto surface(SkSurface::MakeRasterN32Premul(1000, 1000));
SkCanvas* canvas = surface->getCanvas();
SkPaint p;
SkRect r = SkRect::MakeLTRB(-246.0f, 33.0f, 848.0f, 33554464.0f);
diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp
index 1f9361ad1e..bab6d3a89b 100644
--- a/tests/GpuDrawPathTest.cpp
+++ b/tests/GpuDrawPathTest.cpp
@@ -80,9 +80,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuDrawPath, reporter, context) {
for (auto& test_func : { &test_drawPathEmpty, &test_drawSameRectOvals }) {
for (auto& sampleCount : {0, 4, 16}) {
SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
- SkAutoTUnref<SkSurface> surface(
- SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info,
- sampleCount, nullptr));
+ auto surface(
+ SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, sampleCount, nullptr));
if (!surface) {
continue;
}
diff --git a/tests/GrTextureMipMapInvalidationTest.cpp b/tests/GrTextureMipMapInvalidationTest.cpp
index b047550e6d..539a8ce55c 100644
--- a/tests/GrTextureMipMapInvalidationTest.cpp
+++ b/tests/GrTextureMipMapInvalidationTest.cpp
@@ -41,7 +41,7 @@ DEF_GPUTEST_FOR_NULL_CONTEXT(GrTextureMipMapInvalidationTest, reporter, context)
REPORTER_ASSERT(reporter, false == tex->texturePriv().hasMipMaps());
// Painting with downscale and medium filter quality should result in mipmap creation
- SkSurface* surface = SkSurface::NewRenderTargetDirect(texRT2->asRenderTarget());
+ auto surface = SkSurface::MakeRenderTargetDirect(texRT2->asRenderTarget());
SkPaint paint;
paint.setFilterQuality(kMedium_SkFilterQuality);
surface->getCanvas()->scale(0.2f, 0.2f);
@@ -56,7 +56,6 @@ DEF_GPUTEST_FOR_NULL_CONTEXT(GrTextureMipMapInvalidationTest, reporter, context)
REPORTER_ASSERT(reporter, true == tex->texturePriv().hasMipMaps());
REPORTER_ASSERT(reporter, true == tex->texturePriv().mipMapsAreDirty());
- surface->unref();
texRT1->unref();
texRT2->unref();
}
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index 6521070552..0014089322 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -184,7 +184,7 @@ static void TestGradientShaders(skiatest::Reporter* reporter) {
}
static void test_nearly_vertical(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(200, 200));
+ auto surface(SkSurface::MakeRasterN32Premul(200, 200));
const SkPoint pts[] = {{ 100, 50 }, { 100.0001f, 50000 }};
const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
@@ -200,7 +200,7 @@ static void test_nearly_vertical(skiatest::Reporter* reporter) {
// The old code had an assert which this test triggered.
// We now explicitly clamp the resulting fx value.
static void test_linear_fuzz(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(1300, 630));
+ auto surface(SkSurface::MakeRasterN32Premul(1300, 630));
const SkPoint pts[] = {{ 179.5f, -179.5f }, { 1074.5f, 715.5f }};
const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE };
@@ -216,7 +216,7 @@ static void test_linear_fuzz(skiatest::Reporter* reporter) {
// https://bugs.chromium.org/p/skia/issues/detail?id=5023
// We should still shade pixels for which the radius is exactly 0.
static void test_two_point_conical_zero_radius(skiatest::Reporter* reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(5, 5));
+ auto surface(SkSurface::MakeRasterN32Premul(5, 5));
surface->getCanvas()->clear(SK_ColorRED);
const SkColor colors[] = { SK_ColorGREEN, SK_ColorBLUE };
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 3350b4a25f..acdd369ff3 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -231,7 +231,7 @@ void MatrixTestImageFilter::toString(SkString* str) const {
#endif
static sk_sp<SkImage> make_small_image() {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kBitmapSize, kBitmapSize));
+ auto surface(SkSurface::MakeRasterN32Premul(kBitmapSize, kBitmapSize));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkPaint darkPaint;
@@ -1495,7 +1495,7 @@ DEF_TEST(ImageFilterCanComputeFastBounds, reporter) {
// Verify that SkImageSource survives serialization
DEF_TEST(ImageFilterImageSourceSerialization, reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10));
+ auto surface(SkSurface::MakeRasterN32Premul(10, 10));
surface->getCanvas()->clear(SK_ColorGREEN);
sk_sp<SkImage> image(surface->makeImageSnapshot());
SkAutoTUnref<SkImageFilter> filter(SkImageSource::Create(image.get()));
@@ -1562,7 +1562,7 @@ static void test_large_blur_input(skiatest::Reporter* reporter, SkCanvas* canvas
}
DEF_TEST(BlurLargeImage, reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(SkImageInfo::MakeN32Premul(100, 100)));
+ auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100)));
test_large_blur_input(reporter, surface->getCanvas());
}
@@ -1597,9 +1597,8 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(XfermodeImageFilterCroppedInput_Gpu, reporter, co
}
DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) {
- SkAutoTUnref<SkSurface> surface(
- SkSurface::NewRenderTarget(context, SkBudgeted::kYes,
- SkImageInfo::MakeN32Premul(100, 100)));
+ auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes,
+ SkImageInfo::MakeN32Premul(100, 100)));
test_large_blur_input(reporter, surface->getCanvas());
}
#endif
diff --git a/tests/ImageIsOpaqueTest.cpp b/tests/ImageIsOpaqueTest.cpp
index 6f13708335..6b8b64ac21 100644
--- a/tests/ImageIsOpaqueTest.cpp
+++ b/tests/ImageIsOpaqueTest.cpp
@@ -48,18 +48,19 @@ DEF_TEST(ImageInfo_flattening, reporter) {
}
}
-static void check_isopaque(skiatest::Reporter* reporter, SkSurface* surface, bool expectedOpaque) {
+static void check_isopaque(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface,
+ bool expectedOpaque) {
sk_sp<SkImage> image(surface->makeImageSnapshot());
REPORTER_ASSERT(reporter, image->isOpaque() == expectedOpaque);
}
DEF_TEST(ImageIsOpaqueTest, reporter) {
SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
- SkAutoTUnref<SkSurface> surfaceTransparent(SkSurface::NewRaster(infoTransparent));
+ auto surfaceTransparent(SkSurface::MakeRaster(infoTransparent));
check_isopaque(reporter, surfaceTransparent, false);
SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
- SkAutoTUnref<SkSurface> surfaceOpaque(SkSurface::NewRaster(infoOpaque));
+ auto surfaceOpaque(SkSurface::MakeRaster(infoOpaque));
check_isopaque(reporter, surfaceOpaque, true);
}
@@ -67,13 +68,11 @@ DEF_TEST(ImageIsOpaqueTest, reporter) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageIsOpaqueTest_Gpu, reporter, context) {
SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
- SkAutoTUnref<SkSurface> surfaceTransparent(
- SkSurface::NewRenderTarget(context, SkBudgeted::kNo, infoTransparent));
+ auto surfaceTransparent(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, infoTransparent));
check_isopaque(reporter, surfaceTransparent, false);
SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
- SkAutoTUnref<SkSurface> surfaceOpaque(
- SkSurface::NewRenderTarget(context,SkBudgeted::kNo, infoOpaque));
+ auto surfaceOpaque(SkSurface::MakeRenderTarget(context,SkBudgeted::kNo, infoOpaque));
check_isopaque(reporter, surfaceOpaque, true);
}
diff --git a/tests/ImageNewShaderTest.cpp b/tests/ImageNewShaderTest.cpp
index b6266ed60d..4ae0b6de8e 100644
--- a/tests/ImageNewShaderTest.cpp
+++ b/tests/ImageNewShaderTest.cpp
@@ -104,8 +104,8 @@ void runShaderTest(skiatest::Reporter* reporter, SkSurface* sourceSurface, SkSur
DEF_TEST(ImageNewShader, reporter) {
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
- SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRaster(info));
- SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRaster(info));
+ auto sourceSurface(SkSurface::MakeRaster(info));
+ auto destinationSurface(SkSurface::MakeRaster(info));
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
}
@@ -115,10 +115,8 @@ DEF_TEST(ImageNewShader, reporter) {
void gpuToGpu(skiatest::Reporter* reporter, GrContext* context) {
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
- SkAutoTUnref<SkSurface> sourceSurface(
- SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info));
- SkAutoTUnref<SkSurface> destinationSurface(
- SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info));
+ auto sourceSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
+ auto destinationSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
}
@@ -126,9 +124,8 @@ void gpuToGpu(skiatest::Reporter* reporter, GrContext* context) {
void gpuToRaster(skiatest::Reporter* reporter, GrContext* context) {
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
- SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRenderTarget(context,
- SkBudgeted::kNo, info));
- SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRaster(info));
+ auto sourceSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
+ auto destinationSurface(SkSurface::MakeRaster(info));
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
}
@@ -136,9 +133,8 @@ void gpuToRaster(skiatest::Reporter* reporter, GrContext* context) {
void rasterToGpu(skiatest::Reporter* reporter, GrContext* context) {
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
- SkAutoTUnref<SkSurface> sourceSurface(SkSurface::NewRaster(info));
- SkAutoTUnref<SkSurface> destinationSurface(SkSurface::NewRenderTarget(context,
- SkBudgeted::kNo, info));
+ auto sourceSurface(SkSurface::MakeRaster(info));
+ auto destinationSurface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
runShaderTest(reporter, sourceSurface.get(), destinationSurface.get(), info);
}
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index ce3cb99265..15ee54c000 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -62,13 +62,13 @@ static void draw_image_test_pattern(SkCanvas* canvas) {
}
static sk_sp<SkImage> create_image() {
const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
draw_image_test_pattern(surface->getCanvas());
return surface->makeImageSnapshot();
}
static sk_sp<SkImage> create_image_565() {
const SkImageInfo info = SkImageInfo::Make(20, 20, kRGB_565_SkColorType, kOpaque_SkAlphaType);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
draw_image_test_pattern(surface->getCanvas());
return surface->makeImageSnapshot();
}
@@ -146,8 +146,7 @@ static sk_sp<SkImage> create_codec_image() {
#if SK_SUPPORT_GPU
static sk_sp<SkImage> create_gpu_image(GrContext* context) {
const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkBudgeted::kNo,
- info));
+ auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
draw_image_test_pattern(surface->getCanvas());
return surface->makeImageSnapshot();
}
@@ -224,7 +223,7 @@ DEF_TEST(Image_Encode_Serializer, reporter) {
// Test that image encoding failures do not break picture serialization/deserialization.
DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ auto surface(SkSurface::MakeRasterN32Premul(100, 100));
surface->getCanvas()->clear(SK_ColorGREEN);
sk_sp<SkImage> image(surface->makeImageSnapshot());
REPORTER_ASSERT(reporter, image);
@@ -287,7 +286,7 @@ DEF_TEST(Image_RetainSnapshot, reporter) {
const SkPMColor red = SkPackARGB32(0xFF, 0xFF, 0, 0);
const SkPMColor green = SkPackARGB32(0xFF, 0, 0xFF, 0);
SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
surface->getCanvas()->clear(0xFF00FF00);
SkPMColor pixels[4];
@@ -373,7 +372,7 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(SkImage_Gpu2Cpu, reporter, context) {
sk_sp<SkImage> image(create_gpu_image(context));
const uint32_t uniqueID = image->uniqueID();
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
// now we can test drawing a gpu-backed image into a cpu-backed surface
diff --git a/tests/IndexedPngOverflowTest.cpp b/tests/IndexedPngOverflowTest.cpp
index f516898a1a..1a48b6499b 100644
--- a/tests/IndexedPngOverflowTest.cpp
+++ b/tests/IndexedPngOverflowTest.cpp
@@ -33,7 +33,7 @@ DEF_TEST(IndexedPngOverflow, reporter) {
bool success = decode_memory(gPng, sizeof(gPng), &image);
REPORTER_ASSERT(reporter, success);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(SkImageInfo::MakeN32Premul(20, 1)));
+ auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(20, 1)));
SkCanvas* canvas = surface->getCanvas();
SkRect destRect = SkRect::MakeXYWH(0, 0, 20, 1);
canvas->drawBitmapRect(image, destRect, nullptr);
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 2ba40005d4..dd6f41cbfa 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -99,7 +99,7 @@ static void make_path_crbug364224_simplified(SkPath* path) {
static void test_path_crbug364224() {
SkPath path;
SkPaint paint;
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(84, 88));
+ auto surface(SkSurface::MakeRasterN32Premul(84, 88));
SkCanvas* canvas = surface->getCanvas();
make_path_crbug364224_simplified(&path);
@@ -293,7 +293,7 @@ static void test_bad_cubic_crbug234190() {
SkPaint paint;
paint.setAntiAlias(true);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(84, 88));
+ auto surface(SkSurface::MakeRasterN32Premul(84, 88));
surface->getCanvas()->drawPath(path, paint);
}
@@ -412,7 +412,7 @@ static void test_crbug_170666() {
SkPaint paint;
paint.setAntiAlias(true);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(1000, 1000));
+ auto surface(SkSurface::MakeRasterN32Premul(1000, 1000));
build_path_simple_170666(path);
surface->getCanvas()->drawPath(path, paint);
@@ -553,7 +553,7 @@ static void build_big_path(SkPath* path, bool reducedCase) {
}
static void test_clipped_cubic() {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(640, 480));
+ auto surface(SkSurface::MakeRasterN32Premul(640, 480));
// This path used to assert, because our cubic-chopping code incorrectly
// moved control points after the chop. This test should be run in SK_DEBUG
@@ -626,9 +626,7 @@ static void test_tricky_cubic() {
SkPaint paint;
paint.setAntiAlias(true);
- SkSurface* surface = SkSurface::NewRasterN32Premul(19, 130);
- surface->getCanvas()->drawPath(path, paint);
- surface->unref();
+ SkSurface::MakeRasterN32Premul(19, 130)->getCanvas()->drawPath(path, paint);
}
// Inspired by http://code.google.com/p/chromium/issues/detail?id=141651
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 87e51163da..b538fc8c9b 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -324,7 +324,7 @@ const SkIRect gReadPixelsTestRects[] = {
SkIRect::MakeLTRB(3 * DEV_W / 4, -10, DEV_W + 10, DEV_H + 10),
};
-static void test_readpixels(skiatest::Reporter* reporter, SkSurface* surface,
+static void test_readpixels(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface,
BitmapInit lastBitmapInit) {
SkCanvas* canvas = surface->getCanvas();
fill_src_canvas(canvas);
@@ -382,7 +382,7 @@ static void test_readpixels(skiatest::Reporter* reporter, SkSurface* surface,
}
DEF_TEST(ReadPixels, reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
// SW readback fails a premul check when reading back to an unaligned rowbytes.
test_readpixels(reporter, surface, kLastAligned_BitmapInit);
}
@@ -397,7 +397,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, context) {
desc.fOrigin = origin;
SkAutoTUnref<GrTexture> surfaceTexture(
context->textureProvider()->createTexture(desc, SkBudgeted::kNo));
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(surfaceTexture->asRenderTarget()));
+ auto surface(SkSurface::MakeRenderTargetDirect(surfaceTexture->asRenderTarget()));
desc.fFlags = kNone_GrSurfaceFlags;
test_readpixels(reporter, surface, kLast_BitmapInit);
}
@@ -603,8 +603,8 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(ReadPixels_Subset_Gpu, reporter, context) {
// do they draw the same?
const SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128);
- SkAutoTUnref<SkSurface> surfA(SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0));
- SkAutoTUnref<SkSurface> surfB(SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0));
+ auto surfA(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
+ auto surfB(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
if (false) {
//
@@ -613,8 +613,8 @@ DEF_GPUTEST_FOR_NATIVE_CONTEXT(ReadPixels_Subset_Gpu, reporter, context) {
//
SkFilterQuality quality = kLow_SkFilterQuality;
- SkAutoTUnref<SkData> dataA(draw_into_surface(surfA, bm_subset, quality));
- SkAutoTUnref<SkData> dataB(draw_into_surface(surfB, tx_subset, quality));
+ SkAutoTUnref<SkData> dataA(draw_into_surface(surfA.get(), bm_subset, quality));
+ SkAutoTUnref<SkData> dataB(draw_into_surface(surfB.get(), tx_subset, quality));
REPORTER_ASSERT(reporter, dataA->equals(dataB));
if (false) {
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index 8d91fbc8d2..17d971126c 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -279,7 +279,7 @@ DEF_TEST(RecordDraw_drawImage, r){
bool fDrawImageRectCalled;
};
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10));
+ auto surface(SkSurface::MakeRasterN32Premul(10, 10));
surface->getCanvas()->clear(SK_ColorGREEN);
sk_sp<SkImage> image(surface->makeImageSnapshot());
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index 59d5a8e6cd..a709a51381 100644
--- a/tests/RecorderTest.cpp
+++ b/tests/RecorderTest.cpp
@@ -74,7 +74,7 @@ DEF_TEST(Recorder_drawImage_takeReference, reporter) {
sk_sp<SkImage> image;
{
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(100, 100));
+ auto surface(SkSurface::MakeRasterN32Premul(100, 100));
surface->getCanvas()->clear(SK_ColorGREEN);
image = surface->makeImageSnapshot();
}
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 784ae7e94d..0931876cf1 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -37,8 +37,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheCache, reporter, context) {
desc.fWidth = gWidth;
desc.fHeight = gHeight;
SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context,
- SkBudgeted::kNo, info));
+ auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info));
SkCanvas* canvas = surface->getCanvas();
const SkIRect size = SkIRect::MakeWH(gWidth, gHeight);
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp
index 7ae5f6486f..3c0d1ffee3 100644
--- a/tests/SkResourceCacheTest.cpp
+++ b/tests/SkResourceCacheTest.cpp
@@ -264,7 +264,7 @@ DEF_TEST(BitmapCache_discarded_bitmap, reporter) {
static void test_discarded_image(skiatest::Reporter* reporter, const SkMatrix& transform,
sk_sp<SkImage> (*buildImage)()) {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10));
+ auto surface(SkSurface::MakeRasterN32Premul(10, 10));
SkCanvas* canvas = surface->getCanvas();
// SkBitmapCache is global, so other threads could be evicting our bitmaps. Loop a few times
@@ -313,7 +313,7 @@ DEF_TEST(BitmapCache_discarded_image, reporter) {
for (size_t i = 0; i < SK_ARRAY_COUNT(xforms); ++i) {
test_discarded_image(reporter, xforms[i], []() {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10));
+ auto surface(SkSurface::MakeRasterN32Premul(10, 10));
surface->getCanvas()->clear(SK_ColorCYAN);
return surface->makeImageSnapshot();
});
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 89c7765c56..4aaabd8062 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -27,57 +27,57 @@ static void release_direct_surface_storage(void* pixels, void* context) {
SkASSERT(pixels == context);
sk_free(pixels);
}
-static SkSurface* create_surface(SkAlphaType at = kPremul_SkAlphaType,
- SkImageInfo* requestedInfo = nullptr) {
+static sk_sp<SkSurface> create_surface(SkAlphaType at = kPremul_SkAlphaType,
+ SkImageInfo* requestedInfo = nullptr) {
const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
if (requestedInfo) {
*requestedInfo = info;
}
- return SkSurface::NewRaster(info);
+ return SkSurface::MakeRaster(info);
}
-static SkSurface* create_direct_surface(SkAlphaType at = kPremul_SkAlphaType,
- SkImageInfo* requestedInfo = nullptr) {
+static sk_sp<SkSurface> create_direct_surface(SkAlphaType at = kPremul_SkAlphaType,
+ SkImageInfo* requestedInfo = nullptr) {
const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
if (requestedInfo) {
*requestedInfo = info;
}
const size_t rowBytes = info.minRowBytes();
void* storage = sk_malloc_throw(info.getSafeSize(rowBytes));
- return SkSurface::NewRasterDirectReleaseProc(info, storage, rowBytes,
- release_direct_surface_storage,
- storage);
+ return SkSurface::MakeRasterDirectReleaseProc(info, storage, rowBytes,
+ release_direct_surface_storage,
+ storage);
}
#if SK_SUPPORT_GPU
-static SkSurface* create_gpu_surface(GrContext* context, SkAlphaType at = kPremul_SkAlphaType,
- SkImageInfo* requestedInfo = nullptr) {
+static sk_sp<SkSurface> create_gpu_surface(GrContext* context, SkAlphaType at = kPremul_SkAlphaType,
+ SkImageInfo* requestedInfo = nullptr) {
const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
if (requestedInfo) {
*requestedInfo = info;
}
- return SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr);
+ return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr);
}
-static SkSurface* create_gpu_scratch_surface(GrContext* context,
- SkAlphaType at = kPremul_SkAlphaType,
- SkImageInfo* requestedInfo = nullptr) {
+static sk_sp<SkSurface> create_gpu_scratch_surface(GrContext* context,
+ SkAlphaType at = kPremul_SkAlphaType,
+ SkImageInfo* requestedInfo = nullptr) {
const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
if (requestedInfo) {
*requestedInfo = info;
}
- return SkSurface::NewRenderTarget(context, SkBudgeted::kYes, info, 0, nullptr);
+ return SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0, nullptr);
}
#endif
DEF_TEST(SurfaceEmpty, reporter) {
const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType);
- REPORTER_ASSERT(reporter, nullptr == SkSurface::NewRaster(info));
- REPORTER_ASSERT(reporter, nullptr == SkSurface::NewRasterDirect(info, nullptr, 0));
+ REPORTER_ASSERT(reporter, nullptr == SkSurface::MakeRaster(info));
+ REPORTER_ASSERT(reporter, nullptr == SkSurface::MakeRasterDirect(info, nullptr, 0));
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceEmpty_Gpu, reporter, context) {
const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType);
REPORTER_ASSERT(reporter, nullptr ==
- SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr));
+ SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, nullptr));
}
#endif
@@ -107,8 +107,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWrappedTexture, reporter, context) {
wrappedDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
wrappedDesc.fTextureHandle = texHandle;
- SkAutoTUnref<SkSurface> surface(
- SkSurface::NewWrappedRenderTarget(context, wrappedDesc, nullptr));
+ auto surface(SkSurface::MakeFromBackendTexture(context, wrappedDesc, nullptr));
REPORTER_ASSERT(reporter, surface);
if (surface) {
// Validate that we can draw to the canvas and that the original texture color is preserved
@@ -152,7 +151,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWrappedTexture, reporter, context) {
#endif
static void test_canvas_peek(skiatest::Reporter* reporter,
- SkSurface* surface,
+ sk_sp<SkSurface>& surface,
const SkImageInfo& requestInfo,
bool expectPeekSuccess) {
const SkColor color = SK_ColorRED;
@@ -181,7 +180,7 @@ static void test_canvas_peek(skiatest::Reporter* reporter,
DEF_TEST(SurfaceCanvasPeek, reporter) {
for (auto& surface_func : { &create_surface, &create_direct_surface }) {
SkImageInfo requestInfo;
- SkAutoTUnref<SkSurface> surface(surface_func(kPremul_SkAlphaType, &requestInfo));
+ auto surface(surface_func(kPremul_SkAlphaType, &requestInfo));
test_canvas_peek(reporter, surface, requestInfo, true);
}
}
@@ -189,7 +188,7 @@ DEF_TEST(SurfaceCanvasPeek, reporter) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCanvasPeek_Gpu, reporter, context) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
SkImageInfo requestInfo;
- SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaType, &requestInfo));
+ auto surface(surface_func(context, kPremul_SkAlphaType, &requestInfo));
test_canvas_peek(reporter, surface, requestInfo, false);
}
}
@@ -199,7 +198,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCanvasPeek_Gpu, reporter, context) {
// the bitmap's genID when we draw to it, else they won't know it has new values. When they are
// exclusively using surface/image, and we can hide accessBitmap from device, we can remove this
// test.
-void test_access_pixels(skiatest::Reporter* reporter, SkSurface* surface) {
+void test_access_pixels(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface) {
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0);
@@ -214,20 +213,20 @@ void test_access_pixels(skiatest::Reporter* reporter, SkSurface* surface) {
}
DEF_TEST(SurfaceAccessPixels, reporter) {
for (auto& surface_func : { &create_surface, &create_direct_surface }) {
- SkAutoTUnref<SkSurface> surface(surface_func(kPremul_SkAlphaType, nullptr));
+ auto surface(surface_func(kPremul_SkAlphaType, nullptr));
test_access_pixels(reporter, surface);
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceAccessPixels_Gpu, reporter, context) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
- SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaType, nullptr));
+ auto surface(surface_func(context, kPremul_SkAlphaType, nullptr));
test_access_pixels(reporter, surface);
}
}
#endif
-static void test_snapshot_alphatype(skiatest::Reporter* reporter, SkSurface* surface,
+static void test_snapshot_alphatype(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface,
bool expectOpaque) {
REPORTER_ASSERT(reporter, surface);
if (surface) {
@@ -242,7 +241,7 @@ DEF_TEST(SurfaceSnapshotAlphaType, reporter) {
for (auto& surface_func : { &create_surface, &create_direct_surface }) {
for (auto& isOpaque : { true, false }) {
SkAlphaType alphaType = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
- SkAutoTUnref<SkSurface> surface(surface_func(alphaType, nullptr));
+ auto surface(surface_func(alphaType, nullptr));
test_snapshot_alphatype(reporter, surface, isOpaque);
}
}
@@ -252,7 +251,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceSnapshotAlphaType_Gpu, reporter, conte
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
for (auto& isOpaque : { true, false }) {
SkAlphaType alphaType = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
- SkAutoTUnref<SkSurface> surface(surface_func(context, alphaType, nullptr));
+ auto surface(surface_func(context, alphaType, nullptr));
test_snapshot_alphatype(reporter, surface, isOpaque);
}
}
@@ -293,8 +292,8 @@ DEF_TEST(SurfaceBackendHandleAccessCopyOnWrite, reporter) {
for (auto& handle_access_func :
{ &get_surface_backend_texture_handle, &get_surface_backend_render_target_handle }) {
for (auto& accessMode : accessModes) {
- SkAutoTUnref<SkSurface> surface(create_surface());
- test_backend_handle_access_copy_on_write(reporter, surface, accessMode,
+ auto surface(create_surface());
+ test_backend_handle_access_copy_on_write(reporter, surface.get(), accessMode,
handle_access_func);
}
}
@@ -310,9 +309,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessCopyOnWrite_Gpu, re
for (auto& handle_access_func :
{ &get_surface_backend_texture_handle, &get_surface_backend_render_target_handle }) {
for (auto& accessMode : accessModes) {
- SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaType,
- nullptr));
- test_backend_handle_access_copy_on_write(reporter, surface, accessMode,
+ auto surface(surface_func(context, kPremul_SkAlphaType, nullptr));
+ test_backend_handle_access_copy_on_write(reporter, surface.get(), accessMode,
handle_access_func);
}
}
@@ -390,16 +388,18 @@ DEF_TEST(UniqueImageSnapshot, reporter) {
return reinterpret_cast<intptr_t>(pixels);
};
- SkAutoTUnref<SkSurface> surface(create_surface());
- test_unique_image_snap(reporter, surface, false, getImageBackingStore, getSufaceBackingStore);
- surface.reset(create_direct_surface());
- test_unique_image_snap(reporter, surface, true, getImageBackingStore, getSufaceBackingStore);
+ auto surface(create_surface());
+ test_unique_image_snap(reporter, surface.get(), false, getImageBackingStore,
+ getSufaceBackingStore);
+ surface = create_direct_surface();
+ test_unique_image_snap(reporter, surface.get(), true, getImageBackingStore,
+ getSufaceBackingStore);
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, context) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
- SkAutoTUnref<SkSurface> surface(surface_func(context, kOpaque_SkAlphaType, nullptr));
+ auto surface(surface_func(context, kOpaque_SkAlphaType, nullptr));
auto imageBackingStore = [reporter](SkImage* image) {
GrTexture* texture = as_IB(image)->peekTexture();
@@ -420,7 +420,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, context) {
return static_cast<intptr_t>(rt->getUniqueID());
};
- test_unique_image_snap(reporter, surface, false, imageBackingStore, surfaceBackingStore);
+ test_unique_image_snap(reporter, surface.get(), false, imageBackingStore,
+ surfaceBackingStore);
// Test again with a "direct" render target;
GrBackendObject textureObject = context->getGpu()->createTestingOnlyBackendTexture(nullptr,
@@ -433,9 +434,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, context) {
desc.fTextureHandle = textureObject;
GrTexture* texture = context->textureProvider()->wrapBackendTexture(desc);
{
- SkAutoTUnref<SkSurface> surface(
- SkSurface::NewRenderTargetDirect(texture->asRenderTarget()));
- test_unique_image_snap(reporter, surface, true, imageBackingStore,
+ auto surface(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget()));
+ test_unique_image_snap(reporter, surface.get(), true, imageBackingStore,
surfaceBackingStore);
}
texture->unref();
@@ -504,9 +504,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessIDs_Gpu, reporter,
for (auto& test_func : { &test_backend_handle_unique_id, &test_backend_handle_gen_id }) {
for (auto& handle_access_func :
{ &get_surface_backend_texture_handle, &get_surface_backend_render_target_handle}) {
- SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaType,
- nullptr));
- test_func(reporter, surface, handle_access_func);
+ auto surface(surface_func(context, kPremul_SkAlphaType, nullptr));
+ test_func(reporter, surface.get(), handle_access_func);
}
}
}
@@ -589,14 +588,13 @@ static void test_copy_on_write(skiatest::Reporter* reporter, SkSurface* surface)
testPaint))
}
DEF_TEST(SurfaceCopyOnWrite, reporter) {
- SkAutoTUnref<SkSurface> surface(create_surface());
- test_copy_on_write(reporter, surface);
+ test_copy_on_write(reporter, create_surface().get());
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCopyOnWrite_Gpu, reporter, context) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
- SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaType, nullptr));
- test_copy_on_write(reporter, surface);
+ auto surface(surface_func(context, kPremul_SkAlphaType, nullptr));
+ test_copy_on_write(reporter, surface.get());
}
}
#endif
@@ -612,14 +610,13 @@ static void test_writable_after_snapshot_release(skiatest::Reporter* reporter,
canvas->clear(2); // Must not assert internally
}
DEF_TEST(SurfaceWriteableAfterSnapshotRelease, reporter) {
- SkAutoTUnref<SkSurface> surface(create_surface());
- test_writable_after_snapshot_release(reporter, surface);
+ test_writable_after_snapshot_release(reporter, create_surface().get());
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWriteableAfterSnapshotRelease_Gpu, reporter, context) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
- SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaType, nullptr));
- test_writable_after_snapshot_release(reporter, surface);
+ auto surface(surface_func(context, kPremul_SkAlphaType, nullptr));
+ test_writable_after_snapshot_release(reporter, surface.get());
}
}
#endif
@@ -659,15 +656,15 @@ static void test_crbug263329(skiatest::Reporter* reporter,
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCRBug263329_Gpu, reporter, context) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
- SkAutoTUnref<SkSurface> surface1(surface_func(context, kPremul_SkAlphaType, nullptr));
- SkAutoTUnref<SkSurface> surface2(surface_func(context, kPremul_SkAlphaType, nullptr));
- test_crbug263329(reporter, surface1, surface2);
+ auto surface1(surface_func(context, kPremul_SkAlphaType, nullptr));
+ auto surface2(surface_func(context, kPremul_SkAlphaType, nullptr));
+ test_crbug263329(reporter, surface1.get(), surface2.get());
}
}
#endif
DEF_TEST(SurfaceGetTexture, reporter) {
- SkAutoTUnref<SkSurface> surface(create_surface());
+ auto surface(create_surface());
sk_sp<SkImage> image(surface->makeImageSnapshot());
REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == nullptr);
surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode);
@@ -676,7 +673,7 @@ DEF_TEST(SurfaceGetTexture, reporter) {
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, context) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
- SkAutoTUnref<SkSurface> surface(surface_func(context, kPremul_SkAlphaType, nullptr));
+ auto surface(surface_func(context, kPremul_SkAlphaType, nullptr));
sk_sp<SkImage> image(surface->makeImageSnapshot());
GrTexture* texture = as_IB(image)->peekTexture();
REPORTER_ASSERT(reporter, texture);
@@ -693,8 +690,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, context) {
#include "SkImage_Gpu.h"
#include "SkSurface_Gpu.h"
-static SkBudgeted is_budgeted(SkSurface* surf) {
- return ((SkSurface_Gpu*)surf)->getDevice()->accessRenderTarget()->resourcePriv().isBudgeted();
+static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) {
+ SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get();
+ return gsurf->getDevice()->accessRenderTarget()->resourcePriv().isBudgeted();
}
static SkBudgeted is_budgeted(SkImage* image) {
@@ -709,8 +707,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBudget, reporter, context) {
SkImageInfo info = SkImageInfo::MakeN32Premul(8,8);
for (auto sbudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
for (auto ibudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
- SkAutoTUnref<SkSurface>
- surface(SkSurface::NewRenderTarget(context, sbudgeted, info, 0));
+ auto surface(SkSurface::MakeRenderTarget(context, sbudgeted, info));
SkASSERT(surface);
REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface));
@@ -763,8 +760,7 @@ DEF_TEST(SurfaceNoCanvas, reporter) {
{ SkSurface::kDiscard_ContentChangeMode, SkSurface::kRetain_ContentChangeMode};
for (auto& test_func : { &test_no_canvas1, &test_no_canvas2 }) {
for (auto& mode : modes) {
- SkAutoTUnref<SkSurface> surface(create_surface());
- test_func(reporter, surface, mode);
+ test_func(reporter, create_surface().get(), mode);
}
}
}
@@ -775,9 +771,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceNoCanvas_Gpu, reporter, context) {
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
for (auto& test_func : { &test_no_canvas1, &test_no_canvas2 }) {
for (auto& mode : modes) {
- SkAutoTUnref<SkSurface> surface(
- surface_func(context, kPremul_SkAlphaType, nullptr));
- test_func(reporter, surface, mode);
+ auto surface(surface_func(context, kPremul_SkAlphaType, nullptr));
+ test_func(reporter, surface.get(), mode);
}
}
}
@@ -807,26 +802,25 @@ static void check_rowbytes_remain_consistent(SkSurface* surface, skiatest::Repor
DEF_TEST(surface_rowbytes, reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- SkAutoTUnref<SkSurface> surf0(SkSurface::NewRaster(info));
- check_rowbytes_remain_consistent(surf0, reporter);
+ auto surf0(SkSurface::MakeRaster(info));
+ check_rowbytes_remain_consistent(surf0.get(), reporter);
// specify a larger rowbytes
- SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info, 500, nullptr));
- check_rowbytes_remain_consistent(surf1, reporter);
+ auto surf1(SkSurface::MakeRaster(info, 500, nullptr));
+ check_rowbytes_remain_consistent(surf1.get(), reporter);
// Try some illegal rowByte values
- SkSurface* s = SkSurface::NewRaster(info, 396, nullptr); // needs to be at least 400
+ auto s = SkSurface::MakeRaster(info, 396, nullptr); // needs to be at least 400
REPORTER_ASSERT(reporter, nullptr == s);
- s = SkSurface::NewRaster(info, 1 << 30, nullptr); // allocation to large
+ s = SkSurface::MakeRaster(info, 1 << 30, nullptr); // allocation to large
REPORTER_ASSERT(reporter, nullptr == s);
}
#if SK_SUPPORT_GPU
-void test_surface_clear(skiatest::Reporter* reporter, SkSurface* surfacePtr,
+void test_surface_clear(skiatest::Reporter* reporter, sk_sp<SkSurface> surface,
std::function<GrSurface*(SkSurface*)> grSurfaceGetter,
uint32_t expectedValue) {
- SkAutoTUnref<SkSurface> surface(surfacePtr);
if (!surface) {
ERRORF(reporter, "Could not create GPU SkSurface.");
return;
@@ -836,12 +830,11 @@ void test_surface_clear(skiatest::Reporter* reporter, SkSurface* surfacePtr,
SkAutoTDeleteArray<uint32_t> pixels(new uint32_t[w * h]);
memset(pixels.get(), ~expectedValue, sizeof(uint32_t) * w * h);
- SkAutoTUnref<GrSurface> grSurface(SkSafeRef(grSurfaceGetter(surface)));
+ SkAutoTUnref<GrSurface> grSurface(SkSafeRef(grSurfaceGetter(surface.get())));
if (!grSurface) {
ERRORF(reporter, "Could access render target of GPU SkSurface.");
return;
}
- SkASSERT(surface->unique());
surface.reset();
grSurface->readPixels(0, 0, w, h, kRGBA_8888_GrPixelConfig, pixels.get());
for (int y = 0; y < h; ++y) {
@@ -875,7 +868,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, context) {
};
for (auto grSurfaceGetter : grSurfaceGetters) {
for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surface}) {
- SkSurface* surface = surface_func(context, kPremul_SkAlphaType, nullptr);
+ auto surface = surface_func(context, kPremul_SkAlphaType, nullptr);
test_surface_clear(reporter, surface, grSurfaceGetter, 0x0);
}
// Wrapped RTs are *not* supposed to clear (to allow client to partially update a surface).
@@ -895,7 +888,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, context) {
desc.fFlags = kRenderTarget_GrBackendTextureFlag;
desc.fTextureHandle = textureObject;
- SkSurface* surface = SkSurface::NewFromBackendTexture(context, desc, nullptr);
+ auto surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr);
test_surface_clear(reporter, surface, grSurfaceGetter, 0xABABABAB);
context->getGpu()->deleteTestingOnlyBackendTexture(textureObject);
}
diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp
index b7456d6b39..6ec32637cb 100644
--- a/tests/TextBlobCacheTest.cpp
+++ b/tests/TextBlobCacheTest.cpp
@@ -66,8 +66,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte
}
SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kN32_SkColorType, kPremul_SkAlphaType);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkBudgeted::kNo, info,
- 0, &props));
+ auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, &props));
REPORTER_ASSERT(reporter, surface);
if (!surface) {
return;
@@ -133,7 +132,7 @@ static void text_blob_cache_inner(skiatest::Reporter* reporter, GrContext* conte
// create surface where LCD is impossible
info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
SkSurfaceProps propsNoLCD(0, kUnknown_SkPixelGeometry);
- SkAutoTUnref<SkSurface> surfaceNoLCD(canvas->newSurface(info, &propsNoLCD));
+ auto surfaceNoLCD(canvas->makeSurface(info, &propsNoLCD));
REPORTER_ASSERT(reporter, surface);
if (!surface) {
return;
diff --git a/tests/TextureStorageAllocator.cpp b/tests/TextureStorageAllocator.cpp
index 5c9962e2c6..1d226861e2 100644
--- a/tests/TextureStorageAllocator.cpp
+++ b/tests/TextureStorageAllocator.cpp
@@ -66,7 +66,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTexture, reporter, context, glContext)
grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateTextureStorage;
grAllocator.fCtx = &allocator;
- SkAutoTUnref<SkSurface> surface(SkSurface_Gpu::NewRenderTarget(
+ auto surface(SkSurface_Gpu::MakeRenderTarget(
context, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0,
NULL, grAllocator));
REPORTER_ASSERT(reporter, surface);
@@ -100,7 +100,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CustomTextureFailure, reporter, context, glCo
grAllocator.fAllocateTextureStorage = &TestStorageAllocator::allocateTextureStorage;
grAllocator.fDeallocateTextureStorage= &TestStorageAllocator::deallocateTextureStorage;
grAllocator.fCtx = &allocator;
- SkAutoTUnref<SkSurface> surface(SkSurface_Gpu::NewRenderTarget(
+ auto surface(SkSurface_Gpu::MakeRenderTarget(
context, SkBudgeted::kNo, SkImageInfo::MakeN32Premul(kWidth, kHeight), 0,
NULL, grAllocator));
REPORTER_ASSERT(reporter, !surface);
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 0141bf351f..6dda6ff89e 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -294,7 +294,7 @@ static void call_writepixels(SkCanvas* canvas) {
DEF_TEST(WritePixelsSurfaceGenID, reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
+ auto surface(SkSurface::MakeRaster(info));
uint32_t genID1 = surface->generationID();
call_writepixels(surface->getCanvas());
uint32_t genID2 = surface->generationID();
@@ -400,8 +400,9 @@ DEF_TEST(WritePixels, reporter) {
if (!tightRowBytes) {
memset(pixels, DEV_PAD, size);
}
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterDirectReleaseProc(info, pixels, rowBytes, free_pixels, nullptr));
- test_write_pixels(reporter, surface);
+ auto surface(SkSurface::MakeRasterDirectReleaseProc(info, pixels, rowBytes,
+ free_pixels, nullptr));
+ test_write_pixels(reporter, surface.get());
}
}
#if SK_SUPPORT_GPU
@@ -415,8 +416,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixels_Gpu, reporter, context) {
desc.fOrigin = origin;
SkAutoTUnref<GrTexture> texture(context->textureProvider()->createTexture(desc,
SkBudgeted::kNo));
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect(texture->asRenderTarget()));
- test_write_pixels(reporter, surface);
+ auto surface(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget()));
+ test_write_pixels(reporter, surface.get());
}
}
#endif