summaryrefslogtreecommitdiff
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-23 00:33:45 -0800
commita089139e5ca0315a5e7d58ce5f80c2c4200c4668 (patch)
tree14ee76e780587f17a8d9b366085e105ebbd1ae45
parentfee22273be2d33049311de72ff6bf973b6b05164 (diff)
downloadqtlocation-mapboxgl-upstream/1ec5-opengllayer-context-12945.tar.gz
[ios, macos] Expose MGLMapView OpenGL context to OpenGL style layersupstream/1ec5-opengllayer-context-12945
Added a property to MGLOpenGLStyleLayer that contains the map view’s underlying OpenGL rendering context.
-rw-r--r--platform/darwin/src/MGLOpenGLStyleLayer.h6
-rw-r--r--platform/darwin/src/MGLOpenGLStyleLayer.mm10
-rw-r--r--platform/ios/src/MGLMapView.mm2
-rw-r--r--platform/ios/src/MGLMapView_Private.h3
-rw-r--r--platform/macos/src/MGLMapView.mm5
-rw-r--r--platform/macos/src/MGLMapView_Private.h3
6 files changed, 28 insertions, 1 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;
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 752a1a780b..f5b51330a0 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -195,7 +195,7 @@ public:
MGLMultiPointDelegate,
MGLAnnotationImageDelegate>
-@property (nonatomic) EAGLContext *context;
+@property (nonatomic, readwrite) EAGLContext *context;
@property (nonatomic) GLKView *glView;
@property (nonatomic) UIImageView *glSnapshotView;
diff --git a/platform/ios/src/MGLMapView_Private.h b/platform/ios/src/MGLMapView_Private.h
index bddb9b093e..bffccec5fd 100644
--- a/platform/ios/src/MGLMapView_Private.h
+++ b/platform/ios/src/MGLMapView_Private.h
@@ -13,6 +13,9 @@ FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLUnderlyingMapUnavailableE
@interface MGLMapView (Private)
+/// The map view’s OpenGL rendering context.
+@property (nonatomic, readonly) EAGLContext *context;
+
/// Currently shown popover representing the selected annotation.
@property (nonatomic) UIView<MGLCalloutView> *calloutViewForSelectedAnnotation;
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 482333a26c..5a24524b4a 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -707,6 +707,11 @@ public:
return !_isTargetingInterfaceBuilder;
}
+- (CGLContextObj)context {
+ MGLOpenGLLayer *layer = _isTargetingInterfaceBuilder ? nil : (MGLOpenGLLayer *)self.layer;
+ return layer.openGLContext.CGLContextObj;
+}
+
- (void)setFrame:(NSRect)frame {
super.frame = frame;
if (!_isTargetingInterfaceBuilder) {
diff --git a/platform/macos/src/MGLMapView_Private.h b/platform/macos/src/MGLMapView_Private.h
index f2d178bc31..986ae1143a 100644
--- a/platform/macos/src/MGLMapView_Private.h
+++ b/platform/macos/src/MGLMapView_Private.h
@@ -22,6 +22,9 @@ namespace mbgl {
/// Center longitude set independently of the center latitude in an inspectable.
@property (nonatomic) CLLocationDegrees pendingLongitude;
+/// The map view’s OpenGL rendering context.
+- (CGLContextObj)context;
+
/// Asynchronously render a frame of the map.
- (void)setNeedsGLDisplay;