Skip to content

Commit e51341c

Browse files
committed
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 <[email protected]>
1 parent af387b9 commit e51341c

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

src/plugins/platforms/webgl/qwebglintegration.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ QPlatformWindow *QWebGLIntegration::createPlatformWindow(QWindow *window) const
253253
return platformWindow;
254254
}
255255

256+
QPlatformOffscreenSurface *QWebGLIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
257+
{
258+
qCDebug(lcWebGL, "New offscreen surface %p", surface);
259+
return new QWebGLOffscreenSurface(surface);
260+
}
261+
256262
QPlatformOpenGLContext *QWebGLIntegration::createPlatformOpenGLContext(QOpenGLContext *context)
257263
const
258264
{

src/plugins/platforms/webgl/qwebglintegration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class QWebGLIntegration : public QPlatformIntegration, public QPlatformNativeInt
5959
QPlatformInputContext *inputContext() const override;
6060
QPlatformTheme *createPlatformTheme(const QString &name) const override;
6161
QPlatformWindow *createPlatformWindow(QWindow *window) const override;
62+
QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
6263
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
6364
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
6465

src/plugins/platforms/webgl/qwebglwindow.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <QtGui/qpa/qwindowsysteminterface.h>
4141
#include <QtGui/qpa/qplatformintegration.h>
4242
#include <QtGui/qopenglcontext.h>
43+
#include <QtGui/qoffscreensurface.h>
4344

4445
#include "qwebglwindow.h"
4546

@@ -170,4 +171,19 @@ WId QWebGLWindow::winId() const
170171
return d->id;
171172
}
172173

174+
QWebGLOffscreenSurface::QWebGLOffscreenSurface(QOffscreenSurface *offscreenSurface)
175+
: QPlatformOffscreenSurface(offscreenSurface)
176+
{
177+
}
178+
179+
QSurfaceFormat QWebGLOffscreenSurface::format() const
180+
{
181+
return offscreenSurface()->format();
182+
}
183+
184+
bool QWebGLOffscreenSurface::isValid() const
185+
{
186+
return true;
187+
}
188+
173189
QT_END_NAMESPACE

src/plugins/platforms/webgl/qwebglwindow.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include <QtCore/qscopedpointer.h>
3737
#include <QtGui/qpa/qplatformwindow.h>
38+
#include <QtGui/qpa/qplatformoffscreensurface.h>
3839

3940
QT_BEGIN_NAMESPACE
4041

@@ -72,6 +73,15 @@ class QWebGLWindow : public QPlatformWindow
7273
QScopedPointer<QWebGLWindowPrivate> d_ptr;
7374
};
7475

76+
class QWebGLOffscreenSurface : public QPlatformOffscreenSurface
77+
{
78+
public:
79+
QWebGLOffscreenSurface(QOffscreenSurface *offscreenSurface);
80+
81+
QSurfaceFormat format() const override;
82+
bool isValid() const override;
83+
};
84+
7585
QT_END_NAMESPACE
7686

7787
#endif // QWEBGLWINDOW_H

0 commit comments

Comments
 (0)