Fix issue where GrStyle::applyToPath exited before applying stroke
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1954123002 Review-Url: https://codereview.chromium.org/1954123002
This commit is contained in:
parent
4d0cd76477
commit
1a0b9ed7d8
@ -137,14 +137,20 @@ bool GrStyle::applyToPath(SkPath* dst, SkStrokeRec::InitStyle* style, const SkPa
|
||||
SkASSERT(style);
|
||||
SkASSERT(dst);
|
||||
SkStrokeRec strokeRec = fStrokeRec;
|
||||
if (!apply_path_effect(dst, &strokeRec, fPathEffect, src)) {
|
||||
const SkPath* pathForStrokeRec = &src;
|
||||
if (apply_path_effect(dst, &strokeRec, fPathEffect, src)) {
|
||||
pathForStrokeRec = dst;
|
||||
} else if (fPathEffect) {
|
||||
return false;
|
||||
}
|
||||
if (strokeRec.needToApply()) {
|
||||
if (!strokeRec.applyToPath(dst, *dst)) {
|
||||
if (!strokeRec.applyToPath(dst, *pathForStrokeRec)) {
|
||||
return false;
|
||||
}
|
||||
*style = SkStrokeRec::kFill_InitStyle;
|
||||
} else if (!fPathEffect) {
|
||||
// Nothing to do for path effect or stroke, fail.
|
||||
return false;
|
||||
} else {
|
||||
SkASSERT(SkStrokeRec::kFill_Style == strokeRec.getStyle() ||
|
||||
SkStrokeRec::kHairline_Style == strokeRec.getStyle());
|
||||
|
@ -135,14 +135,18 @@ public:
|
||||
|
||||
/**
|
||||
* Applies just the path effect and returns remaining stroke information. This will fail if
|
||||
* there is no path effect.
|
||||
* there is no path effect. dst may or may not have been overwritten on failure.
|
||||
*/
|
||||
bool applyPathEffectToPath(SkPath* dst, SkStrokeRec* remainingStoke, const SkPath& src) const;
|
||||
bool SK_WARN_UNUSED_RESULT applyPathEffectToPath(SkPath* dst, SkStrokeRec* remainingStoke,
|
||||
const SkPath& src) const;
|
||||
|
||||
/** If this succeeds then the result path should be filled or hairlined as indicated by the
|
||||
returned SkStrokeRec::InitStyle value. Will fail if there is no path effect and the
|
||||
strokerec doesn't change the geometry. */
|
||||
bool applyToPath(SkPath* dst, SkStrokeRec::InitStyle* fillOrHairline, const SkPath& src) const;
|
||||
strokerec doesn't change the geometry. When this fails the outputs may or may not have
|
||||
been overwritten.
|
||||
*/
|
||||
bool SK_WARN_UNUSED_RESULT applyToPath(SkPath* dst, SkStrokeRec::InitStyle* fillOrHairline,
|
||||
const SkPath& src) const;
|
||||
|
||||
/** Given bounds of a path compute the bounds of path with the style applied. */
|
||||
void adjustBounds(SkRect* dst, const SkRect& src) const {
|
||||
|
@ -88,17 +88,23 @@ private:
|
||||
SkPath postAllStyle;
|
||||
|
||||
fBase.asPath(&preStyle);
|
||||
SkStrokeRec postPathEffectStrokeRec(SkStrokeRec::kFill_InitStyle);
|
||||
if (fBase.style().applyPathEffectToPath(&postPathEffect, &postPathEffectStrokeRec,
|
||||
preStyle)) {
|
||||
SkStrokeRec postPEStrokeRec(SkStrokeRec::kFill_InitStyle);
|
||||
if (fBase.style().applyPathEffectToPath(&postPathEffect, &postPEStrokeRec, preStyle)) {
|
||||
// run postPathEffect through GrShape to get any geometry reductions that would have
|
||||
// occurred to fAppliedPE.
|
||||
GrShape(postPathEffect, GrStyle(postPEStrokeRec, nullptr)).asPath(&postPathEffect);
|
||||
|
||||
SkPath testPath;
|
||||
fAppliedPE.asPath(&testPath);
|
||||
REPORTER_ASSERT(r, testPath == postPathEffect);
|
||||
REPORTER_ASSERT(r,
|
||||
postPathEffectStrokeRec.hasEqualEffect(fAppliedPE.style().strokeRec()));
|
||||
REPORTER_ASSERT(r, postPEStrokeRec.hasEqualEffect(fAppliedPE.style().strokeRec()));
|
||||
}
|
||||
SkStrokeRec::InitStyle fillOrHairline;
|
||||
if (fBase.style().applyToPath(&postAllStyle, &fillOrHairline, preStyle)) {
|
||||
// run postPathEffect through GrShape to get any reductions that would have occurred
|
||||
// to fAppliedFull.
|
||||
GrShape(postAllStyle, GrStyle(fillOrHairline)).asPath(&postAllStyle);
|
||||
|
||||
SkPath testPath;
|
||||
fAppliedFull.asPath(&testPath);
|
||||
REPORTER_ASSERT(r, testPath == postAllStyle);
|
||||
|
Loading…
Reference in New Issue
Block a user