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
GskCanvas: implement drawRect
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class GskCanvas extends Canvas {
|
||||
|
||||
@Override
|
||||
public void drawRect(float left, float top, float right, float bottom, Paint paint) {
|
||||
System.out.println("GskCanvas.drawRect(" + left + ", " + top + ", " + right + ", " + bottom + ", " + paint + ")");
|
||||
native_drawRect(snapshot, left, top, right, bottom, paint.getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,4 +75,5 @@ public class GskCanvas extends Canvas {
|
||||
}
|
||||
|
||||
protected native void native_drawBitmap(long snapshot, long pixbuf, 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user