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
GskCanvas: implement drawPath, rotate, translate, save, restore
This is enough to make DrawerArrowDrawable functional. drawPath() only draws line segments for now.
This commit is contained in:
@@ -6,31 +6,39 @@ package android.graphics;
|
||||
*/
|
||||
public class GskCanvas extends Canvas {
|
||||
private long snapshot;
|
||||
private int save_count = 0;
|
||||
|
||||
public GskCanvas(long snapshot) {
|
||||
System.out.println("GskCanvas(" + snapshot + ")");
|
||||
this.snapshot = snapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save() {
|
||||
System.out.println("GskCanvas.save()");
|
||||
return -1;
|
||||
native_save(snapshot);
|
||||
return save_count++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore() {
|
||||
System.out.println("GskCanvas.restore()");
|
||||
save_count--;
|
||||
native_restore(snapshot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreToCount(int count) {
|
||||
while (save_count > count) {
|
||||
restore();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(float dx, float dy) {
|
||||
System.out.println("GskCanvas.translate(" + dx + ", " + dy + ")");
|
||||
native_translate(snapshot, dx, dy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rotate(float degrees) {
|
||||
System.out.println("GskCanvas.rotate(" + degrees + ")");
|
||||
native_rotate(snapshot, degrees);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,7 +52,7 @@ public class GskCanvas extends Canvas {
|
||||
|
||||
@Override
|
||||
public void drawPath(Path path, Paint paint) {
|
||||
System.out.println("GskCanvas.drawPath(" + path + ", " + paint + ")");
|
||||
native_drawPath(snapshot, path.mNativePath, paint.skia_paint);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,4 +84,9 @@ public class GskCanvas extends Canvas {
|
||||
|
||||
protected native void native_drawBitmap(long snapshot, long pixbuf, int x, int y, int width, int height, int color);
|
||||
protected native void native_drawRect(long snapshot, float left, float top, float right, float bottom, int color);
|
||||
protected native void native_drawPath(long snapshot, long path, long paint);
|
||||
protected native void native_translate(long snapshot, float dx, float dy);
|
||||
protected native void native_rotate(long snapshot, float degrees);
|
||||
protected native void native_save(long snapshot);
|
||||
protected native void native_restore(long snapshot);
|
||||
}
|
||||
|
||||
@@ -323,8 +323,7 @@ public class Matrix {
|
||||
* M' = M * T(dx, dy)
|
||||
*/
|
||||
public boolean preTranslate(float dx, float dy) {
|
||||
// return native_preTranslate(native_instance, dx, dy);
|
||||
return false;
|
||||
return native_preTranslate(native_instance, dx, dy);
|
||||
}
|
||||
/**
|
||||
* Preconcats the matrix with the specified scale.
|
||||
|
||||
@@ -30,7 +30,9 @@ public class Paint {
|
||||
}
|
||||
|
||||
public void setAntiAlias(boolean aa) {}
|
||||
public void setStrokeWidth(float width) {}
|
||||
public void setStrokeWidth(float width) {
|
||||
native_set_stroke_width(skia_paint, width);
|
||||
}
|
||||
public void setTextSize(float size) {
|
||||
if(skia_font == 0)
|
||||
skia_font = native_create_font();
|
||||
@@ -51,7 +53,9 @@ public class Paint {
|
||||
public void getTextBounds(char[] text, int index, int count, Rect bounds) {}
|
||||
public void setFlags(int flags) {}
|
||||
public void setFilterBitmap(boolean filter) {}
|
||||
public void setStyle(Style style) {}
|
||||
public void setStyle(Style style) {
|
||||
native_set_style(skia_paint, style.nativeInt);
|
||||
}
|
||||
public float ascent() {
|
||||
if(skia_font == 0)
|
||||
return 0;
|
||||
@@ -237,4 +241,6 @@ public class Paint {
|
||||
private static native void native_set_typeface(long skia_font, long skia_typeface);
|
||||
private static native void native_set_text_size(long skia_font, float size);
|
||||
private static native float native_measure_text(long skia_font, CharSequence text, int start, int end, long skia_paint);
|
||||
private static native void native_set_stroke_width(long skia_font, float width);
|
||||
private static native void native_set_style(long skia_paint, int style);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user