aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2011-01-19 16:18:45 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-01-19 16:18:45 -0800
commit0e70d358a989a1d88ebf579063cb59153e9f0638 (patch)
tree5143b9daff9d914b68c66fd16e742f10f816473e
parentb5c608b7dc12e41d59bc0654786e224bc7ad6c65 (diff)
parent67a98d6726e2bcb1d3d7b8863b89ad753ae15774 (diff)
downloadexternal_skia-0e70d358a989a1d88ebf579063cb59153e9f0638.zip
external_skia-0e70d358a989a1d88ebf579063cb59153e9f0638.tar.gz
external_skia-0e70d358a989a1d88ebf579063cb59153e9f0638.tar.bz2
am 67a98d67: am 9221e808: Implement SkRegion::toString().
* commit '67a98d6726e2bcb1d3d7b8863b89ad753ae15774': Implement SkRegion::toString().
-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)