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 RoundedRect filling
This commit is contained in:
@@ -94,3 +94,8 @@ JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1blendmode(JNIEnv
|
||||
{
|
||||
sk_paint_set_blendmode(_PTR(skia_paint), (sk_blendmode_t)blendmode);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_android_graphics_Paint_native_1get_1style(JNIEnv *env, jclass this, jlong skia_paint)
|
||||
{
|
||||
return sk_paint_get_style(_PTR(skia_paint));
|
||||
}
|
||||
|
||||
@@ -84,10 +84,10 @@ JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawText
|
||||
/*
|
||||
* Class: android_graphics_GskCanvas
|
||||
* Method: native_drawRoundRect
|
||||
* Signature: (JFFFFFFIF)V
|
||||
* Signature: (JFFFFFFIFI)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawRoundRect
|
||||
(JNIEnv *, jobject, jlong, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jint, jfloat);
|
||||
(JNIEnv *, jobject, jlong, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jint, jfloat, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -137,6 +137,14 @@ JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1style
|
||||
JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1blendmode
|
||||
(JNIEnv *, jclass, jlong, jint);
|
||||
|
||||
/*
|
||||
* Class: android_graphics_Paint
|
||||
* Method: native_get_style
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_android_graphics_Paint_native_1get_1style
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
|
||||
#include "../generated_headers/android_graphics_GskCanvas.h"
|
||||
|
||||
#define STYLE_FILL 0
|
||||
#define STYLE_STROKE 1
|
||||
#define STYLE_FILL_AND_STROKE 2
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawBitmap(JNIEnv *env, jclass this_class, jlong snapshot_ptr, jlong texture_ptr, jint x, jint y, jint width, jint height, jint color)
|
||||
{
|
||||
GdkSnapshot *snapshot = (GdkSnapshot *)_PTR(snapshot_ptr);
|
||||
@@ -126,7 +130,7 @@ JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawText(JNIEnv *
|
||||
g_object_unref(description);
|
||||
}
|
||||
|
||||
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)
|
||||
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, int style)
|
||||
{
|
||||
GdkSnapshot *snapshot = (GdkSnapshot *)_PTR(snapshot_ptr);
|
||||
GdkRGBA gdk_color[4];
|
||||
@@ -141,5 +145,12 @@ JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawRoundRect(JNI
|
||||
.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);
|
||||
if (style == STYLE_FILL || style == STYLE_FILL_AND_STROKE) {
|
||||
gtk_snapshot_push_rounded_clip(snapshot, &round_rect);
|
||||
gtk_snapshot_append_color(snapshot, gdk_color, &round_rect.bounds);
|
||||
gtk_snapshot_pop(snapshot);
|
||||
}
|
||||
if (style == STYLE_STROKE || style == STYLE_FILL_AND_STROKE) {
|
||||
gtk_snapshot_append_border(snapshot, &round_rect, widths, gdk_color);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user