diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/configure.json | 10 | ||||
-rw-r--r-- | src/gui/configure.pri | 1 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 12 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 3 | ||||
-rw-r--r-- | src/gui/opengl/qopenglframebufferobject.cpp | 45 |
5 files changed, 66 insertions, 5 deletions
diff --git a/src/gui/configure.json b/src/gui/configure.json index 26a5ae9a3d..4741ed345a 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -164,7 +164,8 @@ }, "sources": [ { "type": "pkgConfig", "args": "freetype2" }, - { "type": "freetype", "libs": "-lfreetype" } + { "type": "freetype", "libs": "-lfreetype", "condition": "!config.wasm" }, + { "type": "freetype", "libs": "-s USE_FREETYPE=1", "condition": "config.wasm" } ] }, "fontconfig": { @@ -308,7 +309,8 @@ { "libs": "-llibpng16", "condition": "config.msvc" }, { "libs": "-llibpng", "condition": "config.msvc" }, { "libs": "-lpng16", "condition": "!config.msvc" }, - { "libs": "-lpng", "condition": "!config.msvc" } + { "libs": "-lpng", "condition": "!config.msvc" }, + { "libs": "-s USE_LIBPNG=1", "condition": "config.wasm" } ], "use": [ { "lib": "zlib", "condition": "features.system-zlib" } @@ -1111,7 +1113,7 @@ }, "opengles3": { "label": "OpenGL ES 3.0", - "condition": "features.opengles2 && !features.angle && tests.opengles3", + "condition": "features.opengles2 && !features.angle && tests.opengles3 && !config.wasm", "output": [ "publicFeature", { "type": "define", "name": "QT_OPENGL_ES_3" } @@ -1138,7 +1140,7 @@ "enable": "input.opengl == 'desktop'", "disable": "input.opengl == 'es2' || input.opengl == 'dynamic' || input.opengl == 'no'", "condition": "(config.win32 && !config.winrt && !features.opengles2 && (config.msvc || libs.opengl)) - || (!config.watchos && !config.win32 && libs.opengl)" + || (!config.watchos && !config.win32 && !config.wasm && libs.opengl)" }, "opengl-dynamic": { "label": "Dynamic OpenGL", diff --git a/src/gui/configure.pri b/src/gui/configure.pri index b40536e41d..2971fd136e 100644 --- a/src/gui/configure.pri +++ b/src/gui/configure.pri @@ -55,6 +55,7 @@ defineTest(qtConfTest_qpaDefaultPlatform) { else: qnx: name = qnx else: integrity: name = integrityfb else: haiku: name = haiku + else: wasm: name = webassembly else: name = xcb $${1}.value = $$name diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 93e8b6ee8f..bc1f83a9c8 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -114,6 +114,10 @@ # include <QtCore/QLibraryInfo> #endif // Q_OS_WIN +#ifdef Q_OS_WASM +#include <emscripten.h> +#endif + #include <qtgui_tracepoints_p.h> #include <ctype.h> @@ -1620,7 +1624,13 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate() qt_gl_set_global_share_context(0); } #endif - +#ifdef Q_OS_WASM + EM_ASM( + // unmount persistent directory as IDBFS + // see QTBUG-70002 + FS.unmount('/home/web_user'); + ); +#endif platform_integration->destroy(); delete platform_theme; diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 7bf941b9a1..cd50294a6c 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -977,8 +977,11 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) if (!surface->surfaceHandle()) return false; if (!surface->supportsOpenGL()) { +#ifndef Q_OS_WASM // ### work around the WASM platform plugin using QOpenGLContext with raster surfaces. + // see QTBUG-70076 qWarning() << "QOpenGLContext::makeCurrent() called with non-opengl surface" << surface; return false; +#endif } QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this); diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 6486a447ee..cae3d516c4 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -142,6 +142,14 @@ QT_BEGIN_NAMESPACE #define GL_CONTEXT_LOST 0x0507 #endif +#ifndef GL_DEPTH_STENCIL_ATTACHMENT +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#endif + +#ifndef GL_DEPTH_STENCIL +#define GL_DEPTH_STENCIL 0x84F9 +#endif + /*! @@ -619,7 +627,11 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext // free existing attachments if (depth_buffer_guard) { +#ifdef Q_OS_WASM + funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); +#else funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); +#endif depth_buffer_guard->free(); } if (stencil_buffer_guard) { @@ -637,7 +649,35 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext // In practice, a combined depth-stencil buffer is supported by all desktop platforms, while a // separate stencil buffer is not. On embedded devices however, a combined depth-stencil buffer // might not be supported while separate buffers are, according to QTBUG-12861. +#ifdef Q_OS_WASM + // WebGL doesn't allow separately attach buffers to + // STENCIL_ATTACHMENT and DEPTH_ATTACHMENT + // QTBUG-69913 + if (attachment == QOpenGLFramebufferObject::CombinedDepthStencil) { + funcs.glGenRenderbuffers(1, &depth_buffer); + funcs.glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer); + Q_ASSERT(funcs.glIsRenderbuffer(depth_buffer)); + + GLenum storageFormat = GL_DEPTH_STENCIL; + + if (samples != 0 ) { + funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, + storageFormat, dsSize.width(), dsSize.height()); + } else { + funcs.glRenderbufferStorage(GL_RENDERBUFFER, storageFormat, + dsSize.width(), dsSize.height()); + } + + funcs.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + GL_RENDERBUFFER, depth_buffer); + valid = checkFramebufferStatus(ctx); + if (!valid) { + funcs.glDeleteRenderbuffers(1, &depth_buffer); + depth_buffer = 0; + } + } +#else if (attachment == QOpenGLFramebufferObject::CombinedDepthStencil && funcs.hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil)) { @@ -729,11 +769,16 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext stencil_buffer = 0; } } +#endif //Q_OS_WASM // The FBO might have become valid after removing the depth or stencil buffer. valid = checkFramebufferStatus(ctx); +#ifdef Q_OS_WASM + if (depth_buffer) { +#else if (depth_buffer && stencil_buffer) { +#endif fbo_attachment = QOpenGLFramebufferObject::CombinedDepthStencil; } else if (depth_buffer) { fbo_attachment = QOpenGLFramebufferObject::Depth; |