diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-07-25 15:33:30 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-07-25 16:19:46 +0000 |
commit | e51341cf20447c42a62281e633513837058f62e5 (patch) | |
tree | 29aed073574ab06112f311b87d984ba8e75ac4d0 | |
parent | af387b932e6ad0e017298256d0437223c4919225 (diff) |
Handle offscreen surfaces
Implement createPlatformOffscreenSurface(). This way a QOffscreenSurface
will not lead to creating a QWindow. Fairly dummy, and may need amending
later, but fixes the immediate problem with the - still default - direct
OpenGL code path of Qt Quick.
Task-number: QTBUG-76993
Change-Id: Ia4198163fc91d3f353d0067a2a807ec075168ace
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
-rw-r--r-- | src/plugins/platforms/webgl/qwebglintegration.cpp | 6 | ||||
-rw-r--r-- | src/plugins/platforms/webgl/qwebglintegration.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/webgl/qwebglwindow.cpp | 16 | ||||
-rw-r--r-- | src/plugins/platforms/webgl/qwebglwindow.h | 10 |
4 files changed, 33 insertions, 0 deletions
diff --git a/src/plugins/platforms/webgl/qwebglintegration.cpp b/src/plugins/platforms/webgl/qwebglintegration.cpp index dfae866..645c766 100644 --- a/src/plugins/platforms/webgl/qwebglintegration.cpp +++ b/src/plugins/platforms/webgl/qwebglintegration.cpp @@ -253,6 +253,12 @@ QPlatformWindow *QWebGLIntegration::createPlatformWindow(QWindow *window) const return platformWindow; } +QPlatformOffscreenSurface *QWebGLIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const +{ + qCDebug(lcWebGL, "New offscreen surface %p", surface); + return new QWebGLOffscreenSurface(surface); +} + QPlatformOpenGLContext *QWebGLIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { diff --git a/src/plugins/platforms/webgl/qwebglintegration.h b/src/plugins/platforms/webgl/qwebglintegration.h index f3e22df..2e1d6c4 100644 --- a/src/plugins/platforms/webgl/qwebglintegration.h +++ b/src/plugins/platforms/webgl/qwebglintegration.h @@ -59,6 +59,7 @@ public: QPlatformInputContext *inputContext() const override; QPlatformTheme *createPlatformTheme(const QString &name) const override; QPlatformWindow *createPlatformWindow(QWindow *window) const override; + QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; diff --git a/src/plugins/platforms/webgl/qwebglwindow.cpp b/src/plugins/platforms/webgl/qwebglwindow.cpp index 93a77bc..8b2af2e 100644 --- a/src/plugins/platforms/webgl/qwebglwindow.cpp +++ b/src/plugins/platforms/webgl/qwebglwindow.cpp @@ -40,6 +40,7 @@ #include <QtGui/qpa/qwindowsysteminterface.h> #include <QtGui/qpa/qplatformintegration.h> #include <QtGui/qopenglcontext.h> +#include <QtGui/qoffscreensurface.h> #include "qwebglwindow.h" @@ -170,4 +171,19 @@ WId QWebGLWindow::winId() const return d->id; } +QWebGLOffscreenSurface::QWebGLOffscreenSurface(QOffscreenSurface *offscreenSurface) + : QPlatformOffscreenSurface(offscreenSurface) +{ +} + +QSurfaceFormat QWebGLOffscreenSurface::format() const +{ + return offscreenSurface()->format(); +} + +bool QWebGLOffscreenSurface::isValid() const +{ + return true; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/webgl/qwebglwindow.h b/src/plugins/platforms/webgl/qwebglwindow.h index 945541d..8724d9c 100644 --- a/src/plugins/platforms/webgl/qwebglwindow.h +++ b/src/plugins/platforms/webgl/qwebglwindow.h @@ -35,6 +35,7 @@ #include <QtCore/qscopedpointer.h> #include <QtGui/qpa/qplatformwindow.h> +#include <QtGui/qpa/qplatformoffscreensurface.h> QT_BEGIN_NAMESPACE @@ -72,6 +73,15 @@ private: QScopedPointer<QWebGLWindowPrivate> d_ptr; }; +class QWebGLOffscreenSurface : public QPlatformOffscreenSurface +{ +public: + QWebGLOffscreenSurface(QOffscreenSurface *offscreenSurface); + + QSurfaceFormat format() const override; + bool isValid() const override; +}; + QT_END_NAMESPACE #endif // QWEBGLWINDOW_H |