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 ColorFilter in GskCanvas
This is needed to make icons follow night mode setting
This commit is contained in:
@@ -35,7 +35,11 @@ public class GskCanvas extends Canvas {
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) {
|
||||
native_drawBitmap(snapshot, bitmap.pixbuf, dst.left, dst.top, dst.width(), dst.height());
|
||||
int color = 0;
|
||||
if (paint != null && paint.colorFilter instanceof PorterDuffColorFilter) {
|
||||
color = ((PorterDuffColorFilter) paint.colorFilter).getColor();
|
||||
}
|
||||
native_drawBitmap(snapshot, bitmap.pixbuf, dst.left, dst.top, dst.width(), dst.height(), color);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,5 +74,5 @@ public class GskCanvas extends Canvas {
|
||||
drawBitmap(bitmap, src, dst, paint);
|
||||
}
|
||||
|
||||
protected native void native_drawBitmap(long snapshot, long pixbuf, int x, int y, int width, int height);
|
||||
protected native void native_drawBitmap(long snapshot, long pixbuf, int x, int y, int width, int height, int color);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ public class Paint {
|
||||
public long skia_paint = 0;
|
||||
private Typeface typeface = null;
|
||||
public long skia_font = 0;
|
||||
ColorFilter colorFilter = null;
|
||||
|
||||
public Paint() {
|
||||
skia_paint = native_constructor();
|
||||
@@ -64,6 +65,11 @@ public class Paint {
|
||||
}
|
||||
public float measureText(CharSequence text, int start, int end) { return 10; }
|
||||
|
||||
public ColorFilter setColorFilter(ColorFilter colorFilter) {
|
||||
this.colorFilter = colorFilter;
|
||||
return colorFilter;
|
||||
}
|
||||
|
||||
public Shader setShader(Shader shader) { return shader; }
|
||||
|
||||
public enum Style {
|
||||
|
||||
@@ -92,6 +92,10 @@ public class PorterDuff {
|
||||
ADD(16),
|
||||
OVERLAY(17);
|
||||
|
||||
Mode(int nativeInt) {}
|
||||
public int nativeInt;
|
||||
|
||||
Mode(int nativeInt) {
|
||||
this.nativeInt = nativeInt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user