aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkRegionPriv.h
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-01 14:43:22 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-01 14:43:22 +0000
commitaf7e6943b74260ff9038bfbe0f8c50cf66657e83 (patch)
treef4a0e17630f5d11d52e8eed97332786aa51a7f36 /src/core/SkRegionPriv.h
parented4155d610442b75e906a3489c984394c34b5ff9 (diff)
record yspancount and intervalcount in regions
Review URL: https://codereview.appspot.com/6132055 git-svn-id: http://skia.googlecode.com/svn/trunk@3808 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkRegionPriv.h')
-rw-r--r--src/core/SkRegionPriv.h52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/core/SkRegionPriv.h b/src/core/SkRegionPriv.h
index cef4b3547d..fe0dfbe488 100644
--- a/src/core/SkRegionPriv.h
+++ b/src/core/SkRegionPriv.h
@@ -22,15 +22,57 @@ struct SkRegion::RunHead {
int32_t fRefCnt;
int32_t fRunCount;
+ /**
+ * Number of spans with different Y values. This does not count the initial
+ * Top value, nor does it count the final Y-Sentinel value. In the logical
+ * case of a rectangle, this would return 1, and an empty region would
+ * return 0.
+ */
+ int getYSpanCount() const {
+ return fYSpanCount;
+ }
+
+ /**
+ * Number of intervals in the entire region. This equals the number of
+ * rects that would be returned by the Iterator. In the logical case of
+ * a rect, this would return 1, and an empty region would return 0.
+ */
+ int getIntervalCount() const {
+ return fIntervalCount;
+ }
+
+ void updateYSpanCount(int n) {
+ SkASSERT(n > 0);
+ fYSpanCount = n;
+ }
+
+ void updateIntervalCount(int n) {
+ SkASSERT(n > 1);
+ fIntervalCount = n;
+ }
+
static RunHead* Alloc(int count) {
//SkDEBUGCODE(sk_atomic_inc(&gRgnAllocCounter);)
//SkDEBUGF(("************** gRgnAllocCounter::alloc %d\n", gRgnAllocCounter));
-
+
SkASSERT(count >= SkRegion::kRectRegionRuns);
-
+
RunHead* head = (RunHead*)sk_malloc_throw(sizeof(RunHead) + count * sizeof(RunType));
head->fRefCnt = 1;
head->fRunCount = count;
+ // these must be filled in later, otherwise we will be invalid
+ head->fYSpanCount = 0;
+ head->fIntervalCount = 0;
+ return head;
+ }
+
+ static RunHead* Alloc(int count, int yspancount, int intervalCount) {
+ SkASSERT(yspancount > 0);
+ SkASSERT(intervalCount > 1);
+
+ RunHead* head = Alloc(count);
+ head->fYSpanCount = yspancount;
+ head->fIntervalCount = intervalCount;
return head;
}
@@ -57,7 +99,7 @@ struct SkRegion::RunHead {
// We need to alloc & copy the current region before we call
// sk_atomic_dec because it could be freed in the meantime,
// otherwise.
- writable = Alloc(fRunCount);
+ writable = Alloc(fRunCount, fYSpanCount, fIntervalCount);
memcpy(writable->writable_runs(), this->readonly_runs(),
fRunCount * sizeof(RunType));
@@ -70,6 +112,10 @@ struct SkRegion::RunHead {
}
return writable;
}
+
+private:
+ int32_t fYSpanCount;
+ int32_t fIntervalCount;
};
#endif