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

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 758813002: free up picturerecorder refs after returning picture or drawable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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 | « include/core/SkPictureRecorder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPictureRecorder.cpp
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
index d64390c6ef80d58e0c3c26015f8b80ad24b7c02b..69411d3bc374e78a004883abbfdc05bfdf48ca11 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -15,7 +15,7 @@
#include "SkRecordOpts.h"
#include "SkTypes.h"
-SkPictureRecorder::SkPictureRecorder() : fBBHFactory(NULL) {}
+SkPictureRecorder::SkPictureRecorder() {}
SkPictureRecorder::~SkPictureRecorder() {}
@@ -23,7 +23,6 @@ SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect,
SkBBHFactory* bbhFactory /* = NULL */,
uint32_t recordFlags /* = 0 */) {
fCullRect = cullRect;
- fBBHFactory = bbhFactory;
fFlags = recordFlags;
if (bbhFactory) {
@@ -68,7 +67,12 @@ SkPicture* SkPictureRecorder::endRecordingAsPicture() {
if (saveLayerData) {
pict->EXPERIMENTAL_addAccelData(saveLayerData);
}
-
+
+ // release our refs now, so only the picture will be the owner.
+ fRecorder.reset(NULL);
+ fRecord.reset(NULL);
+ fBBH.reset(NULL);
+
return pict;
}
@@ -157,7 +161,15 @@ SkCanvasDrawable* SkPictureRecorder::EXPERIMENTAL_endRecordingAsDrawable() {
SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
}
- return SkNEW_ARGS(SkRecordedDrawable, (fRecord, fBBH, fRecorder->detachDrawableList(),
- fCullRect,
- SkToBool(fFlags & kComputeSaveLayerInfo_RecordFlag)));
+ SkCanvasDrawable* drawable = SkNEW_ARGS(SkRecordedDrawable,
+ (fRecord, fBBH, fRecorder->detachDrawableList(),
+ fCullRect,
+ SkToBool(fFlags & kComputeSaveLayerInfo_RecordFlag)));
+
+ // release our refs now, so only the drawable will be the owner.
+ fRecorder.reset(NULL);
+ fRecord.reset(NULL);
+ fBBH.reset(NULL);
+
+ return drawable;
}
« no previous file with comments | « include/core/SkPictureRecorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698