diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-02-09 12:08:23 +0100 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2017-02-20 12:34:05 -0800 |
commit | e5b9605ab2dc8fd73bdc44ff0d40034d326c1bdf (patch) | |
tree | da3796e343ba0b0a8c62cc41068029cec41be2ff /platform/macos/src | |
parent | 4eef3df183bb74ca02b6b40cc21ecd5cbf4694b4 (diff) | |
download | qtlocation-mapboxgl-e5b9605ab2dc8fd73bdc44ff0d40034d326c1bdf.tar.gz |
[macos] reuse OpenGL context when switching screens
Cherry-picked from 43e81509fb0be54bea5912fb5a10bfa0e0667a44.
Diffstat (limited to 'platform/macos/src')
-rw-r--r-- | platform/macos/src/MGLOpenGLLayer.mm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/platform/macos/src/MGLOpenGLLayer.mm b/platform/macos/src/MGLOpenGLLayer.mm index 654fa4f2bc..b1040f26e8 100644 --- a/platform/macos/src/MGLOpenGLLayer.mm +++ b/platform/macos/src/MGLOpenGLLayer.mm @@ -4,7 +4,9 @@ #import <mbgl/gl/gl.hpp> -@implementation MGLOpenGLLayer +@implementation MGLOpenGLLayer { + NSOpenGLContext *_context; +} - (MGLMapView *)mapView { return (MGLMapView *)super.view; @@ -22,6 +24,13 @@ 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, |