diff options
author | Jason Wray <friedbunny@users.noreply.github.com> | 2016-08-16 17:38:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-16 17:38:18 -0400 |
commit | 1de65e2a511f258610c8c3d6f6940a4408f58a40 (patch) | |
tree | 666397dd5e8a740da31ae19649496c3dbfb90c98 /platform | |
parent | bbd6cfcf8a51881c1d6879fa92e161313b513741 (diff) | |
download | qtlocation-mapboxgl-1de65e2a511f258610c8c3d6f6940a4408f58a40.tar.gz |
[ios] Improve user location annotation performance (#6019)
* [ios] Don't animate zoom-induced accuracy ring size changes
Improves perceived and actual performance by eliminating the implicit animation that occurred when the accuracy ring changed size during zooms. This previously would pile up animations as the zoom changed, causing an unsightly wobbling effect.
* [ios] Pre-calculate shadow paths for user dot and puck
Performance enhancement suggested by https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreAnimation_guide/ImprovingAnimationPerformance/ImprovingAnimationPerformance.html
* [ios] Rasterize pulsating inner dot of user location annotation
Supposed performance enhancement and also improves edge smoothness.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/src/MGLFaux3DUserLocationAnnotationView.m | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m b/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m index ac0551430b..95a0084f9f 100644 --- a/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m +++ b/platform/ios/src/MGLFaux3DUserLocationAnnotationView.m @@ -148,6 +148,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _puckDot.backgroundColor = [[UIColor whiteColor] CGColor]; _puckDot.shadowColor = [[UIColor blackColor] CGColor]; _puckDot.shadowOpacity = 0.25; + _puckDot.shadowPath = [[UIBezierPath bezierPathWithOvalInRect:_puckDot.bounds] CGPath]; if (self.mapView.camera.pitch) { @@ -291,6 +292,13 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck if (accuracyRingSize > MGLUserLocationAnnotationDotSize + 15) { _accuracyRingLayer.hidden = NO; + + // disable implicit animation of the accuracy ring, unless triggered by a change in accuracy + id shouldDisableActions = (_oldHorizontalAccuracy == self.userLocation.location.horizontalAccuracy) ? (id)kCFBooleanTrue : (id)kCFBooleanFalse; + + [CATransaction begin]; + [CATransaction setValue:shouldDisableActions forKey:kCATransactionDisableActions]; + _accuracyRingLayer.bounds = CGRectMake(0, 0, accuracyRingSize, accuracyRingSize); _accuracyRingLayer.cornerRadius = accuracyRingSize / 2; @@ -298,6 +306,8 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _haloLayer.bounds = _accuracyRingLayer.bounds; _haloLayer.cornerRadius = _accuracyRingLayer.cornerRadius; _haloLayer.shouldRasterize = NO; + + [CATransaction commit]; } else { @@ -365,6 +375,7 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck _dotBorderLayer.backgroundColor = [[UIColor whiteColor] CGColor]; _dotBorderLayer.shadowColor = [[UIColor blackColor] CGColor]; _dotBorderLayer.shadowOpacity = 0.25; + _dotBorderLayer.shadowPath = [[UIBezierPath bezierPathWithOvalInRect:_dotBorderLayer.bounds] CGPath]; if (self.mapView.camera.pitch) { @@ -385,7 +396,6 @@ const CGFloat MGLUserLocationAnnotationArrowSize = MGLUserLocationAnnotationPuck { _dotLayer = [self circleLayerWithSize:MGLUserLocationAnnotationDotSize * 0.75]; _dotLayer.backgroundColor = [self.mapView.tintColor CGColor]; - _dotLayer.shouldRasterize = NO; // set defaults for the animations CAAnimationGroup *animationGroup = [self loopingAnimationGroupWithDuration:1.5]; |