Refactoring into a public facing facing SkDebugger class first pass.

Review URL: https://codereview.appspot.com/6450096

git-svn-id: http://skia.googlecode.com/svn/trunk@4986 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/debugger/SkDebugger.cpp b/debugger/SkDebugger.cpp
index 86a4574..7934c73 100644
--- a/debugger/SkDebugger.cpp
+++ b/debugger/SkDebugger.cpp
@@ -6,12 +6,39 @@
  * found in the LICENSE file.
  */
 
-#include "SkDebuggerGUI.h"
-#include <QApplication>
+#include "SkDebugger.h"
 
-int main(int argc, char *argv[]) {
-    QApplication a(argc, argv);
-    SkDebuggerGUI w;
-    w.show();
-    return a.exec();
+SkDebugger::SkDebugger() {
+    // Create this some other dynamic way?
+    fDebugCanvas = new SkDebugCanvas(100, 100);
+    fPicture = NULL;
+    fPictureWidth = 0;
+    fPictureHeight = 0;
+    fIndex = 0;
+}
+
+SkDebugger::~SkDebugger() {
+    // Need to inherit from SkRef object in order for following to work
+    SkSafeUnref(fDebugCanvas);
+    SkSafeUnref(fPicture);
+}
+
+void SkDebugger::loadPicture(SkPicture* picture) {
+    fPictureWidth = picture->width();
+    fPictureHeight = picture->height();
+    delete fDebugCanvas;
+    fDebugCanvas = new SkDebugCanvas(fPictureWidth, fPictureHeight);
+    fDebugCanvas->setBounds(fPictureWidth, fPictureHeight);
+    picture->draw(fDebugCanvas);
+    fIndex = fDebugCanvas->getSize() - 1;
+    SkRefCnt_SafeAssign(fPicture, picture);
+}
+
+SkPicture* SkDebugger::makePicture() {
+    SkSafeUnref(fPicture);
+    fPicture = new SkPicture();
+    SkCanvas* canvas = fPicture->beginRecording(fPictureWidth, fPictureHeight);
+    fDebugCanvas->draw(canvas);
+    fPicture->endRecording();
+    return fPicture;
 }