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

Unified Diff: src/core/SkMiniRecorder.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 | « src/core/SkDrawable.cpp ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMiniRecorder.cpp
diff --git a/src/core/SkMiniRecorder.cpp b/src/core/SkMiniRecorder.cpp
index ea179d78b33f01ecde8ab682de410afe382c4eaf..2d5b0943e58eb646e767d782017bcc431d67449f 100644
--- a/src/core/SkMiniRecorder.cpp
+++ b/src/core/SkMiniRecorder.cpp
@@ -62,7 +62,7 @@ SkMiniRecorder::~SkMiniRecorder() {
if (fState != State::kEmpty) {
// We have internal state pending.
// Detaching then deleting a picture is an easy way to clean up.
- delete this->detachAsPicture(SkRect::MakeEmpty());
+ (void)this->detachAsPicture(SkRect::MakeEmpty());
}
SkASSERT(fState == State::kEmpty);
}
@@ -101,14 +101,14 @@ bool SkMiniRecorder::drawTextBlob(const SkTextBlob* b, SkScalar x, SkScalar y, c
#undef TRY_TO_STORE
-SkPicture* SkMiniRecorder::detachAsPicture(const SkRect& cull) {
+sk_sp<SkPicture> SkMiniRecorder::detachAsPicture(const SkRect& cull) {
#define CASE(Type) \
case State::k##Type: \
fState = State::kEmpty; \
- return new SkMiniPicture<Type>(cull, reinterpret_cast<Type*>(fBuffer.get()))
+ return sk_make_sp<SkMiniPicture<Type>>(cull, reinterpret_cast<Type*>(fBuffer.get()))
switch (fState) {
- case State::kEmpty: return SkRef(gEmptyPicture.get([]{ return new SkEmptyPicture; }));
+ case State::kEmpty: return sk_ref_sp(gEmptyPicture.get([]{ return new SkEmptyPicture; }));
CASE(DrawBitmapRectFixedSize);
CASE(DrawPath);
CASE(DrawRect);
« no previous file with comments | « src/core/SkDrawable.cpp ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698