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

Unified Diff: src/core/SkPictureRecorder.cpp

Issue 1067893002: SkCanvas::resetForNextPicture() (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: make sure missing restores end up on the right SkRecord Created 5 years, 8 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 850be275300246763828217d4a4cb589a1935740..7c0abcef7435d16d69fcb18896d47b3e04950732 100644
--- a/src/core/SkPictureRecorder.cpp
+++ b/src/core/SkPictureRecorder.cpp
@@ -15,7 +15,9 @@
#include "SkRecordOpts.h"
#include "SkTypes.h"
-SkPictureRecorder::SkPictureRecorder() {}
+SkPictureRecorder::SkPictureRecorder() {
+ fRecorder.reset(SkNEW_ARGS(SkRecorder, (nullptr, SkRect::MakeWH(0,0))));
+}
SkPictureRecorder::~SkPictureRecorder() {}
@@ -31,7 +33,7 @@ SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect,
}
fRecord.reset(SkNEW(SkRecord));
- fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), cullRect)));
+ fRecorder->reset(fRecord.get(), cullRect);
return this->getRecordingCanvas();
}
@@ -40,6 +42,7 @@ SkCanvas* SkPictureRecorder::getRecordingCanvas() {
}
SkPicture* SkPictureRecorder::endRecordingAsPicture() {
+ 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);
@@ -73,7 +76,6 @@ SkPicture* SkPictureRecorder::endRecordingAsPicture() {
}
// release our refs now, so only the picture will be the owner.
- fRecorder.reset(NULL);
fRecord.reset(NULL);
fBBH.reset(NULL);
@@ -158,6 +160,7 @@ protected:
};
SkDrawable* SkPictureRecorder::endRecordingAsDrawable() {
+ 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);
@@ -171,7 +174,6 @@ SkDrawable* SkPictureRecorder::endRecordingAsDrawable() {
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);
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkRecorder.h » ('j') | src/core/SkRecorder.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698