diff options
author | 2016-07-06 09:29:16 -0700 | |
---|---|---|
committer | 2016-07-06 09:29:17 -0700 | |
commit | 41c27e15ec2740850700f1b82038ce0f7a632481 (patch) | |
tree | 5830ed6b2047502cb68cf0e0a805a4d670f74c64 /src | |
parent | 7ec92413307c9da43c013d1e4e15716a44059810 (diff) |
Experiment: add flag for finish-recording to return null
BUG=skia:5495
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2106843004
Review-Url: https://codereview.chromium.org/2106843004
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPictureRecorder.cpp | 25 | ||||
-rw-r--r-- | src/core/SkRecordOpts.cpp | 2 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp index a157d0dfe0..8ce770efce 100644 --- a/src/core/SkPictureRecorder.cpp +++ b/src/core/SkPictureRecorder.cpp @@ -51,17 +51,26 @@ SkCanvas* SkPictureRecorder::getRecordingCanvas() { return fActivelyRecording ? fRecorder.get() : nullptr; } -sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPicture() { +sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPicture(uint32_t finishFlags) { fActivelyRecording = false; fRecorder->restoreToCount(1); // If we were missing any restores, add them now. if (fRecord->count() == 0) { + if (finishFlags & kReturnNullForEmpty_FinishFlag) { + return nullptr; + } return fMiniRecorder.detachAsPicture(fCullRect); } // TODO: delay as much of this work until just before first playback? SkRecordOptimize(fRecord); + if (fRecord->count() == 0) { + if (finishFlags & kReturnNullForEmpty_FinishFlag) { + return nullptr; + } + } + SkAutoTUnref<SkLayerInfo> saveLayerData; if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) { @@ -97,9 +106,10 @@ sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPicture() { saveLayerData.release(), subPictureBytes); } -sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPictureWithCull(const SkRect& cullRect) { +sk_sp<SkPicture> SkPictureRecorder::finishRecordingAsPictureWithCull(const SkRect& cullRect, + uint32_t finishFlags) { fCullRect = cullRect; - return this->finishRecordingAsPicture(); + return this->finishRecordingAsPicture(finishFlags); } @@ -118,14 +128,19 @@ void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, nullptr/*bbh*/, nullptr/*callback*/); } -sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable() { +sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable(uint32_t finishFlags) { fActivelyRecording = false; fRecorder->flushMiniRecorder(); fRecorder->restoreToCount(1); // If we were missing any restores, add them now. - // TODO: delay as much of this work until just before first playback? SkRecordOptimize(fRecord); + if (fRecord->count() == 0) { + if (finishFlags & kReturnNullForEmpty_FinishFlag) { + return nullptr; + } + } + if (fBBH.get()) { SkAutoTMalloc<SkRect> bounds(fRecord->count()); SkRecordFillBounds(fCullRect, *fRecord, bounds); diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp index ea19d6eaa5..aa07facb19 100644 --- a/src/core/SkRecordOpts.cpp +++ b/src/core/SkRecordOpts.cpp @@ -276,7 +276,7 @@ void SkRecordOptimize(SkRecord* record) { // out junk for other optimization passes. Right now, nothing needs it, // and the bounding box hierarchy will do the work of skipping no-op // Save-NoDraw-Restore sequences better than we can here. - //SkRecordNoopSaveRestores(record); + SkRecordNoopSaveRestores(record); SkRecordNoopSaveLayerDrawRestores(record); SkRecordMergeSvgOpacityAndFilterLayers(record); |