diff options
author | Andrew Kitchen <andrew.kitchen@mapbox.com> | 2017-12-04 13:29:16 -0800 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2017-12-11 10:43:00 -0800 |
commit | b2f06677a787fe7b9b08608e5a55aaedbe50ed3a (patch) | |
tree | 6ee6e3687aa8c7f68e8a75354d8c57f0f0be70a5 /platform/darwin/src/MGLRendererConfiguration.mm | |
parent | 00ed34f7d700ae255eae1af1ca46b939ffee219d (diff) | |
download | qtlocation-mapboxgl-b2f06677a787fe7b9b08608e5a55aaedbe50ed3a.tar.gz |
[darwin, ios, macos] Introduces an MGLRendererConfiguration class
Instructions for enabling client-side rendering of CJK glyphs live in
this header, and this class provides the rest of the values needed for
instantiating the renderer on iOS and macOS.
Diffstat (limited to 'platform/darwin/src/MGLRendererConfiguration.mm')
-rw-r--r-- | platform/darwin/src/MGLRendererConfiguration.mm | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLRendererConfiguration.mm b/platform/darwin/src/MGLRendererConfiguration.mm new file mode 100644 index 0000000000..ae7d7dd9fe --- /dev/null +++ b/platform/darwin/src/MGLRendererConfiguration.mm @@ -0,0 +1,43 @@ +#import "MGLRendererConfiguration.h" +#import "MGLOfflineStorage_Private.h" + +#if TARGET_OS_IPHONE +#import <UIKit/UIKit.h> +#else +#import <AppKit/AppKit.h> +#endif + + +@implementation MGLRendererConfiguration + ++ (instancetype)currentConfiguration { + return [[self alloc] init]; +} + +- (mbgl::DefaultFileSource *)fileSource { + return [MGLOfflineStorage sharedOfflineStorage].mbglFileSource; +} + +- (mbgl::GLContextMode)contextMode { + return mbgl::GLContextMode::Unique; +} + +- (const float)scaleFactor { +#if TARGET_OS_IPHONE + return [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [[UIScreen mainScreen] nativeScale] : [[UIScreen mainScreen] scale]; +#else + return [NSScreen mainScreen].backingScaleFactor; +#endif +} + +- (mbgl::optional<std::string>)cacheDir { + return mbgl::optional<std::string>(); +} + +- (mbgl::optional<std::string>)localFontFamilyName { + NSString *fontFamilyName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLIdeographicFontFamilyName"]; + + return fontFamilyName ? std::string([fontFamilyName UTF8String]) : mbgl::optional<std::string>(); +} + +@end |