Fix saving modified skp from debugger
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 22 Jan 2013 18:03:56 +0000 (18:03 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 22 Jan 2013 18:03:56 +0000 (18:03 +0000)
https://codereview.appspot.com/7181048/

git-svn-id: http://skia.googlecode.com/svn/trunk@7314 2bbb7eff-a529-9590-31e7-b0007b416f81

debugger/QT/SkDebuggerGUI.cpp
debugger/SkDebugger.cpp
debugger/SkDebugger.h

index 058cb5c..812ce03 100644 (file)
@@ -555,7 +555,9 @@ void SkDebuggerGUI::drawComplete() {
 
 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) {
index 7934c73..caa361e 100644 (file)
@@ -34,11 +34,12 @@ void SkDebugger::loadPicture(SkPicture* picture) {
     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;
 }
index 0e3906e..6b85de3 100644 (file)
@@ -60,7 +60,7 @@ public:
 
     void loadPicture(SkPicture* picture);
 
-    SkPicture* makePicture();
+    SkPicture* copyPicture();
 
     int getSize() {
         return fDebugCanvas->getSize();