From 24ba1251583dc637ff1699550aa99811e886b4cf Mon Sep 17 00:00:00 2001 From: Doris Liu Date: Tue, 15 Mar 2016 17:01:55 -0700 Subject: [PATCH] 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 --- libs/hwui/VectorDrawable.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp index 2e3856fafb606..f7b38e33cae73 100644 --- a/libs/hwui/VectorDrawable.cpp +++ b/libs/hwui/VectorDrawable.cpp @@ -229,19 +229,25 @@ void FullPath::applyTrim() { // 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);