summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTenghui Zhu <ztenghui@google.com>2015-09-14 20:32:23 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-09-14 20:32:23 +0000
commitf247ea6d4e20d9dfe5eb2033fa277c4328e200a1 (patch)
tree113e0bc148bcf03c9cf044eafd061414426af3d2 /core/java
parent105f38ccd76f26d4271b83d3b6e22b2d19e199f9 (diff)
parent17a1422a12d03b18d7fecffa8f24958a127ac14a (diff)
Merge "Fix implicit lineTo issue"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/util/PathParser.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/core/java/android/util/PathParser.java b/core/java/android/util/PathParser.java
index 18dc26279f6c..954dcfbe9b2d 100644
--- a/core/java/android/util/PathParser.java
+++ b/core/java/android/util/PathParser.java
@@ -364,18 +364,32 @@ public class PathParser {
for (int k = 0; k < val.length; k += incr) {
switch (cmd) {
case 'm': // moveto - Start a new sub-path (relative)
- path.rMoveTo(val[k + 0], val[k + 1]);
currentX += val[k + 0];
currentY += val[k + 1];
- currentSegmentStartX = currentX;
- currentSegmentStartY = currentY;
+ if (k > 0) {
+ // According to the spec, if a moveto is followed by multiple
+ // pairs of coordinates, the subsequent pairs are treated as
+ // implicit lineto commands.
+ path.rLineTo(val[k + 0], val[k + 1]);
+ } else {
+ path.rMoveTo(val[k + 0], val[k + 1]);
+ currentSegmentStartX = currentX;
+ currentSegmentStartY = currentY;
+ }
break;
case 'M': // moveto - Start a new sub-path
- path.moveTo(val[k + 0], val[k + 1]);
currentX = val[k + 0];
currentY = val[k + 1];
- currentSegmentStartX = currentX;
- currentSegmentStartY = currentY;
+ if (k > 0) {
+ // According to the spec, if a moveto is followed by multiple
+ // pairs of coordinates, the subsequent pairs are treated as
+ // implicit lineto commands.
+ path.lineTo(val[k + 0], val[k + 1]);
+ } else {
+ path.moveTo(val[k + 0], val[k + 1]);
+ currentSegmentStartX = currentX;
+ currentSegmentStartY = currentY;
+ }
break;
case 'l': // lineto - Draw a line from the current point (relative)
path.rLineTo(val[k + 0], val[k + 1]);