summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2017-12-05 10:02:22 -0800
committerChris Loer <chris.loer@gmail.com>2017-12-05 10:02:22 -0800
commita3eb18ae1fe78d58f815aaea845616a380a624fd (patch)
tree1711557c82e9d30c36d842e91a9b33c992c700e8
parent7d9e9dcf4a785a4c570320acc4c6d0ad2afd25af (diff)
downloadqtlocation-mapboxgl-a3eb18ae1fe78d58f815aaea845616a380a624fd.tar.gz
[android] Addressing review
- Add JavaDoc - Use WorkerThread annotation - Rename '_impl' -> '_jni'
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java24
-rw-r--r--platform/android/config.cmake2
-rwxr-xr-xplatform/android/src/jni.cpp2
-rw-r--r--platform/android/src/text/local_glyph_rasterizer.cpp2
-rw-r--r--platform/android/src/text/local_glyph_rasterizer_jni.hpp (renamed from platform/android/src/text/local_glyph_rasterizer_impl.hpp)0
5 files changed, 26 insertions, 4 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java
index 0c0d98d0d7..920a1270ac 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java
@@ -4,10 +4,32 @@ import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Bitmap;
import android.graphics.Typeface;
+import android.support.annotation.WorkerThread;
+/**
+ * LocalGlyphRasterizer is the Android-specific platform implementation used
+ * by the portable local_glyph_rasterizer.hpp
+ */
public class LocalGlyphRasterizer {
- public static Bitmap drawGlyphBitmap(String fontFamily, boolean bold, char glyphID) {
+ /***
+ * Uses Android-native drawing code to rasterize a single glyph
+ * to a square @{link Bitmap} which can be returned to portable
+ * code for transformation into a Signed Distance Field glyph.
+ *
+ * @param fontFamily Font family string to pass to Typeface.create
+ * @param bold If true, use Typeface.BOLD option
+ * @param glyphID 16-bit Unicode BMP codepoint to draw
+ *
+ * @return Return a @{link Bitmap} to be displayed in the requested tile.
+ */
+ @WorkerThread
+ protected static Bitmap drawGlyphBitmap(String fontFamily, boolean bold, char glyphID) {
+ /*
+ 35x35px dimensions are hardwired to match local_glyph_rasterizer.cpp
+ These dimensions are large enough to draw a 24 point character in the middle
+ of the bitmap (y: 20) with some buffer around the edge
+ */
Bitmap bitmap = Bitmap.createBitmap(35, 35, Bitmap.Config.ARGB_8888);
Paint paint = new Paint();
diff --git a/platform/android/config.cmake b/platform/android/config.cmake
index 3ef1b8f830..f5de7a6052 100644
--- a/platform/android/config.cmake
+++ b/platform/android/config.cmake
@@ -37,7 +37,7 @@ macro(mbgl_platform_core)
PRIVATE platform/android/src/timer.cpp
# Misc
- PRIVATE platform/android/src/text/local_glyph_rasterizer_impl.hpp
+ PRIVATE platform/android/src/text/local_glyph_rasterizer_jni.hpp
PRIVATE platform/android/src/text/local_glyph_rasterizer.cpp
PRIVATE platform/android/src/logging_android.cpp
PRIVATE platform/android/src/thread.cpp
diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp
index b18f471a37..88ad0edb9e 100755
--- a/platform/android/src/jni.cpp
+++ b/platform/android/src/jni.cpp
@@ -51,7 +51,7 @@
#include "style/light.hpp"
#include "snapshotter/map_snapshotter.hpp"
#include "snapshotter/map_snapshot.hpp"
-#include "text/local_glyph_rasterizer_impl.hpp"
+#include "text/local_glyph_rasterizer_jni.hpp"
namespace mbgl {
namespace android {
diff --git a/platform/android/src/text/local_glyph_rasterizer.cpp b/platform/android/src/text/local_glyph_rasterizer.cpp
index 4845234944..7382425d4f 100644
--- a/platform/android/src/text/local_glyph_rasterizer.cpp
+++ b/platform/android/src/text/local_glyph_rasterizer.cpp
@@ -7,7 +7,7 @@
#include "../attach_env.hpp"
#include "../bitmap.hpp"
-#include "local_glyph_rasterizer_impl.hpp"
+#include "local_glyph_rasterizer_jni.hpp"
/*
Android implementation of LocalGlyphRasterizer:
diff --git a/platform/android/src/text/local_glyph_rasterizer_impl.hpp b/platform/android/src/text/local_glyph_rasterizer_jni.hpp
index 38d98d5368..38d98d5368 100644
--- a/platform/android/src/text/local_glyph_rasterizer_impl.hpp
+++ b/platform/android/src/text/local_glyph_rasterizer_jni.hpp