diff options
author | Benjamin Jaeger <bjaeger@fb.com> | 2018-01-23 15:33:29 -0500 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-02-12 15:56:58 +0100 |
commit | 0b27909b8b9959a14f9075d3b61c33c93ddd8c31 (patch) | |
tree | 368ac780ede1abc50d2fab2b6242bc7f2e51263c /platform/android/src/native_map_view.cpp | |
parent | f3b32599061402316b0d1ab698301a8941c51ff5 (diff) | |
download | qtlocation-mapboxgl-0b27909b8b9959a14f9075d3b61c33c93ddd8c31.tar.gz |
NativeMapView.addImage without copying into Java
Diffstat (limited to 'platform/android/src/native_map_view.cpp')
-rwxr-xr-x | platform/android/src/native_map_view.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 36a73fee35..eefb578f39 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -893,16 +893,9 @@ void NativeMapView::removeSource(JNIEnv& env, jni::Object<Source> obj, jlong sou source->removeFromMap(env, obj, *map); } -void NativeMapView::addImage(JNIEnv& env, jni::String name, jni::jint w, jni::jint h, jni::jfloat scale, jni::Array<jbyte> pixels) { - jni::NullCheck(env, &pixels); - std::size_t size = pixels.Length(env); - - mbgl::PremultipliedImage premultipliedImage({ static_cast<uint32_t>(w), static_cast<uint32_t>(h) }); - if (premultipliedImage.bytes() != uint32_t(size)) { - throw mbgl::util::SpriteImageException("Sprite image pixel count mismatch"); - } - - jni::GetArrayRegion(env, *pixels, 0, size, reinterpret_cast<jbyte*>(premultipliedImage.data.get())); +void NativeMapView::addImage(JNIEnv& env, jni::String name, jni::Object<Bitmap> bitmap, jni::jfloat scale) { + jni::NullCheck(env, &bitmap); + mbgl::PremultipliedImage premultipliedImage = Bitmap::GetImage(env, bitmap); map->getStyle().addImage(std::make_unique<mbgl::style::Image>( jni::Make<std::string>(env, name), |