| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkRecording.h" | 8 #include "SkRecording.h" |
| 9 | 9 |
| 10 #include "SkRecord.h" | 10 #include "SkRecord.h" |
| 11 #include "SkRecordOpts.h" | 11 #include "SkRecordOpts.h" |
| 12 #include "SkRecordDraw.h" | 12 #include "SkRecordDraw.h" |
| 13 #include "SkRecorder.h" | 13 #include "SkRecorder.h" |
| 14 | 14 |
| 15 namespace EXPERIMENTAL { | 15 namespace EXPERIMENTAL { |
| 16 | 16 |
| 17 SkPlayback::SkPlayback(const SkRecord* record) : fRecord(record) {} | 17 SkPlayback::SkPlayback(const SkRecord* record) : fRecord(record) {} |
| 18 | 18 |
| 19 SkPlayback::~SkPlayback() { | 19 SkPlayback::~SkPlayback() {} |
| 20 SkDELETE(fRecord); | |
| 21 } | |
| 22 | 20 |
| 23 void SkPlayback::draw(SkCanvas* canvas) const { | 21 void SkPlayback::draw(SkCanvas* canvas) const { |
| 24 SkASSERT(fRecord != NULL); | 22 SkASSERT(fRecord.get() != NULL); |
| 25 SkRecordDraw(*fRecord, canvas); | 23 SkRecordDraw(*fRecord, canvas); |
| 26 } | 24 } |
| 27 | 25 |
| 28 /*static*/ SkRecording* SkRecording::Create(int width, int height) { | 26 SkRecording::SkRecording(int width, int height) |
| 29 return SkNEW_ARGS(SkRecording, (width, height)); | 27 : fRecord(SkNEW(SkRecord)) |
| 28 , fRecorder(SkNEW_ARGS(SkRecorder, (SkRecorder::kReadWrite_Mode, fRecord.get
(), width, height))) |
| 29 {} |
| 30 |
| 31 SkPlayback* SkRecording::releasePlayback() { |
| 32 SkASSERT(fRecorder->unique()); |
| 33 fRecorder->forgetRecord(); |
| 34 SkRecordOptimize(fRecord.get()); |
| 35 return SkNEW_ARGS(SkPlayback, (fRecord.detach())); |
| 30 } | 36 } |
| 31 | 37 |
| 32 SkRecording::SkRecording(int width, int height) { | 38 SkRecording::~SkRecording() {} |
| 33 SkRecord* record = SkNEW(SkRecord); | |
| 34 fRecorder = SkNEW_ARGS(SkRecorder, (SkRecorder::kReadWrite_Mode, record, wid
th, height)); | |
| 35 fRecord = record; | |
| 36 } | |
| 37 | |
| 38 /*static*/ const SkPlayback* SkRecording::Delete(SkRecording* recording) { | |
| 39 SkRecord* record = recording->fRecord; | |
| 40 SkRecordOptimize(record); | |
| 41 SkDELETE(recording); | |
| 42 return SkNEW_ARGS(SkPlayback, (record)); | |
| 43 } | |
| 44 | |
| 45 SkRecording::~SkRecording() { | |
| 46 SkDELETE(fRecorder); | |
| 47 } | |
| 48 | 39 |
| 49 SkCanvas* SkRecording::canvas() { | 40 SkCanvas* SkRecording::canvas() { |
| 50 return fRecorder; | 41 return fRecord.get() ? fRecorder.get() : NULL; |
| 51 } | 42 } |
| 52 | 43 |
| 53 } // namespace EXPERIMENTAL | 44 } // namespace EXPERIMENTAL |
| OLD | NEW |