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

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 1098183003: Reduce ref counting in SkPictureRecorder. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 8 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/SkPicture.cpp ('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 22b1ee3eac13ac6a8732bec8d9927695c33db986..6639bfcc85a246334ee5cd99989bc289fb05f91a 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -77,17 +77,13 @@ SkPicture* SkPictureRecorder::endRecordingAsPicture() {
for (int i = 0; pictList && i < pictList->count(); i++) {
subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin()[i]);
}
- SkPicture* pict =
- SkNEW_ARGS(SkPicture, (fCullRect, fRecord, pictList, fBBH, subPictureBytes));
+ SkPicture* pict = SkNEW_ARGS(SkPicture,
+ (fCullRect, fRecord.detach(), pictList, fBBH.detach(), subPictureBytes));
if (saveLayerData) {
pict->EXPERIMENTAL_addAccelData(saveLayerData);
}
- // release our refs now, so only the picture will be the owner.
- fRecord.reset(NULL);
- fBBH.reset(NULL);
-
return pict;
}
@@ -163,8 +159,10 @@ protected:
for (int i = 0; pictList && i < pictList->count(); i++) {
subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin()[i]);
}
- SkPicture* pict =
- SkNEW_ARGS(SkPicture, (fBounds, fRecord, pictList, fBBH, subPictureBytes));
+ // SkPicture will take ownership of a ref on both fRecord and fBBH.
+ // We're not willing to give up our ownership, so we must ref them for SkPicture.
+ SkPicture* pict = SkNEW_ARGS(SkPicture,
+ (fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(fBBH.get()), subPictureBytes));
if (saveLayerData) {
pict->EXPERIMENTAL_addAccelData(saveLayerData);
« no previous file with comments | « src/core/SkPicture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698