Workaround for PathMeasure.getSegment() behavior change
SkPathMeasure::getSegment(SkScalar startD, SkScalar stopD, SkPath* dst,
bool startWithMoveTo) in SkPathMeasure used to ignore the case when
startD == stopD in MNC release. In NYC, the same paramaters would yield
a tiny segment, which leaves undesirable artifacts as shown in the bug
below.
Bug: 27665826
Change-Id: I8289dc32773fd55d686458183af44ff072866c6e
diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp
index 2e3856f..f7b38e3 100644
--- a/libs/hwui/VectorDrawable.cpp
+++ b/libs/hwui/VectorDrawable.cpp
@@ -229,19 +229,25 @@
// No trimming necessary.
return;
}
+ mTrimDirty = false;
+ mTrimmedSkPath.reset();
+ if (mProperties.trimPathStart == mProperties.trimPathEnd) {
+ // Trimmed path should be empty.
+ return;
+ }
SkPathMeasure measure(mSkPath, false);
float len = SkScalarToFloat(measure.getLength());
float start = len * fmod((mProperties.trimPathStart + mProperties.trimPathOffset), 1.0f);
float end = len * fmod((mProperties.trimPathEnd + mProperties.trimPathOffset), 1.0f);
- mTrimmedSkPath.reset();
if (start > end) {
measure.getSegment(start, len, &mTrimmedSkPath, true);
- measure.getSegment(0, end, &mTrimmedSkPath, true);
+ if (end > 0) {
+ measure.getSegment(0, end, &mTrimmedSkPath, true);
+ }
} else {
measure.getSegment(start, end, &mTrimmedSkPath, true);
}
- mTrimDirty = false;
}
REQUIRE_COMPATIBLE_LAYOUT(FullPath::Properties);