| Index: src/core/SkPictureRecorder.cpp
|
| diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp
|
| index a157d0dfe0a5bd76b4159a853498d6f560e3e9ea..8ce770efce8d16957e145468aea3711f7eac5a4a 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);
|
|
|