Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] Recalculate source tile cache size when appropiate
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoabinader committed Apr 6, 2017
1 parent 4c75092 commit 7bcb6b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions platform/android/src/native_map_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
MapMode::Continuous, GLContextMode::Unique, ConstrainMode::HeightOnly,
ViewportMode::Default, jni::Make<std::string>(_env, _programCacheDir));

recalculateSourceTileCacheSize();
}

void NativeMapView::recalculateSourceTileCacheSize() {
//Calculate a fitting cache size based on device parameters
float zoomFactor = map->getMaxZoom() - map->getMinZoom() + 1;
float cpuFactor = availableProcessors;
Expand Down Expand Up @@ -324,6 +328,7 @@ void NativeMapView::resizeView(jni::JNIEnv&, int w, int h) {
width = util::max(64, w);
height = util::max(64, h);
map->setSize({ static_cast<uint32_t>(width), static_cast<uint32_t>(height) });
recalculateSourceTileCacheSize();
}

void NativeMapView::resizeFramebuffer(jni::JNIEnv&, int w, int h) {
Expand Down Expand Up @@ -480,6 +485,7 @@ void NativeMapView::resetZoom(jni::JNIEnv&) {

void NativeMapView::setMinZoom(jni::JNIEnv&, jni::jdouble zoom) {
map->setMinZoom(zoom);
recalculateSourceTileCacheSize();
}

jni::jdouble NativeMapView::getMinZoom(jni::JNIEnv&) {
Expand All @@ -488,6 +494,7 @@ jni::jdouble NativeMapView::getMinZoom(jni::JNIEnv&) {

void NativeMapView::setMaxZoom(jni::JNIEnv&, jni::jdouble zoom) {
map->setMaxZoom(zoom);
recalculateSourceTileCacheSize();
}

jni::jdouble NativeMapView::getMaxZoom(jni::JNIEnv&) {
Expand Down
1 change: 1 addition & 0 deletions platform/android/src/native_map_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class NativeMapView : public View, public Backend {
void updateFps();

private:
void recalculateSourceTileCacheSize();

JavaVM *vm = nullptr;
jni::UniqueWeakObject<NativeMapView> javaPeer;
Expand Down

0 comments on commit 7bcb6b7

Please sign in to comment.