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

Unified Diff: src/record/SkRecording.cpp

Issue 248033002: Rearrange SkRecord public API to fit better with cc/resources/picture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add forgetRecord() Created 6 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/record/SkRecording.cpp
diff --git a/src/record/SkRecording.cpp b/src/record/SkRecording.cpp
index 6af19593f85894bd1f41b3cda1326c9111859a56..57743622fb1059620dba0750758a4abe2f55edee 100644
--- a/src/record/SkRecording.cpp
+++ b/src/record/SkRecording.cpp
@@ -16,38 +16,29 @@ namespace EXPERIMENTAL {
SkPlayback::SkPlayback(const SkRecord* record) : fRecord(record) {}
-SkPlayback::~SkPlayback() {
- SkDELETE(fRecord);
-}
+SkPlayback::~SkPlayback() {}
void SkPlayback::draw(SkCanvas* canvas) const {
- SkASSERT(fRecord != NULL);
+ SkASSERT(fRecord.get() != NULL);
SkRecordDraw(*fRecord, canvas);
}
-/*static*/ SkRecording* SkRecording::Create(int width, int height) {
- return SkNEW_ARGS(SkRecording, (width, height));
-}
+SkRecording::SkRecording(int width, int height)
+ : fRecord(SkNEW(SkRecord))
+ , fRecorder(SkNEW_ARGS(SkRecorder, (SkRecorder::kReadWrite_Mode, fRecord.get(), width, height)))
+ {}
-SkRecording::SkRecording(int width, int height) {
- SkRecord* record = SkNEW(SkRecord);
- fRecorder = SkNEW_ARGS(SkRecorder, (SkRecorder::kReadWrite_Mode, record, width, height));
- fRecord = record;
+SkPlayback* SkRecording::releasePlayback() {
+ SkASSERT(fRecorder->unique());
+ fRecorder->forgetRecord();
+ SkRecordOptimize(fRecord.get());
+ return SkNEW_ARGS(SkPlayback, (fRecord.detach()));
}
-/*static*/ const SkPlayback* SkRecording::Delete(SkRecording* recording) {
- SkRecord* record = recording->fRecord;
- SkRecordOptimize(record);
- SkDELETE(recording);
- return SkNEW_ARGS(SkPlayback, (record));
-}
-
-SkRecording::~SkRecording() {
- SkDELETE(fRecorder);
-}
+SkRecording::~SkRecording() {}
SkCanvas* SkRecording::canvas() {
- return fRecorder;
+ return fRecord.get() ? fRecorder.get() : NULL;
}
} // namespace EXPERIMENTAL

Powered by Google App Engine
This is Rietveld 408576698