Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[macos] reuse OpenGL context when switching screens
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed Feb 13, 2017
1 parent b9be66f commit 940f01e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions platform/macos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Improved the line wrapping behavior of point-placed labels, especially labels written in Chinese and Japanese. ([#6828](https://github.com/mapbox/mapbox-gl-native/pull/6828), [#7446](https://github.com/mapbox/mapbox-gl-native/pull/7446))
* CJK characters now remain upright in vertically oriented labels that have line placement, such as road labels. ([#7114](https://github.com/mapbox/mapbox-gl-native/issues/7114))
* Added Chinese (Simplified and Traditional), French, German, Japanese, Portuguese (Brazilian), Swedish, and Vietnamese localizations. ([#7316](https://github.com/mapbox/mapbox-gl-native/pull/7316), [#7503](https://github.com/mapbox/mapbox-gl-native/pull/7503), [#7899](https://github.com/mapbox/mapbox-gl-native/pull/7899), [#7999](https://github.com/mapbox/mapbox-gl-native/pull/7999))
* Fixed an issue that let the app crash when moving the window between screens. ([#8004](https://github.com/mapbox/mapbox-gl-native/pull/8004))

### Styles

Expand Down
11 changes: 10 additions & 1 deletion platform/macos/src/MGLOpenGLLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#import "MGLMapView_Private.h"

@implementation MGLOpenGLLayer
@implementation MGLOpenGLLayer {
NSOpenGLContext *_context;
}

- (MGLMapView *)mapView {
return (MGLMapView *)super.view;
Expand All @@ -20,6 +22,13 @@ - (CGRect)frame {
return self.view.bounds;
}

- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat {
if (!_context) {
_context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
}
return _context;
}

- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask {
NSOpenGLPixelFormatAttribute pfas[] = {
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy,
Expand Down

0 comments on commit 940f01e

Please sign in to comment.