am 67a98d67: am 9221e808: Implement SkRegion::toString().

* commit '67a98d6726e2bcb1d3d7b8863b89ad753ae15774':
  Implement SkRegion::toString().
diff --git a/include/core/SkRegion.h b/include/core/SkRegion.h
index 8b15a89..09b835d 100644
--- a/include/core/SkRegion.h
+++ b/include/core/SkRegion.h
@@ -242,6 +242,10 @@
     */
     bool op(const SkRegion& rgna, const SkRegion& rgnb, Op op);
 
+    /** Returns a new char* containing the list of rectangles in this region
+     */
+    char* toString();
+
     /** Returns the sequence of rectangles, sorted in Y and X, that make up
         this region.
     */
diff --git a/src/core/SkRegion.cpp b/src/core/SkRegion.cpp
index a5a1555..565b6ad 100644
--- a/src/core/SkRegion.cpp
+++ b/src/core/SkRegion.cpp
@@ -18,6 +18,7 @@
 #include "SkRegionPriv.h"
 #include "SkTemplates.h"
 #include "SkThread.h"
+#include <stdio.h>
 
 SkDEBUGCODE(int32_t gRgnAllocCounter;)
 
@@ -211,6 +212,33 @@
 
 //////////////////////////////////////////////////////////////////////////////////////
 
+char* SkRegion::toString()
+{
+    Iterator iter(*this);
+    int count = 0;
+    while (!iter.done()) {
+        count++;
+        iter.next();
+    }
+    // 4 ints, up to 10 digits each plus sign, 3 commas, '(', ')', SkRegion() and '\0'
+    const int max = (count*((11*4)+5))+11+1;
+    char* result = (char*)malloc(max);
+    if (result == NULL) {
+        return NULL;
+    }
+    count = sprintf(result, "SkRegion(");
+    iter.reset(*this);
+    while (!iter.done()) {
+        const SkIRect& r = iter.rect();
+        count += sprintf(result+count, "(%d,%d,%d,%d)", r.fLeft, r.fTop, r.fRight, r.fBottom);
+        iter.next();
+    }
+    count += sprintf(result+count, ")");
+    return result;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+
 int SkRegion::count_runtype_values(int* itop, int* ibot) const
 {
     if (this == NULL)