diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-09-26 14:07:31 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-09-30 18:23:08 +0200 |
commit | 684990d1481b0858489596dc7b28310bb87a6dfa (patch) | |
tree | 29f6b2df7a35d610e71315cdc01e2a8b82ba9380 /src/plugins/platforms/kms/qkmsintegration.cpp | |
parent | 3a2fdc48ad1066eb043f83024ddd76098f933d3a (diff) |
kms: Support QOpenGLWidget and QQuickWidget
Also fixes the handling of shareContext() for contexts and format() for windows
and makes QOffscreenSurface working.
Change-Id: I3c3374a9de14a5b8428de3e11d9d7e1285c5b9c7
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/plugins/platforms/kms/qkmsintegration.cpp')
-rw-r--r-- | src/plugins/platforms/kms/qkmsintegration.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/plugins/platforms/kms/qkmsintegration.cpp b/src/plugins/platforms/kms/qkmsintegration.cpp index ed6ab8f885..d94d7d9aaa 100644 --- a/src/plugins/platforms/kms/qkmsintegration.cpp +++ b/src/plugins/platforms/kms/qkmsintegration.cpp @@ -48,10 +48,13 @@ #include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> #include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h> #include <QtPlatformSupport/private/qfbvthandler_p.h> +#include <QtPlatformSupport/private/qeglconvenience_p.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/QOpenGLContext> #include <QtGui/QScreen> +#include <QtGui/QOffscreenSurface> +#include <qpa/qplatformoffscreensurface.h> QT_BEGIN_NAMESPACE @@ -116,6 +119,7 @@ bool QKmsIntegration::hasCapability(QPlatformIntegration::Capability cap) const case ThreadedPixmaps: return true; case OpenGL: return true; case ThreadedOpenGL: return false; + case RasterGLSurface: return true; default: return QPlatformIntegration::hasCapability(cap); } } @@ -138,6 +142,44 @@ QPlatformBackingStore *QKmsIntegration::createPlatformBackingStore(QWindow *wind return new QKmsBackingStore(window); } +// Neither a pbuffer nor a hidden QWindow is suitable. Just use an additional, small gbm surface. +QKmsOffscreenWindow::QKmsOffscreenWindow(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface) + : QPlatformOffscreenSurface(offscreenSurface) + , m_format(format) + , m_display(display) + , m_surface(EGL_NO_SURFACE) + , m_window(0) +{ + QKmsScreen *screen = static_cast<QKmsScreen *>(offscreenSurface->screen()->handle()); + m_window = gbm_surface_create(screen->device()->gbmDevice(), + 10, 10, + GBM_FORMAT_XRGB8888, + GBM_BO_USE_RENDERING); + if (!m_window) { + qWarning("QKmsOffscreenWindow: Failed to create native window"); + return; + } + + EGLConfig config = q_configFromGLFormat(m_display, m_format); + m_surface = eglCreateWindowSurface(m_display, config, m_window, 0); + if (m_surface != EGL_NO_SURFACE) + m_format = q_glFormatFromConfig(m_display, config); +} + +QKmsOffscreenWindow::~QKmsOffscreenWindow() +{ + if (m_surface != EGL_NO_SURFACE) + eglDestroySurface(m_display, m_surface); + if (m_window) + gbm_surface_destroy((gbm_surface *) m_window); +} + +QPlatformOffscreenSurface *QKmsIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const +{ + QKmsScreen *screen = static_cast<QKmsScreen *>(surface->screen()->handle()); + return new QKmsOffscreenWindow(screen->device()->eglDisplay(), QKmsScreen::tweakFormat(surface->format()), surface); +} + QPlatformFontDatabase *QKmsIntegration::fontDatabase() const { return m_fontDatabase; |