Fix SkPath::reverseAddPath and fuzzing of SkPath enums
Bug: 882423 Change-Id: I2be2863574a5951b86e4d5e213094efee6081098 Reviewed-on: https://skia-review.googlesource.com/154300 Reviewed-by: Kevin Lubick <kjlubick@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
637c06aec7
commit
8051d38358
@ -83,24 +83,33 @@ void FuzzPath(Fuzz* fuzz, SkPath* path, int maxOps) {
|
||||
path->close();
|
||||
break;
|
||||
case 13:
|
||||
fuzz->next(&r, &dir);
|
||||
fuzz->next(&r);
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
dir = static_cast<SkPath::Direction>(ui);
|
||||
path->addRect(r, dir);
|
||||
break;
|
||||
case 14:
|
||||
fuzz->next(&r, &dir, &ui);
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
dir = static_cast<SkPath::Direction>(ui);
|
||||
fuzz->next(&r, &ui);
|
||||
path->addRect(r, dir, ui);
|
||||
break;
|
||||
case 15:
|
||||
fuzz->next(&r, &dir);
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
dir = static_cast<SkPath::Direction>(ui);
|
||||
fuzz->next(&r);
|
||||
path->addOval(r, dir);
|
||||
break;
|
||||
case 16:
|
||||
fuzz->next(&r, &dir, &ui);
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
dir = static_cast<SkPath::Direction>(ui);
|
||||
fuzz->next(&r, &ui);
|
||||
path->addOval(r, dir, ui);
|
||||
break;
|
||||
case 17:
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
dir = static_cast<SkPath::Direction>(ui);
|
||||
fuzz_nice_float(fuzz, &a, &b, &c);
|
||||
fuzz->next(&dir);
|
||||
path->addCircle(a, b, c, dir);
|
||||
break;
|
||||
case 18:
|
||||
@ -110,27 +119,35 @@ void FuzzPath(Fuzz* fuzz, SkPath* path, int maxOps) {
|
||||
break;
|
||||
case 19:
|
||||
fuzz_nice_float(fuzz, &a, &b);
|
||||
fuzz->next(&r, &dir);
|
||||
fuzz->next(&r);
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
dir = static_cast<SkPath::Direction>(ui);
|
||||
path->addRoundRect(r, a, b, dir);
|
||||
break;
|
||||
case 20:
|
||||
fuzz->next(&rr, &dir);
|
||||
fuzz->next(&rr);
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
dir = static_cast<SkPath::Direction>(ui);
|
||||
path->addRRect(rr, dir);
|
||||
break;
|
||||
case 21:
|
||||
fuzz->next(&rr, &dir, &ui);
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
dir = static_cast<SkPath::Direction>(ui);
|
||||
fuzz->next(&rr, &ui);
|
||||
path->addRRect(rr, dir, ui);
|
||||
break;
|
||||
case 22: {
|
||||
SkPath::AddPathMode mode;
|
||||
fuzz->next(&m, &mode);
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
SkPath::AddPathMode mode = static_cast<SkPath::AddPathMode>(ui);
|
||||
fuzz->next(&m);
|
||||
FuzzPath(fuzz, &p, maxOps-1);
|
||||
path->addPath(p, m, mode);
|
||||
break;
|
||||
}
|
||||
case 23: {
|
||||
SkPath::AddPathMode mode;
|
||||
fuzz->next(&m, &mode);
|
||||
fuzz->nextRange(&ui, 0, 1);
|
||||
SkPath::AddPathMode mode = static_cast<SkPath::AddPathMode>(ui);
|
||||
fuzz->next(&m);
|
||||
path->addPath(*path, m, mode);
|
||||
break;
|
||||
}
|
||||
|
@ -1708,14 +1708,21 @@ SkPath& SkPath::reversePathTo(const SkPath& path) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
SkPath& SkPath::reverseAddPath(const SkPath& src) {
|
||||
SkPathRef::Editor ed(&fPathRef, src.fPathRef->countPoints(), src.fPathRef->countVerbs());
|
||||
SkPath& SkPath::reverseAddPath(const SkPath& srcPath) {
|
||||
// Detect if we're trying to add ourself
|
||||
const SkPath* src = &srcPath;
|
||||
SkTLazy<SkPath> tmp;
|
||||
if (this == src) {
|
||||
src = tmp.set(srcPath);
|
||||
}
|
||||
|
||||
const SkPoint* pts = src.fPathRef->pointsEnd();
|
||||
SkPathRef::Editor ed(&fPathRef, src->fPathRef->countPoints(), src->fPathRef->countVerbs());
|
||||
|
||||
const SkPoint* pts = src->fPathRef->pointsEnd();
|
||||
// we will iterator through src's verbs backwards
|
||||
const uint8_t* verbs = src.fPathRef->verbsMemBegin(); // points at the last verb
|
||||
const uint8_t* verbsEnd = src.fPathRef->verbs(); // points just past the first verb
|
||||
const SkScalar* conicWeights = src.fPathRef->conicWeightsEnd();
|
||||
const uint8_t* verbs = src->fPathRef->verbsMemBegin(); // points at the last verb
|
||||
const uint8_t* verbsEnd = src->fPathRef->verbs(); // points just past the first verb
|
||||
const SkScalar* conicWeights = src->fPathRef->conicWeightsEnd();
|
||||
|
||||
bool needMove = true;
|
||||
bool needClose = false;
|
||||
|
Loading…
Reference in New Issue
Block a user