Merge "Implement native methods in VectorDrawable" into nyc-dev
This commit is contained in:
@@ -305,6 +305,12 @@ public final class BridgeTypedArray extends TypedArray {
|
||||
return defValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComplexColor getComplexColor(int index) {
|
||||
// TODO: Support GradientColor
|
||||
return getColorStateList(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the ColorStateList for the attribute at <var>index</var>.
|
||||
* The value may be either a single solid color or a reference to
|
||||
|
||||
@@ -142,7 +142,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_setBitmap(long canvas, Bitmap bitmap) {
|
||||
public static void native_setBitmap(long canvas, Bitmap bitmap) {
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(canvas);
|
||||
Bitmap_Delegate bitmapDelegate = Bitmap_Delegate.getDelegate(bitmap);
|
||||
if (canvasDelegate == null || bitmapDelegate==null) {
|
||||
@@ -153,7 +153,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static boolean native_isOpaque(long nativeCanvas) {
|
||||
public static boolean native_isOpaque(long nativeCanvas) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -164,10 +164,10 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_setHighContrastText(long nativeCanvas, boolean highContrastText){}
|
||||
public static void native_setHighContrastText(long nativeCanvas, boolean highContrastText){}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static int native_getWidth(long nativeCanvas) {
|
||||
public static int native_getWidth(long nativeCanvas) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -178,7 +178,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static int native_getHeight(long nativeCanvas) {
|
||||
public static int native_getHeight(long nativeCanvas) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -189,7 +189,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static int native_save(long nativeCanvas, int saveFlags) {
|
||||
public static int native_save(long nativeCanvas, int saveFlags) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -200,7 +200,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static int native_saveLayer(long nativeCanvas, float l,
|
||||
public static int native_saveLayer(long nativeCanvas, float l,
|
||||
float t, float r, float b,
|
||||
long paint, int layerFlags) {
|
||||
// get the delegate from the native int.
|
||||
@@ -219,7 +219,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static int native_saveLayerAlpha(long nativeCanvas, float l,
|
||||
public static int native_saveLayerAlpha(long nativeCanvas, float l,
|
||||
float t, float r, float b,
|
||||
int alpha, int layerFlags) {
|
||||
// get the delegate from the native int.
|
||||
@@ -232,7 +232,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_restore(long nativeCanvas, boolean throwOnUnderflow) {
|
||||
public static void native_restore(long nativeCanvas, boolean throwOnUnderflow) {
|
||||
// FIXME: implement throwOnUnderflow.
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
@@ -244,7 +244,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_restoreToCount(long nativeCanvas, int saveCount,
|
||||
public static void native_restoreToCount(long nativeCanvas, int saveCount,
|
||||
boolean throwOnUnderflow) {
|
||||
// FIXME: implement throwOnUnderflow.
|
||||
// get the delegate from the native int.
|
||||
@@ -257,7 +257,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static int native_getSaveCount(long nativeCanvas) {
|
||||
public static int native_getSaveCount(long nativeCanvas) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -268,7 +268,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_translate(long nativeCanvas, float dx, float dy) {
|
||||
public static void native_translate(long nativeCanvas, float dx, float dy) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -279,7 +279,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_scale(long nativeCanvas, float sx, float sy) {
|
||||
public static void native_scale(long nativeCanvas, float sx, float sy) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -290,7 +290,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_rotate(long nativeCanvas, float degrees) {
|
||||
public static void native_rotate(long nativeCanvas, float degrees) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -301,7 +301,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_skew(long nativeCanvas, float kx, float ky) {
|
||||
public static void native_skew(long nativeCanvas, float kx, float ky) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -325,7 +325,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_concat(long nCanvas, long nMatrix) {
|
||||
public static void native_concat(long nCanvas, long nMatrix) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -353,7 +353,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_setMatrix(long nCanvas, long nMatrix) {
|
||||
public static void native_setMatrix(long nCanvas, long nMatrix) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -383,7 +383,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static boolean native_clipRect(long nCanvas,
|
||||
public static boolean native_clipRect(long nCanvas,
|
||||
float left, float top,
|
||||
float right, float bottom,
|
||||
int regionOp) {
|
||||
@@ -397,7 +397,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static boolean native_clipPath(long nativeCanvas,
|
||||
public static boolean native_clipPath(long nativeCanvas,
|
||||
long nativePath,
|
||||
int regionOp) {
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
@@ -414,7 +414,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static boolean native_clipRegion(long nativeCanvas,
|
||||
public static boolean native_clipRegion(long nativeCanvas,
|
||||
long nativeRegion,
|
||||
int regionOp) {
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
@@ -431,7 +431,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void nativeSetDrawFilter(long nativeCanvas, long nativeFilter) {
|
||||
public static void nativeSetDrawFilter(long nativeCanvas, long nativeFilter) {
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
return;
|
||||
@@ -446,7 +446,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static boolean native_getClipBounds(long nativeCanvas,
|
||||
public static boolean native_getClipBounds(long nativeCanvas,
|
||||
Rect bounds) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
@@ -467,7 +467,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_getCTM(long canvas, long matrix) {
|
||||
public static void native_getCTM(long canvas, long matrix) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(canvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -484,13 +484,13 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static boolean native_quickReject(long nativeCanvas, long path) {
|
||||
public static boolean native_quickReject(long nativeCanvas, long path) {
|
||||
// FIXME properly implement quickReject
|
||||
return false;
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static boolean native_quickReject(long nativeCanvas,
|
||||
public static boolean native_quickReject(long nativeCanvas,
|
||||
float left, float top,
|
||||
float right, float bottom) {
|
||||
// FIXME properly implement quickReject
|
||||
@@ -498,7 +498,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawColor(long nativeCanvas, final int color, final int mode) {
|
||||
public static void native_drawColor(long nativeCanvas, final int color, final int mode) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
|
||||
if (canvasDelegate == null) {
|
||||
@@ -529,14 +529,14 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawPaint(long nativeCanvas, long paint) {
|
||||
public static void native_drawPaint(long nativeCanvas, long paint) {
|
||||
// FIXME
|
||||
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
|
||||
"Canvas.drawPaint is not supported.", null, null /*data*/);
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawPoint(long nativeCanvas, float x, float y,
|
||||
public static void native_drawPoint(long nativeCanvas, float x, float y,
|
||||
long nativePaint) {
|
||||
// FIXME
|
||||
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
|
||||
@@ -544,7 +544,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawPoints(long nativeCanvas, float[] pts, int offset, int count,
|
||||
public static void native_drawPoints(long nativeCanvas, float[] pts, int offset, int count,
|
||||
long nativePaint) {
|
||||
// FIXME
|
||||
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
|
||||
@@ -552,7 +552,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawLine(long nativeCanvas,
|
||||
public static void native_drawLine(long nativeCanvas,
|
||||
final float startX, final float startY, final float stopX, final float stopY,
|
||||
long paint) {
|
||||
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
|
||||
@@ -565,7 +565,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawLines(long nativeCanvas,
|
||||
public static void native_drawLines(long nativeCanvas,
|
||||
final float[] pts, final int offset, final int count,
|
||||
long nativePaint) {
|
||||
draw(nativeCanvas, nativePaint, false /*compositeOnly*/,
|
||||
@@ -581,7 +581,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawRect(long nativeCanvas,
|
||||
public static void native_drawRect(long nativeCanvas,
|
||||
final float left, final float top, final float right, final float bottom, long paint) {
|
||||
|
||||
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
|
||||
@@ -607,7 +607,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawOval(long nativeCanvas, final float left,
|
||||
public static void native_drawOval(long nativeCanvas, final float left,
|
||||
final float top, final float right, final float bottom, long paint) {
|
||||
if (right > left && bottom > top) {
|
||||
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
|
||||
@@ -634,7 +634,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawCircle(long nativeCanvas,
|
||||
public static void native_drawCircle(long nativeCanvas,
|
||||
float cx, float cy, float radius, long paint) {
|
||||
native_drawOval(nativeCanvas,
|
||||
cx - radius, cy - radius, cx + radius, cy + radius,
|
||||
@@ -642,7 +642,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawArc(long nativeCanvas,
|
||||
public static void native_drawArc(long nativeCanvas,
|
||||
final float left, final float top, final float right, final float bottom,
|
||||
final float startAngle, final float sweep,
|
||||
final boolean useCenter, long paint) {
|
||||
@@ -674,7 +674,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawRoundRect(long nativeCanvas,
|
||||
public static void native_drawRoundRect(long nativeCanvas,
|
||||
final float left, final float top, final float right, final float bottom,
|
||||
final float rx, final float ry, long paint) {
|
||||
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
|
||||
@@ -704,7 +704,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawPath(long nativeCanvas, long path, long paint) {
|
||||
public static void native_drawPath(long nativeCanvas, long path, long paint) {
|
||||
final Path_Delegate pathDelegate = Path_Delegate.getDelegate(path);
|
||||
if (pathDelegate == null) {
|
||||
return;
|
||||
@@ -756,7 +756,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawRegion(long nativeCanvas, long nativeRegion,
|
||||
public static void native_drawRegion(long nativeCanvas, long nativeRegion,
|
||||
long nativePaint) {
|
||||
// FIXME
|
||||
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
|
||||
@@ -764,7 +764,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawNinePatch(Canvas thisCanvas, long nativeCanvas,
|
||||
public static void native_drawNinePatch(Canvas thisCanvas, long nativeCanvas,
|
||||
long nativeBitmap, long ninePatch, final float dstLeft, final float dstTop,
|
||||
final float dstRight, final float dstBottom, long nativePaintOrZero,
|
||||
final int screenDensity, final int bitmapDensity) {
|
||||
@@ -811,7 +811,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, Bitmap bitmap,
|
||||
public static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, Bitmap bitmap,
|
||||
float left, float top,
|
||||
long nativePaintOrZero,
|
||||
int canvasDensity,
|
||||
@@ -833,7 +833,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, Bitmap bitmap,
|
||||
public static void native_drawBitmap(Canvas thisCanvas, long nativeCanvas, Bitmap bitmap,
|
||||
float srcLeft, float srcTop, float srcRight, float srcBottom,
|
||||
float dstLeft, float dstTop, float dstRight, float dstBottom,
|
||||
long nativePaintOrZero, int screenDensity, int bitmapDensity) {
|
||||
@@ -849,7 +849,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawBitmap(long nativeCanvas, int[] colors,
|
||||
public static void native_drawBitmap(long nativeCanvas, int[] colors,
|
||||
int offset, int stride, final float x,
|
||||
final float y, int width, int height,
|
||||
boolean hasAlpha,
|
||||
@@ -874,7 +874,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void nativeDrawBitmapMatrix(long nCanvas, Bitmap bitmap,
|
||||
public static void nativeDrawBitmapMatrix(long nCanvas, Bitmap bitmap,
|
||||
long nMatrix, long nPaint) {
|
||||
// get the delegate from the native int.
|
||||
Canvas_Delegate canvasDelegate = sManager.getDelegate(nCanvas);
|
||||
@@ -915,7 +915,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void nativeDrawBitmapMesh(long nCanvas, Bitmap bitmap,
|
||||
public static void nativeDrawBitmapMesh(long nCanvas, Bitmap bitmap,
|
||||
int meshWidth, int meshHeight, float[] verts, int vertOffset, int[] colors,
|
||||
int colorOffset, long nPaint) {
|
||||
// FIXME
|
||||
@@ -924,7 +924,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void nativeDrawVertices(long nCanvas, int mode, int n,
|
||||
public static void nativeDrawVertices(long nCanvas, int mode, int n,
|
||||
float[] verts, int vertOffset,
|
||||
float[] texs, int texOffset,
|
||||
int[] colors, int colorOffset,
|
||||
@@ -936,14 +936,14 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawText(long nativeCanvas, char[] text, int index, int count,
|
||||
public static void native_drawText(long nativeCanvas, char[] text, int index, int count,
|
||||
float startX, float startY, int flags, long paint, long typeface) {
|
||||
drawText(nativeCanvas, text, index, count, startX, startY, (flags & 1) != 0,
|
||||
paint, typeface);
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawText(long nativeCanvas, String text,
|
||||
public static void native_drawText(long nativeCanvas, String text,
|
||||
int start, int end, float x, float y, final int flags, long paint,
|
||||
long typeface) {
|
||||
int count = end - start;
|
||||
@@ -954,7 +954,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawTextRun(long nativeCanvas, String text,
|
||||
public static void native_drawTextRun(long nativeCanvas, String text,
|
||||
int start, int end, int contextStart, int contextEnd,
|
||||
float x, float y, boolean isRtl, long paint, long typeface) {
|
||||
int count = end - start;
|
||||
@@ -965,14 +965,14 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawTextRun(long nativeCanvas, char[] text,
|
||||
public static void native_drawTextRun(long nativeCanvas, char[] text,
|
||||
int start, int count, int contextStart, int contextCount,
|
||||
float x, float y, boolean isRtl, long paint, long typeface) {
|
||||
drawText(nativeCanvas, text, start, count, x, y, isRtl, paint, typeface);
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawTextOnPath(long nativeCanvas,
|
||||
public static void native_drawTextOnPath(long nativeCanvas,
|
||||
char[] text, int index,
|
||||
int count, long path,
|
||||
float hOffset,
|
||||
@@ -984,7 +984,7 @@ public final class Canvas_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static void native_drawTextOnPath(long nativeCanvas,
|
||||
public static void native_drawTextOnPath(long nativeCanvas,
|
||||
String text, long path,
|
||||
float hOffset,
|
||||
float vOffset,
|
||||
|
||||
@@ -223,6 +223,10 @@ public class Paint_Delegate {
|
||||
return mColorFilter;
|
||||
}
|
||||
|
||||
public void setColorFilter(long colorFilterPtr) {
|
||||
mColorFilter = ColorFilter_Delegate.getDelegate(colorFilterPtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Shader} delegate or null if none have been set
|
||||
*
|
||||
|
||||
@@ -572,7 +572,7 @@ public final class Path_Delegate {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void addPath(long destPath, long srcPath, AffineTransform transform) {
|
||||
public static void addPath(long destPath, long srcPath, AffineTransform transform) {
|
||||
Path_Delegate destPathDelegate = sManager.getDelegate(destPath);
|
||||
if (destPathDelegate == null) {
|
||||
return;
|
||||
@@ -630,7 +630,7 @@ public final class Path_Delegate {
|
||||
* Fills the given {@link RectF} with the path bounds.
|
||||
* @param bounds the RectF to be filled.
|
||||
*/
|
||||
private void fillBounds(RectF bounds) {
|
||||
public void fillBounds(RectF bounds) {
|
||||
Rectangle2D rect = mPath.getBounds2D();
|
||||
bounds.left = (float)rect.getMinX();
|
||||
bounds.right = (float)rect.getMaxX();
|
||||
@@ -644,7 +644,7 @@ public final class Path_Delegate {
|
||||
* @param x The x-coordinate of the start of a new contour
|
||||
* @param y The y-coordinate of the start of a new contour
|
||||
*/
|
||||
private void moveTo(float x, float y) {
|
||||
public void moveTo(float x, float y) {
|
||||
mPath.moveTo(mLastX = x, mLastY = y);
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ public final class Path_Delegate {
|
||||
* @param dy The amount to add to the y-coordinate of the end of the
|
||||
* previous contour, to specify the start of a new contour
|
||||
*/
|
||||
private void rMoveTo(float dx, float dy) {
|
||||
public void rMoveTo(float dx, float dy) {
|
||||
dx += mLastX;
|
||||
dy += mLastY;
|
||||
mPath.moveTo(mLastX = dx, mLastY = dy);
|
||||
@@ -672,7 +672,7 @@ public final class Path_Delegate {
|
||||
* @param x The x-coordinate of the end of a line
|
||||
* @param y The y-coordinate of the end of a line
|
||||
*/
|
||||
private void lineTo(float x, float y) {
|
||||
public void lineTo(float x, float y) {
|
||||
if (!hasPoints()) {
|
||||
mPath.moveTo(mLastX = 0, mLastY = 0);
|
||||
}
|
||||
@@ -689,7 +689,7 @@ public final class Path_Delegate {
|
||||
* @param dy The amount to add to the y-coordinate of the previous point on
|
||||
* this contour, to specify a line
|
||||
*/
|
||||
private void rLineTo(float dx, float dy) {
|
||||
public void rLineTo(float dx, float dy) {
|
||||
if (!hasPoints()) {
|
||||
mPath.moveTo(mLastX = 0, mLastY = 0);
|
||||
}
|
||||
@@ -714,7 +714,7 @@ public final class Path_Delegate {
|
||||
* @param x2 The x-coordinate of the end point on a quadratic curve
|
||||
* @param y2 The y-coordinate of the end point on a quadratic curve
|
||||
*/
|
||||
private void quadTo(float x1, float y1, float x2, float y2) {
|
||||
public void quadTo(float x1, float y1, float x2, float y2) {
|
||||
mPath.quadTo(x1, y1, mLastX = x2, mLastY = y2);
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ public final class Path_Delegate {
|
||||
* @param dy2 The amount to add to the y-coordinate of the last point on
|
||||
* this contour, for the end point of a quadratic curve
|
||||
*/
|
||||
private void rQuadTo(float dx1, float dy1, float dx2, float dy2) {
|
||||
public void rQuadTo(float dx1, float dy1, float dx2, float dy2) {
|
||||
if (!hasPoints()) {
|
||||
mPath.moveTo(mLastX = 0, mLastY = 0);
|
||||
}
|
||||
@@ -755,7 +755,7 @@ public final class Path_Delegate {
|
||||
* @param x3 The x-coordinate of the end point on a cubic curve
|
||||
* @param y3 The y-coordinate of the end point on a cubic curve
|
||||
*/
|
||||
private void cubicTo(float x1, float y1, float x2, float y2,
|
||||
public void cubicTo(float x1, float y1, float x2, float y2,
|
||||
float x3, float y3) {
|
||||
if (!hasPoints()) {
|
||||
mPath.moveTo(0, 0);
|
||||
@@ -768,7 +768,7 @@ public final class Path_Delegate {
|
||||
* current point on this contour. If there is no previous point, then a
|
||||
* moveTo(0,0) is inserted automatically.
|
||||
*/
|
||||
private void rCubicTo(float dx1, float dy1, float dx2, float dy2,
|
||||
public void rCubicTo(float dx1, float dy1, float dx2, float dy2,
|
||||
float dx3, float dy3) {
|
||||
if (!hasPoints()) {
|
||||
mPath.moveTo(mLastX = 0, mLastY = 0);
|
||||
@@ -798,7 +798,7 @@ public final class Path_Delegate {
|
||||
* mod 360.
|
||||
* @param forceMoveTo If true, always begin a new contour with the arc
|
||||
*/
|
||||
private void arcTo(float left, float top, float right, float bottom, float startAngle,
|
||||
public void arcTo(float left, float top, float right, float bottom, float startAngle,
|
||||
float sweepAngle,
|
||||
boolean forceMoveTo) {
|
||||
Arc2D arc = new Arc2D.Float(left, top, right - left, bottom - top, -startAngle,
|
||||
@@ -812,7 +812,7 @@ public final class Path_Delegate {
|
||||
* Close the current contour. If the current point is not equal to the
|
||||
* first point of the contour, a line segment is automatically added.
|
||||
*/
|
||||
private void close() {
|
||||
public void close() {
|
||||
mPath.closePath();
|
||||
}
|
||||
|
||||
@@ -831,7 +831,7 @@ public final class Path_Delegate {
|
||||
* @param bottom The bottom of a rectangle to add to the path
|
||||
* @param dir The direction to wind the rectangle's contour
|
||||
*/
|
||||
private void addRect(float left, float top, float right, float bottom,
|
||||
public void addRect(float left, float top, float right, float bottom,
|
||||
int dir) {
|
||||
moveTo(left, top);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,6 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
|
||||
import android.annotation.NonNull;
|
||||
import android.graphics.Path_Delegate;
|
||||
|
||||
import java.awt.geom.Path2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
@@ -52,10 +51,18 @@ public class PathParser_Delegate {
|
||||
@NonNull
|
||||
private PathDataNode[] mPathDataNodes;
|
||||
|
||||
public static PathParser_Delegate getDelegate(long nativePtr) {
|
||||
return sManager.getDelegate(nativePtr);
|
||||
}
|
||||
|
||||
private PathParser_Delegate(@NonNull PathDataNode[] nodes) {
|
||||
mPathDataNodes = nodes;
|
||||
}
|
||||
|
||||
public PathDataNode[] getPathDataNodes() {
|
||||
return mPathDataNodes;
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static boolean nParseStringForPath(long pathPtr, @NonNull String pathString, int
|
||||
stringLength) {
|
||||
@@ -64,7 +71,7 @@ public class PathParser_Delegate {
|
||||
return false;
|
||||
}
|
||||
assert pathString.length() == stringLength;
|
||||
PathDataNode.nodesToPath(createNodesFromPathData(pathString), path_delegate.getJavaShape());
|
||||
PathDataNode.nodesToPath(createNodesFromPathData(pathString), path_delegate);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,7 +82,7 @@ public class PathParser_Delegate {
|
||||
if (source == null || path_delegate == null) {
|
||||
return;
|
||||
}
|
||||
PathDataNode.nodesToPath(source.mPathDataNodes, path_delegate.getJavaShape());
|
||||
PathDataNode.nodesToPath(source.mPathDataNodes, path_delegate);
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
@@ -124,8 +131,11 @@ public class PathParser_Delegate {
|
||||
out.mPathDataNodes = new PathDataNode[length];
|
||||
}
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (out.mPathDataNodes[i] == null) {
|
||||
out.mPathDataNodes[i] = new PathDataNode(from.mPathDataNodes[i]);
|
||||
}
|
||||
out.mPathDataNodes[i].interpolatePathDataNode(from.mPathDataNodes[i],
|
||||
to.mPathDataNodes[i], fraction);
|
||||
to.mPathDataNodes[i], fraction);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -137,9 +147,13 @@ public class PathParser_Delegate {
|
||||
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static boolean nCanMorph(long fromDataPtr, long toDataPtr) {
|
||||
Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED, "morphing path data isn't " +
|
||||
"supported", null, null);
|
||||
return false;
|
||||
PathParser_Delegate fromPath = PathParser_Delegate.getDelegate(fromDataPtr);
|
||||
PathParser_Delegate toPath = PathParser_Delegate.getDelegate(toDataPtr);
|
||||
if (fromPath == null || toPath == null || fromPath.getPathDataNodes() == null || toPath
|
||||
.getPathDataNodes() == null) {
|
||||
return true;
|
||||
}
|
||||
return PathParser_Delegate.canMorph(fromPath.getPathDataNodes(), toPath.getPathDataNodes());
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
@@ -158,7 +172,7 @@ public class PathParser_Delegate {
|
||||
* @return an array of the PathDataNode.
|
||||
*/
|
||||
@NonNull
|
||||
private static PathDataNode[] createNodesFromPathData(@NonNull String pathData) {
|
||||
public static PathDataNode[] createNodesFromPathData(@NonNull String pathData) {
|
||||
int start = 0;
|
||||
int end = 1;
|
||||
|
||||
@@ -186,7 +200,7 @@ public class PathParser_Delegate {
|
||||
* @return a deep copy of the <code>source</code>.
|
||||
*/
|
||||
@NonNull
|
||||
private static PathDataNode[] deepCopyNodes(@NonNull PathDataNode[] source) {
|
||||
public static PathDataNode[] deepCopyNodes(@NonNull PathDataNode[] source) {
|
||||
PathDataNode[] copy = new PathDataNode[source.length];
|
||||
for (int i = 0; i < source.length; i++) {
|
||||
copy[i] = new PathDataNode(source[i]);
|
||||
@@ -194,6 +208,45 @@ public class PathParser_Delegate {
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodesFrom The source path represented in an array of PathDataNode
|
||||
* @param nodesTo The target path represented in an array of PathDataNode
|
||||
* @return whether the <code>nodesFrom</code> can morph into <code>nodesTo</code>
|
||||
*/
|
||||
public static boolean canMorph(PathDataNode[] nodesFrom, PathDataNode[] nodesTo) {
|
||||
if (nodesFrom == null || nodesTo == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nodesFrom.length != nodesTo.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < nodesFrom.length; i ++) {
|
||||
if (nodesFrom[i].mType != nodesTo[i].mType
|
||||
|| nodesFrom[i].mParams.length != nodesTo[i].mParams.length) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the target's data to match the source.
|
||||
* Before calling this, make sure canMorph(target, source) is true.
|
||||
*
|
||||
* @param target The target path represented in an array of PathDataNode
|
||||
* @param source The source path represented in an array of PathDataNode
|
||||
*/
|
||||
public static void updateNodes(PathDataNode[] target, PathDataNode[] source) {
|
||||
for (int i = 0; i < source.length; i ++) {
|
||||
target[i].mType = source[i].mType;
|
||||
for (int j = 0; j < source[i].mParams.length; j ++) {
|
||||
target[i].mParams[j] = source[i].mParams[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int nextStart(@NonNull String s, int end) {
|
||||
char c;
|
||||
|
||||
@@ -330,7 +383,7 @@ public class PathParser_Delegate {
|
||||
* Each PathDataNode represents one command in the "d" attribute of the svg file. An array of
|
||||
* PathDataNode can represent the whole "d" attribute.
|
||||
*/
|
||||
private static class PathDataNode {
|
||||
public static class PathDataNode {
|
||||
private char mType;
|
||||
@NonNull
|
||||
private float[] mParams;
|
||||
@@ -355,12 +408,13 @@ public class PathParser_Delegate {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an array of PathDataNode to Path.
|
||||
* Convert an array of PathDataNode to Path. Reset the passed path as needed before
|
||||
* calling this method.
|
||||
*
|
||||
* @param node The source array of PathDataNode.
|
||||
* @param path The target Path object.
|
||||
*/
|
||||
private static void nodesToPath(@NonNull PathDataNode[] node, @NonNull Path2D path) {
|
||||
public static void nodesToPath(@NonNull PathDataNode[] node, @NonNull Path_Delegate path) {
|
||||
float[] current = new float[6];
|
||||
char previousCommand = 'm';
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
@@ -387,24 +441,32 @@ public class PathParser_Delegate {
|
||||
}
|
||||
|
||||
@SuppressWarnings("PointlessArithmeticExpression")
|
||||
private static void addCommand(@NonNull Path2D path, float[] current, char cmd,
|
||||
char lastCmd, @NonNull float[] val) {
|
||||
private static void addCommand(@NonNull Path_Delegate path, float[] current,
|
||||
char previousCmd, char cmd, @NonNull float[] val) {
|
||||
|
||||
int incr = 2;
|
||||
|
||||
float cx = current[0];
|
||||
float cy = current[1];
|
||||
float cpx = current[2];
|
||||
float cpy = current[3];
|
||||
float loopX = current[4];
|
||||
float loopY = current[5];
|
||||
float currentX = current[0];
|
||||
float currentY = current[1];
|
||||
float ctrlPointX = current[2];
|
||||
float ctrlPointY = current[3];
|
||||
float currentSegmentStartX = current[4];
|
||||
float currentSegmentStartY = current[5];
|
||||
float reflectiveCtrlPointX;
|
||||
float reflectiveCtrlPointY;
|
||||
|
||||
switch (cmd) {
|
||||
case 'z':
|
||||
case 'Z':
|
||||
path.closePath();
|
||||
cx = loopX;
|
||||
cy = loopY;
|
||||
path.close();
|
||||
// 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 'l':
|
||||
@@ -432,185 +494,206 @@ public class PathParser_Delegate {
|
||||
case 'a':
|
||||
case 'A':
|
||||
incr = 7;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int k = 0; k < val.length; k += incr) {
|
||||
boolean reflectCtrl;
|
||||
float tempReflectedX, tempReflectedY;
|
||||
|
||||
switch (cmd) {
|
||||
case 'm':
|
||||
cx += val[k + 0];
|
||||
cy += val[k + 1];
|
||||
case 'm': // moveto - Start a new sub-path (relative)
|
||||
currentX += val[k + 0];
|
||||
currentY += val[k + 1];
|
||||
|
||||
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(cx, cy);
|
||||
path.rLineTo(val[k + 0], val[k + 1]);
|
||||
} else {
|
||||
path.moveTo(cx, cy);
|
||||
loopX = cx;
|
||||
loopY = cy;
|
||||
path.rMoveTo(val[k + 0], val[k + 1]);
|
||||
currentSegmentStartX = currentX;
|
||||
currentSegmentStartY = currentY;
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
cx = val[k + 0];
|
||||
cy = val[k + 1];
|
||||
case 'M': // moveto - Start a new sub-path
|
||||
currentX = val[k + 0];
|
||||
currentY = val[k + 1];
|
||||
|
||||
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(cx, cy);
|
||||
path.lineTo(val[k + 0], val[k + 1]);
|
||||
} else {
|
||||
path.moveTo(cx, cy);
|
||||
loopX = cx;
|
||||
loopY = cy;
|
||||
path.moveTo(val[k + 0], val[k + 1]);
|
||||
currentSegmentStartX = currentX;
|
||||
currentSegmentStartY = currentY;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
cx += val[k + 0];
|
||||
cy += val[k + 1];
|
||||
path.lineTo(cx, cy);
|
||||
case 'l': // lineto - Draw a line from the current point (relative)
|
||||
path.rLineTo(val[k + 0], val[k + 1]);
|
||||
currentX += val[k + 0];
|
||||
currentY += val[k + 1];
|
||||
break;
|
||||
case 'L':
|
||||
cx = val[k + 0];
|
||||
cy = val[k + 1];
|
||||
path.lineTo(cx, cy);
|
||||
case 'L': // lineto - Draw a line from the current point
|
||||
path.lineTo(val[k + 0], val[k + 1]);
|
||||
currentX = val[k + 0];
|
||||
currentY = val[k + 1];
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
path.closePath();
|
||||
cx = loopX;
|
||||
cy = loopY;
|
||||
case 'h': // horizontal lineto - Draws a horizontal line (relative)
|
||||
path.rLineTo(val[k + 0], 0);
|
||||
currentX += val[k + 0];
|
||||
break;
|
||||
case 'h':
|
||||
cx += val[k + 0];
|
||||
path.lineTo(cx, cy);
|
||||
case 'H': // horizontal lineto - Draws a horizontal line
|
||||
path.lineTo(val[k + 0], currentY);
|
||||
currentX = val[k + 0];
|
||||
break;
|
||||
case 'H':
|
||||
path.lineTo(val[k + 0], cy);
|
||||
cx = val[k + 0];
|
||||
case 'v': // vertical lineto - Draws a vertical line from the current point (r)
|
||||
path.rLineTo(0, val[k + 0]);
|
||||
currentY += val[k + 0];
|
||||
break;
|
||||
case 'v':
|
||||
cy += val[k + 0];
|
||||
path.lineTo(cx, cy);
|
||||
case 'V': // vertical lineto - Draws a vertical line from the current point
|
||||
path.lineTo(currentX, val[k + 0]);
|
||||
currentY = val[k + 0];
|
||||
break;
|
||||
case 'V':
|
||||
path.lineTo(cx, val[k + 0]);
|
||||
cy = val[k + 0];
|
||||
break;
|
||||
case 'c':
|
||||
path.curveTo(cx + val[k + 0], cy + val[k + 1], cx + val[k + 2],
|
||||
cy + val[k + 3], cx + val[k + 4], cy + val[k + 5]);
|
||||
cpx = cx + val[k + 2];
|
||||
cpy = cy + val[k + 3];
|
||||
cx += val[k + 4];
|
||||
cy += val[k + 5];
|
||||
break;
|
||||
case 'C':
|
||||
path.curveTo(val[k + 0], val[k + 1], val[k + 2], val[k + 3],
|
||||
case 'c': // curveto - Draws a cubic Bézier curve (relative)
|
||||
path.rCubicTo(val[k + 0], val[k + 1], val[k + 2], val[k + 3],
|
||||
val[k + 4], val[k + 5]);
|
||||
cx = val[k + 4];
|
||||
cy = val[k + 5];
|
||||
cpx = val[k + 2];
|
||||
cpy = val[k + 3];
|
||||
break;
|
||||
case 's':
|
||||
reflectCtrl = (lastCmd == 'c' || lastCmd == 's' || lastCmd == 'C' ||
|
||||
lastCmd == 'S');
|
||||
path.curveTo(reflectCtrl ? 2 * cx - cpx : cx, reflectCtrl ? 2
|
||||
* cy - cpy : cy, cx + val[k + 0], cy + val[k + 1], cx
|
||||
+ val[k + 2], cy + val[k + 3]);
|
||||
|
||||
cpx = cx + val[k + 0];
|
||||
cpy = cy + val[k + 1];
|
||||
cx += val[k + 2];
|
||||
cy += val[k + 3];
|
||||
ctrlPointX = currentX + val[k + 2];
|
||||
ctrlPointY = currentY + val[k + 3];
|
||||
currentX += val[k + 4];
|
||||
currentY += val[k + 5];
|
||||
|
||||
break;
|
||||
case 'S':
|
||||
reflectCtrl = (lastCmd == 'c' || lastCmd == 's' || lastCmd == 'C' ||
|
||||
lastCmd == 'S');
|
||||
path.curveTo(reflectCtrl ? 2 * cx - cpx : cx, reflectCtrl ? 2
|
||||
* cy - cpy : cy, val[k + 0], val[k + 1], val[k + 2],
|
||||
val[k + 3]);
|
||||
cpx = (val[k + 0]);
|
||||
cpy = (val[k + 1]);
|
||||
cx = val[k + 2];
|
||||
cy = val[k + 3];
|
||||
case 'C': // curveto - Draws a cubic Bézier curve
|
||||
path.cubicTo(val[k + 0], val[k + 1], val[k + 2], val[k + 3],
|
||||
val[k + 4], val[k + 5]);
|
||||
currentX = val[k + 4];
|
||||
currentY = val[k + 5];
|
||||
ctrlPointX = val[k + 2];
|
||||
ctrlPointY = val[k + 3];
|
||||
break;
|
||||
case 'q':
|
||||
path.quadTo(cx + val[k + 0], cy + val[k + 1], cx + val[k + 2],
|
||||
cy + val[k + 3]);
|
||||
cpx = cx + val[k + 0];
|
||||
cpy = cy + val[k + 1];
|
||||
// Note that we have to update cpx first, since cx will be updated here.
|
||||
cx += val[k + 2];
|
||||
cy += val[k + 3];
|
||||
case 's': // smooth curveto - Draws a cubic Bézier curve (reflective cp)
|
||||
reflectiveCtrlPointX = 0;
|
||||
reflectiveCtrlPointY = 0;
|
||||
if (previousCmd == 'c' || previousCmd == 's'
|
||||
|| previousCmd == 'C' || previousCmd == 'S') {
|
||||
reflectiveCtrlPointX = currentX - ctrlPointX;
|
||||
reflectiveCtrlPointY = currentY - ctrlPointY;
|
||||
}
|
||||
path.rCubicTo(reflectiveCtrlPointX, reflectiveCtrlPointY,
|
||||
val[k + 0], val[k + 1],
|
||||
val[k + 2], val[k + 3]);
|
||||
|
||||
ctrlPointX = currentX + val[k + 0];
|
||||
ctrlPointY = currentY + val[k + 1];
|
||||
currentX += val[k + 2];
|
||||
currentY += val[k + 3];
|
||||
break;
|
||||
case 'Q':
|
||||
case 'S': // shorthand/smooth curveto Draws a cubic Bézier curve(reflective cp)
|
||||
reflectiveCtrlPointX = currentX;
|
||||
reflectiveCtrlPointY = currentY;
|
||||
if (previousCmd == 'c' || previousCmd == 's'
|
||||
|| previousCmd == 'C' || previousCmd == 'S') {
|
||||
reflectiveCtrlPointX = 2 * currentX - ctrlPointX;
|
||||
reflectiveCtrlPointY = 2 * currentY - ctrlPointY;
|
||||
}
|
||||
path.cubicTo(reflectiveCtrlPointX, reflectiveCtrlPointY,
|
||||
val[k + 0], val[k + 1], val[k + 2], val[k + 3]);
|
||||
ctrlPointX = val[k + 0];
|
||||
ctrlPointY = val[k + 1];
|
||||
currentX = val[k + 2];
|
||||
currentY = val[k + 3];
|
||||
break;
|
||||
case 'q': // Draws a quadratic Bézier (relative)
|
||||
path.rQuadTo(val[k + 0], val[k + 1], val[k + 2], val[k + 3]);
|
||||
ctrlPointX = currentX + val[k + 0];
|
||||
ctrlPointY = currentY + val[k + 1];
|
||||
currentX += val[k + 2];
|
||||
currentY += val[k + 3];
|
||||
break;
|
||||
case 'Q': // Draws a quadratic Bézier
|
||||
path.quadTo(val[k + 0], val[k + 1], val[k + 2], val[k + 3]);
|
||||
cx = val[k + 2];
|
||||
cy = val[k + 3];
|
||||
cpx = val[k + 0];
|
||||
cpy = val[k + 1];
|
||||
ctrlPointX = val[k + 0];
|
||||
ctrlPointY = val[k + 1];
|
||||
currentX = val[k + 2];
|
||||
currentY = val[k + 3];
|
||||
break;
|
||||
case 't':
|
||||
reflectCtrl = (lastCmd == 'q' || lastCmd == 't' || lastCmd == 'Q' ||
|
||||
lastCmd == 'T');
|
||||
tempReflectedX = reflectCtrl ? 2 * cx - cpx : cx;
|
||||
tempReflectedY = reflectCtrl ? 2 * cy - cpy : cy;
|
||||
path.quadTo(tempReflectedX, tempReflectedY, cx + val[k + 0],
|
||||
cy + val[k + 1]);
|
||||
cpx = tempReflectedX;
|
||||
cpy = tempReflectedY;
|
||||
cx += val[k + 0];
|
||||
cy += val[k + 1];
|
||||
case 't': // Draws a quadratic Bézier curve(reflective control point)(relative)
|
||||
reflectiveCtrlPointX = 0;
|
||||
reflectiveCtrlPointY = 0;
|
||||
if (previousCmd == 'q' || previousCmd == 't'
|
||||
|| previousCmd == 'Q' || previousCmd == 'T') {
|
||||
reflectiveCtrlPointX = currentX - ctrlPointX;
|
||||
reflectiveCtrlPointY = currentY - ctrlPointY;
|
||||
}
|
||||
path.rQuadTo(reflectiveCtrlPointX, reflectiveCtrlPointY,
|
||||
val[k + 0], val[k + 1]);
|
||||
ctrlPointX = currentX + reflectiveCtrlPointX;
|
||||
ctrlPointY = currentY + reflectiveCtrlPointY;
|
||||
currentX += val[k + 0];
|
||||
currentY += val[k + 1];
|
||||
break;
|
||||
case 'T':
|
||||
reflectCtrl = (lastCmd == 'q' || lastCmd == 't' || lastCmd == 'Q' ||
|
||||
lastCmd == 'T');
|
||||
tempReflectedX = reflectCtrl ? 2 * cx - cpx : cx;
|
||||
tempReflectedY = reflectCtrl ? 2 * cy - cpy : cy;
|
||||
path.quadTo(tempReflectedX, tempReflectedY, val[k + 0], val[k + 1]);
|
||||
cx = val[k + 0];
|
||||
cy = val[k + 1];
|
||||
cpx = tempReflectedX;
|
||||
cpy = tempReflectedY;
|
||||
case 'T': // Draws a quadratic Bézier curve (reflective control point)
|
||||
reflectiveCtrlPointX = currentX;
|
||||
reflectiveCtrlPointY = currentY;
|
||||
if (previousCmd == 'q' || previousCmd == 't'
|
||||
|| previousCmd == 'Q' || previousCmd == 'T') {
|
||||
reflectiveCtrlPointX = 2 * currentX - ctrlPointX;
|
||||
reflectiveCtrlPointY = 2 * currentY - ctrlPointY;
|
||||
}
|
||||
path.quadTo(reflectiveCtrlPointX, reflectiveCtrlPointY,
|
||||
val[k + 0], val[k + 1]);
|
||||
ctrlPointX = reflectiveCtrlPointX;
|
||||
ctrlPointY = reflectiveCtrlPointY;
|
||||
currentX = val[k + 0];
|
||||
currentY = val[k + 1];
|
||||
break;
|
||||
case 'a':
|
||||
case 'a': // Draws an elliptical arc
|
||||
// (rx ry x-axis-rotation large-arc-flag sweep-flag x y)
|
||||
drawArc(path, cx, cy, val[k + 5] + cx, val[k + 6] + cy,
|
||||
val[k + 0], val[k + 1], val[k + 2], val[k + 3] != 0,
|
||||
drawArc(path,
|
||||
currentX,
|
||||
currentY,
|
||||
val[k + 5] + currentX,
|
||||
val[k + 6] + currentY,
|
||||
val[k + 0],
|
||||
val[k + 1],
|
||||
val[k + 2],
|
||||
val[k + 3] != 0,
|
||||
val[k + 4] != 0);
|
||||
cx += val[k + 5];
|
||||
cy += val[k + 6];
|
||||
cpx = cx;
|
||||
cpy = cy;
|
||||
|
||||
currentX += val[k + 5];
|
||||
currentY += val[k + 6];
|
||||
ctrlPointX = currentX;
|
||||
ctrlPointY = currentY;
|
||||
break;
|
||||
case 'A':
|
||||
drawArc(path, cx, cy, val[k + 5], val[k + 6], val[k + 0],
|
||||
val[k + 1], val[k + 2], val[k + 3] != 0,
|
||||
case 'A': // Draws an elliptical arc
|
||||
drawArc(path,
|
||||
currentX,
|
||||
currentY,
|
||||
val[k + 5],
|
||||
val[k + 6],
|
||||
val[k + 0],
|
||||
val[k + 1],
|
||||
val[k + 2],
|
||||
val[k + 3] != 0,
|
||||
val[k + 4] != 0);
|
||||
cx = val[k + 5];
|
||||
cy = val[k + 6];
|
||||
cpx = cx;
|
||||
cpy = cy;
|
||||
currentX = val[k + 5];
|
||||
currentY = val[k + 6];
|
||||
ctrlPointX = currentX;
|
||||
ctrlPointY = currentY;
|
||||
break;
|
||||
|
||||
}
|
||||
lastCmd = cmd;
|
||||
previousCmd = cmd;
|
||||
}
|
||||
current[0] = cx;
|
||||
current[1] = cy;
|
||||
current[2] = cpx;
|
||||
current[3] = cpy;
|
||||
current[4] = loopX;
|
||||
current[5] = loopY;
|
||||
|
||||
current[0] = currentX;
|
||||
current[1] = currentY;
|
||||
current[2] = ctrlPointX;
|
||||
current[3] = ctrlPointY;
|
||||
current[4] = currentSegmentStartX;
|
||||
current[5] = currentSegmentStartY;
|
||||
}
|
||||
|
||||
private static void drawArc(@NonNull Path2D p, float x0, float y0, float x1,
|
||||
private static void drawArc(@NonNull Path_Delegate p, float x0, float y0, float x1,
|
||||
float y1, float a, float b, float theta, boolean isMoreThanHalf,
|
||||
boolean isPositiveArc) {
|
||||
|
||||
@@ -707,7 +790,7 @@ public class PathParser_Delegate {
|
||||
* @param start The start angle of the arc on the ellipse
|
||||
* @param sweep The angle (positive or negative) of the sweep of the arc on the ellipse
|
||||
*/
|
||||
private static void arcToBezier(@NonNull Path2D p, double cx, double cy, double a,
|
||||
private static void arcToBezier(@NonNull Path_Delegate p, double cx, double cy, double a,
|
||||
double b, double e1x, double e1y, double theta, double start,
|
||||
double sweep) {
|
||||
// Taken from equations at:
|
||||
@@ -744,8 +827,12 @@ public class PathParser_Delegate {
|
||||
double q2x = e2x - alpha * ep2x;
|
||||
double q2y = e2y - alpha * ep2y;
|
||||
|
||||
p.curveTo((float) q1x, (float) q1y, (float) q2x, (float) q2y,
|
||||
(float) e2x, (float) e2y);
|
||||
p.cubicTo((float) q1x,
|
||||
(float) q1y,
|
||||
(float) q2x,
|
||||
(float) q2y,
|
||||
(float) e2x,
|
||||
(float) e2y);
|
||||
eta1 = eta2;
|
||||
e1x = e2x;
|
||||
e1y = e2y;
|
||||
|
||||
@@ -60,6 +60,7 @@ import android.app.Fragment_Delegate;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap_Delegate;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Looper;
|
||||
import android.preference.Preference_Delegate;
|
||||
import android.view.AttachInfo_Accessor;
|
||||
import android.view.BridgeInflater;
|
||||
@@ -1398,6 +1399,14 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
boolean createdLooper = false;
|
||||
if (Looper.myLooper() == null) {
|
||||
// Detaching the root view from the window will try to stop any running animations.
|
||||
// The stop method checks that it can run in the looper so, if there is no current
|
||||
// looper, we create a temporary one to complete the shutdown.
|
||||
Bridge.prepareThread();
|
||||
createdLooper = true;
|
||||
}
|
||||
AttachInfo_Accessor.detachFromWindow(mViewRoot);
|
||||
if (mCanvas != null) {
|
||||
mCanvas.release();
|
||||
@@ -1412,5 +1421,9 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
||||
mImage = null;
|
||||
mViewRoot = null;
|
||||
mContentRoot = null;
|
||||
|
||||
if (createdLooper) {
|
||||
Bridge.cleanupThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,6 +269,7 @@ public final class CreateInfo implements ICreateInfo {
|
||||
"android.graphics.SweepGradient",
|
||||
"android.graphics.Typeface",
|
||||
"android.graphics.Xfermode",
|
||||
"android.graphics.drawable.VectorDrawable",
|
||||
"android.os.SystemClock",
|
||||
"android.os.SystemProperties",
|
||||
"android.text.AndroidBidi",
|
||||
@@ -321,7 +322,12 @@ public final class CreateInfo implements ICreateInfo {
|
||||
"org.kxml2.io.KXmlParser"
|
||||
};
|
||||
|
||||
/**
|
||||
* List of fields for which we will update the visibility to be public. This is sometimes
|
||||
* needed when access from the delegate classes is needed.
|
||||
*/
|
||||
private final static String[] PROMOTED_FIELDS = new String[] {
|
||||
"android.graphics.drawable.VectorDrawable#mVectorState",
|
||||
"android.view.Choreographer#mLastFrameTimeNanos"
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user