aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-18 07:25:55 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-18 07:25:55 -0700
commitca2622ba051829fed5f30facd74c5b41cd4b931c (patch)
tree3d8248b7764e500f857b3d6cfb6866e72b632199 /tests
parenteb75c7db3a7372de68347d0df8d58acebc33a9ad (diff)
return pictures as sk_sp
Diffstat (limited to 'tests')
-rw-r--r--tests/CanvasTest.cpp3
-rw-r--r--tests/GpuLayerCacheTest.cpp4
-rw-r--r--tests/ImageFilterTest.cpp31
-rw-r--r--tests/ImageTest.cpp8
-rw-r--r--tests/PathOpsSkpClipTest.cpp22
-rw-r--r--tests/PictureBBHTest.cpp2
-rw-r--r--tests/PictureShaderTest.cpp4
-rw-r--r--tests/PictureTest.cpp131
-rw-r--r--tests/RecordOptsTest.cpp6
-rw-r--r--tests/RecordReplaceDrawTest.cpp18
-rw-r--r--tests/RecordingXfermodeTest.cpp2
-rw-r--r--tests/SerializationTest.cpp17
-rw-r--r--tests/SkResourceCacheTest.cpp4
-rw-r--r--tests/SkpSkGrTest.cpp12
14 files changed, 127 insertions, 137 deletions
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 8681ca4f18..05ce60469b 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -431,9 +431,8 @@ static void DrawPictureTestStep(SkCanvas* canvas, const TestData& d,
testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
testCanvas->clipRect(d.fRect);
testCanvas->drawRect(d.fRect, d.fPaint);
- SkAutoTUnref<SkPicture> testPicture(recorder.endRecording());
- canvas->drawPicture(testPicture);
+ canvas->drawPicture(recorder.finishRecordingAsPicture());
}
TEST_STEP(DrawPicture, DrawPictureTestStep);
diff --git a/tests/GpuLayerCacheTest.cpp b/tests/GpuLayerCacheTest.cpp
index ba5134085a..bbc021fc78 100644
--- a/tests/GpuLayerCacheTest.cpp
+++ b/tests/GpuLayerCacheTest.cpp
@@ -115,7 +115,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GpuLayerCache, reporter, context) {
GrResourceCache::Stats stats;
#endif
- SkAutoTUnref<const SkPicture> picture;
+ sk_sp<SkPicture> picture;
{
SkPictureRecorder recorder;
@@ -123,7 +123,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GpuLayerCache, reporter, context) {
// Draw something, anything, to prevent an empty-picture optimization,
// which is a singleton and never purged.
c->drawRect(SkRect::MakeWH(1,1), SkPaint());
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
}
GrResourceCache* resourceCache = context->getResourceCache();
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index a648cb08dc..6a2f942658 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -590,7 +590,7 @@ DEF_TEST(ImageFilterDrawTiled, reporter) {
SkPaint greenPaint;
greenPaint.setColor(SK_ColorGREEN);
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 30, 20)), greenPaint);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkAutoTUnref<SkImageFilter> pictureFilter(SkPictureImageFilter::Create(picture.get()));
SkAutoTUnref<SkShader> shader(SkPerlinNoiseShader::CreateTurbulence(SK_Scalar1, SK_Scalar1, 1, 0));
SkPaint noisePaint;
@@ -707,7 +707,7 @@ static void draw_saveLayer_picture(int width, int height, int tileSize,
recordingCanvas->translate(-55, 0);
recordingCanvas->saveLayer(&bounds, &paint);
recordingCanvas->restore();
- SkAutoTUnref<SkPicture> picture1(recorder.endRecording());
+ sk_sp<SkPicture> picture1(recorder.finishRecordingAsPicture());
result->allocN32Pixels(width, height);
SkCanvas canvas(*result);
@@ -900,13 +900,13 @@ DEF_TEST(ImageFilterDrawTiledBlurRTree, reporter) {
&factory, 0);
draw_blurred_rect(recordingCanvas1);
draw_blurred_rect(recordingCanvas2);
- SkAutoTUnref<SkPicture> picture1(recorder1.endRecording());
- SkAutoTUnref<SkPicture> picture2(recorder2.endRecording());
+ sk_sp<SkPicture> picture1(recorder1.finishRecordingAsPicture());
+ sk_sp<SkPicture> picture2(recorder2.finishRecordingAsPicture());
for (int y = 0; y < height; y += tileSize) {
for (int x = 0; x < width; x += tileSize) {
SkRect tileRect = SkRect::Make(SkIRect::MakeXYWH(x, y, tileSize, tileSize));
- draw_picture_clipped(&canvas1, tileRect, picture1);
- draw_picture_clipped(&canvas2, tileRect, picture2);
+ draw_picture_clipped(&canvas1, tileRect, picture1.get());
+ draw_picture_clipped(&canvas2, tileRect, picture2.get());
}
}
for (int y = 0; y < height; y++) {
@@ -1010,9 +1010,8 @@ DEF_TEST(ImageFilterMatrix, reporter) {
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPaint);
recordingCanvas->restore(); // scale
recordingCanvas->restore(); // saveLayer
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- canvas.drawPicture(picture);
+ canvas.drawPicture(recorder.finishRecordingAsPicture());
}
DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) {
@@ -1024,7 +1023,7 @@ DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) {
SkPaint greenPaint;
greenPaint.setColor(SK_ColorGREEN);
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// Wrap that SkPicture in an SkPictureImageFilter.
SkAutoTUnref<SkImageFilter> imageFilter(
@@ -1040,7 +1039,7 @@ DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) {
redPaintWithFilter.setColor(SK_ColorRED);
redPaintWithFilter.setImageFilter(imageFilter.get());
outerCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWithFilter);
- SkAutoTUnref<SkPicture> outerPicture(outerRecorder.endRecording());
+ sk_sp<SkPicture> outerPicture(outerRecorder.finishRecordingAsPicture());
SkBitmap bitmap;
bitmap.allocN32Pixels(1, 1);
@@ -1064,7 +1063,7 @@ DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) {
SkPictureRecorder crossProcessRecorder;
SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &factory, 0);
crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWithFilter);
- SkAutoTUnref<SkPicture> crossProcessPicture(crossProcessRecorder.endRecording());
+ sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsPicture());
canvas.clear(0x0);
canvas.drawPicture(crossProcessPicture);
@@ -1078,7 +1077,7 @@ DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) {
static void test_clipped_picture_imagefilter(SkImageFilter::Proxy* proxy,
skiatest::Reporter* reporter,
GrContext* context) {
- SkAutoTUnref<SkPicture> picture;
+ sk_sp<SkPicture> picture;
{
SkRTreeFactory factory;
@@ -1089,7 +1088,7 @@ static void test_clipped_picture_imagefilter(SkImageFilter::Proxy* proxy,
SkPaint greenPaint;
greenPaint.setColor(SK_ColorGREEN);
recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint);
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
}
sk_sp<SkSpecialImage> srcImg(create_empty_special_image(context, proxy, 2));
@@ -1138,7 +1137,7 @@ DEF_TEST(ImageFilterEmptySaveLayer, reporter) {
SkCanvas* recordingCanvas = recorder.beginRecording(10, 10, &factory, 0);
recordingCanvas->saveLayer(&bounds, &imageFilterPaint);
recordingCanvas->restore();
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
canvas.clear(0);
canvas.drawPicture(picture);
@@ -1148,7 +1147,7 @@ DEF_TEST(ImageFilterEmptySaveLayer, reporter) {
recordingCanvas = recorder.beginRecording(10, 10, &factory, 0);
recordingCanvas->saveLayer(nullptr, &imageFilterPaint);
recordingCanvas->restore();
- SkAutoTUnref<SkPicture> picture2(recorder.endRecording());
+ sk_sp<SkPicture> picture2(recorder.finishRecordingAsPicture());
canvas.clear(0);
canvas.drawPicture(picture2);
@@ -1158,7 +1157,7 @@ DEF_TEST(ImageFilterEmptySaveLayer, reporter) {
recordingCanvas = recorder.beginRecording(10, 10, &factory, 0);
recordingCanvas->saveLayer(&bounds, &colorFilterPaint);
recordingCanvas->restore();
- SkAutoTUnref<SkPicture> picture3(recorder.endRecording());
+ sk_sp<SkPicture> picture3(recorder.finishRecordingAsPicture());
canvas.clear(0);
canvas.drawPicture(picture3);
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 4781aea625..ce3cb99265 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -111,8 +111,8 @@ static sk_sp<SkImage> create_picture_image() {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->clear(SK_ColorCYAN);
- sk_sp<SkPicture> picture(recorder.endRecording());
- return SkImage::MakeFromPicture(picture, SkISize::Make(10, 10), nullptr, nullptr);
+ return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(), SkISize::Make(10, 10),
+ nullptr, nullptr);
};
#endif
// Want to ensure that our Release is called when the owning image is destroyed
@@ -232,7 +232,7 @@ DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(100, 100);
canvas->drawImage(image, 0, 0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, picture);
REPORTER_ASSERT(reporter, picture->approximateOpCount() > 0);
@@ -247,7 +247,7 @@ DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
REPORTER_ASSERT(reporter, serializers[i]->didEncode());
SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
- SkAutoTUnref<SkPicture> deserialized(SkPicture::CreateFromStream(rstream));
+ sk_sp<SkPicture> deserialized(SkPicture::MakeFromStream(rstream));
REPORTER_ASSERT(reporter, deserialized);
REPORTER_ASSERT(reporter, deserialized->approximateOpCount() > 0);
}
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
index 6d66a69e6d..d11f8e0634 100644
--- a/tests/PathOpsSkpClipTest.cpp
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -437,7 +437,7 @@ static void writePict(const SkBitmap& bitmap, const char* outDir, const char* pn
}
void TestResult::testOne() {
- SkPicture* pic = nullptr;
+ sk_sp<SkPicture> pic;
{
#if DEBUG_SHOW_TEST_NAME
if (fTestStep == kCompareBits) {
@@ -465,12 +465,12 @@ void TestResult::testOne() {
SkFILEStream stream(path.c_str());
if (!stream.isValid()) {
SkDebugf("invalid stream %s\n", path.c_str());
- goto finish;
+ return;
}
- pic = SkPicture::CreateFromStream(&stream);
+ pic = SkPicture::MakeFromStream(&stream);
if (!pic) {
SkDebugf("unable to decode %s\n", fFilename);
- goto finish;
+ return;
}
SkScalar width = pic->cullRect().width();
SkScalar height = pic->cullRect().height();
@@ -490,7 +490,7 @@ void TestResult::testOne() {
if (fScale >= 256) {
SkDebugf("unable to allocate bitmap for %s (w=%f h=%f)\n", fFilename,
width, height);
- goto finish;
+ return;
}
oldBitmap.eraseColor(SK_ColorWHITE);
SkCanvas oldCanvas(oldBitmap);
@@ -498,12 +498,12 @@ void TestResult::testOne() {
opBitmap.eraseColor(SK_ColorWHITE);
SkCanvas opCanvas(opBitmap);
opCanvas.setAllowSimplifyClip(true);
- drawPict(pic, &oldCanvas, fScale);
- drawPict(pic, &opCanvas, fScale);
+ drawPict(pic.get(), &oldCanvas, fScale);
+ drawPict(pic.get(), &opCanvas, fScale);
if (fTestStep == kCompareBits) {
fPixelError = similarBits(oldBitmap, opBitmap);
- int oldTime = timePict(pic, &oldCanvas);
- int opTime = timePict(pic, &opCanvas);
+ int oldTime = timePict(pic.get(), &oldCanvas);
+ int opTime = timePict(pic.get(), &opCanvas);
fTime = SkTMax(0, oldTime - opTime);
} else if (fTestStep == kEncodeFiles) {
SkString pngStr = make_png_name(fFilename);
@@ -512,10 +512,6 @@ void TestResult::testOne() {
writePict(opBitmap, outOpDir, pngName);
}
}
-finish:
- if (pic) {
- pic->unref();
- }
}
DEFINE_string2(match, m, "PathOpsSkpClipThreaded",
diff --git a/tests/PictureBBHTest.cpp b/tests/PictureBBHTest.cpp
index 0a0d3da914..deb299ae69 100644
--- a/tests/PictureBBHTest.cpp
+++ b/tests/PictureBBHTest.cpp
@@ -45,7 +45,7 @@ private:
SkIntToScalar(fPictureHeight),
factory);
this->doTest(playbackCanvas, *recordCanvas);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
playbackCanvas.drawPicture(picture);
REPORTER_ASSERT(reporter, SK_ColorGREEN == fResultBitmap.getColor(0, 0));
}
diff --git a/tests/PictureShaderTest.cpp b/tests/PictureShaderTest.cpp
index 4da7aab511..78d59afd41 100644
--- a/tests/PictureShaderTest.cpp
+++ b/tests/PictureShaderTest.cpp
@@ -31,8 +31,8 @@ DEF_TEST(PictureShader_empty, reporter) {
SkPictureRecorder factory;
factory.beginRecording(0, 0, nullptr, 0);
- sk_sp<SkPicture> picture(factory.endRecording());
- paint.setShader(SkShader::MakePictureShader(std::move(picture), SkShader::kClamp_TileMode,
+ paint.setShader(SkShader::MakePictureShader(factory.finishRecordingAsPicture(),
+ SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode, nullptr, nullptr));
canvas.drawRect(SkRect::MakeWH(1,1), paint);
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index ba787a0c1b..0ac50d97f9 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -54,7 +54,7 @@ static void test_images_are_found_by_willPlayBackBitmaps(skiatest::Reporter* rep
SkPictureRecorder recorder;
recorder.beginRecording(100,100)->drawImage(image, 0,0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps());
}
@@ -67,7 +67,7 @@ static void test_analysis(skiatest::Reporter* reporter) {
{
canvas->drawRect(SkRect::MakeWH(10, 10), SkPaint ());
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, !picture->willPlayBackBitmaps());
canvas = recorder.beginRecording(100, 100);
@@ -85,8 +85,7 @@ static void test_analysis(skiatest::Reporter* reporter) {
canvas->drawRect(SkRect::MakeWH(10, 10), paint);
}
- picture.reset(recorder.endRecording());
- REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps());
+ REPORTER_ASSERT(reporter, recorder.finishRecordingAsPicture()->willPlayBackBitmaps());
}
@@ -98,7 +97,7 @@ static void test_deleting_empty_picture() {
// Creates an SkPictureRecord
recorder.beginRecording(0, 0);
// Turns that into an SkPicture
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// Ceates a new SkPictureRecord
recorder.beginRecording(0, 0);
}
@@ -107,7 +106,7 @@ static void test_deleting_empty_picture() {
static void test_serializing_empty_picture() {
SkPictureRecorder recorder;
recorder.beginRecording(0, 0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkDynamicMemoryWStream stream;
picture->serialize(&stream);
}
@@ -155,7 +154,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
canvas->drawPath(path, paint);
}
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// path effects currently render an SkPicture undesireable for GPU rendering
const char *reason = nullptr;
@@ -180,7 +179,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
canvas->drawPath(path, paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// A lot of small AA concave paths should be fine for GPU rendering
REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
@@ -202,7 +201,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
canvas->drawPath(path, paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// A lot of large AA concave paths currently render an SkPicture undesireable for GPU rendering
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
@@ -226,7 +225,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
canvas->drawPath(path, paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// hairline stroked AA concave paths are fine for GPU rendering
REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
@@ -243,7 +242,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// fast-path dashed effects are fine for GPU rendering ...
REPORTER_ASSERT(reporter, picture->suitableForGpuRasterization(nullptr));
@@ -258,7 +257,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
canvas->drawRect(SkRect::MakeWH(10, 10), paint);
}
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
// ... but only when applied to drawPoint() calls
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
@@ -267,7 +266,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
{
canvas->drawPicture(picture.get());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(nullptr));
}
@@ -287,7 +286,7 @@ static void test_savelayer_extraction(skiatest::Reporter* reporter) {
SkPaint complexPaint;
complexPaint.setImageFilter(filter);
- SkAutoTUnref<SkPicture> pict, child;
+ sk_sp<SkPicture> pict, child;
SkRTreeFactory bbhFactory;
{
@@ -300,7 +299,7 @@ static void test_savelayer_extraction(skiatest::Reporter* reporter) {
c->saveLayer(nullptr, &complexPaint);
c->restore();
- child.reset(recorder.endRecording());
+ child = recorder.finishRecordingAsPicture();
}
// create a picture with the structure:
@@ -368,7 +367,7 @@ static void test_savelayer_extraction(skiatest::Reporter* reporter) {
c->restore();
}
- pict.reset(recorder.endRecording());
+ pict = recorder.finishRecordingAsPicture();
}
// Now test out the SaveLayer extraction
@@ -446,7 +445,7 @@ static void test_savelayer_extraction(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, !info4.fIsNested &&
info4.fHasNestedLayers); // has a nested SL
- REPORTER_ASSERT(reporter, child == info5.fPicture); // in a child picture
+ REPORTER_ASSERT(reporter, child.get() == info5.fPicture); // in a child picture
REPORTER_ASSERT(reporter, kWidth == info5.fBounds.width() &&
kHeight == info5.fBounds.height());
REPORTER_ASSERT(reporter, 0 == info5.fBounds.fLeft && 0 == info5.fBounds.fTop);
@@ -465,7 +464,7 @@ static void test_savelayer_extraction(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, !info6.fIsNested &&
info6.fHasNestedLayers); // has a nested SL
- REPORTER_ASSERT(reporter, child == info7.fPicture); // in a child picture
+ REPORTER_ASSERT(reporter, child.get() == info7.fPicture); // in a child picture
REPORTER_ASSERT(reporter, kWidth == info7.fBounds.width() &&
kHeight == info7.fBounds.height());
REPORTER_ASSERT(reporter, 0 == info7.fBounds.fLeft && 0 == info7.fBounds.fTop);
@@ -483,7 +482,7 @@ static void test_has_text(skiatest::Reporter* reporter) {
{
canvas->drawRect(SkRect::MakeWH(20, 20), SkPaint());
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, !picture->hasText());
SkPoint point = SkPoint::Make(10, 10);
@@ -491,21 +490,21 @@ static void test_has_text(skiatest::Reporter* reporter) {
{
canvas->drawText("Q", 1, point.fX, point.fY, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
canvas = recorder.beginRecording(100,100);
{
canvas->drawPosText("Q", 1, &point, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
canvas = recorder.beginRecording(100,100);
{
canvas->drawPosTextH("Q", 1, &point.fX, point.fY, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
canvas = recorder.beginRecording(100,100);
@@ -516,7 +515,7 @@ static void test_has_text(skiatest::Reporter* reporter) {
canvas->drawTextOnPathHV("Q", 1, path, point.fX, point.fY, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
canvas = recorder.beginRecording(100,100);
@@ -527,7 +526,7 @@ static void test_has_text(skiatest::Reporter* reporter) {
canvas->drawTextOnPath("Q", 1, path, nullptr, SkPaint());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
// Nest the previous picture inside a new one.
@@ -535,7 +534,7 @@ static void test_has_text(skiatest::Reporter* reporter) {
{
canvas->drawPicture(picture.get());
}
- picture.reset(recorder.endRecording());
+ picture = recorder.finishRecordingAsPicture();
REPORTER_ASSERT(reporter, picture->hasText());
}
@@ -604,14 +603,14 @@ void check_save_state(skiatest::Reporter* reporter, SkPicture* picture,
// the 'partialReplay' method.
class SkPictureRecorderReplayTester {
public:
- static SkPicture* Copy(SkPictureRecorder* recorder) {
+ static sk_sp<SkPicture> Copy(SkPictureRecorder* recorder) {
SkPictureRecorder recorder2;
SkCanvas* canvas = recorder2.beginRecording(10, 10);
recorder->partialReplay(canvas);
- return recorder2.endRecording();
+ return recorder2.finishRecordingAsPicture();
}
};
@@ -664,19 +663,19 @@ DEF_TEST(PictureRecorder_replay, reporter) {
canvas->saveLayer(nullptr, nullptr);
- SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
+ sk_sp<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
// The extra save and restore comes from the Copy process.
- check_save_state(reporter, copy, 2, 1, 3);
+ check_save_state(reporter, copy.get(), 2, 1, 3);
canvas->saveLayer(nullptr, nullptr);
- SkAutoTUnref<SkPicture> final(recorder.endRecording());
+ sk_sp<SkPicture> final(recorder.finishRecordingAsPicture());
- check_save_state(reporter, final, 1, 2, 3);
+ check_save_state(reporter, final.get(), 1, 2, 3);
// The copy shouldn't pick up any operations added after it was made
- check_save_state(reporter, copy, 2, 1, 3);
+ check_save_state(reporter, copy.get(), 2, 1, 3);
}
// (partially) check leakage of draw ops
@@ -690,7 +689,7 @@ DEF_TEST(PictureRecorder_replay, reporter) {
canvas->drawRect(r, p);
- SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
+ sk_sp<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps());
@@ -700,7 +699,7 @@ DEF_TEST(PictureRecorder_replay, reporter) {
r.offset(5.0f, 5.0f);
canvas->drawBitmapRect(bm, r, nullptr);
- SkAutoTUnref<SkPicture> final(recorder.endRecording());
+ sk_sp<SkPicture> final(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, final->willPlayBackBitmaps());
REPORTER_ASSERT(reporter, copy->uniqueID() != final->uniqueID());
@@ -718,14 +717,14 @@ DEF_TEST(PictureRecorder_replay, reporter) {
int expectedSaveCount = canvas->getSaveCount();
- SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
- check_balance(reporter, copy);
+ sk_sp<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&recorder));
+ check_balance(reporter, copy.get());
REPORTER_ASSERT(reporter, expectedSaveCount = canvas->getSaveCount());
// End the recording of source to test the picture finalization
// process isn't complicated by the partialReplay step
- SkAutoTUnref<SkPicture> final(recorder.endRecording());
+ sk_sp<SkPicture> final(recorder.finishRecordingAsPicture());
}
}
@@ -749,7 +748,7 @@ static void test_unbalanced_save_restores(skiatest::Reporter* reporter) {
canvas->save();
canvas->translate(10, 10);
canvas->drawRect(rect, paint);
- SkAutoTUnref<SkPicture> extraSavePicture(recorder.endRecording());
+ sk_sp<SkPicture> extraSavePicture(recorder.finishRecordingAsPicture());
testCanvas.drawPicture(extraSavePicture);
REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount());
@@ -770,7 +769,7 @@ static void test_unbalanced_save_restores(skiatest::Reporter* reporter) {
canvas->restore();
canvas->restore();
canvas->restore();
- SkAutoTUnref<SkPicture> extraRestorePicture(recorder.endRecording());
+ sk_sp<SkPicture> extraRestorePicture(recorder.finishRecordingAsPicture());
testCanvas.drawPicture(extraRestorePicture);
REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount());
@@ -782,7 +781,7 @@ static void test_unbalanced_save_restores(skiatest::Reporter* reporter) {
SkCanvas* canvas = recorder.beginRecording(100, 100);
canvas->translate(10, 10);
canvas->drawRect(rect, paint);
- SkAutoTUnref<SkPicture> noSavePicture(recorder.endRecording());
+ sk_sp<SkPicture> noSavePicture(recorder.finishRecordingAsPicture());
testCanvas.drawPicture(noSavePicture);
REPORTER_ASSERT(reporter, 4 == testCanvas.getSaveCount());
@@ -803,7 +802,7 @@ static void test_peephole() {
for (int i = 0; i < 1000; ++i) {
rand_op(canvas, rand);
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
rand = rand2;
}
@@ -819,7 +818,7 @@ static void test_peephole() {
canvas->clipRect(rect);
canvas->restore();
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
}
}
@@ -834,7 +833,7 @@ static void test_bad_bitmap() {
SkPictureRecorder recorder;
SkCanvas* recordingCanvas = recorder.beginRecording(100, 100);
recordingCanvas->drawBitmap(bm, 0, 0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkCanvas canvas;
canvas.drawPicture(picture);
@@ -846,7 +845,7 @@ static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) {
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()),
SkIntToScalar(bitmap.height()));
canvas->drawBitmap(bitmap, 0, 0);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkDynamicMemoryWStream wStream;
SkAutoTUnref<SkPixelSerializer> serializer(
@@ -911,7 +910,7 @@ DEF_TEST(Picture_EncodedData, reporter) {
SkSetErrorCallback(assert_one_parse_error_cb, &context);
SkMemoryStream pictureStream(picture1);
SkClearLastError();
- SkAutoTUnref<SkPicture> pictureFromStream(SkPicture::CreateFromStream(&pictureStream, nullptr));
+ sk_sp<SkPicture> pictureFromStream(SkPicture::MakeFromStream(&pictureStream, nullptr));
REPORTER_ASSERT(reporter, pictureFromStream.get() != nullptr);
SkClearLastError();
SkSetErrorCallback(nullptr, nullptr);
@@ -927,7 +926,7 @@ DEF_TEST(Picture_EncodedData, reporter) {
SkCanvas canvas(dst);
pictureStream.rewind();
- pictureFromStream.reset(SkPicture::CreateFromStream(&pictureStream));
+ pictureFromStream = SkPicture::MakeFromStream(&pictureStream);
canvas.drawPicture(pictureFromStream.get());
SkMD5::Digest digest2;
@@ -1032,7 +1031,7 @@ static void test_cull_rect_reset(skiatest::Reporter* reporter) {
SkPaint paint;
canvas->drawRect(bounds, paint);
canvas->drawRect(bounds, paint);
- SkAutoTUnref<const SkPicture> p(recorder.endRecordingAsPicture(bounds));
+ sk_sp<SkPicture> p(recorder.finishRecordingAsPictureWithCull(bounds));
const SkBigPicture* picture = p->asSkBigPicture();
REPORTER_ASSERT(reporter, picture);
@@ -1106,7 +1105,7 @@ static void test_clip_expansion(skiatest::Reporter* reporter) {
SkPaint p;
p.setColor(SK_ColorBLUE);
canvas->drawPaint(p);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
ClipCountingCanvas testCanvas(10, 10);
picture->playback(&testCanvas);
@@ -1122,37 +1121,37 @@ static void test_hierarchical(skiatest::Reporter* reporter) {
SkPictureRecorder recorder;
recorder.beginRecording(10, 10);
- SkAutoTUnref<SkPicture> childPlain(recorder.endRecording());
+ sk_sp<SkPicture> childPlain(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, !childPlain->willPlayBackBitmaps()); // 0
recorder.beginRecording(10, 10)->drawBitmap(bm, 0, 0);
- SkAutoTUnref<SkPicture> childWithBitmap(recorder.endRecording());
+ sk_sp<SkPicture> childWithBitmap(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, childWithBitmap->willPlayBackBitmaps()); // 1
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->drawPicture(childPlain);
- SkAutoTUnref<SkPicture> parentPP(recorder.endRecording());
+ sk_sp<SkPicture> parentPP(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, !parentPP->willPlayBackBitmaps()); // 0
}
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->drawPicture(childWithBitmap);
- SkAutoTUnref<SkPicture> parentPWB(recorder.endRecording());
+ sk_sp<SkPicture> parentPWB(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, parentPWB->willPlayBackBitmaps()); // 1
}
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->drawBitmap(bm, 0, 0);
canvas->drawPicture(childPlain);
- SkAutoTUnref<SkPicture> parentWBP(recorder.endRecording());
+ sk_sp<SkPicture> parentWBP(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, parentWBP->willPlayBackBitmaps()); // 1
}
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->drawBitmap(bm, 0, 0);
canvas->drawPicture(childWithBitmap);
- SkAutoTUnref<SkPicture> parentWBWB(recorder.endRecording());
+ sk_sp<SkPicture> parentWBWB(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, parentWBWB->willPlayBackBitmaps()); // 2
}
}
@@ -1161,14 +1160,14 @@ static void test_gen_id(skiatest::Reporter* reporter) {
SkPictureRecorder recorder;
recorder.beginRecording(0, 0);
- SkAutoTUnref<SkPicture> empty(recorder.endRecording());
+ sk_sp<SkPicture> empty(recorder.finishRecordingAsPicture());
// Empty pictures should still have a valid ID
REPORTER_ASSERT(reporter, empty->uniqueID() != SK_InvalidGenID);
SkCanvas* canvas = recorder.beginRecording(1, 1);
canvas->drawARGB(255, 255, 255, 255);
- SkAutoTUnref<SkPicture> hasData(recorder.endRecording());
+ sk_sp<SkPicture> hasData(recorder.finishRecordingAsPicture());
// picture should have a non-zero id after recording
REPORTER_ASSERT(reporter, hasData->uniqueID() != SK_InvalidGenID);
@@ -1182,7 +1181,7 @@ static void test_typeface(skiatest::Reporter* reporter) {
SkPaint paint;
paint.setTypeface(SkTypeface::CreateFromName("Arial", SkTypeface::kItalic));
canvas->drawText("Q", 1, 0, 10, paint);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
REPORTER_ASSERT(reporter, picture->hasText());
SkDynamicMemoryWStream stream;
picture->serialize(&stream);
@@ -1234,7 +1233,7 @@ static void test_draw_bitmaps(SkCanvas* canvas) {
DEF_TEST(Picture_EmptyBitmap, r) {
SkPictureRecorder recorder;
test_draw_bitmaps(recorder.beginRecording(10, 10));
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
}
DEF_TEST(Canvas_EmptyBitmap, r) {
@@ -1277,7 +1276,7 @@ DEF_TEST(DontOptimizeSaveLayerDrawDrawRestore, reporter) {
canvas->drawBitmap(redBM, 50, 50);
canvas->restore();
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// Now replay the picture back on another canvas
// and check a couple of its pixels.
@@ -1329,7 +1328,7 @@ DEF_TEST(Picture_SkipBBH, r) {
// Record a few ops so we don't hit a small- or empty- picture optimization.
c->drawRect(bound, SkPaint());
c->drawRect(bound, SkPaint());
- SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkCanvas big(640, 480), small(300, 200);
@@ -1352,7 +1351,7 @@ DEF_TEST(Picture_BitmapLeak, r) {
REPORTER_ASSERT(r, mut.pixelRef()->unique());
REPORTER_ASSERT(r, immut.pixelRef()->unique());
- SkAutoTUnref<const SkPicture> pic;
+ sk_sp<SkPicture> pic;
{
// we want the recorder to go out of scope before our subsequent checks, so we
// place it inside local braces.
@@ -1360,7 +1359,7 @@ DEF_TEST(Picture_BitmapLeak, r) {
SkCanvas* canvas = rec.beginRecording(1920, 1200);
canvas->drawBitmap(mut, 0, 0);
canvas->drawBitmap(immut, 800, 600);
- pic.reset(rec.endRecording());
+ pic = rec.finishRecordingAsPicture();
}
// The picture shares the immutable pixels but copies the mutable ones.
@@ -1368,7 +1367,7 @@ DEF_TEST(Picture_BitmapLeak, r) {
REPORTER_ASSERT(r, !immut.pixelRef()->unique());
// When the picture goes away, it's just our bitmaps holding the refs.
- pic.reset(nullptr);
+ pic = nullptr;
REPORTER_ASSERT(r, mut.pixelRef()->unique());
REPORTER_ASSERT(r, immut.pixelRef()->unique());
}
@@ -1380,7 +1379,7 @@ DEF_TEST(Picture_getRecordingCanvas, r) {
for (int i = 0; i < 3; i++) {
rec.beginRecording(100, 100);
REPORTER_ASSERT(r, rec.getRecordingCanvas());
- rec.endRecording()->unref();
+ rec.finishRecordingAsPicture();
REPORTER_ASSERT(r, !rec.getRecordingCanvas());
}
}
@@ -1401,12 +1400,12 @@ DEF_TEST(Picture_preserveCullRect, r) {
SkCanvas* c = recorder.beginRecording(SkRect::MakeLTRB(1, 2, 3, 4));
c->clear(SK_ColorCYAN);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkDynamicMemoryWStream wstream;
picture->serialize(&wstream);
SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
- SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstream));
+ sk_sp<SkPicture> deserializedPicture(SkPicture::MakeFromStream(rstream));
REPORTER_ASSERT(r, deserializedPicture != nullptr);
REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
diff --git a/tests/RecordOptsTest.cpp b/tests/RecordOptsTest.cpp
index 027ea39f57..597639e543 100644
--- a/tests/RecordOptsTest.cpp
+++ b/tests/RecordOptsTest.cpp
@@ -230,16 +230,16 @@ DEF_TEST(RecordOpts_MergeSvgOpacityAndFilterLayers, r) {
opaqueFilterLayerPaint.setColor(0xFF020202); // Opaque.
SkPaint translucentFilterLayerPaint;
translucentFilterLayerPaint.setColor(0x0F020202); // Not opaque.
- SkAutoTUnref<SkPicture> shape;
+ sk_sp<SkPicture> shape;
{
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(100), SkIntToScalar(100));
SkPaint shapePaint;
shapePaint.setColor(SK_ColorWHITE);
canvas->drawRect(SkRect::MakeWH(SkIntToScalar(50), SkIntToScalar(50)), shapePaint);
- shape.reset(recorder.endRecordingAsPicture());
+ shape = recorder.finishRecordingAsPicture();
}
- translucentFilterLayerPaint.setImageFilter(SkPictureImageFilter::Create(shape))->unref();
+ translucentFilterLayerPaint.setImageFilter(SkPictureImageFilter::Create(shape.get()))->unref();
int index = 0;
diff --git a/tests/RecordReplaceDrawTest.cpp b/tests/RecordReplaceDrawTest.cpp
index 216f1ca85d..73c6647686 100644
--- a/tests/RecordReplaceDrawTest.cpp
+++ b/tests/RecordReplaceDrawTest.cpp
@@ -33,7 +33,7 @@ private:
// Make sure the abort callback works
DEF_TEST(RecordReplaceDraw_Abort, r) {
- SkAutoTUnref<const SkPicture> pic;
+ sk_sp<SkPicture> pic;
{
// Record two commands.
@@ -43,14 +43,14 @@ DEF_TEST(RecordReplaceDraw_Abort, r) {
canvas->drawRect(SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)), SkPaint());
canvas->clipRect(SkRect::MakeWH(SkIntToScalar(kWidth), SkIntToScalar(kHeight)));
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
}
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
JustOneDraw callback;
- GrRecordReplaceDraw(pic, &canvas, nullptr, SkMatrix::I(), &callback);
+ GrRecordReplaceDraw(pic.get(), &canvas, nullptr, SkMatrix::I(), &callback);
switch (rerecord.count()) {
case 3:
@@ -68,7 +68,7 @@ DEF_TEST(RecordReplaceDraw_Abort, r) {
// Make sure GrRecordReplaceDraw balances unbalanced saves
DEF_TEST(RecordReplaceDraw_Unbalanced, r) {
- SkAutoTUnref<const SkPicture> pic;
+ sk_sp<SkPicture> pic;
{
SkPictureRecorder recorder;
@@ -77,13 +77,13 @@ DEF_TEST(RecordReplaceDraw_Unbalanced, r) {
// We won't balance this, but GrRecordReplaceDraw will for us.
canvas->save();
canvas->scale(2, 2);
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
}
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
- GrRecordReplaceDraw(pic, &canvas, nullptr, SkMatrix::I(), nullptr/*callback*/);
+ GrRecordReplaceDraw(pic.get(), &canvas, nullptr, SkMatrix::I(), nullptr/*callback*/);
// ensure rerecord is balanced (in this case by checking that the count is odd)
REPORTER_ASSERT(r, (rerecord.count() & 1) == 1);
@@ -91,7 +91,7 @@ DEF_TEST(RecordReplaceDraw_Unbalanced, r) {
// Test out the layer replacement functionality with and w/o a BBH
void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace) {
- SkAutoTUnref<const SkPicture> pic;
+ sk_sp<SkPicture> pic;
{
SkPictureRecorder recorder;
@@ -102,7 +102,7 @@ void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace
canvas->restore();
canvas->drawRect(SkRect::MakeWH(SkIntToScalar(kWidth / 2), SkIntToScalar(kHeight / 2)),
SkPaint());
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
}
SkAutoTUnref<GrTexture> texture;
@@ -131,7 +131,7 @@ void test_replacements(skiatest::Reporter* r, GrContext* context, bool doReplace
SkRecord rerecord;
SkRecorder canvas(&rerecord, kWidth, kHeight);
- GrRecordReplaceDraw(pic, &canvas, layerCache, SkMatrix::I(), nullptr/*callback*/);
+ GrRecordReplaceDraw(pic.get(), &canvas, layerCache, SkMatrix::I(), nullptr/*callback*/);
int numLayers = count_instances_of_type<SkRecords::SaveLayer>(rerecord);
if (doReplace) {
diff --git a/tests/RecordingXfermodeTest.cpp b/tests/RecordingXfermodeTest.cpp
index 05af84c377..0f91aea964 100644
--- a/tests/RecordingXfermodeTest.cpp
+++ b/tests/RecordingXfermodeTest.cpp
@@ -114,7 +114,7 @@ class PictureStrategy : public RecordingStrategy {
SkIntToScalar(fHeight),
&factory);
drawer.draw(canvas, canvasRect, mode);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
SkCanvas replayCanvas(fBitmap);
replayCanvas.clear(0xffffffff);
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index eca9e64dbe..c58020724d 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -338,13 +338,13 @@ static void serialize_and_compare_typeface(SkTypeface* typeface, const char* tex
nullptr, 0);
canvas->drawColor(SK_ColorWHITE);
canvas->drawText(text, 2, 24, 32, paint);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
// Serlialize picture and create its clone from stream.
SkDynamicMemoryWStream stream;
picture->serialize(&stream);
SkAutoTDelete<SkStream> inputStream(stream.detachAsStream());
- SkAutoTUnref<SkPicture> loadedPicture(SkPicture::CreateFromStream(inputStream.get()));
+ sk_sp<SkPicture> loadedPicture(SkPicture::MakeFromStream(inputStream.get()));
// Draw both original and clone picture and compare bitmaps -- they should be identical.
SkBitmap origBitmap = draw_picture(*picture);
@@ -529,7 +529,7 @@ DEF_TEST(Serialization, reporter) {
draw_something(recorder.beginRecording(SkIntToScalar(kBitmapSize),
SkIntToScalar(kBitmapSize),
nullptr, 0));
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
+ sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
// Serialize picture
SkWriteBuffer writer(SkWriteBuffer::kValidation_Flag);
@@ -540,8 +540,7 @@ DEF_TEST(Serialization, reporter) {
// Deserialize picture
SkValidatingReadBuffer reader(static_cast<void*>(data.get()), size);
- SkAutoTUnref<SkPicture> readPict(
- SkPicture::CreateFromBuffer(reader));
+ sk_sp<SkPicture> readPict(SkPicture::MakeFromBuffer(reader));
REPORTER_ASSERT(reporter, readPict.get());
}
@@ -551,11 +550,11 @@ DEF_TEST(Serialization, reporter) {
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "SkAnnotation.h"
-static SkPicture* copy_picture_via_serialization(SkPicture* src) {
+static sk_sp<SkPicture> copy_picture_via_serialization(SkPicture* src) {
SkDynamicMemoryWStream wstream;
src->serialize(&wstream);
SkAutoTDelete<SkStreamAsset> rstream(wstream.detachAsStream());
- return SkPicture::CreateFromStream(rstream);
+ return SkPicture::MakeFromStream(rstream);
}
struct AnnotationRec {
@@ -622,8 +621,8 @@ DEF_TEST(Annotations, reporter) {
{ r2, SkAnnotationKeys::Link_Named_Dest_Key(), d2 },
};
- SkAutoTUnref<SkPicture> pict0(recorder.endRecording());
- SkAutoTUnref<SkPicture> pict1(copy_picture_via_serialization(pict0));
+ sk_sp<SkPicture> pict0(recorder.finishRecordingAsPicture());
+ sk_sp<SkPicture> pict1(copy_picture_via_serialization(pict0.get()));
TestAnnotationCanvas canvas(reporter, recs, SK_ARRAY_COUNT(recs));
canvas.drawPicture(pict1);
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp
index 625b98a903..7ae5f6486f 100644
--- a/tests/SkResourceCacheTest.cpp
+++ b/tests/SkResourceCacheTest.cpp
@@ -322,8 +322,8 @@ DEF_TEST(BitmapCache_discarded_image, reporter) {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->clear(SK_ColorCYAN);
- sk_sp<SkPicture> picture(recorder.endRecording());
- return SkImage::MakeFromPicture(picture, SkISize::Make(10, 10), nullptr, nullptr);
+ return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
+ SkISize::Make(10, 10), nullptr, nullptr);
});
}
}
diff --git a/tests/SkpSkGrTest.cpp b/tests/SkpSkGrTest.cpp
index 67a6b26b2b..23bec84b8f 100644
--- a/tests/SkpSkGrTest.cpp
+++ b/tests/SkpSkGrTest.cpp
@@ -378,7 +378,7 @@ static void writePict(const SkBitmap& bitmap, const char* outDir, const char* pn
}
void TestResult::testOne() {
- SkPicture* pic = nullptr;
+ sk_sp<SkPicture> pic;
{
SkString d;
d.printf(" {%d, \"%s\"},", fDirNo, fFilename);
@@ -399,7 +399,7 @@ void TestResult::testOne() {
wStream.write(&bytes[0], length);
wStream.flush();
}
- pic = SkPicture::CreateFromStream(&stream);
+ pic = SkPicture::MakeFromStream(&stream);
if (!pic) {
SkDebugf("unable to decode %s\n", fFilename);
goto finish;
@@ -436,7 +436,7 @@ void TestResult::testOne() {
if (scale >= 256) {
SkDebugf("unable to allocate bitmap for %s (w=%d h=%d) (sw=%d sh=%d)\n",
fFilename, pWidth, pHeight, dim.fX, dim.fY);
- goto finish;
+ return;
}
SkCanvas skCanvas(bitmap);
drawPict(pic, &skCanvas, fScaleOversized ? scale : 1);
@@ -450,11 +450,11 @@ void TestResult::testOne() {
if (!texture) {
SkDebugf("unable to allocate texture for %s (w=%d h=%d)\n", fFilename,
dim.fX, dim.fY);
- goto finish;
+ return;
}
SkGpuDevice grDevice(context, texture.get());
SkCanvas grCanvas(&grDevice);
- drawPict(pic, &grCanvas, fScaleOversized ? scale : 1);
+ drawPict(pic.get(), &grCanvas, fScaleOversized ? scale : 1);
SkBitmap grBitmap;
grBitmap.allocPixels(grCanvas.imageInfo());
@@ -472,8 +472,6 @@ void TestResult::testOne() {
writePict(bitmap, outSkDir, pngName);
}
}
-finish:
- delete pic;
}
static SkString makeStatusString(int dirNo) {