summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2018-09-12 19:11:13 -0400
committerJason Wray <jason@mapbox.com>2018-09-25 18:41:00 -0700
commitb626ad40ddec5924ae7fcefcf774941f36bb363a (patch)
treea5a247bc5d11da49d3455ffda9798dbae6a82271
parent66e95ac2ab6260654ba09b26e83591e3d4334c02 (diff)
downloadqtlocation-mapboxgl-b626ad40ddec5924ae7fcefcf774941f36bb363a.tar.gz
Enabled `presentsWithTransaction` to help synchronize UIKit elements with the GL view.
-rw-r--r--platform/darwin/src/MGLFoundation.h7
-rw-r--r--platform/ios/src/MGLMapView.mm4
2 files changed, 11 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLFoundation.h b/platform/darwin/src/MGLFoundation.h
index 3400c63979..be86bb92f9 100644
--- a/platform/darwin/src/MGLFoundation.h
+++ b/platform/darwin/src/MGLFoundation.h
@@ -3,3 +3,10 @@
#import <Foundation/Foundation.h>
#define MGL_EXPORT __attribute__((visibility ("default")))
+
+/* Using a compound statement (GNU Extension, supported by clang) */
+#define MGL_OBJC_DYNAMIC_CAST(object, type) \
+ ({ \
+ __typeof__( object ) temp##__LINE__ = (object); \
+ (type *)([temp##__LINE__ isKindOfClass:[type class]] ? temp##__LINE__ : nil); \
+ })
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 92d3724b03..216464a7d4 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -636,6 +636,10 @@ public:
_glView.layer.opaque = _opaque;
_glView.delegate = self;
+ // `CAEAGLLayer.presentsWithTransaction` was introduced in iOS 9.
+ CAEAGLLayer *eaglLayer = MGL_OBJC_DYNAMIC_CAST(_glView.layer, CAEAGLLayer);
+ eaglLayer.presentsWithTransaction = YES;
+
[_glView bindDrawable];
[self insertSubview:_glView atIndex:0];
_glView.contentMode = UIViewContentModeCenter;