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
This commit is contained in:
@@ -36,7 +36,6 @@ import java.awt.geom.PathIterator;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Delegate implementing the native methods of android.graphics.Path
|
||||
@@ -504,13 +503,13 @@ public final class Path_Delegate {
|
||||
switch (type) {
|
||||
case PathIterator.SEG_MOVETO:
|
||||
case PathIterator.SEG_LINETO:
|
||||
store(coords, tmp, 1, isFirstPoint);
|
||||
store(tmp, coords, 1, isFirstPoint);
|
||||
break;
|
||||
case PathIterator.SEG_QUADTO:
|
||||
store(coords, tmp, 2, isFirstPoint);
|
||||
store(tmp, coords, 2, isFirstPoint);
|
||||
break;
|
||||
case PathIterator.SEG_CUBICTO:
|
||||
store(coords, tmp, 3, isFirstPoint);
|
||||
store(tmp, coords, 3, isFirstPoint);
|
||||
break;
|
||||
case PathIterator.SEG_CLOSE:
|
||||
// No points returned.
|
||||
@@ -528,14 +527,14 @@ public final class Path_Delegate {
|
||||
|
||||
private static void store(float[] src, float[] dst, int count, boolean isFirst) {
|
||||
if (isFirst) {
|
||||
dst[0] = 0;
|
||||
dst[1] = src[0];
|
||||
dst[2] = src[1];
|
||||
dst[0] = 0; // fraction
|
||||
dst[1] = src[0]; // abscissa
|
||||
dst[2] = src[1]; // ordinate
|
||||
}
|
||||
if (count > 1 || !isFirst) {
|
||||
dst[3] = 1;
|
||||
dst[4] = src[2 * count];
|
||||
dst[5] = src[2 * count + 1];
|
||||
dst[4] = src[2 * count - 2];
|
||||
dst[5] = src[2 * count - 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user