You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement android.graphics.Path using skia
This commit is contained in:
@@ -382,7 +382,9 @@ public class Canvas {
|
||||
|
||||
public void setBitmap(Bitmap bitmap) {}
|
||||
|
||||
public void drawPath(Path path, Paint paint) {}
|
||||
public void drawPath(Path path, Paint paint) {
|
||||
native_drawPath(skia_canvas, path.mNativePath, paint.skia_paint);
|
||||
}
|
||||
|
||||
public boolean clipPath(Path path) {
|
||||
return false;
|
||||
@@ -401,4 +403,5 @@ public class Canvas {
|
||||
private static native void native_drawBitmap(long skia_canvas, long widget, long pixbuf, float src_left, float src_top, float src_right, float src_bottom, float dest_left, float dest_top, float dest_right, float dest_bottm, long skia_paint);
|
||||
private static native void native_rotate(long skia_canvas, long widget, float angle);
|
||||
private static native void native_rotate_and_translate(long skia_canvas, long widget, float angle, float tx, float ty);
|
||||
private static native void native_drawPath(long skia_canvas, long path, long skia_paint);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Path {
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public final int mNativePath;
|
||||
public final long mNativePath;
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@@ -41,10 +41,8 @@ public class Path {
|
||||
* Create an empty path
|
||||
*/
|
||||
public Path() {
|
||||
mNativePath = -1; /*
|
||||
mNativePath = init1();
|
||||
mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
*/
|
||||
mNativePath = init1();
|
||||
// mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
}
|
||||
/**
|
||||
* Create a new path, copying the contents from the src path.
|
||||
@@ -52,18 +50,16 @@ public class Path {
|
||||
* @param src The path to copy from when initializing the new path
|
||||
*/
|
||||
public Path(Path src) {
|
||||
mNativePath = -1; /*
|
||||
int valNative = 0;
|
||||
if (src != null) {
|
||||
valNative = src.mNativePath;
|
||||
isSimplePath = src.isSimplePath;
|
||||
if (src.rects != null) {
|
||||
rects = new Region(src.rects);
|
||||
}
|
||||
}
|
||||
mNativePath = init2(valNative);
|
||||
mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
*/
|
||||
long valNative = 0;
|
||||
if (src != null) {
|
||||
valNative = src.mNativePath;
|
||||
isSimplePath = src.isSimplePath;
|
||||
if (src.rects != null) {
|
||||
rects = new Region(src.rects);
|
||||
}
|
||||
}
|
||||
mNativePath = init2(valNative);
|
||||
// mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +76,7 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
// We promised not to change this, so preserve it around the native
|
||||
// call, which does now reset fill type.
|
||||
final FillType fillType = getFillType();
|
||||
// native_reset(mNativePath);
|
||||
native_reset(mNativePath);
|
||||
setFillType(fillType);
|
||||
}
|
||||
/**
|
||||
@@ -213,8 +209,7 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
* @return the path's fill type
|
||||
*/
|
||||
public FillType getFillType() {
|
||||
return FillType.WINDING;
|
||||
// return sFillTypeArray[native_getFillType(mNativePath)];
|
||||
return sFillTypeArray[native_getFillType(mNativePath)];
|
||||
}
|
||||
/**
|
||||
* Set the path's fill type. This defines how "inside" is computed.
|
||||
@@ -222,7 +217,7 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
* @param ft The new fill type for this path
|
||||
*/
|
||||
public void setFillType(FillType ft) {
|
||||
// native_setFillType(mNativePath, ft.nativeInt);
|
||||
native_setFillType(mNativePath, ft.nativeInt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,7 +288,7 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
* @param y The y-coordinate of the start of a new contour
|
||||
*/
|
||||
public void moveTo(float x, float y) {
|
||||
// native_moveTo(mNativePath, x, y);
|
||||
native_moveTo(mNativePath, x, y);
|
||||
}
|
||||
/**
|
||||
* Set the beginning of the next contour relative to the last point on the
|
||||
@@ -318,7 +313,7 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
*/
|
||||
public void lineTo(float x, float y) {
|
||||
isSimplePath = false;
|
||||
// native_lineTo(mNativePath, x, y);
|
||||
native_lineTo(mNativePath, x, y);
|
||||
}
|
||||
/**
|
||||
* Same as lineTo, but the coordinates are considered relative to the last
|
||||
@@ -346,7 +341,7 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
*/
|
||||
public void quadTo(float x1, float y1, float x2, float y2) {
|
||||
isSimplePath = false;
|
||||
// native_quadTo(mNativePath, x1, y1, x2, y2);
|
||||
native_quadTo(mNativePath, x1, y1, x2, y2);
|
||||
}
|
||||
/**
|
||||
* Same as quadTo, but the coordinates are considered relative to the last
|
||||
@@ -434,7 +429,7 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
*/
|
||||
public void close() {
|
||||
isSimplePath = false;
|
||||
// native_close(mNativePath);
|
||||
native_close(mNativePath);
|
||||
}
|
||||
/**
|
||||
* Specifies how closed shapes (e.g. rects, ovals) are oriented when they
|
||||
@@ -609,7 +604,7 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
* the original path is modified.
|
||||
*/
|
||||
public void offset(float dx, float dy, Path dst) {
|
||||
int dstNative = 0;
|
||||
long dstNative = 0;
|
||||
if (dst != null) {
|
||||
dstNative = dst.mNativePath;
|
||||
dst.isSimplePath = false;
|
||||
@@ -645,7 +640,7 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
* then the the original path is modified
|
||||
*/
|
||||
public void transform(Matrix matrix, Path dst) {
|
||||
int dstNative = 0;
|
||||
long dstNative = 0;
|
||||
if (dst != null) {
|
||||
dst.isSimplePath = false;
|
||||
dstNative = dst.mNativePath;
|
||||
@@ -663,58 +658,58 @@ mDetectSimplePaths = HardwareRenderer.isAvailable();
|
||||
}
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
// finalizer(mNativePath);
|
||||
finalizer(mNativePath);
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
final int ni() {
|
||||
final long ni() {
|
||||
return mNativePath;
|
||||
}
|
||||
private static native int init1();
|
||||
private static native int init2(int nPath);
|
||||
private static native void native_reset(int nPath);
|
||||
private static native void native_rewind(int nPath);
|
||||
private static native void native_set(int native_dst, int native_src);
|
||||
private static native int native_getFillType(int nPath);
|
||||
private static native void native_setFillType(int nPath, int ft);
|
||||
private static native boolean native_isEmpty(int nPath);
|
||||
private static native boolean native_isRect(int nPath, RectF rect);
|
||||
private static native void native_computeBounds(int nPath, RectF bounds);
|
||||
private static native void native_incReserve(int nPath, int extraPtCount);
|
||||
private static native void native_moveTo(int nPath, float x, float y);
|
||||
private static native void native_rMoveTo(int nPath, float dx, float dy);
|
||||
private static native void native_lineTo(int nPath, float x, float y);
|
||||
private static native void native_rLineTo(int nPath, float dx, float dy);
|
||||
private static native void native_quadTo(int nPath, float x1, float y1,
|
||||
private static native long init1();
|
||||
private static native long init2(long nPath);
|
||||
private static native void native_reset(long nPath);
|
||||
private static native void native_rewind(long nPath);
|
||||
private static native void native_set(long native_dst, long native_src);
|
||||
private static native int native_getFillType(long nPath);
|
||||
private static native void native_setFillType(long nPath, int ft);
|
||||
private static native boolean native_isEmpty(long nPath);
|
||||
private static native boolean native_isRect(long nPath, RectF rect);
|
||||
private static native void native_computeBounds(long nPath, RectF bounds);
|
||||
private static native void native_incReserve(long nPath, int extraPtCount);
|
||||
private static native void native_moveTo(long nPath, float x, float y);
|
||||
private static native void native_rMoveTo(long nPath, float dx, float dy);
|
||||
private static native void native_lineTo(long nPath, float x, float y);
|
||||
private static native void native_rLineTo(long nPath, float dx, float dy);
|
||||
private static native void native_quadTo(long nPath, float x1, float y1,
|
||||
float x2, float y2);
|
||||
private static native void native_rQuadTo(int nPath, float dx1, float dy1,
|
||||
private static native void native_rQuadTo(long nPath, float dx1, float dy1,
|
||||
float dx2, float dy2);
|
||||
private static native void native_cubicTo(int nPath, float x1, float y1,
|
||||
private static native void native_cubicTo(long nPath, float x1, float y1,
|
||||
float x2, float y2, float x3, float y3);
|
||||
private static native void native_rCubicTo(int nPath, float x1, float y1,
|
||||
private static native void native_rCubicTo(long nPath, float x1, float y1,
|
||||
float x2, float y2, float x3, float y3);
|
||||
private static native void native_arcTo(int nPath, RectF oval,
|
||||
private static native void native_arcTo(long nPath, RectF oval,
|
||||
float startAngle, float sweepAngle, boolean forceMoveTo);
|
||||
private static native void native_close(int nPath);
|
||||
private static native void native_addRect(int nPath, RectF rect, int dir);
|
||||
private static native void native_addRect(int nPath, float left, float top,
|
||||
private static native void native_close(long nPath);
|
||||
private static native void native_addRect(long nPath, RectF rect, int dir);
|
||||
private static native void native_addRect(long nPath, float left, float top,
|
||||
float right, float bottom, int dir);
|
||||
private static native void native_addOval(int nPath, RectF oval, int dir);
|
||||
private static native void native_addCircle(int nPath, float x, float y, float radius, int dir);
|
||||
private static native void native_addArc(int nPath, RectF oval,
|
||||
private static native void native_addOval(long nPath, RectF oval, int dir);
|
||||
private static native void native_addCircle(long nPath, float x, float y, float radius, int dir);
|
||||
private static native void native_addArc(long nPath, RectF oval,
|
||||
float startAngle, float sweepAngle);
|
||||
private static native void native_addRoundRect(int nPath, RectF rect,
|
||||
private static native void native_addRoundRect(long nPath, RectF rect,
|
||||
float rx, float ry, int dir);
|
||||
private static native void native_addRoundRect(int nPath, RectF r, float[] radii, int dir);
|
||||
private static native void native_addPath(int nPath, int src, float dx, float dy);
|
||||
private static native void native_addPath(int nPath, int src);
|
||||
private static native void native_addPath(int nPath, int src, long matrix);
|
||||
private static native void native_offset(int nPath, float dx, float dy, int dst_path);
|
||||
private static native void native_offset(int nPath, float dx, float dy);
|
||||
private static native void native_setLastPoint(int nPath, float dx, float dy);
|
||||
private static native void native_transform(int nPath, long matrix, int dst_path);
|
||||
private static native void native_transform(int nPath, long matrix);
|
||||
private static native boolean native_op(int path1, int path2, int op, int result);
|
||||
private static native void finalizer(int nPath);
|
||||
private static native void native_addRoundRect(long nPath, RectF r, float[] radii, int dir);
|
||||
private static native void native_addPath(long nPath, long src, float dx, float dy);
|
||||
private static native void native_addPath(long nPath, long src);
|
||||
private static native void native_addPath(long nPath, long src, long matrix);
|
||||
private static native void native_offset(long nPath, float dx, float dy, long dst_path);
|
||||
private static native void native_offset(long nPath, float dx, float dy);
|
||||
private static native void native_setLastPoint(long nPath, float dx, float dy);
|
||||
private static native void native_transform(long nPath, long matrix, long dst_path);
|
||||
private static native void native_transform(long nPath, long matrix);
|
||||
private static native boolean native_op(long path1, long path2, int op, long result);
|
||||
private static native void finalizer(long nPath);
|
||||
}
|
||||
|
||||
@@ -335,11 +335,11 @@ public class Region {
|
||||
private static native void nativeSetRegion(int native_dst, int native_src);
|
||||
private static native boolean nativeSetRect(int native_dst, int left,
|
||||
int top, int right, int bottom);
|
||||
private static native boolean nativeSetPath(int native_dst, int native_path,
|
||||
private static native boolean nativeSetPath(int native_dst, long native_path,
|
||||
int native_clip);
|
||||
private static native boolean nativeGetBounds(int native_region, Rect rect);
|
||||
private static native boolean nativeGetBoundaryPath(int native_region,
|
||||
int native_path);
|
||||
long native_path);
|
||||
private static native boolean nativeOp(int native_dst, int left, int top,
|
||||
int right, int bottom, int op);
|
||||
private static native boolean nativeOp(int native_dst, Rect rect,
|
||||
|
||||
Reference in New Issue
Block a user