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
drop Skia dependency
Everything is implementede using GTK Scene Graph now. Skia is no longer needed.
This commit is contained in:
@@ -52,7 +52,7 @@ public class GskCanvas extends Canvas {
|
||||
|
||||
@Override
|
||||
public void drawPath(Path path, Paint paint) {
|
||||
native_drawPath(snapshot, path.getGskPath(), paint.skia_paint);
|
||||
native_drawPath(snapshot, path.getGskPath(), paint.getColor(), paint.getStyle().nativeInt);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,12 +69,12 @@ public class GskCanvas extends Canvas {
|
||||
|
||||
@Override
|
||||
public void drawText(String text, float x, float y, Paint paint) {
|
||||
native_drawText(snapshot, text, x, y, paint.skia_paint, paint.skia_font);
|
||||
native_drawText(snapshot, text, x, y, paint.getColor(), paint.getTextSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
|
||||
native_drawLine(snapshot, startX, startY, stopX, stopY, paint.skia_paint);
|
||||
native_drawLine(snapshot, startX, startY, stopX, stopY, paint.getColor(), paint.getStrokeWidth());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,13 +101,13 @@ public class GskCanvas extends Canvas {
|
||||
|
||||
protected native void native_drawBitmap(long snapshot, long texture, 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_drawPath(long snapshot, long path, int color, int style);
|
||||
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);
|
||||
protected native void native_drawLine(long snapshot, float startX, float startY, float stopX, float stopY, long paint);
|
||||
protected native void native_drawText(long snapshot, String text, float x, float y, long paint, long font);
|
||||
protected native void native_drawLine(long snapshot, float startX, float startY, float stopX, float stopY, int color, float strokeWidth);
|
||||
protected native void native_drawText(long snapshot, String text, float x, float y, int color, float textSize);
|
||||
protected native void native_drawRoundRect(long snapshot, float left, float top, float right, float bottom, float rx, float ry, int color, float strokeWidth, int style);
|
||||
protected native void native_scale(long snapshot, float sx, float sy);
|
||||
}
|
||||
|
||||
@@ -17,13 +17,14 @@ public class Paint {
|
||||
public static final int AUTO_HINTING_TEXT_FLAG = (1 << 11);
|
||||
public static final int VERTICAL_TEXT_FLAG = (1 << 12);
|
||||
|
||||
public long skia_paint = 0;
|
||||
private Typeface typeface = null;
|
||||
public long skia_font = 0;
|
||||
ColorFilter colorFilter = null;
|
||||
private int color = 0;
|
||||
private float strokeWidth = 0;
|
||||
private float textSize = 7;
|
||||
private Style style = Style.FILL;
|
||||
|
||||
public Paint() {
|
||||
skia_paint = native_constructor();
|
||||
}
|
||||
|
||||
public Paint (int flags) {
|
||||
@@ -38,34 +39,25 @@ public class Paint {
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
native_set_color(skia_paint, color);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return native_get_color(skia_paint);
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setAntiAlias(boolean aa) {
|
||||
native_set_antialias(skia_paint, aa);
|
||||
}
|
||||
|
||||
public void setStrokeWidth(float width) {
|
||||
native_set_stroke_width(skia_paint, width);
|
||||
this.strokeWidth = width;
|
||||
}
|
||||
public void setTextSize(float size) {
|
||||
if(skia_font == 0)
|
||||
skia_font = native_create_font();
|
||||
|
||||
native_set_text_size(skia_font, size);
|
||||
this.textSize = size;
|
||||
}
|
||||
|
||||
public Typeface setTypeface(Typeface typeface) {
|
||||
this.typeface = typeface;
|
||||
if(skia_font == 0)
|
||||
skia_font = native_create_font();
|
||||
|
||||
if (typeface != null)
|
||||
native_set_typeface(skia_font, typeface.skia_typeface);
|
||||
return this.typeface;
|
||||
}
|
||||
public void getTextBounds(String text, int start, int end, Rect bounds) {}
|
||||
@@ -82,20 +74,16 @@ public class Paint {
|
||||
}
|
||||
|
||||
public void setStyle(Style style) {
|
||||
native_set_style(skia_paint, style.nativeInt);
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public float ascent() {
|
||||
if(skia_font == 0)
|
||||
return 0;
|
||||
return native_ascent(skia_font);
|
||||
return 10;
|
||||
}
|
||||
|
||||
public float measureText(char[] text, int index, int count) { return 10; }
|
||||
public float measureText(String text, int start, int end) {
|
||||
if (skia_font == 0)
|
||||
skia_font = native_create_font();
|
||||
return native_measure_text(skia_font, text, start, end, skia_paint);
|
||||
return (end-start)*textSize;
|
||||
}
|
||||
public float measureText(String text) {
|
||||
return measureText(text, 0, text.length());
|
||||
@@ -192,7 +180,7 @@ public class Paint {
|
||||
public /*native*/ int getAlpha() { return 0; }
|
||||
public /*native*/ void setAlpha(int a) {}
|
||||
public float getStrokeWidth() {
|
||||
return native_get_stroke_width(skia_paint);
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
public /*native*/ float getStrokeMiter() { return 0; }
|
||||
@@ -211,9 +199,6 @@ public class Paint {
|
||||
public void setShadowLayer(float radius, float dx, float dy, int color) {}
|
||||
|
||||
public Xfermode setXfermode(Xfermode xfermode) {
|
||||
if (xfermode instanceof PorterDuffXfermode) {
|
||||
native_set_blendmode(skia_paint, ((PorterDuffXfermode)xfermode).mode.nativeInt);
|
||||
}
|
||||
return xfermode;
|
||||
}
|
||||
|
||||
@@ -312,21 +297,6 @@ public class Paint {
|
||||
public float getLetterSpacing() { return 1.0f; }
|
||||
|
||||
public Style getStyle() {
|
||||
return Style.values()[native_get_style(skia_paint)];
|
||||
return style;
|
||||
}
|
||||
|
||||
private native long native_constructor();
|
||||
private native void native_set_antialias(long skia_paint, boolean aa);
|
||||
private native void native_set_color(long skia_paint, int color);
|
||||
private native int native_get_color(long skia_paint);
|
||||
private static native long native_create_font();
|
||||
private static native float native_ascent(long skia_font);
|
||||
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 float native_get_stroke_width(long skia_font);
|
||||
private static native void native_set_style(long skia_paint, int style);
|
||||
private static native void native_set_blendmode(long skia_paint, int mode);
|
||||
private static native int native_get_style(long skia_paint);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ public class Typeface {
|
||||
public static final int ITALIC = 2;
|
||||
public static final int BOLD_ITALIC = 3;
|
||||
|
||||
public long skia_typeface = 0;
|
||||
public long native_instance = 0; // directly accessed by androidx
|
||||
|
||||
public static Typeface createFromAsset(AssetManager mgr, String path) {
|
||||
@@ -42,7 +41,6 @@ public class Typeface {
|
||||
|
||||
public static Typeface create(String family_name, int style) {
|
||||
Typeface ret = new Typeface();
|
||||
ret.skia_typeface = native_create(family_name, style);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -54,8 +52,6 @@ public class Typeface {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
private static native long native_create(CharSequence family_name, int style);
|
||||
|
||||
public int getStyle() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user