diff options
Diffstat (limited to 'src/plugins/platforms/eglfs/qeglfscontext.cpp')
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfscontext.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp index 6470280e2c..4bda09653f 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp @@ -46,7 +46,8 @@ QT_BEGIN_NAMESPACE QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLConfig *config, const QVariant &nativeHandle) - : QEGLPlatformContext(format, share, display, config, nativeHandle) + : QEGLPlatformContext(format, share, display, config, nativeHandle), + m_tempWindow(0) { } @@ -58,17 +59,45 @@ EGLSurface QEglFSContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface return static_cast<QEGLPbuffer *>(surface)->pbuffer(); } +EGLSurface QEglFSContext::createTemporaryOffscreenSurface() +{ + if (qt_egl_device_integration()->supportsPBuffers()) + return QEGLPlatformContext::createTemporaryOffscreenSurface(); + + if (!m_tempWindow) { + m_tempWindow = qt_egl_device_integration()->createNativeOffscreenWindow(format()); + if (!m_tempWindow) { + qWarning("QEglFSContext: Failed to create temporary native window"); + return EGL_NO_SURFACE; + } + } + EGLConfig config = q_configFromGLFormat(eglDisplay(), format()); + return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, 0); +} + +void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface) +{ + if (qt_egl_device_integration()->supportsPBuffers()) { + QEGLPlatformContext::destroyTemporaryOffscreenSurface(surface); + } else { + eglDestroySurface(eglDisplay(), surface); + qt_egl_device_integration()->destroyNativeWindow(m_tempWindow); + m_tempWindow = 0; + } +} + void QEglFSContext::swapBuffers(QPlatformSurface *surface) { // draw the cursor if (surface->surface()->surfaceClass() == QSurface::Window) { QPlatformWindow *window = static_cast<QPlatformWindow *>(surface); - if (QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(window->screen()->cursor())) + if (QEGLPlatformCursor *cursor = qobject_cast<QEGLPlatformCursor *>(window->screen()->cursor())) cursor->paintOnScreen(); } - QEglFSHooks::hooks()->waitForVSync(); + qt_egl_device_integration()->waitForVSync(surface); QEGLPlatformContext::swapBuffers(surface); + qt_egl_device_integration()->presentBuffer(surface); } QT_END_NAMESPACE |