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 20:01:26 +0300
commita03ccf34f275417f7575fa89f6b30aa984151c8d (patch)
tree9cb568160cc82b33731cd8614fa89363416b1323
parent75abef7b7b7172af34590fed0072fa9fb6c4af5a (diff)
downloadqtlocation-mapboxgl-a03ccf34f275417f7575fa89f6b30aa984151c8d.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: