path: root/src/plugins/platforms/ios/
diff options
authorTor Arne Vestbø <>2014-03-27 16:41:56 +0100
committerThe Qt Project <>2014-03-31 13:48:52 +0200
commite432787ad0b760b887bfbcde1a397acc9adfb6c6 (patch)
treee447c020dfa60c1903b17c77d7bef2435accabfa /src/plugins/platforms/ios/
parent38b66bdcde4c99c4a4263de406228b1be457f534 (diff)
iOS: Share default-FBO for windows between contexts in a share-group
The current implementation of QOpenGLContext sharing assumes that the contexts form a tree and that leaf-nodes are destroyed before their parents. We build on this assumption and keep track of the default FBOs for windows in the root context of the tree. This allows two shared contexts to both makeCurrent() on the same window surface without resulting in two FBOs being set up (which doesn't work on iOS due to the CEAGLLayer already being tied to another render-buffer). Change-Id: Ib9f8c597effe488480fe99e10846be22c257f490 Reviewed-by: Laszlo Agocs <>
Diffstat (limited to 'src/plugins/platforms/ios/')
1 files changed, 9 insertions, 4 deletions
diff --git a/src/plugins/platforms/ios/ b/src/plugins/platforms/ios/
index 1ea040308f..ddee52196a 100644
--- a/src/plugins/platforms/ios/
+++ b/src/plugins/platforms/ios/
@@ -140,17 +140,22 @@ void QIOSContext::swapBuffers(QPlatformSurface *surface)
if (surface->surface()->surfaceClass() == QSurface::Offscreen)
return; // Nothing to do
- Q_ASSERT(surface->surface()->surfaceClass() == QSurface::Window);
- QIOSWindow *window = static_cast<QIOSWindow *>(surface);
- Q_ASSERT(m_framebufferObjects.contains(window));
+ FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface);
[EAGLContext setCurrentContext:m_eaglContext];
- glBindRenderbuffer(GL_RENDERBUFFER, m_framebufferObjects[window].colorRenderbuffer);
+ glBindRenderbuffer(GL_RENDERBUFFER, framebufferObject.colorRenderbuffer);
[m_eaglContext presentRenderbuffer:GL_RENDERBUFFER];
QIOSContext::FramebufferObject &QIOSContext::backingFramebufferObjectFor(QPlatformSurface *surface) const
+ // We keep track of default-FBOs in the root context of a share-group. This assumes
+ // that the contexts form a tree, where leaf nodes are always destroyed before their
+ // parents. If that assumption (based on the current implementation) doesn't hold we
+ // should probably use QOpenGLMultiGroupSharedResource to track the shared default-FBOs.
+ if (m_sharedContext)
+ return m_sharedContext->backingFramebufferObjectFor(surface);
Q_ASSERT(surface && surface->surface()->surfaceClass() == QSurface::Window);
QIOSWindow *window = static_cast<QIOSWindow *>(surface);