diff options
author | Paul Olav Tvete <paul.tvete@digia.com> | 2013-12-18 14:48:22 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-12 20:12:17 +0100 |
commit | eacd58d4e78e7238ba5fcca90ba960aaf3ebd263 (patch) | |
tree | 779bf1735aecb7985bc3136264b9147eb23d5374 /src/plugins/platforms/xcb | |
parent | 5ae5bebb93ec38e17c0dcb9bec47e0ebfbce4937 (diff) |
Enabling QQuickWidget and QOpenGLWidget
Enable child widgets (without a native window) that render to an FBO
and are composed with the raster backingstore by the platform plugin.
A preliminary version of QOpenGLWidget is included as private API.
Change-Id: I8f984a4d7db285069ce3d6564707942c823d890d
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qglxintegration.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbbackingstore.cpp | 24 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbbackingstore.h | 5 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.cpp | 1 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 11 |
5 files changed, 38 insertions, 5 deletions
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index 3f1c53b122..f7abb4662b 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -328,7 +328,7 @@ QGLXContext::~QGLXContext() bool QGLXContext::makeCurrent(QPlatformSurface *surface) { bool success = false; - Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface); + Q_ASSERT(surface->surface()->supportsOpenGL()); Display *dpy = DISPLAY_FROM_XCB(m_screen); GLXDrawable glxDrawable = 0; diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 366e043e98..1579797f85 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -280,6 +280,11 @@ void QXcbBackingStore::beginPaint(const QRegion ®ion) } } +QImage QXcbBackingStore::toImage() const +{ + return m_image && m_image->image() ? *m_image->image() : QImage(); +} + void QXcbBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { if (!m_image || m_image->size().isEmpty()) @@ -319,6 +324,25 @@ void QXcbBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoin } } +#ifndef QT_NO_OPENGL +void QXcbBackingStore::composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, + QPlatformTextureList *textures, QOpenGLContext *context) +{ + QPlatformBackingStore::composeAndFlush(window, region, offset, textures, context); + + Q_XCB_NOOP(connection()); + + if (m_syncingResize) { + QXcbWindow *platformWindow = static_cast<QXcbWindow *>(window->handle()); + connection()->sync(); + m_syncingResize = false; + platformWindow->updateSyncRequestCounter(); + } else { + xcb_flush(xcb_connection()); + } +} +#endif // QT_NO_OPENGL + void QXcbBackingStore::resize(const QSize &size, const QRegion &) { if (m_image && size == m_image->size()) diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.h b/src/plugins/platforms/xcb/qxcbbackingstore.h index d2548242db..19a5ac62d0 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.h +++ b/src/plugins/platforms/xcb/qxcbbackingstore.h @@ -60,6 +60,11 @@ public: QPaintDevice *paintDevice(); void flush(QWindow *window, const QRegion ®ion, const QPoint &offset); +#ifndef QT_NO_OPENGL + void composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, + QPlatformTextureList *textures, QOpenGLContext *context); +#endif + QImage toImage() const; void resize(const QSize &size, const QRegion &staticContents); bool scroll(const QRegion &area, int dx, int dy); diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 1803282071..768a591ab5 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -284,6 +284,7 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const case MultipleWindows: return true; case ForeignWindows: return true; case SyncState: return true; + case RasterGLSurface: return true; default: return QPlatformIntegration::hasCapability(cap); } } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 58abc7abfe..d0106984a2 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -292,8 +292,6 @@ void QXcbWindow::create() if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { #if defined(XCB_USE_GLX) XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen), m_screen->screenNumber(), &m_format); - if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) - qFatal("Could not initialize GLX"); #elif defined(XCB_USE_EGL) EGLDisplay eglDisplay = connection()->egl_display(); EGLConfig eglConfig = q_configFromGLFormat(eglDisplay, m_format, true); @@ -308,9 +306,14 @@ void QXcbWindow::create() XVisualInfo *visualInfo; int matchingCount = 0; visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount); - if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) - qFatal("Could not initialize EGL"); #endif //XCB_USE_GLX + if (!visualInfo && window()->surfaceType() == QSurface::OpenGLSurface) + qFatal("Could not initialize OpenGL"); + + if (!visualInfo && window()->surfaceType() == QSurface::RasterGLSurface) { + qWarning("Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface."); + window()->setSurfaceType(QSurface::RasterSurface); + } if (visualInfo) { m_depth = visualInfo->depth; m_imageFormat = imageFormatForDepth(m_depth); |