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