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

Unified Diff: src/core/SkPath.cpp

Issue 1073473002: change isNestedRect to isNestedFillRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix lua Created 5 years, 8 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 | « src/core/SkMaskFilter.cpp ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPath.cpp
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 76e70d99cfbc79e9fa523d69451cfc486cc6bdfe..19e7048869a4adb34703b389c2970361037739e3 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -396,13 +396,16 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts
int nextDirection = 0;
bool closedOrMoved = false;
bool autoClose = false;
+ bool insertClose = false;
int verbCnt = fPathRef->countVerbs();
while (*currVerb < verbCnt && (!allowPartial || !autoClose)) {
- switch (fPathRef->atVerb(*currVerb)) {
+ uint8_t verb = insertClose ? (uint8_t) kClose_Verb : fPathRef->atVerb(*currVerb);
+ switch (verb) {
case kClose_Verb:
savePts = pts;
pts = *ptsPtr;
autoClose = true;
+ insertClose = false;
case kLine_Verb: {
SkScalar left = last.fX;
SkScalar top = last.fY;
@@ -455,6 +458,11 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts
case kCubic_Verb:
return false; // quadratic, cubic not allowed
case kMove_Verb:
+ if (allowPartial && !autoClose && firstDirection) {
+ insertClose = true;
+ *currVerb -= 1; // try move again afterwards
+ goto addMissingClose;
+ }
last = *pts++;
closedOrMoved = true;
break;
@@ -464,6 +472,8 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts
}
*currVerb += 1;
lastDirection = nextDirection;
+addMissingClose:
+ ;
}
// Success if 4 corners and first point equals last
bool result = 4 == corners && (first == last || autoClose);
@@ -518,7 +528,7 @@ bool SkPath::isRect(SkRect* rect, bool* isClosed, Direction* direction) const {
return true;
}
-bool SkPath::isNestedRects(SkRect rects[2], Direction dirs[2]) const {
+bool SkPath::isNestedFillRects(SkRect rects[2], Direction dirs[2]) const {
SkDEBUGCODE(this->validate();)
int currVerb = 0;
const SkPoint* pts = fPathRef->points();
@@ -529,8 +539,12 @@ bool SkPath::isNestedRects(SkRect rects[2], Direction dirs[2]) const {
}
const SkPoint* last = pts;
SkRect testRects[2];
- if (isRectContour(false, &currVerb, &pts, NULL, &testDirs[1])) {
+ bool isClosed;
+ if (isRectContour(false, &currVerb, &pts, &isClosed, &testDirs[1])) {
testRects[0].set(first, SkToS32(last - first));
+ if (!isClosed) {
+ pts = fPathRef->points() + fPathRef->countPoints();
+ }
testRects[1].set(last, SkToS32(pts - last));
if (testRects[0].contains(testRects[1])) {
if (rects) {
« no previous file with comments | « src/core/SkMaskFilter.cpp ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698