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

Unified Diff: src/core/SkStroke.cpp

Issue 953383002: fuzzer fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix up width and height in initializer Created 5 years, 10 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/SkPath.cpp ('k') | tests/StrokeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkStroke.cpp
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp
index 29da19f4c5bf49e8baef904cb34f1e4b25559938..062406aa2c98a411fbd8d400e00fedb1033f583f 100644
--- a/src/core/SkStroke.cpp
+++ b/src/core/SkStroke.cpp
@@ -271,7 +271,7 @@ private:
#endif
void finishContour(bool close, bool isLine);
- void preJoinTo(const SkPoint&, SkVector* normal, SkVector* unitNormal,
+ bool preJoinTo(const SkPoint&, SkVector* normal, SkVector* unitNormal,
bool isLine);
void postJoinTo(const SkPoint&, const SkVector& normal,
const SkVector& unitNormal);
@@ -291,15 +291,16 @@ private:
///////////////////////////////////////////////////////////////////////////////
-void SkPathStroker::preJoinTo(const SkPoint& currPt, SkVector* normal,
+bool SkPathStroker::preJoinTo(const SkPoint& currPt, SkVector* normal,
SkVector* unitNormal, bool currIsLine) {
SkASSERT(fSegmentCount >= 0);
SkScalar prevX = fPrevPt.fX;
SkScalar prevY = fPrevPt.fY;
- SkAssertResult(set_normal_unitnormal(fPrevPt, currPt, fRadius, normal,
- unitNormal));
+ if (!set_normal_unitnormal(fPrevPt, currPt, fRadius, normal, unitNormal)) {
+ return false;
+ }
if (fSegmentCount == 0) {
fFirstNormal = *normal;
@@ -313,6 +314,7 @@ void SkPathStroker::preJoinTo(const SkPoint& currPt, SkVector* normal,
fRadius, fInvMiterLimit, fPrevIsLine, currIsLine);
}
fPrevIsLine = currIsLine;
+ return true;
}
void SkPathStroker::postJoinTo(const SkPoint& currPt, const SkVector& normal,
@@ -418,7 +420,9 @@ void SkPathStroker::lineTo(const SkPoint& currPt) {
}
SkVector normal, unitNormal;
- this->preJoinTo(currPt, &normal, &unitNormal, true);
+ if (!this->preJoinTo(currPt, &normal, &unitNormal, true)) {
+ return;
+ }
this->line_to(currPt, normal);
this->postJoinTo(currPt, normal, unitNormal);
}
@@ -796,16 +800,15 @@ void SkPathStroker::conicTo(const SkPoint& pt1, const SkPoint& pt2, SkScalar wei
}
SkASSERT(kQuad_ReductionType == reductionType);
SkVector normalAB, unitAB, normalBC, unitBC;
- this->preJoinTo(pt1, &normalAB, &unitAB, false);
- SkQuadConstruct quadPts;
- this->init(kOuter_StrokeType, &quadPts, 0, 1);
- if (!this->conicStroke(conic, &quadPts)) {
+ if (!this->preJoinTo(pt1, &normalAB, &unitAB, false)) {
+ this->lineTo(pt2);
return;
}
+ SkQuadConstruct quadPts;
+ this->init(kOuter_StrokeType, &quadPts, 0, 1);
+ (void) this->conicStroke(conic, &quadPts);
this->init(kInner_StrokeType, &quadPts, 0, 1);
- if (!this->conicStroke(conic, &quadPts)) {
- return;
- }
+ (void) this->conicStroke(conic, &quadPts);
this->setConicEndNormal(conic, normalAB, unitAB, &normalBC, &unitBC);
this->postJoinTo(pt2, normalBC, unitBC);
}
@@ -833,16 +836,15 @@ void SkPathStroker::quadTo(const SkPoint& pt1, const SkPoint& pt2) {
}
SkASSERT(kQuad_ReductionType == reductionType);
SkVector normalAB, unitAB, normalBC, unitBC;
- this->preJoinTo(pt1, &normalAB, &unitAB, false);
- SkQuadConstruct quadPts;
- this->init(kOuter_StrokeType, &quadPts, 0, 1);
- if (!this->quadStroke(quad, &quadPts)) {
+ if (!this->preJoinTo(pt1, &normalAB, &unitAB, false)) {
+ this->lineTo(pt2);
return;
}
+ SkQuadConstruct quadPts;
+ this->init(kOuter_StrokeType, &quadPts, 0, 1);
+ (void) this->quadStroke(quad, &quadPts);
this->init(kInner_StrokeType, &quadPts, 0, 1);
- if (!this->quadStroke(quad, &quadPts)) {
- return;
- }
+ (void) this->quadStroke(quad, &quadPts);
this->setQuadEndNormal(quad, normalAB, unitAB, &normalBC, &unitBC);
#else
bool degenerateAB = SkPath::IsLineDegenerate(fPrevPt, pt1);
@@ -1404,7 +1406,10 @@ void SkPathStroker::cubicTo(const SkPoint& pt1, const SkPoint& pt2,
}
SkASSERT(kQuad_ReductionType == reductionType);
SkVector normalAB, unitAB, normalCD, unitCD;
- this->preJoinTo(*tangentPt, &normalAB, &unitAB, false);
+ if (!this->preJoinTo(*tangentPt, &normalAB, &unitAB, false)) {
+ this->lineTo(pt3);
+ return;
+ }
SkScalar tValues[2];
int count = SkFindCubicInflections(cubic, tValues);
SkScalar lastT = 0;
@@ -1412,13 +1417,9 @@ void SkPathStroker::cubicTo(const SkPoint& pt1, const SkPoint& pt2,
SkScalar nextT = index < count ? tValues[index] : 1;
SkQuadConstruct quadPts;
this->init(kOuter_StrokeType, &quadPts, lastT, nextT);
- if (!this->cubicStroke(cubic, &quadPts)) {
- break;
- }
+ (void) this->cubicStroke(cubic, &quadPts);
this->init(kInner_StrokeType, &quadPts, lastT, nextT);
- if (!this->cubicStroke(cubic, &quadPts)) {
- break;
- }
+ (void) this->cubicStroke(cubic, &quadPts);
lastT = nextT;
}
// emit the join even if one stroke succeeded but the last one failed
« no previous file with comments | « src/core/SkPath.cpp ('k') | tests/StrokeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698