diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/glfw_view.cpp | 9 | ||||
-rw-r--r-- | platform/default/headless_view.cpp | 9 | ||||
-rw-r--r-- | platform/ios/MGLMapView.mm | 31 |
3 files changed, 23 insertions, 26 deletions
diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 6d23a51ffb..2d0da355b2 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -297,16 +297,13 @@ void GLFWView::notify() { glfwPostEmptyEvent(); } -void GLFWView::swap() { +void GLFWView::invalidate() { + assert(map); + map->render(); glfwSwapBuffers(window); - map->swapped(); fps(); } -void GLFWView::notifyMapChange(mbgl::MapChange /*change*/, std::chrono::steady_clock::duration /*delay*/) { - // no-op -} - void GLFWView::fps() { static int frames = 0; static double timeElapsed = 0; diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index 975e7f58f7..7509c48eec 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -264,10 +264,6 @@ void HeadlessView::notify() { // no-op } -void HeadlessView::notifyMapChange(mbgl::MapChange /*change*/, std::chrono::steady_clock::duration /*delay*/) { - // no-op -} - void HeadlessView::activate() { #if MBGL_USE_CGL CGLError error = CGLSetCurrentContext(glContext); @@ -298,6 +294,9 @@ void HeadlessView::deactivate() { #endif } -void HeadlessView::swap() {} +void HeadlessView::invalidate() { + assert(map); + map->render(); +} } diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index f60d3a05ff..57760717d9 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -200,7 +200,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; // _glView = [[GLKView alloc] initWithFrame:self.bounds context:_context]; _glView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - _glView.enableSetNeedsDisplay = NO; + _glView.enableSetNeedsDisplay = YES; _glView.drawableStencilFormat = GLKViewDrawableStencilFormat8; _glView.drawableDepthFormat = GLKViewDrawableDepthFormat16; if ([UIScreen instancesRespondToSelector:@selector(nativeScale)]) { @@ -210,6 +210,8 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; [_glView bindDrawable]; [self addSubview:_glView]; + _glView.contentMode = UIViewContentModeCenter; + [self setBackgroundColor:[UIColor whiteColor]]; // load extensions // @@ -488,16 +490,18 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; [super updateConstraints]; } +// This is the delegate of the GLKView object's display call. - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { mbglView->resize(rect.size.width, rect.size.height, view.contentScaleFactor, view.drawableWidth, view.drawableHeight); + mbglMap->renderSync(); } +// This gets called when the view dimension changes, e.g. because the device is being rotated. - (void)layoutSubviews { - mbglMap->update(); - [super layoutSubviews]; + mbglMap->triggerUpdate(); } #pragma mark - Life Cycle - @@ -1600,13 +1604,10 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; return resourceBundlePath; } -- (void)swap +- (void)invalidate { - if (mbglMap->needsSwap()) - { - [self.glView display]; - mbglMap->swapped(); - } + // This is run in the main/UI thread. + [self.glView setNeedsDisplay]; } class MBGLView : public mbgl::View @@ -1616,12 +1617,12 @@ class MBGLView : public mbgl::View virtual ~MBGLView() {} - void notify() + void notify() override { // no-op } - void notifyMapChange(mbgl::MapChange change, std::chrono::steady_clock::duration delay = std::chrono::steady_clock::duration::zero()) + void notifyMapChange(mbgl::MapChange change, std::chrono::steady_clock::duration delay = std::chrono::steady_clock::duration::zero()) override { if (delay != std::chrono::steady_clock::duration::zero()) { @@ -1643,12 +1644,12 @@ class MBGLView : public mbgl::View } } - void activate() + void activate() override { [EAGLContext setCurrentContext:nativeView.context]; } - void deactivate() + void deactivate() override { [EAGLContext setCurrentContext:nil]; } @@ -1657,9 +1658,9 @@ class MBGLView : public mbgl::View View::resize(width, height, ratio, fbWidth, fbHeight); } - void swap() + void invalidate() override { - [nativeView performSelectorOnMainThread:@selector(swap) + [nativeView performSelectorOnMainThread:@selector(invalidate) withObject:nil waitUntilDone:NO]; } |