Relax SkStrokeRec::hasEqualEffect
Ignores the miter limit if the join type is not kMiter.
Bug: skia:10419
Change-Id: Ib05895cf90c7bb0e25e9e8c3e26c13fef32f2e97
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317163
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/include/core/SkStrokeRec.h b/include/core/SkStrokeRec.h
index 6fa3872..b4796fc 100644
--- a/include/core/SkStrokeRec.h
+++ b/include/core/SkStrokeRec.h
@@ -127,7 +127,7 @@
return this->getStyle() == other.getStyle();
}
return fWidth == other.fWidth &&
- fMiterLimit == other.fMiterLimit &&
+ (fJoin != SkPaint::kMiter_Join || fMiterLimit == other.fMiterLimit) &&
fCap == other.fCap &&
fJoin == other.fJoin &&
fStrokeAndFill == other.fStrokeAndFill;
diff --git a/tests/StrokeTest.cpp b/tests/StrokeTest.cpp
index 84cc5e1..ed348d3 100644
--- a/tests/StrokeTest.cpp
+++ b/tests/StrokeTest.cpp
@@ -148,7 +148,7 @@
REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
s2.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kRound_Join, 2.1f);
- REPORTER_ASSERT(reporter, !s1.hasEqualEffect(s2));
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2)); // Miter limit not relevant to butt caps.
s2.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kBevel_Join, 2.9f);
REPORTER_ASSERT(reporter, !s1.hasEqualEffect(s2));
s2.setStrokeParams(SkPaint::kRound_Cap, SkPaint::kRound_Join, 2.9f);