diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-02-16 16:16:47 +0200 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-02-24 17:54:20 +0200 |
commit | 465c949153a838bb3159204ab268eb551fbd2e6c (patch) | |
tree | 250922b879261580b1252a78b461218be9012bc0 /platform/android/src/graphics | |
parent | 7d9018093a61d327fa7ca1312845d2a00d928380 (diff) | |
download | qtlocation-mapboxgl-465c949153a838bb3159204ab268eb551fbd2e6c.tar.gz |
[android] jni high level binding refactor
Diffstat (limited to 'platform/android/src/graphics')
-rw-r--r-- | platform/android/src/graphics/pointf.cpp | 20 | ||||
-rw-r--r-- | platform/android/src/graphics/pointf.hpp | 25 | ||||
-rw-r--r-- | platform/android/src/graphics/rectf.cpp | 35 | ||||
-rw-r--r-- | platform/android/src/graphics/rectf.hpp | 31 |
4 files changed, 111 insertions, 0 deletions
diff --git a/platform/android/src/graphics/pointf.cpp b/platform/android/src/graphics/pointf.cpp new file mode 100644 index 0000000000..6e91b81416 --- /dev/null +++ b/platform/android/src/graphics/pointf.cpp @@ -0,0 +1,20 @@ +#include "pointf.hpp" + +namespace mbgl { +namespace android { + +jni::Object<PointF> PointF::New(jni::JNIEnv& env, float x, float y) { + static auto constructor = PointF::javaClass.GetConstructor<float, float>(env); + return PointF::javaClass.New(env, constructor, x, y); +} + +void PointF::registerNative(jni::JNIEnv& env) { + // Lookup the class + PointF::javaClass = *jni::Class<PointF>::Find(env).NewGlobalRef(env).release(); +} + +jni::Class<PointF> PointF::javaClass; + + +} // namespace android +} // namespace mbgl
\ No newline at end of file diff --git a/platform/android/src/graphics/pointf.hpp b/platform/android/src/graphics/pointf.hpp new file mode 100644 index 0000000000..ea25ad2b40 --- /dev/null +++ b/platform/android/src/graphics/pointf.hpp @@ -0,0 +1,25 @@ +#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::Object<PointF> New(jni::JNIEnv&, float, float); + + static jni::Class<PointF> javaClass; + + static void registerNative(jni::JNIEnv&); + +}; + + +} // namespace android +} // namespace mbgl
\ No newline at end of file diff --git a/platform/android/src/graphics/rectf.cpp b/platform/android/src/graphics/rectf.cpp new file mode 100644 index 0000000000..1b375dad18 --- /dev/null +++ b/platform/android/src/graphics/rectf.cpp @@ -0,0 +1,35 @@ +#include "rectf.hpp" + +namespace mbgl { +namespace android { + +float RectF::getLeft(jni::JNIEnv& env, jni::Object<RectF> rectf) { + static auto field = RectF::javaClass.GetField<float>(env, "left"); + return rectf.Get(env, field); +} + +float RectF::getTop(jni::JNIEnv& env, jni::Object<RectF> rectf) { + static auto field = RectF::javaClass.GetField<float>(env, "top"); + return rectf.Get(env, field); +} + +float RectF::getRight(jni::JNIEnv& env, jni::Object<RectF> rectf) { + static auto field = RectF::javaClass.GetField<float>(env, "right"); + return rectf.Get(env, field); +} + +float RectF::getBottom(jni::JNIEnv& env, jni::Object<RectF> rectf) { + static auto field = RectF::javaClass.GetField<float>(env, "bottom"); + return rectf.Get(env, field); +} + +void RectF::registerNative(jni::JNIEnv& env) { + // Lookup the class + RectF::javaClass = *jni::Class<RectF>::Find(env).NewGlobalRef(env).release(); +} + +jni::Class<RectF> RectF::javaClass; + + +} // namespace android +} // namespace mbgl
\ No newline at end of file diff --git a/platform/android/src/graphics/rectf.hpp b/platform/android/src/graphics/rectf.hpp new file mode 100644 index 0000000000..0f3a7756d5 --- /dev/null +++ b/platform/android/src/graphics/rectf.hpp @@ -0,0 +1,31 @@ +#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&, jni::Object<RectF>); + + static float getTop(jni::JNIEnv&, jni::Object<RectF>); + + static float getRight(jni::JNIEnv&, jni::Object<RectF>); + + static float getBottom(jni::JNIEnv&, jni::Object<RectF>); + + static jni::Class<RectF> javaClass; + + static void registerNative(jni::JNIEnv&); + +}; + + +} // namespace android +} // namespace mbgl
\ No newline at end of file |