summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2020-03-21 22:14:57 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2020-04-01 16:18:55 -0400
commitca1ae7604c1632e64e39fdaabb410e7579118ed4 (patch)
tree51a4aac3e556d25946eb8cb9a877715c26e4b235
parent15f73a06f2048d4b5f0481d54a79f3f349187b11 (diff)
downloadqtlocation-mapboxgl-ca1ae7604c1632e64e39fdaabb410e7579118ed4.tar.gz
[android] Add Android bindings
-rw-r--r--platform/android/src/style/sources/source.cpp33
-rw-r--r--platform/android/src/style/sources/source.hpp4
2 files changed, 30 insertions, 7 deletions
diff --git a/platform/android/src/style/sources/source.cpp b/platform/android/src/style/sources/source.cpp
index 5c43c2ae7c..b33e7da723 100644
--- a/platform/android/src/style/sources/source.cpp
+++ b/platform/android/src/style/sources/source.cpp
@@ -118,6 +118,22 @@ static std::unique_ptr<Source> createSourcePeer(jni::JNIEnv& env,
return jni::Local<jni::Integer>(env, nullptr);
}
+ void Source::setMaxOverscaleFactorForParentTiles(jni::JNIEnv& env, jni::Integer& maxOverscaleFactor) {
+ if (!maxOverscaleFactor) {
+ source.setMaxOverscaleFactorForParentTiles(nullopt);
+ } else {
+ source.setMaxOverscaleFactorForParentTiles(jni::Unbox(env, maxOverscaleFactor));
+ }
+ }
+
+ jni::Local<jni::Integer> Source::getMaxOverscaleFactorForParentTiles(jni::JNIEnv& env) {
+ auto maxOverscaleFactor = source.getMaxOverscaleFactorForParentTiles();
+ if (maxOverscaleFactor) {
+ return jni::Box(env, jni::jint(*maxOverscaleFactor));
+ }
+ return jni::Local<jni::Integer>(env, nullptr);
+ }
+
void Source::addToStyle(JNIEnv& env, const jni::Object<Source>& obj, mbgl::style::Style& style) {
if (!ownedSource) {
throw std::runtime_error("Cannot add source twice");
@@ -189,13 +205,16 @@ static std::unique_ptr<Source> createSourcePeer(jni::JNIEnv& env,
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
- jni::RegisterNativePeer<Source>(env,
- javaClass,
- "nativePtr",
- METHOD(&Source::getId, "nativeGetId"),
- METHOD(&Source::getAttribution, "nativeGetAttribution"),
- METHOD(&Source::setPrefetchZoomDelta, "nativeSetPrefetchZoomDelta"),
- METHOD(&Source::getPrefetchZoomDelta, "nativeGetPrefetchZoomDelta"));
+ jni::RegisterNativePeer<Source>(
+ env,
+ javaClass,
+ "nativePtr",
+ METHOD(&Source::getId, "nativeGetId"),
+ METHOD(&Source::getAttribution, "nativeGetAttribution"),
+ METHOD(&Source::setPrefetchZoomDelta, "nativeSetPrefetchZoomDelta"),
+ METHOD(&Source::getPrefetchZoomDelta, "nativeGetPrefetchZoomDelta"),
+ METHOD(&Source::setMaxOverscaleFactorForParentTiles, "nativeSetMaxOverscaleFactorForParentTiles"),
+ METHOD(&Source::getMaxOverscaleFactorForParentTiles, "nativeGetMaxOverscaleFactorForParentTiles"));
// Register subclasses
GeoJSONSource::registerNative(env);
diff --git a/platform/android/src/style/sources/source.hpp b/platform/android/src/style/sources/source.hpp
index e0f2b2229f..fbeb201c7d 100644
--- a/platform/android/src/style/sources/source.hpp
+++ b/platform/android/src/style/sources/source.hpp
@@ -48,6 +48,10 @@ public:
jni::Local<jni::Integer> getPrefetchZoomDelta(jni::JNIEnv&);
+ void setMaxOverscaleFactorForParentTiles(jni::JNIEnv& env, jni::Integer& delta);
+
+ jni::Local<jni::Integer> getMaxOverscaleFactorForParentTiles(jni::JNIEnv&);
+
void addToStyle(JNIEnv& env, const jni::Object<Source>& obj, mbgl::style::Style& style);
protected: