diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-03-15 18:43:58 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-03-22 15:59:10 +0100 |
commit | 3c91b6b7de487993e75de552ba44249740644e42 (patch) | |
tree | 69b8b2642b3d8496657db92459b0a23e130b501d /platform | |
parent | d20327844cac88b6bf42b201eac35e816a189a8a (diff) | |
download | qtlocation-mapboxgl-3c91b6b7de487993e75de552ba44249740644e42.tar.gz |
[core] cache binary shaders on Android
Diffstat (limited to 'platform')
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 c5eaf2deb9..f2905cd6c3 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); } // @@ -961,8 +962,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 af8ae16bf6..c65c241458 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; @@ -1462,7 +1468,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 fbfe69040e..9a490ddbae 100755 --- a/platform/android/src/native_map_view.hpp +++ b/platform/android/src/native_map_view.hpp @@ -42,7 +42,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(); |