1 /* 2 * Copyright 2021 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include <android/log.h> 9 #include <jni.h> 10 11 #define REGISTER_NATIVES(class_name) \ 12 extern int register_androidkit_##class_name(JNIEnv*); \ 13 if (auto rc = register_androidkit_##class_name(env)) { \ 14 __android_log_print(ANDROID_LOG_ERROR, "AndroidKit", \ 15 "Failed to load natives: " #class_name); \ 16 return rc; \ 17 } 18 19 JNI_OnLoad(JavaVM * vm,void * reserved)20JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { 21 JNIEnv* env; 22 if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { 23 return JNI_ERR; 24 } 25 26 REGISTER_NATIVES(Canvas) 27 REGISTER_NATIVES(ColorFilter) 28 REGISTER_NATIVES(ComposeColorFilter) 29 REGISTER_NATIVES(Font) 30 REGISTER_NATIVES(FontChain) 31 REGISTER_NATIVES(HSLAMatrixColorFilter) 32 REGISTER_NATIVES(Image) 33 REGISTER_NATIVES(ImageFilter) 34 REGISTER_NATIVES(LinearGradient) 35 REGISTER_NATIVES(Matrix) 36 REGISTER_NATIVES(MatrixColorFilter) 37 REGISTER_NATIVES(Paint) 38 REGISTER_NATIVES(Path) 39 REGISTER_NATIVES(PathBuilder) 40 REGISTER_NATIVES(RadialGradient) 41 REGISTER_NATIVES(RuntimeShaderBuilder) 42 REGISTER_NATIVES(Shader) 43 REGISTER_NATIVES(SkottieAnimation) 44 REGISTER_NATIVES(Surface) 45 REGISTER_NATIVES(SweepGradient) 46 REGISTER_NATIVES(Text) 47 REGISTER_NATIVES(TwoPointConicalGradient) 48 49 return JNI_VERSION_1_6; 50 } 51