17static jlong Paint_Create(JNIEnv*, jobject) {
18 return reinterpret_cast<jlong
>(
new SkPaint);
21static void Paint_Release(JNIEnv*, jobject, jlong native_paint) {
22 delete reinterpret_cast<SkPaint*
>(native_paint);
25static void Paint_SetColor(JNIEnv*, jobject, jlong native_paint,
26 float r,
float g,
float b,
float a) {
27 if (
auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint)) {
28 paint->setColor4f({r, g,
b,
a});
32static void Paint_SetStroke(JNIEnv*, jobject, jlong native_paint, jboolean stroke) {
33 if (
auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint)) {
34 paint->setStroke(stroke);
38static void Paint_SetStrokeWidth(JNIEnv*, jobject, jlong native_paint, jfloat
width) {
39 if (
auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint)) {
44static void Paint_SetStrokeCap(JNIEnv*
env, jobject, jlong native_paint, jint native_cap) {
45 if (
auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint)) {
63static void Paint_SetStrokeJoin(JNIEnv*
env, jobject, jlong native_paint, jint native_join) {
64 if (
auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint)) {
82static void Paint_SetStrokeMiter(JNIEnv*
env, jobject, jlong native_paint, jfloat limit) {
83 if (
auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint)) {
84 paint->setStrokeMiter(limit);
88static void Paint_SetColorFilter(JNIEnv*, jobject, jlong native_paint, jlong native_cf) {
89 if (
auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint)) {
94static void Paint_SetShader(JNIEnv*, jobject, jlong native_paint, jlong native_shader) {
95 if (
auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint)) {
100static void Paint_SetImageFilter(JNIEnv*, jobject, jlong native_paint, jlong native_filter) {
101 if (
auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint)) {
109 static const JNINativeMethod methods[] = {
110 {
"nCreate" ,
"()J" ,
reinterpret_cast<void*
>(Paint_Create)},
111 {
"nRelease" ,
"(J)V" ,
reinterpret_cast<void*
>(Paint_Release)},
112 {
"nSetColor" ,
"(JFFFF)V",
reinterpret_cast<void*
>(Paint_SetColor)},
113 {
"nSetStroke" ,
"(JZ)V" ,
reinterpret_cast<void*
>(Paint_SetStroke)},
114 {
"nSetStrokeWidth" ,
"(JF)V" ,
reinterpret_cast<void*
>(Paint_SetStrokeWidth)},
115 {
"nSetStrokeCap" ,
"(JI)V" ,
reinterpret_cast<void*
>(Paint_SetStrokeCap)},
116 {
"nSetStrokeJoin" ,
"(JI)V" ,
reinterpret_cast<void*
>(Paint_SetStrokeJoin)},
117 {
"nSetStrokeMiter" ,
"(JF)V" ,
reinterpret_cast<void*
>(Paint_SetStrokeMiter)},
118 {
"nSetColorFilter" ,
"(JJ)V" ,
reinterpret_cast<void*
>(Paint_SetColorFilter)},
119 {
"nSetShader" ,
"(JJ)V" ,
reinterpret_cast<void*
>(Paint_SetShader)},
120 {
"nSetImageFilter" ,
"(JJ)V" ,
reinterpret_cast<void*
>(Paint_SetImageFilter)},
123 const auto clazz =
env->FindClass(
"org/skia/jetski/Paint");
125 ?
env->RegisterNatives(clazz, methods, std::size(methods))
int register_jetski_Paint(JNIEnv *env)
sk_sp< T > sk_ref_sp(T *obj)
@ kButt_Cap
no stroke extension
@ kMiter_Join
extends to miter limit
@ kBevel_Join
connects outside edges