summaryrefslogtreecommitdiff
path: root/platform/darwin
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin')
-rw-r--r--platform/darwin/src/MGLRendererConfiguration.h40
-rw-r--r--platform/darwin/src/MGLRendererConfiguration.mm43
2 files changed, 83 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLRendererConfiguration.h b/platform/darwin/src/MGLRendererConfiguration.h
new file mode 100644
index 0000000000..35cf828536
--- /dev/null
+++ b/platform/darwin/src/MGLRendererConfiguration.h
@@ -0,0 +1,40 @@
+#import <Foundation/Foundation.h>
+#import <mbgl/storage/default_file_source.hpp>
+#import <mbgl/renderer/mode.hpp>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ The MGLRendererConfiguration object represents configuration values for the
+ renderer.
+ */
+@interface MGLRendererConfiguration : NSObject
+
+/** Returns an instance of the current renderer configuration. */
++ (instancetype)currentConfiguration;
+
+/** The file source to use. Defaults to `mbgl::DefaultFileSource` */
+@property (nonatomic, readonly) mbgl::DefaultFileSource *fileSource;
+
+/** The GL context mode to use. Defaults to `mbgl::GLContextMode::Unique` */
+@property (nonatomic, readonly) mbgl::GLContextMode contextMode;
+
+/** The scale factor to use.
+
+ Based on the native scale where available, otherwise the standard screen scale. */
+@property (nonatomic, readonly) const float scaleFactor;
+
+/** The cache dir to use. */
+@property (nonatomic, readonly) mbgl::optional<std::string> cacheDir;
+
+/** The name of the font family to use for client-side text rendering.
+
+ Currently only used for CJK glyphs. Changing this at run time is not currently
+ supported. Enable client-side rendering of CJK glyphs by setting
+ `MGLIdeographicFontFamilyName` in your containing app's Info.plist to a value
+ which will be available at runtime, i.e. "Arial Unicode MS". */
+@property (nonatomic, readonly) mbgl::optional<std::string> localFontFamilyName;
+
+@end
+
+NS_ASSUME_NONNULL_END
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