summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-03-15 18:43:58 +0100
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-04-03 11:01:43 -0700
commitf86333961eeacb9f2dd83a4c3680d30e06f947a7 (patch)
treee26d375a7852526196428bc86e9b7b94e2baf6f9 /platform/android
parentc1cd6759b4a87ef58442e864a192317284cf20ae (diff)
downloadqtlocation-mapboxgl-f86333961eeacb9f2dd83a4c3680d30e06f947a7.tar.gz
[core] cache binary shaders on Android
Diffstat (limited to 'platform/android')
-rwxr-xr-xplatform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java11
-rwxr-xr-xplatform/android/src/native_map_view.cpp26
-rwxr-xr-xplatform/android/src/native_map_view.hpp8
3 files changed, 31 insertions, 14 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 1460f08e10..a9394d0b66 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
@@ -97,7 +97,8 @@ final class NativeMapView {
onMapChangedListeners = new CopyOnWriteArrayList<>();
this.mapView = mapView;
- nativeInitialize(this, fileSource, pixelRatio, availableProcessors, totalMemory);
+ String programCacheDir = context.getCacheDir().getAbsolutePath();
+ nativeInitialize(this, fileSource, pixelRatio, programCacheDir, availableProcessors, totalMemory);
}
//
@@ -957,8 +958,12 @@ final class NativeMapView {
// JNI methods
//
- private native void nativeInitialize(NativeMapView nativeMapView, FileSource fileSource,
- float pixelRatio, int availableProcessors, long totalMemory);
+ private native void nativeInitialize(NativeMapView nativeMapView,
+ FileSource fileSource,
+ float pixelRatio,
+ String programCacheDir,
+ int availableProcessors,
+ long totalMemory);
private native void nativeDestroy();
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 696849b11b..529ea23304 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -48,13 +48,18 @@
namespace mbgl {
namespace android {
-NativeMapView::NativeMapView(jni::JNIEnv& _env, jni::Object<NativeMapView> _obj, jni::Object<FileSource> jFileSource,
- jni::jfloat _pixelRatio, jni::jint _availableProcessors, jni::jlong _totalMemory) :
- javaPeer(_obj.NewWeakGlobalRef(_env)),
- pixelRatio(_pixelRatio),
- availableProcessors(_availableProcessors),
- totalMemory(_totalMemory),
- threadPool(sharedThreadPool()) {
+NativeMapView::NativeMapView(jni::JNIEnv& _env,
+ jni::Object<NativeMapView> _obj,
+ jni::Object<FileSource> jFileSource,
+ jni::jfloat _pixelRatio,
+ jni::String _programCacheDir,
+ jni::jint _availableProcessors,
+ jni::jlong _totalMemory)
+ : javaPeer(_obj.NewWeakGlobalRef(_env)),
+ pixelRatio(_pixelRatio),
+ availableProcessors(_availableProcessors),
+ totalMemory(_totalMemory),
+ threadPool(sharedThreadPool()) {
// Get a reference to the JavaVM for callbacks
if (_env.GetJavaVM(&vm) < 0) {
@@ -65,8 +70,9 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, jni::Object<NativeMapView> _obj,
// Create the core map
map = std::make_unique<mbgl::Map>(
*this, mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) },
- pixelRatio, mbgl::android::FileSource::getDefaultFileSource(_env, jFileSource)
- , *threadPool, MapMode::Continuous);
+ pixelRatio, mbgl::android::FileSource::getDefaultFileSource(_env, jFileSource), *threadPool,
+ MapMode::Continuous, GLContextMode::Unique, ConstrainMode::HeightOnly,
+ ViewportMode::Default, jni::Make<std::string>(_env, _programCacheDir));
//Calculate a fitting cache size based on device parameters
float zoomFactor = map->getMaxZoom() - map->getMinZoom() + 1;
@@ -1398,7 +1404,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
// Register the peer
jni::RegisterNativePeer<NativeMapView>(env, NativeMapView::javaClass, "nativePtr",
- std::make_unique<NativeMapView, JNIEnv&, jni::Object<NativeMapView>, jni::Object<FileSource>, jni::jfloat, jni::jint, jni::jlong>,
+ std::make_unique<NativeMapView, JNIEnv&, jni::Object<NativeMapView>, jni::Object<FileSource>, jni::jfloat, jni::String, jni::jint, jni::jlong>,
"nativeInitialize",
"nativeDestroy",
METHOD(&NativeMapView::render, "nativeRender"),
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index 4afea036bf..08133b85cd 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -40,7 +40,13 @@ public:
static void registerNative(jni::JNIEnv&);
- NativeMapView(jni::JNIEnv&, jni::Object<NativeMapView>, jni::Object<FileSource>, jni::jfloat, jni::jint, jni::jlong);
+ NativeMapView(jni::JNIEnv&,
+ jni::Object<NativeMapView>,
+ jni::Object<FileSource>,
+ jni::jfloat pixelRatio,
+ jni::String programCacheDir,
+ jni::jint availableProcessors,
+ jni::jlong totalMemory);
virtual ~NativeMapView();