Skip to content

Commit 7b1e486

Browse files
committed
Fix bugs introduced in 78aa664.
Fix a couple of bugs (ArrayIndexOutOfBoundsException due to miscalculation and a typo - swapped src and dst) introduced in the CL: 78aa664 Poor implementation of Path.approximate() Change-Id: Iff7dbbf66d2714df51699ddb9a4169c38feefa7b
1 parent e836a22 commit 7b1e486

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import java.awt.geom.Point2D;
3737
import java.awt.geom.Rectangle2D;
3838
import java.awt.geom.RoundRectangle2D;
39-
import java.util.ArrayList;
4039

4140
/**
4241
* Delegate implementing the native methods of android.graphics.Path
@@ -504,13 +503,13 @@ public void setPathIterator(PathIterator iterator) {
504503
switch (type) {
505504
case PathIterator.SEG_MOVETO:
506505
case PathIterator.SEG_LINETO:
507-
store(coords, tmp, 1, isFirstPoint);
506+
store(tmp, coords, 1, isFirstPoint);
508507
break;
509508
case PathIterator.SEG_QUADTO:
510-
store(coords, tmp, 2, isFirstPoint);
509+
store(tmp, coords, 2, isFirstPoint);
511510
break;
512511
case PathIterator.SEG_CUBICTO:
513-
store(coords, tmp, 3, isFirstPoint);
512+
store(tmp, coords, 3, isFirstPoint);
514513
break;
515514
case PathIterator.SEG_CLOSE:
516515
// No points returned.
@@ -528,14 +527,14 @@ public void setPathIterator(PathIterator iterator) {
528527

529528
private static void store(float[] src, float[] dst, int count, boolean isFirst) {
530529
if (isFirst) {
531-
dst[0] = 0;
532-
dst[1] = src[0];
533-
dst[2] = src[1];
530+
dst[0] = 0; // fraction
531+
dst[1] = src[0]; // abscissa
532+
dst[2] = src[1]; // ordinate
534533
}
535534
if (count > 1 || !isFirst) {
536535
dst[3] = 1;
537-
dst[4] = src[2 * count];
538-
dst[5] = src[2 * count + 1];
536+
dst[4] = src[2 * count - 2];
537+
dst[5] = src[2 * count - 1];
539538
}
540539
}
541540

0 commit comments

Comments
 (0)