Merge branch 'release-agua' into tvn-merge-release
This commit is contained in:
@@ -112,6 +112,11 @@ AnnotationIDs AndroidRendererFrontend::queryPointAnnotations(const ScreenBox& bo
|
||||
return mapRenderer.actor().ask(&Renderer::queryPointAnnotations, box).get();
|
||||
}
|
||||
|
||||
AnnotationIDs AndroidRendererFrontend::queryShapeAnnotations(const ScreenBox& box) const {
|
||||
// Waits for the result from the orchestration thread and returns
|
||||
return mapRenderer.actor().ask(&Renderer::queryShapeAnnotations, box).get();
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
std::vector<Feature> queryRenderedFeatures(const ScreenBox&, const RenderedQueryOptions&) const;
|
||||
std::vector<Feature> querySourceFeatures(const std::string& sourceID, const SourceQueryOptions&) const;
|
||||
AnnotationIDs queryPointAnnotations(const ScreenBox& box) const;
|
||||
AnnotationIDs queryShapeAnnotations(const ScreenBox& box) const;
|
||||
|
||||
// Memory
|
||||
void onLowMemory();
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "asset_manager_file_source.hpp"
|
||||
#include "jni/generic_global_ref_deleter.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
@@ -64,6 +62,14 @@ void FileSource::setResourceTransform(jni::JNIEnv& env, jni::Object<FileSource::
|
||||
}
|
||||
}
|
||||
|
||||
void FileSource::resume(jni::JNIEnv&) {
|
||||
fileSource->resume();
|
||||
}
|
||||
|
||||
void FileSource::pause(jni::JNIEnv&) {
|
||||
fileSource->pause();
|
||||
}
|
||||
|
||||
jni::Class<FileSource> FileSource::javaClass;
|
||||
|
||||
FileSource* FileSource::getNativePeer(jni::JNIEnv& env, jni::Object<FileSource> jFileSource) {
|
||||
@@ -93,7 +99,9 @@ void FileSource::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&FileSource::getAccessToken, "getAccessToken"),
|
||||
METHOD(&FileSource::setAccessToken, "setAccessToken"),
|
||||
METHOD(&FileSource::setAPIBaseUrl, "setApiBaseUrl"),
|
||||
METHOD(&FileSource::setResourceTransform, "setResourceTransform")
|
||||
METHOD(&FileSource::setResourceTransform, "setResourceTransform"),
|
||||
METHOD(&FileSource::resume, "resume"),
|
||||
METHOD(&FileSource::pause, "pause")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@ public:
|
||||
|
||||
void setResourceTransform(jni::JNIEnv&, jni::Object<FileSource::ResourceTransformCallback>);
|
||||
|
||||
void resume(jni::JNIEnv&);
|
||||
|
||||
void pause(jni::JNIEnv&);
|
||||
|
||||
static jni::Class<FileSource> javaClass;
|
||||
|
||||
static FileSource* getNativePeer(jni::JNIEnv&, jni::Object<FileSource>);
|
||||
|
||||
@@ -172,6 +172,7 @@ void registerNatives(JavaVM *vm) {
|
||||
|
||||
// Map
|
||||
CameraPosition::registerNative(env);
|
||||
Image::registerNative(env);
|
||||
|
||||
// Connectivity
|
||||
ConnectivityListener::registerNative(env);
|
||||
|
||||
44
platform/android/src/map/image.cpp
Normal file
44
platform/android/src/map/image.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <mbgl/style/image.hpp>
|
||||
#include <mbgl/util/exception.hpp>
|
||||
#include "image.hpp"
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
mbgl::style::Image Image::getImage(jni::JNIEnv& env, jni::Object<Image> image) {
|
||||
static auto widthField = Image::javaClass.GetField<jni::jint>(env, "width");
|
||||
static auto heightField = Image::javaClass.GetField<jni::jint>(env, "height");
|
||||
static auto pixelRatioField = Image::javaClass.GetField<jni::jfloat>(env, "pixelRatio");
|
||||
static auto bufferField = Image::javaClass.GetField<jni::Array<jbyte>>(env, "buffer");
|
||||
static auto nameField = Image::javaClass.GetField<jni::String>(env, "name");
|
||||
|
||||
auto height = image.Get(env, heightField);
|
||||
auto width = image.Get(env, widthField);
|
||||
auto pixelRatio = image.Get(env, pixelRatioField);
|
||||
auto pixels = image.Get(env, bufferField);
|
||||
auto name = jni::Make<std::string>(env, image.Get(env, nameField));
|
||||
|
||||
jni::NullCheck(env, &pixels);
|
||||
std::size_t size = pixels.Length(env);
|
||||
|
||||
mbgl::PremultipliedImage premultipliedImage({ static_cast<uint32_t>(width), static_cast<uint32_t>(height) });
|
||||
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()));
|
||||
|
||||
return mbgl::style::Image {name, std::move(premultipliedImage), pixelRatio};
|
||||
}
|
||||
|
||||
void Image::registerNative(jni::JNIEnv &env) {
|
||||
// Lookup the class
|
||||
Image::javaClass = *jni::Class<Image>::Find(env).NewGlobalRef(env).release();
|
||||
}
|
||||
|
||||
jni::Class<Image> Image::javaClass;
|
||||
|
||||
|
||||
} // namespace android
|
||||
} // namespace mb
|
||||
|
||||
26
platform/android/src/map/image.hpp
Normal file
26
platform/android/src/map/image.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
#include <mbgl/style/image.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class Image : private mbgl::util::noncopyable {
|
||||
public:
|
||||
|
||||
static constexpr auto Name() { return "com/mapbox/mapboxsdk/maps/Image"; };
|
||||
|
||||
static mbgl::style::Image getImage(jni::JNIEnv&, jni::Object<Image>);
|
||||
|
||||
static jni::Class<Image> javaClass;
|
||||
|
||||
static void registerNative(jni::JNIEnv&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace android
|
||||
} // namespace mbgl
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "java/util.hpp"
|
||||
#include "geometry/lat_lng_bounds.hpp"
|
||||
#include "map/camera_position.hpp"
|
||||
#include "map/image.hpp"
|
||||
#include "style/light.hpp"
|
||||
#include "bitmap_factory.hpp"
|
||||
|
||||
@@ -633,6 +634,26 @@ jni::Array<jlong> NativeMapView::queryPointAnnotations(JNIEnv& env, jni::Object<
|
||||
return result;
|
||||
}
|
||||
|
||||
jni::Array<jlong> NativeMapView::queryShapeAnnotations(JNIEnv &env, jni::Object<RectF> rect) {
|
||||
using namespace mbgl::style;
|
||||
using namespace mbgl::style::conversion;
|
||||
|
||||
// Convert input
|
||||
mbgl::ScreenBox box = {
|
||||
{RectF::getLeft(env, rect), RectF::getTop(env, rect)},
|
||||
{RectF::getRight(env, rect), RectF::getBottom(env, rect)},
|
||||
};
|
||||
|
||||
mbgl::AnnotationIDs ids = rendererFrontend->queryShapeAnnotations(box);
|
||||
|
||||
// Convert result
|
||||
std::vector<jlong> longIds(ids.begin(), ids.end());
|
||||
auto result = jni::Array<jni::jlong>::New(env, ids.size());
|
||||
result.SetRegion<std::vector<jni::jlong>>(env, 0, longIds);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jni::Array<jni::Object<geojson::Feature>> NativeMapView::queryRenderedFeaturesForPoint(JNIEnv& env, jni::jfloat x, jni::jfloat y,
|
||||
jni::Array<jni::String> layerIds,
|
||||
jni::Array<jni::Object<>> jfilter) {
|
||||
@@ -904,6 +925,18 @@ void NativeMapView::addImage(JNIEnv& env, jni::String name, jni::jint w, jni::ji
|
||||
float(scale)));
|
||||
}
|
||||
|
||||
void NativeMapView::addImages(JNIEnv& env, jni::Array<jni::Object<mbgl::android::Image>> jimages) {
|
||||
jni::NullCheck(env, &jimages);
|
||||
std::size_t len = jimages.Length(env);
|
||||
|
||||
for (std::size_t i = 0; i < len; i++) {
|
||||
jni::Object<mbgl::android::Image> jimage = jimages.Get(env, i);
|
||||
auto image = mbgl::android::Image::getImage(env, jimage);
|
||||
map->getStyle().addImage(std::make_unique<mbgl::style::Image>(image));
|
||||
jni::DeleteLocalRef(env, jimage);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMapView::removeImage(JNIEnv& env, jni::String name) {
|
||||
map->getStyle().removeImage(jni::Make<std::string>(env, name));
|
||||
}
|
||||
@@ -1000,6 +1033,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&NativeMapView::getTransitionDelay, "nativeGetTransitionDelay"),
|
||||
METHOD(&NativeMapView::setTransitionDelay, "nativeSetTransitionDelay"),
|
||||
METHOD(&NativeMapView::queryPointAnnotations, "nativeQueryPointAnnotations"),
|
||||
METHOD(&NativeMapView::queryShapeAnnotations, "nativeQueryShapeAnnotations"),
|
||||
METHOD(&NativeMapView::queryRenderedFeaturesForPoint, "nativeQueryRenderedFeaturesForPoint"),
|
||||
METHOD(&NativeMapView::queryRenderedFeaturesForBox, "nativeQueryRenderedFeaturesForBox"),
|
||||
METHOD(&NativeMapView::getLight, "nativeGetLight"),
|
||||
@@ -1017,6 +1051,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&NativeMapView::removeSourceById, "nativeRemoveSourceById"),
|
||||
METHOD(&NativeMapView::removeSource, "nativeRemoveSource"),
|
||||
METHOD(&NativeMapView::addImage, "nativeAddImage"),
|
||||
METHOD(&NativeMapView::addImages, "nativeAddImages"),
|
||||
METHOD(&NativeMapView::removeImage, "nativeRemoveImage"),
|
||||
METHOD(&NativeMapView::getImage, "nativeGetImage"),
|
||||
METHOD(&NativeMapView::setLatLngBounds, "nativeSetLatLngBounds"),
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "style/sources/sources.hpp"
|
||||
#include "geometry/lat_lng_bounds.hpp"
|
||||
#include "map/camera_position.hpp"
|
||||
#include "map/image.hpp"
|
||||
#include "style/light.hpp"
|
||||
#include "bitmap.hpp"
|
||||
|
||||
@@ -197,6 +198,8 @@ public:
|
||||
|
||||
jni::Array<jlong> queryPointAnnotations(JNIEnv&, jni::Object<RectF>);
|
||||
|
||||
jni::Array<jlong> queryShapeAnnotations(JNIEnv&, jni::Object<RectF>);
|
||||
|
||||
jni::Array<jni::Object<geojson::Feature>> queryRenderedFeaturesForPoint(JNIEnv&, jni::jfloat, jni::jfloat,
|
||||
jni::Array<jni::String>,
|
||||
jni::Array<jni::Object<>> jfilter);
|
||||
@@ -235,6 +238,8 @@ public:
|
||||
|
||||
void addImage(JNIEnv&, jni::String, jni::jint, jni::jint, jni::jfloat, jni::Array<jbyte>);
|
||||
|
||||
void addImages(JNIEnv&, jni::Array<jni::Object<mbgl::android::Image>>);
|
||||
|
||||
void removeImage(JNIEnv&, jni::String);
|
||||
|
||||
jni::Object<Bitmap> getImage(JNIEnv&, jni::String);
|
||||
|
||||
Reference in New Issue
Block a user