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
src/api-impl: use skia instead of cairo
Using the C API provided by SkiaSharp's skia fork instead of using cairo significantly improves performance. The API is also closer to the android Canvas API, which makes the implementation more straightforward.
This commit is contained in:
27
src/api-impl-jni/android_graphics_Paint.c
Normal file
27
src/api-impl-jni/android_graphics_Paint.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "../sk_area/include/c/sk_paint.h"
|
||||
#include "generated_headers/android_graphics_Paint.h"
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_android_graphics_Paint_native_1constructor(JNIEnv *env, jobject this)
|
||||
{
|
||||
return _INTPTR(sk_paint_new());
|
||||
}
|
||||
|
||||
/* NOTE: sk_color_t seems to have the same internal representation as android uses for color, so we just pass that directly */
|
||||
JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1color(JNIEnv *env, jobject this, jlong skia_paint, jint color)
|
||||
{
|
||||
sk_paint_t *paint = (sk_paint_t *)_PTR(skia_paint);
|
||||
|
||||
sk_paint_set_color(paint, color);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_android_graphics_Paint_native_1get_1color(JNIEnv *env, jobject this, jlong skia_paint)
|
||||
{
|
||||
sk_paint_t *paint = (sk_paint_t *)_PTR(skia_paint);
|
||||
|
||||
return sk_paint_get_color(paint);
|
||||
}
|
||||
Reference in New Issue
Block a user