From 26a6bf6a26b0e837377c876d74508aaefee72658 Mon Sep 17 00:00:00 2001 From: reed Date: Mon, 24 Nov 2014 19:59:22 -0800 Subject: [PATCH] free up picturerecorder refs after returning picture or drawable this just accelerates what would happen on the next beginRecording() call or the destructor. chrome has unittests that break (shaders on the stack) if we hold on to the internals past endRecording(). BUG=skia: TBR= Review URL: https://codereview.chromium.org/758813002 --- include/core/SkPictureRecorder.h | 1 - src/core/SkPictureRecorder.cpp | 24 ++++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/core/SkPictureRecorder.h b/include/core/SkPictureRecorder.h index 37cbe8692a..418fb324d2 100644 --- a/include/core/SkPictureRecorder.h +++ b/include/core/SkPictureRecorder.h @@ -110,7 +110,6 @@ private: SkAutoTUnref fBBH; SkAutoTUnref fRecorder; SkAutoTUnref fRecord; - SkBBHFactory* fBBHFactory; typedef SkNoncopyable INHERITED; }; diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp index d64390c6ef..69411d3bc3 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; }