Move JNI bindings code from mapbox-gl-native to this repo. (#301)
This commit is contained in:
25
MapboxGLAndroidSDK/src/cpp/graphics/pointf.cpp
Normal file
25
MapboxGLAndroidSDK/src/cpp/graphics/pointf.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <mbgl/util/geo.hpp>
|
||||
#include "pointf.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
jni::Local<jni::Object<PointF>> PointF::New(jni::JNIEnv& env, float x, float y) {
|
||||
static auto& javaClass = jni::Class<PointF>::Singleton(env);
|
||||
static auto constructor = javaClass.GetConstructor<float, float>(env);
|
||||
return javaClass.New(env, constructor, x, y);
|
||||
}
|
||||
|
||||
mbgl::ScreenCoordinate PointF::getScreenCoordinate(jni::JNIEnv& env, const jni::Object<PointF>& point) {
|
||||
static auto& javaClass = jni::Class<PointF>::Singleton(env);
|
||||
static auto xField = javaClass.GetField<jni::jfloat>(env, "x");
|
||||
static auto yField = javaClass.GetField<jni::jfloat>(env, "y");
|
||||
return mbgl::ScreenCoordinate{point.Get(env, xField), point.Get(env, yField)};
|
||||
}
|
||||
|
||||
void PointF::registerNative(jni::JNIEnv& env) {
|
||||
jni::Class<PointF>::Singleton(env);
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
24
MapboxGLAndroidSDK/src/cpp/graphics/pointf.hpp
Normal file
24
MapboxGLAndroidSDK/src/cpp/graphics/pointf.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class PointF : private mbgl::util::noncopyable {
|
||||
public:
|
||||
|
||||
static constexpr auto Name() { return "android/graphics/PointF"; };
|
||||
|
||||
static jni::Local<jni::Object<PointF>> New(jni::JNIEnv&, float, float);
|
||||
|
||||
static mbgl::ScreenCoordinate getScreenCoordinate(jni::JNIEnv&, const jni::Object<PointF>&);
|
||||
|
||||
static void registerNative(jni::JNIEnv&);
|
||||
};
|
||||
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
35
MapboxGLAndroidSDK/src/cpp/graphics/rectf.cpp
Normal file
35
MapboxGLAndroidSDK/src/cpp/graphics/rectf.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "rectf.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
float RectF::getLeft(jni::JNIEnv& env, const jni::Object<RectF>& rectf) {
|
||||
static auto& javaClass = jni::Class<RectF>::Singleton(env);
|
||||
static auto field = javaClass.GetField<float>(env, "left");
|
||||
return rectf.Get(env, field);
|
||||
}
|
||||
|
||||
float RectF::getTop(jni::JNIEnv& env, const jni::Object<RectF>& rectf) {
|
||||
static auto& javaClass = jni::Class<RectF>::Singleton(env);
|
||||
static auto field = javaClass.GetField<float>(env, "top");
|
||||
return rectf.Get(env, field);
|
||||
}
|
||||
|
||||
float RectF::getRight(jni::JNIEnv& env, const jni::Object<RectF>& rectf) {
|
||||
static auto& javaClass = jni::Class<RectF>::Singleton(env);
|
||||
static auto field = javaClass.GetField<float>(env, "right");
|
||||
return rectf.Get(env, field);
|
||||
}
|
||||
|
||||
float RectF::getBottom(jni::JNIEnv& env, const jni::Object<RectF>& rectf) {
|
||||
static auto& javaClass = jni::Class<RectF>::Singleton(env);
|
||||
static auto field = javaClass.GetField<float>(env, "bottom");
|
||||
return rectf.Get(env, field);
|
||||
}
|
||||
|
||||
void RectF::registerNative(jni::JNIEnv& env) {
|
||||
jni::Class<RectF>::Singleton(env);
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
28
MapboxGLAndroidSDK/src/cpp/graphics/rectf.hpp
Normal file
28
MapboxGLAndroidSDK/src/cpp/graphics/rectf.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class RectF : private mbgl::util::noncopyable {
|
||||
public:
|
||||
|
||||
static constexpr auto Name() { return "android/graphics/RectF"; };
|
||||
|
||||
static float getLeft(jni::JNIEnv&, const jni::Object<RectF>&);
|
||||
|
||||
static float getTop(jni::JNIEnv&, const jni::Object<RectF>&);
|
||||
|
||||
static float getRight(jni::JNIEnv&, const jni::Object<RectF>&);
|
||||
|
||||
static float getBottom(jni::JNIEnv&, const jni::Object<RectF>&);
|
||||
|
||||
static void registerNative(jni::JNIEnv&);
|
||||
};
|
||||
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
Reference in New Issue
Block a user