Make SkPath::conservativelyContainsRect not assert on paths that begin with repeated moveTos
R=reed@google.com Author: bsalomon@google.com Review URL: https://chromiumcodereview.appspot.com/21565002 git-svn-id: http://skia.googlecode.com/svn/trunk@10484 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
d4c3565aac
commit
62df526042
@ -301,29 +301,35 @@ bool SkPath::conservativelyContainsRect(const SkRect& rect) const {
|
||||
SkPath::Verb verb;
|
||||
SkPoint pts[4];
|
||||
SkDEBUGCODE(int moveCnt = 0;)
|
||||
SkDEBUGCODE(int segmentCount = 0;)
|
||||
SkDEBUGCODE(int closeCount = 0;)
|
||||
|
||||
while ((verb = iter.next(pts)) != kDone_Verb) {
|
||||
int nextPt = -1;
|
||||
switch (verb) {
|
||||
case kMove_Verb:
|
||||
SkASSERT(!moveCnt);
|
||||
SkASSERT(!segmentCount && !closeCount);
|
||||
SkDEBUGCODE(++moveCnt);
|
||||
firstPt = prevPt = pts[0];
|
||||
break;
|
||||
case kLine_Verb:
|
||||
nextPt = 1;
|
||||
SkASSERT(moveCnt);
|
||||
SkASSERT(moveCnt && !closeCount);
|
||||
SkDEBUGCODE(++segmentCount);
|
||||
break;
|
||||
case kQuad_Verb:
|
||||
case kConic_Verb:
|
||||
SkASSERT(moveCnt);
|
||||
SkASSERT(moveCnt && !closeCount);
|
||||
SkDEBUGCODE(++segmentCount);
|
||||
nextPt = 2;
|
||||
break;
|
||||
case kCubic_Verb:
|
||||
SkASSERT(moveCnt);
|
||||
SkASSERT(moveCnt && !closeCount);
|
||||
SkDEBUGCODE(++segmentCount);
|
||||
nextPt = 3;
|
||||
break;
|
||||
case kClose_Verb:
|
||||
SkDEBUGCODE(++closeCount;)
|
||||
break;
|
||||
default:
|
||||
SkDEBUGFAIL("unknown verb");
|
||||
|
@ -1161,6 +1161,18 @@ static void test_conservativelyContains(skiatest::Reporter* reporter) {
|
||||
SkIntToScalar(200),
|
||||
SkIntToScalar(20),
|
||||
SkIntToScalar(5))));
|
||||
|
||||
// same as above path and first test but with an extra moveTo.
|
||||
path.reset();
|
||||
path.moveTo(100, 100);
|
||||
path.moveTo(0, 0);
|
||||
path.lineTo(SkIntToScalar(100), 0);
|
||||
path.lineTo(0, SkIntToScalar(100));
|
||||
|
||||
REPORTER_ASSERT(reporter, path.conservativelyContainsRect(SkRect::MakeXYWH(SkIntToScalar(50), 0,
|
||||
SkIntToScalar(10),
|
||||
SkIntToScalar(10))));
|
||||
|
||||
}
|
||||
|
||||
// Simple isRect test is inline TestPath, below.
|
||||
|
Loading…
Reference in New Issue
Block a user