summaryrefslogtreecommitdiff
path: root/platform/android/src/style/sources/raster_source.cpp
diff options
context:
space:
mode:
authorIvo van Dongen <ivovandongen@users.noreply.github.com>2016-09-21 11:04:32 +0200
committerGitHub <noreply@github.com>2016-09-21 11:04:32 +0200
commiteb97dbe383ca7697feab5860995b97181c39c607 (patch)
tree70bdd7b6ebea32aec132413fa703e92a2a0f63d0 /platform/android/src/style/sources/raster_source.cpp
parent3b546b964609d0f596dac32e155b1489bb85645e (diff)
downloadqtlocation-mapboxgl-eb97dbe383ca7697feab5860995b97181c39c607.tar.gz
[android] Sources: peer model, mutability (#6054)
Diffstat (limited to 'platform/android/src/style/sources/raster_source.cpp')
-rw-r--r--platform/android/src/style/sources/raster_source.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/platform/android/src/style/sources/raster_source.cpp b/platform/android/src/style/sources/raster_source.cpp
new file mode 100644
index 0000000000..b56b56676d
--- /dev/null
+++ b/platform/android/src/style/sources/raster_source.cpp
@@ -0,0 +1,54 @@
+#include "raster_source.hpp"
+
+#include "../android_conversion.hpp"
+#include "../value.hpp"
+#include "../conversion/url_or_tileset.hpp"
+
+#include <mbgl/util/variant.hpp>
+
+#include <string>
+
+namespace mbgl {
+namespace android {
+
+ RasterSource::RasterSource(jni::JNIEnv& env, jni::String sourceId, jni::Object<> urlOrTileSet, jni::jint tileSize)
+ : Source(
+ env,
+ std::make_unique<mbgl::style::RasterSource>(
+ jni::Make<std::string>(env, sourceId),
+ *style::conversion::convert<variant<std::string, Tileset>>(Value(env, urlOrTileSet)),
+ tileSize
+ )
+ ) {
+ }
+
+ RasterSource::RasterSource(mbgl::Map& map, mbgl::style::RasterSource& coreSource)
+ : Source(map, coreSource) {
+ }
+
+ RasterSource::~RasterSource() = default;
+
+ jni::Class<RasterSource> RasterSource::javaClass;
+
+ jni::jobject* RasterSource::createJavaPeer(jni::JNIEnv& env) {
+ static auto constructor = RasterSource::javaClass.template GetConstructor<jni::jlong>(env);
+ return RasterSource::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
+ }
+
+ void RasterSource::registerNative(jni::JNIEnv& env) {
+ //Lookup the class
+ RasterSource::javaClass = *jni::Class<RasterSource>::Find(env).NewGlobalRef(env).release();
+
+ #define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
+
+ //Register the peer
+ jni::RegisterNativePeer<RasterSource>(
+ env, RasterSource::javaClass, "nativePtr",
+ std::make_unique<RasterSource, JNIEnv&, jni::String, jni::Object<>, jni::jint>,
+ "initialize",
+ "finalize"
+ );
+ }
+
+} // namespace android
+} // namespace mbgl