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

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 2106843004: Experiment: add flag for finish-recording to return null (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address comments from #21 Created 4 years, 5 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
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);

Powered by Google App Engine
This is Rietveld 408576698