diff options
author | George Mount <mount@google.com> | 2014-09-11 10:25:31 -0700 |
---|---|---|
committer | George Mount <mount@google.com> | 2014-09-11 10:25:31 -0700 |
commit | 68cfdad20d83400e0cc0ddb4c86deaeda3337d4d (patch) | |
tree | 34f0e417bd0add4462edc424d752a554d740ba68 /core/jni/android | |
parent | 8232d822aa97e78e982ed154ac618cde34baac2a (diff) | |
download | frameworks_base-68cfdad20d83400e0cc0ddb4c86deaeda3337d4d.zip frameworks_base-68cfdad20d83400e0cc0ddb4c86deaeda3337d4d.tar.gz frameworks_base-68cfdad20d83400e0cc0ddb4c86deaeda3337d4d.tar.bz2 |
Allow Path approximation to work with a single point Path.
Bug 17452965
A single point Path (move-to only) was not returning any
verbs in the verb list. This forces an approximation for
single move-to and empty paths by giving the same value
for fraction 0 and fraction 1.
Change-Id: Icb1b932d730457680cf422377a83fe669f0a7687
Diffstat (limited to 'core/jni/android')
-rw-r--r-- | core/jni/android/graphics/Path.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/core/jni/android/graphics/Path.cpp b/core/jni/android/graphics/Path.cpp index 6ef1d2c..9d3e74b 100644 --- a/core/jni/android/graphics/Path.cpp +++ b/core/jni/android/graphics/Path.cpp @@ -435,19 +435,32 @@ public: std::vector<float> lengths; float errorSquared = acceptableError * acceptableError; - while ((verb = pathIter.next(points)) != SkPath::kDone_Verb) { + while ((verb = pathIter.next(points, false)) != SkPath::kDone_Verb) { createVerbSegments(verb, points, segmentPoints, lengths, errorSquared); } if (segmentPoints.empty()) { - return NULL; + int numVerbs = path->countVerbs(); + if (numVerbs == 1) { + addMove(segmentPoints, lengths, path->getPoint(0)); + } else { + // Invalid or empty path. Fall back to point(0,0) + addMove(segmentPoints, lengths, SkPoint()); + } + } + + float totalLength = lengths.back(); + if (totalLength == 0) { + // Lone Move instructions should still be able to animate at the same value. + segmentPoints.push_back(segmentPoints.back()); + lengths.push_back(1); + totalLength = 1; } size_t numPoints = segmentPoints.size(); size_t approximationArraySize = numPoints * 3; float* approximation = new float[approximationArraySize]; - float totalLength = lengths.back(); int approximationIndex = 0; for (size_t i = 0; i < numPoints; i++) { |