Chromium Code Reviews| Index: src/core/SkPictureRecorder.cpp |
| diff --git a/src/core/SkPictureRecorder.cpp b/src/core/SkPictureRecorder.cpp |
| index a157d0dfe0a5bd76b4159a853498d6f560e3e9ea..4fd0bb3cd6c7733c03b97e46ab99ecf3dec1602d 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,7 +128,7 @@ 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. |
| @@ -126,6 +136,13 @@ sk_sp<SkDrawable> SkPictureRecorder::finishRecordingAsDrawable() { |
| // TODO: delay as much of this work until just before first playback? |
| SkRecordOptimize(fRecord); |
| + // Should we call optimize first, in case that makes us empty? |
|
mtklein
2016/06/29 19:44:19
(You've done this now.)
reed1
2016/07/06 13:55:09
Done.
|
| + if (fRecord->count() == 0) { |
| + if (finishFlags & kReturnNullForEmpty_FinishFlag) { |
| + return nullptr; |
| + } |
| + } |
| + |
| if (fBBH.get()) { |
| SkAutoTMalloc<SkRect> bounds(fRecord->count()); |
| SkRecordFillBounds(fCullRect, *fRecord, bounds); |