diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-03-11 19:43:13 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-03-12 12:16:38 +0100 |
commit | 47ede853c4c0dd8e953f3ee98b807f044d178d76 (patch) | |
tree | 75d56f01853cb64b200d8977069dfe992266e9de /platform | |
parent | ba9d2420699507c6d32b12272151529663c8d2fd (diff) | |
download | qtlocation-mapboxgl-47ede853c4c0dd8e953f3ee98b807f044d178d76.tar.gz |
fixes black flicker on rotating the device
fixes #838
instead of rendering ad libitum on the map thread, we are now driving rendering from the UI thread on iOS via the map.renderSync() function. There are still white bars during the rotation, but the general content of the view is kept visible.
- upgrades GLFW to 3.1
- removes swapped/needsSwap in favor of a more explicit scheme
- View#invalidate() now replaces View#swap() and is called whenever the View needs to trigger a rerender. GLFW and Android to this right away, while iOS goes back to the main thread and does the Map redrawing as part of the GLKView update
- sets all iOS deployment targets to 7.0
- disables SQLite3 version check, since the library version changed on iOS 8.2
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 1ab1afcbba..3629430263 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -204,7 +204,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)]) { @@ -214,6 +214,8 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; [_glView bindDrawable]; [self addSubview:_glView]; + _glView.contentMode = UIViewContentModeCenter; + [self setBackgroundColor:[UIColor whiteColor]]; // load extensions // @@ -492,16 +494,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 - @@ -1604,13 +1608,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 @@ -1620,12 +1621,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()) { @@ -1647,12 +1648,12 @@ class MBGLView : public mbgl::View } } - void activate() + void activate() override { [EAGLContext setCurrentContext:nativeView.context]; } - void deactivate() + void deactivate() override { [EAGLContext setCurrentContext:nil]; } @@ -1661,9 +1662,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]; } |