Path: add arcTo and addArc, minor cleanup

This commit is contained in:
Mis012
2025-06-10 00:48:11 +02:00
parent 6f627f7332
commit 65a7e34871
4 changed files with 108 additions and 14 deletions

View File

@@ -1,5 +1,7 @@
package android.graphics;
import android.util.Log;
/*
* Path is implemented as a GskPath or a GskPathBuilder. It can only be one of the two at a time.
* The methods getGskPath() and getBuilder() automatically convert between the two as needed.
@@ -82,6 +84,18 @@ public class Path {
native_line_to(getBuilder(), x, y);
}
public void arcTo(RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo) {
arcTo(oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle, forceMoveTo);
}
public void arcTo(RectF oval, float startAngle, float sweepAngle) {
arcTo(oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle, false);
}
public void arcTo(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean forceMoveTo) {
native_arc_to(getBuilder(), left, top, right, bottom, startAngle, sweepAngle, forceMoveTo);
}
public void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) {
native_cubic_to(getBuilder(), x1, y1, x2, y2, x3, y3);
}
@@ -90,12 +104,6 @@ public class Path {
native_quad_to(getBuilder(), x1, y1, x2, y2);
}
public void arcTo(RectF oval, float startAngle, float sweepAngle, boolean forceMoveTo) {}
public void arcTo(RectF oval, float startAngle, float sweepAngle) {}
public void arcTo(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean forceMoveTo) {}
public void rMoveTo(float x, float y) {
native_rel_move_to(getBuilder(), x, y);
}
@@ -112,9 +120,13 @@ public class Path {
native_rel_quad_to(getBuilder(), x1, y1, x2, y2);
}
public void addArc (RectF oval, float startAngle, float sweepAngle) {}
public void addArc(RectF oval, float startAngle, float sweepAngle) {
addArc(oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle);
}
public void addArc (float left, float top, float right, float bottom, float startAngle, float sweepAngle) {}
public void addArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle) {
native_add_arc(getBuilder(), left, top, right, bottom, startAngle, sweepAngle);
}
public void addPath(Path path, Matrix matrix) {
native_add_path(getBuilder(), path.getGskPath(), matrix.ni());
@@ -131,7 +143,11 @@ public class Path {
}
public void addRect(RectF rect, Direction direction) {
native_add_rect(getBuilder(), rect.left, rect.top, rect.right, rect.bottom);
addRect(rect.left, rect.top, rect.right, rect.bottom, direction);
}
public void addRect(float left, float top, float right, float bottom, Path.Direction dir) {
native_add_rect(getBuilder(), left, top, right, bottom);
}
public void addRoundRect(RectF rect, float[] radii, Direction direction) {
@@ -139,18 +155,26 @@ public class Path {
}
public void addRoundRect(float left, float top, float right, float bottom,
float[] radii, Direction direction) {}
float[] radii, Direction direction) {
Log.w("Path", "STUB: addRoundRect");
}
public void addRoundRect(RectF rect, float rx, float ry, Direction direction) {
addRoundRect(rect.left, rect.top, rect.right, rect.bottom, rx, ry, direction);
}
public void addRoundRect(float left, float top, float right, float bottom,
float rx, float ry, Direction direction) {}
float rx, float ry, Direction direction) {
addRoundRect(left, top, right, bottom, new float[]{rx, ry, rx, ry, rx, ry, rx, ry}, direction);
}
public void addOval(RectF rect, Direction direction) {}
public void addOval(RectF rect, Direction direction) {
Log.w("Path", "STUB: addOval");
}
public void addCircle(float x, float y, float radius, Direction direction) {}
public void addCircle(float x, float y, float radius, Direction direction) {
Log.w("Path", "STUB: addCircle");
}
public void transform(Matrix matrix) {
builder = native_transform(getGskPath(), matrix.ni());
@@ -169,10 +193,12 @@ public class Path {
}
public boolean op(Path path, Op op) {
Log.w("Path", "STUB: op");
return false;
}
public boolean op(Path path, Path dst, Op op) {
Log.w("Path", "STUB: op");
return false;
}
@@ -183,6 +209,7 @@ public class Path {
public void incReserve(int additionalPoints) {}
public boolean isConvex() {
Log.w("Path", "STUB: isConvex");
return false;
}
@@ -216,10 +243,12 @@ public class Path {
private static native void native_line_to(long builder, float x, float y);
private static native void native_cubic_to(long builder, float x1, float y1, float x2, float y2, float x3, float y3);
private static native void native_quad_to(long builder, float x1, float y1, float x2, float y2);
private static native void native_arc_to(long builder, float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean forceMoveTo);
private static native void native_rel_move_to(long builder, float x, float y);
private static native void native_rel_line_to(long builder, float x, float y);
private static native void native_rel_cubic_to(long builder, float x1, float y1, float x2, float y2, float x3, float y3);
private static native void native_rel_quad_to(long builder, float x1, float y1, float x2, float y2);
private static native void native_add_arc(long builder, float left, float top, float right, float bottom, float startAngle, float sweepAngle);
private static native void native_add_path(long builder, long path, long matrix);
private static native void native_add_rect(long builder, float left, float top, float right, float bottom);
private static native void native_get_bounds(long path, RectF rect);