Merge "Fix the starting pen's position when a path close." into lmp-mr1-dev
This commit is contained in:
@@ -280,7 +280,7 @@ public class PathParser {
|
|||||||
* @param path The target Path object.
|
* @param path The target Path object.
|
||||||
*/
|
*/
|
||||||
public static void nodesToPath(PathDataNode[] node, Path path) {
|
public static void nodesToPath(PathDataNode[] node, Path path) {
|
||||||
float[] current = new float[4];
|
float[] current = new float[6];
|
||||||
char previousCommand = 'm';
|
char previousCommand = 'm';
|
||||||
for (int i = 0; i < node.length; i++) {
|
for (int i = 0; i < node.length; i++) {
|
||||||
addCommand(path, current, previousCommand, node[i].mType, node[i].mParams);
|
addCommand(path, current, previousCommand, node[i].mType, node[i].mParams);
|
||||||
@@ -313,6 +313,8 @@ public class PathParser {
|
|||||||
float currentY = current[1];
|
float currentY = current[1];
|
||||||
float ctrlPointX = current[2];
|
float ctrlPointX = current[2];
|
||||||
float ctrlPointY = current[3];
|
float ctrlPointY = current[3];
|
||||||
|
float currentSegmentStartX = current[4];
|
||||||
|
float currentSegmentStartY = current[5];
|
||||||
float reflectiveCtrlPointX;
|
float reflectiveCtrlPointX;
|
||||||
float reflectiveCtrlPointY;
|
float reflectiveCtrlPointY;
|
||||||
|
|
||||||
@@ -320,7 +322,15 @@ public class PathParser {
|
|||||||
case 'z':
|
case 'z':
|
||||||
case 'Z':
|
case 'Z':
|
||||||
path.close();
|
path.close();
|
||||||
return;
|
// Path is closed here, but we need to move the pen to the
|
||||||
|
// closed position. So we cache the segment's starting position,
|
||||||
|
// and restore it here.
|
||||||
|
currentX = currentSegmentStartX;
|
||||||
|
currentY = currentSegmentStartY;
|
||||||
|
ctrlPointX = currentSegmentStartX;
|
||||||
|
ctrlPointY = currentSegmentStartY;
|
||||||
|
path.moveTo(currentX, currentY);
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
case 'M':
|
case 'M':
|
||||||
case 'l':
|
case 'l':
|
||||||
@@ -350,17 +360,22 @@ public class PathParser {
|
|||||||
incr = 7;
|
incr = 7;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int k = 0; k < val.length; k += incr) {
|
for (int k = 0; k < val.length; k += incr) {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 'm': // moveto - Start a new sub-path (relative)
|
case 'm': // moveto - Start a new sub-path (relative)
|
||||||
path.rMoveTo(val[k + 0], val[k + 1]);
|
path.rMoveTo(val[k + 0], val[k + 1]);
|
||||||
currentX += val[k + 0];
|
currentX += val[k + 0];
|
||||||
currentY += val[k + 1];
|
currentY += val[k + 1];
|
||||||
|
currentSegmentStartX = currentX;
|
||||||
|
currentSegmentStartY = currentY;
|
||||||
break;
|
break;
|
||||||
case 'M': // moveto - Start a new sub-path
|
case 'M': // moveto - Start a new sub-path
|
||||||
path.moveTo(val[k + 0], val[k + 1]);
|
path.moveTo(val[k + 0], val[k + 1]);
|
||||||
currentX = val[k + 0];
|
currentX = val[k + 0];
|
||||||
currentY = val[k + 1];
|
currentY = val[k + 1];
|
||||||
|
currentSegmentStartX = currentX;
|
||||||
|
currentSegmentStartY = currentY;
|
||||||
break;
|
break;
|
||||||
case 'l': // lineto - Draw a line from the current point (relative)
|
case 'l': // lineto - Draw a line from the current point (relative)
|
||||||
path.rLineTo(val[k + 0], val[k + 1]);
|
path.rLineTo(val[k + 0], val[k + 1]);
|
||||||
@@ -372,10 +387,6 @@ public class PathParser {
|
|||||||
currentX = val[k + 0];
|
currentX = val[k + 0];
|
||||||
currentY = val[k + 1];
|
currentY = val[k + 1];
|
||||||
break;
|
break;
|
||||||
case 'z': // closepath - Close the current subpath
|
|
||||||
case 'Z': // closepath - Close the current subpath
|
|
||||||
path.close();
|
|
||||||
break;
|
|
||||||
case 'h': // horizontal lineto - Draws a horizontal line (relative)
|
case 'h': // horizontal lineto - Draws a horizontal line (relative)
|
||||||
path.rLineTo(val[k + 0], 0);
|
path.rLineTo(val[k + 0], 0);
|
||||||
currentX += val[k + 0];
|
currentX += val[k + 0];
|
||||||
@@ -526,6 +537,8 @@ public class PathParser {
|
|||||||
current[1] = currentY;
|
current[1] = currentY;
|
||||||
current[2] = ctrlPointX;
|
current[2] = ctrlPointX;
|
||||||
current[3] = ctrlPointY;
|
current[3] = ctrlPointY;
|
||||||
|
current[4] = currentSegmentStartX;
|
||||||
|
current[5] = currentSegmentStartY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawArc(Path p,
|
private static void drawArc(Path p,
|
||||||
|
|||||||
28
tests/VectorDrawableTest/res/drawable/vector_drawable30.xml
Normal file
28
tests/VectorDrawableTest/res/drawable/vector_drawable30.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2014 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:height="48dp"
|
||||||
|
android:width="48dp"
|
||||||
|
android:viewportHeight="48"
|
||||||
|
android:viewportWidth="48" >
|
||||||
|
|
||||||
|
<group>
|
||||||
|
<path
|
||||||
|
android:name="plus1"
|
||||||
|
android:pathData="M20 16h-4v8h-8v4h8v8h4v-8h8v-4h-8zm9-3.84v3.64l5-1v21.2h4v-26z"
|
||||||
|
android:fillColor="#ff00ff00"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
@@ -57,6 +57,7 @@ public class VectorDrawablePerformance extends Activity {
|
|||||||
R.drawable.vector_drawable27,
|
R.drawable.vector_drawable27,
|
||||||
R.drawable.vector_drawable28,
|
R.drawable.vector_drawable28,
|
||||||
R.drawable.vector_drawable29,
|
R.drawable.vector_drawable29,
|
||||||
|
R.drawable.vector_drawable30,
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user