summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@codesorcery.net>2015-04-16 01:15:41 -0700
committerJustin R. Miller <incanus@codesorcery.net>2015-04-16 01:15:41 -0700
commit190709c6b1fd9326d0eef5ffc8eb36070e5ad5c7 (patch)
treedbff7b348f78d0481bf76d3c3313f3e5514cb7b6 /platform
parentc574acd64da34ea8bbd58ef5440c6add8f365e24 (diff)
downloadqtlocation-mapboxgl-190709c6b1fd9326d0eef5ffc8eb36070e5ad5c7.tar.gz
fixes #1157, #1255: cache parsed tiles in memory
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLMapView.mm25
1 files changed, 24 insertions, 1 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 0395114825..8721b2a4d6 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -367,6 +367,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
//
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
// set initial position
//
@@ -574,6 +575,17 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
else
{
mbglView->resize(rect.size.width, rect.size.height, view.contentScaleFactor, view.drawableWidth, view.drawableHeight);
+
+ CGFloat zoomFactor = mbglMap->getMaxZoom() - mbglMap->getMinZoom() + 1;
+ CGFloat cpuFactor = (CGFloat)[[NSProcessInfo processInfo] processorCount];
+ CGFloat memoryFactor = (CGFloat)[[NSProcessInfo processInfo] physicalMemory] / 1000 / 1000 / 1000;
+ CGFloat sizeFactor = ((CGFloat)mbglMap->getState().getWidth() / mbgl::util::tileSize) *
+ ((CGFloat)mbglMap->getState().getHeight() / mbgl::util::tileSize);
+
+ NSUInteger cacheSize = zoomFactor * cpuFactor * memoryFactor * sizeFactor * 0.5;
+
+ mbglMap->setSourceTileCacheSize(cacheSize);
+
mbglMap->renderSync();
}
}
@@ -1166,6 +1178,11 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
mbglMap->toggleDebug();
}
+- (void)emptyMemoryCache
+{
+ mbglMap->onLowMemory();
+}
+
#pragma mark - Geography -
+ (NSSet *)keyPathsForValuesAffectingCenterCoordinate
@@ -2450,7 +2467,8 @@ class MBGLView : public mbgl::View
[EAGLContext setCurrentContext:nil];
}
- void resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight) {
+ void resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight)
+ {
View::resize(width, height, ratio, fbWidth, fbHeight);
}
@@ -2566,4 +2584,9 @@ class MBGLView : public mbgl::View
self.rotateEnabled = allowsRotating;
}
+- (void)didReceiveMemoryWarning
+{
+ mbglMap->onLowMemory();
+}
+
@end