blob: f38faa998bfa8854b5f722f49ec97edeb2e99379 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001#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
30static JNINativeMethod gMathUtilsMethods[] = {
31 {"floor", "(F)F", (void*) MathUtilsGlue::FloorF},
32 {"ceil", "(F)F", (void*) MathUtilsGlue::CeilF},
33 {"sin", "(F)F", (void*) MathUtilsGlue::SinF},
34 {"cos", "(F)F", (void*) MathUtilsGlue::CosF},
35 {"sqrt", "(F)F", (void*) MathUtilsGlue::SqrtF}
36};
37
38int register_android_util_FloatMath(JNIEnv* env)
39{
40 int result = android::AndroidRuntime::registerNativeMethods(env,
41 "android/util/FloatMath",
42 gMathUtilsMethods,
43 SK_ARRAY_COUNT(gMathUtilsMethods));
44 return result;
45}
46