aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleAll.cpp2
-rw-r--r--samplecode/SampleApp.cpp8
-rw-r--r--samplecode/SampleArc.cpp17
-rw-r--r--samplecode/SampleFilterFuzz.cpp2
-rw-r--r--samplecode/SampleHT.cpp6
-rw-r--r--samplecode/SamplePictFile.cpp16
-rw-r--r--samplecode/SampleTiling.cpp6
7 files changed, 26 insertions, 31 deletions
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index 48ac24da1c..90fc5bdb16 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -305,7 +305,7 @@ protected:
SkCanvas* record = recorder.beginRecording(320, 480, nullptr, 0);
this->drawPicture(record, 120);
}
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
canvas->translate(0, SkIntToScalar(120));
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 72122234d9..05d6ce0f7d 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -1389,7 +1389,7 @@ void SampleWindow::afterChildren(SkCanvas* orig) {
}
if (fSaveToSKP) {
- SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording());
+ sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
SkFILEWStream stream("sample_app.skp");
picture->serialize(&stream);
fSaveToSKP = false;
@@ -1398,7 +1398,7 @@ void SampleWindow::afterChildren(SkCanvas* orig) {
}
if (fUsePicture) {
- SkAutoTUnref<const SkPicture> picture(fRecorder.endRecording());
+ sk_sp<SkPicture> picture(fRecorder.finishRecordingAsPicture());
// serialize/deserialize?
if (false) {
@@ -1406,9 +1406,9 @@ void SampleWindow::afterChildren(SkCanvas* orig) {
picture->serialize(&wstream);
SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
- picture.reset(SkPicture::CreateFromStream(rstream));
+ picture = SkPicture::MakeFromStream(rstream);
}
- orig->drawPicture(picture);
+ orig->drawPicture(picture.get());
}
// Do this after presentGL and other finishing, rather than in afterChild
diff --git a/samplecode/SampleArc.cpp b/samplecode/SampleArc.cpp
index 3b5288dd08..f95833e830 100644
--- a/samplecode/SampleArc.cpp
+++ b/samplecode/SampleArc.cpp
@@ -81,8 +81,8 @@ class ArcsView : public SampleView {
public:
SkRect fRect;
- MyDrawable* fAnimatingDrawable;
- SkDrawable* fRootDrawable;
+ sk_sp<MyDrawable> fAnimatingDrawable;
+ sk_sp<SkDrawable> fRootDrawable;
ArcsView() {
testparse();
@@ -91,16 +91,11 @@ public:
fRect.set(0, 0, SkIntToScalar(200), SkIntToScalar(200));
fRect.offset(SkIntToScalar(20), SkIntToScalar(20));
- fAnimatingDrawable = new MyDrawable(fRect);
+ fAnimatingDrawable = sk_make_sp<MyDrawable>(fRect);
SkPictureRecorder recorder;
this->drawRoot(recorder.beginRecording(SkRect::MakeWH(800, 500)));
- fRootDrawable = recorder.endRecordingAsDrawable();
- }
-
- ~ArcsView() override {
- fAnimatingDrawable->unref();
- fRootDrawable->unref();
+ fRootDrawable = recorder.finishRecordingAsDrawable();
}
protected:
@@ -186,13 +181,13 @@ protected:
DrawRectWithLines(canvas, fRect, paint);
- canvas->drawDrawable(fAnimatingDrawable);
+ canvas->drawDrawable(fAnimatingDrawable.get());
DrawArcs(canvas);
}
void onDrawContent(SkCanvas* canvas) override {
- canvas->drawDrawable(fRootDrawable);
+ canvas->drawDrawable(fRootDrawable.get());
}
bool onAnimate(const SkAnimTimer& timer) override {
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 81ea2eaed4..0dd01e95b2 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -712,7 +712,7 @@ static SkImageFilter* make_image_filter(bool canBeNull) {
SkIntToScalar(kBitmapSize),
&factory, 0);
drawSomething(recordingCanvas);
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
+ sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
filter = SkPictureImageFilter::Create(pict.get(), make_rect());
}
break;
diff --git a/samplecode/SampleHT.cpp b/samplecode/SampleHT.cpp
index 099adcc948..1989c3a7c6 100644
--- a/samplecode/SampleHT.cpp
+++ b/samplecode/SampleHT.cpp
@@ -127,7 +127,7 @@ public:
HTDrawable* fDrawable;
};
Rec fArray[N];
- SkAutoTUnref<SkDrawable> fRoot;
+ sk_sp<SkDrawable> fRoot;
SkMSec fTime;
HTView() {
@@ -140,7 +140,7 @@ public:
canvas->drawDrawable(fArray[i].fDrawable);
fArray[i].fDrawable->unref();
}
- fRoot.reset(recorder.endRecordingAsDrawable());
+ fRoot = recorder.finishRecordingAsDrawable();
}
protected:
@@ -153,7 +153,7 @@ protected:
}
void onDrawContent(SkCanvas* canvas) override {
- canvas->drawDrawable(fRoot);
+ canvas->drawDrawable(fRoot.get());
}
bool onAnimate(const SkAnimTimer& timer) override {
diff --git a/samplecode/SamplePictFile.cpp b/samplecode/SamplePictFile.cpp
index 9203cbad77..ae10796901 100644
--- a/samplecode/SamplePictFile.cpp
+++ b/samplecode/SamplePictFile.cpp
@@ -117,7 +117,7 @@ protected:
#endif
if (!*picture) {
- *picture = LoadPicture(fFilename.c_str(), fBBox);
+ *picture = LoadPicture(fFilename.c_str(), fBBox).release();
}
if (*picture) {
SkCounterDrawFilter filter(fCount);
@@ -149,8 +149,8 @@ private:
SkSize fTileSize;
int fCount;
- SkPicture* LoadPicture(const char path[], BBoxType bbox) {
- SkAutoTUnref<SkPicture> pic;
+ sk_sp<SkPicture> LoadPicture(const char path[], BBoxType bbox) {
+ sk_sp<SkPicture> pic;
SkBitmap bm;
if (SkImageDecoder::DecodeFile(path, &bm)) {
@@ -160,11 +160,11 @@ private:
SkIntToScalar(bm.height()),
nullptr, 0);
can->drawBitmap(bm, 0, 0, nullptr);
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
} else {
SkFILEStream stream(path);
if (stream.isValid()) {
- pic.reset(SkPicture::CreateFromStream(&stream));
+ pic = SkPicture::MakeFromStream(&stream);
} else {
SkDebugf("coun't load picture at \"path\"\n", path);
}
@@ -174,7 +174,7 @@ private:
pic->playback(recorder.beginRecording(pic->cullRect().width(),
pic->cullRect().height(),
nullptr, 0));
- SkAutoTUnref<SkPicture> p2(recorder.endRecording());
+ sk_sp<SkPicture> p2(recorder.finishRecordingAsPicture());
SkString path2(path);
path2.append(".new.skp");
@@ -191,7 +191,7 @@ private:
switch (bbox) {
case kNo_BBoxType:
// no bbox playback necessary
- return pic.release();
+ return std::move(pic);
case kRTree_BBoxType:
factory.reset(new SkRTreeFactory);
break;
@@ -203,7 +203,7 @@ private:
pic->playback(recorder.beginRecording(pic->cullRect().width(),
pic->cullRect().height(),
factory.get(), 0));
- return recorder.endRecording();
+ return recorder.finishRecordingAsPicture();
}
typedef SampleView INHERITED;
diff --git a/samplecode/SampleTiling.cpp b/samplecode/SampleTiling.cpp
index 125155e8d0..62f055f61e 100644
--- a/samplecode/SampleTiling.cpp
+++ b/samplecode/SampleTiling.cpp
@@ -54,7 +54,7 @@ static const int gWidth = 32;
static const int gHeight = 32;
class TilingView : public SampleView {
- SkAutoTUnref<SkPicture> fTextPicture;
+ sk_sp<SkPicture> fTextPicture;
SkAutoTUnref<SkDrawLooper> fLooper;
public:
TilingView()
@@ -153,11 +153,11 @@ protected:
if (textCanvas) {
SkASSERT(nullptr == fTextPicture);
- fTextPicture.reset(recorder.endRecording());
+ fTextPicture = recorder.finishRecordingAsPicture();
}
SkASSERT(fTextPicture);
- canvas->drawPicture(fTextPicture);
+ canvas->drawPicture(fTextPicture.get());
}
private: