android_util_FloatMath.cpp revision 5d728bb9ff8c6ad89d5a1b88b2804f954d45d763
1#include "jni.h" 2#include <android_runtime/AndroidRuntime.h> 3#include <math.h> 4#include <float.h> 5#include "SkTypes.h" 6 7class MathUtilsGlue { 8public: 9 static float FloorF(JNIEnv* env, jobject clazz, float x) { 10 return floorf(x); 11 } 12 13 static float CeilF(JNIEnv* env, jobject clazz, float x) { 14 return ceilf(x); 15 } 16 17 static float SinF(JNIEnv* env, jobject clazz, float x) { 18 return sinf(x); 19 } 20 21 static float CosF(JNIEnv* env, jobject clazz, float x) { 22 return cosf(x); 23 } 24 25 static float SqrtF(JNIEnv* env, jobject clazz, float x) { 26 return sqrtf(x); 27 } 28 29 static float ExpF(JNIEnv* env, jobject clazz, float x) { 30 return expf(x); 31 } 32}; 33 34static JNINativeMethod gMathUtilsMethods[] = { 35 {"floor", "(F)F", (void*) MathUtilsGlue::FloorF}, 36 {"ceil", "(F)F", (void*) MathUtilsGlue::CeilF}, 37 {"sin", "(F)F", (void*) MathUtilsGlue::SinF}, 38 {"cos", "(F)F", (void*) MathUtilsGlue::CosF}, 39 {"sqrt", "(F)F", (void*) MathUtilsGlue::SqrtF}, 40 {"exp", "(F)F", (void*) MathUtilsGlue::ExpF}, 41}; 42 43int register_android_util_FloatMath(JNIEnv* env) 44{ 45 int result = android::AndroidRuntime::registerNativeMethods(env, 46 "android/util/FloatMath", 47 gMathUtilsMethods, 48 SK_ARRAY_COUNT(gMathUtilsMethods)); 49 return result; 50} 51 52