From 7b1e486e8778c042eb95e1517ed4ff8cac461759 Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Fri, 31 Jul 2015 11:33:25 -0700 Subject: [PATCH] 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 --- .../src/android/graphics/Path_Delegate.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java index 34d09859e2b4f..3c9a062719e27 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java @@ -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]; } }