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 some Canvas methods needed for composeUI
This commit is contained in:
@@ -80,7 +80,17 @@ JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1stroke_1width(JN
|
||||
sk_paint_set_stroke_width(_PTR(skia_paint), width);
|
||||
}
|
||||
|
||||
JNIEXPORT jfloat JNICALL Java_android_graphics_Paint_native_1get_1stroke_1width(JNIEnv *env, jclass this, jlong skia_paint)
|
||||
{
|
||||
return sk_paint_get_stroke_width(_PTR(skia_paint));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1style(JNIEnv *env, jclass this, jlong skia_paint, jint style)
|
||||
{
|
||||
sk_paint_set_style(_PTR(skia_paint), (sk_paint_style_t)style);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1blendmode(JNIEnv *env, jclass this, jlong skia_paint, jint blendmode)
|
||||
{
|
||||
sk_paint_set_blendmode(_PTR(skia_paint), (sk_blendmode_t)blendmode);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,14 @@ JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawLine
|
||||
JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawText
|
||||
(JNIEnv *, jobject, jlong, jstring, jfloat, jfloat, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_graphics_GskCanvas
|
||||
* Method: native_drawRoundRect
|
||||
* Signature: (JFFFFFFIF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawRoundRect
|
||||
(JNIEnv *, jobject, jlong, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jint, jfloat);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -113,6 +113,14 @@ JNIEXPORT jfloat JNICALL Java_android_graphics_Paint_native_1measure_1text
|
||||
JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1stroke_1width
|
||||
(JNIEnv *, jclass, jlong, jfloat);
|
||||
|
||||
/*
|
||||
* Class: android_graphics_Paint
|
||||
* Method: native_get_stroke_width
|
||||
* Signature: (J)F
|
||||
*/
|
||||
JNIEXPORT jfloat JNICALL Java_android_graphics_Paint_native_1get_1stroke_1width
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_graphics_Paint
|
||||
* Method: native_set_style
|
||||
@@ -121,6 +129,14 @@ JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1stroke_1width
|
||||
JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1style
|
||||
(JNIEnv *, jclass, jlong, jint);
|
||||
|
||||
/*
|
||||
* Class: android_graphics_Paint
|
||||
* Method: native_set_blendmode
|
||||
* Signature: (JI)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1blendmode
|
||||
(JNIEnv *, jclass, jlong, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -223,6 +223,14 @@ JNIEXPORT void JNICALL Java_android_view_ViewGroup_native_1removeView
|
||||
JNIEXPORT void JNICALL Java_android_view_ViewGroup_native_1drawChildren
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_view_ViewGroup
|
||||
* Method: native_drawChild
|
||||
* Signature: (JJJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_view_ViewGroup_native_1drawChild
|
||||
(JNIEnv *, jobject, jlong, jlong, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -119,3 +119,21 @@ JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawText(JNIEnv *
|
||||
gtk_snapshot_translate(snapshot, &GRAPHENE_POINT_INIT(-x, -y));
|
||||
g_object_unref(layout);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawRoundRect(JNIEnv *env, jclass this_class, jlong snapshot_ptr, jfloat left, jfloat top, jfloat right, jfloat bottom, jfloat rx, jfloat ry, jint color, jfloat width)
|
||||
{
|
||||
GdkSnapshot *snapshot = (GdkSnapshot *)_PTR(snapshot_ptr);
|
||||
GdkRGBA gdk_color[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
gdk_color[i].red = (float)((color >> 16) & 0xff) / 0xff;
|
||||
gdk_color[i].green = (float)((color >> 8) & 0xff) / 0xff;
|
||||
gdk_color[i].blue = (float)((color >> 0) & 0xff) / 0xff;
|
||||
gdk_color[i].alpha = (float)((color >> 24) & 0xff) / 0xff;
|
||||
}
|
||||
GskRoundedRect round_rect = {
|
||||
.bounds = GRAPHENE_RECT_INIT(left, top, right - left, bottom - top),
|
||||
.corner = {{rx, ry}, {rx, ry}, {rx, ry}, {rx, ry}},
|
||||
};
|
||||
const float widths[4] = {width, width, width, width};
|
||||
gtk_snapshot_append_border(snapshot, &round_rect, widths, gdk_color);
|
||||
}
|
||||
|
||||
@@ -246,3 +246,10 @@ JNIEXPORT jboolean JNICALL Java_android_graphics_Matrix_native_1preRotate__JFFF(
|
||||
graphene_matrix_translate(matrix, &GRAPHENE_POINT3D_INIT(px, py, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_android_graphics_Matrix_native_1equals(JNIEnv *env, jclass class, jlong matrix1_ptr, jlong matrix2_ptr)
|
||||
{
|
||||
graphene_matrix_t *matrix1 = (graphene_matrix_t *)_PTR(matrix1_ptr);
|
||||
graphene_matrix_t *matrix2 = (graphene_matrix_t *)_PTR(matrix2_ptr);
|
||||
return graphene_matrix_equal(matrix1, matrix2);
|
||||
}
|
||||
|
||||
@@ -54,3 +54,12 @@ JNIEXPORT void JNICALL Java_android_view_ViewGroup_native_1drawChildren(JNIEnv *
|
||||
GdkSnapshot *snapshot = GDK_SNAPSHOT(_PTR(snapshot_ptr));
|
||||
gtk_widget_snapshot_child(&wrapper->parent_instance, wrapper->child, snapshot);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_view_ViewGroup_native_1drawChild(JNIEnv *env, jobject this, jlong widget_ptr, jlong child_ptr, jlong snapshot_ptr)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET(_PTR(widget_ptr));
|
||||
GtkWidget *child = gtk_widget_get_parent(GTK_WIDGET(_PTR(child_ptr)));
|
||||
GdkSnapshot *snapshot = GDK_SNAPSHOT(_PTR(snapshot_ptr));
|
||||
gtk_widget_queue_draw(child); // FIXME: why didn't compose UI invalidate the child?
|
||||
gtk_widget_snapshot_child(widget, child, snapshot);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user