summaryrefslogtreecommitdiff
path: root/platform/darwin
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2019-02-23 00:29:45 -0800
committerMinh Nguyễn <mxn@1ec5.org>2019-02-25 10:44:43 -0800
commit26e1c925f251d868d4bff39cd2c32b7839d02f4e (patch)
tree358df147bd4107d983f97649033c4db250c8a372 /platform/darwin
parentf66848efaf1efe2ce4088bf56ae7af3a765b9d57 (diff)
downloadqtlocation-mapboxgl-26e1c925f251d868d4bff39cd2c32b7839d02f4e.tar.gz
[ios, macos] Expose MGLMapView OpenGL context to OpenGL style layers
Added a property to MGLOpenGLStyleLayer that contains the map view’s underlying OpenGL rendering context.
Diffstat (limited to 'platform/darwin')
-rw-r--r--platform/darwin/src/MGLOpenGLStyleLayer.h6
-rw-r--r--platform/darwin/src/MGLOpenGLStyleLayer.mm10
2 files changed, 16 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLOpenGLStyleLayer.h b/platform/darwin/src/MGLOpenGLStyleLayer.h
index df8d2c5365..f699284c32 100644
--- a/platform/darwin/src/MGLOpenGLStyleLayer.h
+++ b/platform/darwin/src/MGLOpenGLStyleLayer.h
@@ -27,6 +27,12 @@ MGL_EXPORT
@property (nonatomic, weak, readonly) MGLStyle *style;
+#if TARGET_OS_IPHONE
+@property (nonatomic, readonly) EAGLContext *context;
+#else
+@property (nonatomic, readonly) CGLContextObj context;
+#endif
+
- (instancetype)initWithIdentifier:(NSString *)identifier;
- (void)didMoveToMapView:(MGLMapView *)mapView;
diff --git a/platform/darwin/src/MGLOpenGLStyleLayer.mm b/platform/darwin/src/MGLOpenGLStyleLayer.mm
index 678bf15bfc..945348cb03 100644
--- a/platform/darwin/src/MGLOpenGLStyleLayer.mm
+++ b/platform/darwin/src/MGLOpenGLStyleLayer.mm
@@ -107,6 +107,16 @@ private:
return (mbgl::style::CustomLayer *)super.rawLayer;
}
+#if TARGET_OS_IPHONE
+- (EAGLContext *)context {
+ return self.style.mapView.context;
+}
+#else
+- (CGLContextObj)context {
+ return self.style.mapView.context;
+}
+#endif
+
#pragma mark - Adding to and removing from a map view
- (void)addToStyle:(MGLStyle *)style belowLayer:(MGLStyleLayer *)otherLayer {
self.style = style;