summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2018-06-20 14:18:15 +0200
committerTobrun <tobrun@mapbox.com>2018-06-25 13:44:15 +0200
commit279dd93f7cbd57adce60a97bdb760905e30f4580 (patch)
treefbb5ccc6f15d6922b33fc92aa11cc3e87655a8f2 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
parente1af62e87dfd77d1c38802f082c4981dab1beeab (diff)
downloadqtlocation-mapboxgl-279dd93f7cbd57adce60a97bdb760905e30f4580.tar.gz
[android] - add support for sdf by exposing sdf confiigurationn when calling MapboxMap#addImage.
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java')
-rwxr-xr-xplatform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
index 0d506cd746..8bf3524ff5 100755
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
@@ -787,22 +787,29 @@ final class NativeMapView {
return source;
}
- public void addImage(@NonNull String name, @NonNull Bitmap image) {
+ public void addImage(@NonNull String name, @NonNull Bitmap image, boolean sdf) {
if (checkState("addImage")) {
return;
}
// Determine pixel ratio, cast to float to avoid rounding, see mapbox-gl-native/issues/11809
float pixelRatio = (float) image.getDensity() / DisplayMetrics.DENSITY_DEFAULT;
- nativeAddImage(name, image, pixelRatio);
+ nativeAddImage(name, image, pixelRatio, sdf);
}
public void addImages(@NonNull HashMap<String, Bitmap> bitmapHashMap) {
if (checkState("addImages")) {
return;
}
+ this.addImages(bitmapHashMap, false);
+ }
+
+ public void addImages(@NonNull HashMap<String, Bitmap> bitmapHashMap, boolean sdf) {
+ if (checkState("addImages")) {
+ return;
+ }
//noinspection unchecked
- new BitmapImageConversionTask(this).execute(bitmapHashMap);
+ new BitmapImageConversionTask(this, sdf).execute(bitmapHashMap);
}
public void removeImage(String name) {
@@ -1061,7 +1068,7 @@ final class NativeMapView {
private native void nativeRemoveSource(Source source, long sourcePtr);
- private native void nativeAddImage(String name, Bitmap bitmap, float pixelRatio);
+ private native void nativeAddImage(String name, Bitmap bitmap, float pixelRatio, boolean sdf);
private native void nativeAddImages(Image[] images);
@@ -1161,9 +1168,11 @@ final class NativeMapView {
private static class BitmapImageConversionTask extends AsyncTask<HashMap<String, Bitmap>, Void, List<Image>> {
private NativeMapView nativeMapView;
+ private boolean sdf;
- BitmapImageConversionTask(NativeMapView nativeMapView) {
+ BitmapImageConversionTask(NativeMapView nativeMapView, boolean sdf) {
this.nativeMapView = nativeMapView;
+ this.sdf = sdf;
}
@Override
@@ -1186,10 +1195,9 @@ final class NativeMapView {
buffer = ByteBuffer.allocate(bitmap.getByteCount());
bitmap.copyPixelsToBuffer(buffer);
- float density = bitmap.getDensity() == Bitmap.DENSITY_NONE ? Bitmap.DENSITY_NONE : bitmap.getDensity();
- float pixelRatio = density / DisplayMetrics.DENSITY_DEFAULT;
+ float pixelRatio = (float) bitmap.getDensity() / DisplayMetrics.DENSITY_DEFAULT;
- images.add(new Image(buffer.array(), pixelRatio, name, bitmap.getWidth(), bitmap.getHeight()));
+ images.add(new Image(buffer.array(), pixelRatio, name, bitmap.getWidth(), bitmap.getHeight(), sdf));
}
return images;