summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-04-02 09:11:18 -0400
committerJulian Rex <julian.rex@mapbox.com>2019-04-02 09:12:53 -0400
commit8a31df31c9ecc06c055747807806328ae84d643e (patch)
tree0d26d02763d4395e9e22c466077076f5938d4014
parent3e70b5522414fd0d70c08b31e2050782281490e4 (diff)
downloadqtlocation-mapboxgl-8a31df31c9ecc06c055747807806328ae84d643e.tar.gz
Use presentsWithTransaction only if we have annotation UIViews.
-rw-r--r--platform/ios/src/MGLMapView.mm34
1 files changed, 23 insertions, 11 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 97b20f97e6..cc5f98c0eb 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -252,6 +252,7 @@ public:
@property (nonatomic) MGLAnnotationContainerView *annotationContainerView;
@property (nonatomic) MGLUserLocation *userLocation;
@property (nonatomic) NSMutableDictionary<NSString *, NSMutableArray<MGLAnnotationView *> *> *annotationViewReuseQueueByIdentifier;
+@property (nonatomic) BOOL enablePresentsWithTransaction;
/// Experimental rendering performance measurement.
@property (nonatomic) BOOL experimental_enableFrameRateMeasurement;
@@ -702,7 +703,7 @@ public:
_glView.delegate = self;
CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer);
- eaglLayer.presentsWithTransaction = YES;
+ eaglLayer.presentsWithTransaction = NO;
[_glView bindDrawable];
[self insertSubview:_glView atIndex:0];
@@ -1121,14 +1122,21 @@ public:
[self updateAnnotationViews];
[self updateCalloutView];
- CFTimeInterval before = CACurrentMediaTime();
- [self.glView display];
- CFTimeInterval after = CACurrentMediaTime();
-
- if (after-before >= 1.0) {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self emergencyRecreateGL];
- });
+ if (self.enablePresentsWithTransaction)
+ {
+ CFTimeInterval before = CACurrentMediaTime();
+ [self.glView display];
+ CFTimeInterval after = CACurrentMediaTime();
+
+ if (after-before >= 1.0) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self emergencyRecreateGL];
+ });
+ }
+ }
+ else
+ {
+ [self.glView display];
}
}
@@ -1277,7 +1285,7 @@ public:
if (self.window) {
[self wakeGL:nil];
CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer);
- eaglLayer.presentsWithTransaction = YES;
+ eaglLayer.presentsWithTransaction = self.enablePresentsWithTransaction;
}
else {
MGLLogDebug(@"No window - skipping wakeGL");
@@ -1312,7 +1320,7 @@ public:
{
// See above comment
CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer);
- eaglLayer.presentsWithTransaction = YES;
+ eaglLayer.presentsWithTransaction = self.enablePresentsWithTransaction;
[self validateDisplayLink];
}
@@ -4227,6 +4235,8 @@ public:
[newAnnotationContainerView addSubviews:annotationViews];
[_glView insertSubview:newAnnotationContainerView atIndex:0];
self.annotationContainerView = newAnnotationContainerView;
+
+ self.enablePresentsWithTransaction = (self.annotationContainerView.annotationViews.count > 0);
}
/// Initialize and return a default annotation image that depicts a round pin
@@ -4400,6 +4410,8 @@ public:
annotationView.annotation = nil;
[annotationView removeFromSuperview];
[self.annotationContainerView.annotationViews removeObject:annotationView];
+
+ self.enablePresentsWithTransaction = (self.annotationContainerView.annotationViews.count > 0);
if (annotationTag == _selectedAnnotationTag)
{