aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/core/SkRegion.h4
-rw-r--r--src/core/SkRegion.cpp28
2 files changed, 32 insertions, 0 deletions
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 @@ public:
*/
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 @@ bool SkRegion::op(const SkRegion& rgn, const SkIRect& rect, Op op)
//////////////////////////////////////////////////////////////////////////////////////
+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)