Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: samplecode/SampleArc.cpp

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleArc.cpp
diff --git a/samplecode/SampleArc.cpp b/samplecode/SampleArc.cpp
index 3b5288dd08622ba72643a152a258c7c37db4468e..f95833e83035f5afed4060230460cbbb36ff3a15 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 {
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | samplecode/SampleFilterFuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698