void SkDebuggerGUI::saveToFile(const SkString& filename) {
SkFILEWStream file(filename.c_str());
- fDebugger.makePicture()->serialize(&file);
+ SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture());
+
+ copy->serialize(&file);
}
void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
SkRefCnt_SafeAssign(fPicture, picture);
}
-SkPicture* SkDebugger::makePicture() {
- SkSafeUnref(fPicture);
- fPicture = new SkPicture();
- SkCanvas* canvas = fPicture->beginRecording(fPictureWidth, fPictureHeight);
+SkPicture* SkDebugger::copyPicture() {
+ // We can't just call clone here since we want to removed the "deleted"
+ // commands. Playing back will strip those out.
+ SkPicture* newPicture = new SkPicture;
+ SkCanvas* canvas = newPicture->beginRecording(fPictureWidth, fPictureHeight);
fDebugCanvas->draw(canvas);
- fPicture->endRecording();
- return fPicture;
+ newPicture->endRecording();
+ return newPicture;
}
void loadPicture(SkPicture* picture);
- SkPicture* makePicture();
+ SkPicture* copyPicture();
int getSize() {
return fDebugCanvas->getSize();