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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user