fix dumpcanvas to recurse on pictures and shapes
add cached bitmap for gradients to avoid thrashing textures in gl



git-svn-id: http://skia.googlecode.com/svn/trunk@201 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index 7a05f09..2151133 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -1,4 +1,5 @@
 #include "SkDumpCanvas.h"
+#include "SkPicture.h"  
 #include "SkPixelRef.h"
 #include "SkString.h"
 #include <stdarg.h>
@@ -138,7 +139,7 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-SkDumpCanvas::SkDumpCanvas(Dumper* dumper) {
+SkDumpCanvas::SkDumpCanvas(Dumper* dumper) : fNestLevel(0) {
     dumper->safeRef();
     fDumper = dumper;
 
@@ -352,10 +353,20 @@
 
 void SkDumpCanvas::drawShape(SkShape* shape) {
     this->dump(kDrawShape_Verb, NULL, "drawShape(%p)", shape);
+    fNestLevel += 1;
+    this->INHERITED::drawShape(shape);
+    fNestLevel -= 1;
+    this->dump(kDrawShape_Verb, NULL, "endShape(%p)", shape);
 }
 
 void SkDumpCanvas::drawPicture(SkPicture& picture) {
-    this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p)", &picture);
+    this->dump(kDrawPicture_Verb, NULL, "drawPicture(%p) %d:%d", &picture,
+               picture.width(), picture.height());
+    fNestLevel += 1;
+    this->INHERITED::drawPicture(picture);
+    fNestLevel -= 1;
+    this->dump(kDrawPicture_Verb, NULL, "endPicture(%p) %d:%d", &picture,
+               picture.width(), picture.height());
 }
 
 void SkDumpCanvas::drawVertices(VertexMode vmode, int vertexCount,
@@ -397,7 +408,7 @@
 void SkFormatDumper::dump(SkDumpCanvas* canvas, SkDumpCanvas::Verb verb,
                           const char str[], const SkPaint* p) {
     SkString msg, tab;
-    const int level = canvas->getSaveCount() - 1;
+    const int level = canvas->getNestLevel() + canvas->getSaveCount() - 1;
     SkASSERT(level >= 0);
     for (int i = 0; i < level; i++) {
         tab.append("\t");