Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: src/core/SkRegion_path.cpp

Issue 27222005: account for inverse-paths when we prealloc storage in the rgn-builder (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRegion_path.cpp
diff --git a/src/core/SkRegion_path.cpp b/src/core/SkRegion_path.cpp
index 0a5a40180989075bb2321d7a1e72c6328dc7116f..65fe25f21c7df609fcc9ea77796918dddd270021 100644
--- a/src/core/SkRegion_path.cpp
+++ b/src/core/SkRegion_path.cpp
@@ -18,7 +18,7 @@ public:
virtual ~SkRgnBuilder();
// returns true if it could allocate the working storage needed
- bool init(int maxHeight, int maxTransitions);
+ bool init(int maxHeight, int maxTransitions, bool pathIsInverse);
void done() {
if (fCurrScanline != NULL) {
@@ -102,15 +102,29 @@ SkRgnBuilder::~SkRgnBuilder() {
sk_free(fStorage);
}
-bool SkRgnBuilder::init(int maxHeight, int maxTransitions) {
+bool SkRgnBuilder::init(int maxHeight, int maxTransitions, bool pathIsInverse) {
if ((maxHeight | maxTransitions) < 0) {
return false;
}
Sk64 count, size;
+ if (pathIsInverse) {
+ // allow for additional X transitions to "invert" each scanline
+ // [ L' ... normal transitions ... R' ]
+ //
+ maxTransitions += 2;
+ }
+
// compute the count with +1 and +3 slop for the working buffer
count.setMul(maxHeight + 1, 3 + maxTransitions);
+
+ if (pathIsInverse) {
+ // allow for two "empty" rows for the top and bottom
+ // [ Y, 1, L, R, S] == 5 (*2 for top and bottom)
+ count.add(10);
+ }
+
if (!count.is32() || count.isNeg()) {
return false;
}
@@ -120,7 +134,7 @@ bool SkRgnBuilder::init(int maxHeight, int maxTransitions) {
if (!size.is32() || size.isNeg()) {
return false;
}
-
+
fStorage = (SkRegion::RunType*)sk_malloc_flags(size.get32(), 0);
if (NULL == fStorage) {
return false;
@@ -312,7 +326,9 @@ bool SkRegion::setPath(const SkPath& path, const SkRegion& clip) {
SkRgnBuilder builder;
- if (!builder.init(bot - top, SkMax32(pathTransitions, clipTransitions))) {
+ if (!builder.init(bot - top,
+ SkMax32(pathTransitions, clipTransitions),
+ path.isInverseFillType())) {
// can't allocate working space, so return false
return this->setEmpty();
}
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698