GskCanvas: implement drawRect

This commit is contained in:
Mis012
2024-04-07 21:49:40 +02:00
parent 677ff43a20
commit b229d83ad8
3 changed files with 23 additions and 1 deletions

View File

@@ -15,6 +15,14 @@ extern "C" {
JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawBitmap
(JNIEnv *, jobject, jlong, jlong, jint, jint, jint, jint, jint);
/*
* Class: android_graphics_GskCanvas
* Method: native_drawRect
* Signature: (JFFFFI)V
*/
JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawRect
(JNIEnv *, jobject, jlong, jfloat, jfloat, jfloat, jfloat, jint);
#ifdef __cplusplus
}
#endif

View File

@@ -28,3 +28,16 @@ JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawBitmap(JNIEnv
gtk_snapshot_pop(snapshot);
g_object_unref(texture);
}
JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawRect(JNIEnv *env, jclass this_class, jlong snapshot_ptr, jfloat left, jfloat top, jfloat right, jfloat bottom, jint color)
{
GdkSnapshot *snapshot = (GdkSnapshot *)_PTR(snapshot_ptr);
GdkRGBA gdk_color = {
(float)((color >> 16) & 0xff) / 0xff,
(float)((color >> 8) & 0xff) / 0xff,
(float)((color >> 0) & 0xff) / 0xff,
(float)((color >> 24) & 0xff) / 0xff,
};
graphene_rect_t bounds = GRAPHENE_RECT_INIT(left, top, right - left, bottom - top);
gtk_snapshot_append_color(snapshot, &gdk_color, &bounds);
}