This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios] Add preferred FPS setting; vary maximum FPS by device capability
- Add `MGLMapView.preferredFramesPerSecond`, which can be set with the provided `MGLMapViewPreferredFramesPerSecond` enum values or directly with an integer. - Adaptively set the preferred FPS based on the capabilities of the device: the oldest and least powerful devices are now capped at 30 FPS, which results in a more consistent/smoother experience.
- Loading branch information
1 parent
c77aa79
commit 885f6e3
Showing
6 changed files
with
156 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIDevice (MGLAdditions) | ||
|
||
@property (nonatomic, readonly) BOOL mgl_isLegacyDevice; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#import "UIDevice+MGLAdditions.h" | ||
#include <sys/sysctl.h> | ||
|
||
@implementation UIDevice (MGLAdditions) | ||
|
||
- (NSString *)modelString { | ||
char *typeSpecifier = "hw.machine"; | ||
|
||
size_t size; | ||
sysctlbyname(typeSpecifier, NULL, &size, NULL, 0); | ||
|
||
char *answer = malloc(size); | ||
sysctlbyname(typeSpecifier, answer, &size, NULL, 0); | ||
|
||
NSString *results = [NSString stringWithCString:answer encoding:NSUTF8StringEncoding]; | ||
|
||
free(answer); | ||
return results; | ||
} | ||
|
||
- (BOOL)mgl_isLegacyDevice { | ||
// This is a list of supported devices that cannot maintain a reasonable frame | ||
// rate under typical load. For brevity, unsupported devices are not included. | ||
NSSet *blacklist = [NSSet setWithObjects: | ||
@"iPhone4", // iPhone 4s | ||
@"iPhone5", // iPhone 5, 5c | ||
@"iPhone6", // iPhone 5s | ||
|
||
@"iPad2", // iPad 2, Mini | ||
@"iPad3", // iPad 3 | ||
@"iPad4", // iPad Air, Mini 2, Mini 3 | ||
|
||
@"iPod5", // iPod Touch 5 | ||
|
||
nil | ||
]; | ||
|
||
NSString *model = [self modelString]; | ||
|
||
for (NSString *blacklistedModel in blacklist) { | ||
if ([model hasPrefix:[blacklistedModel stringByAppendingString:@","]]) { | ||
return YES; | ||
} | ||
} | ||
|
||
// TODO: Also handle simulator using something like `ProcessInfo().environment["SIMULATOR_MODEL_IDENTIFIER"]`. | ||
|
||
return NO; | ||
} | ||
|
||
@end |