summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmbackingstore.cpp
Commit message (Collapse)AuthorAgeFilesLines
* wasm: move image to web conversion to dom::Lorn Potter2023-12-211-33/+3
| | | | | | | | This allows other areas to utilize this Change-Id: I4bc7e8374289a19afe8b639b2b3b0dc0f8f65a3a Done-with: Mikolaj.Boc@qt.io Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Correctly update the texture in qwasmbackingstoreMikolaj Boc2023-03-311-5/+7
| | | | | | | | | | Both the full-width and partial-width paths in QWasmBackingStore::updateTexture now correctly compute source and target rects. Task-number: QTBUG-112414 Change-Id: I30b0952609960f521119d3d628d2a8036f8b1fe5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Use the browser compositor for drawing windows on WASMMikolaj Boc2022-11-261-58/+45
| | | | | | | | | | | | | | | | Make the browser compositor draw the window non-client area (using css + html). Get rid of OpenGL usage in non-OpenGL windows and use canvas 2d context instead to blit the texture (QImage). Also, as part of the change, remove the deprecated canvas element support in QScreen. Fixes: QTBUG-107116 Fixes: QTBUG-107219 Change-Id: I65f0d91831c806315685ca681ac0e416673f5cd5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io>
* Make Qt on WASM correctly draw windows with QT_SCALE_FACTORMikolaj Boc2022-10-251-3/+4
| | | | | | | | | | | | The GUI scale factor was taken into account twice, once in QBackingStore::resize and then again implicitly in QWasmBackingStore::resize, through window()->devicePixelRatio(), which contains it as one of its multipliers. Fixes: QTBUG-80992 Pick-to: 6.4 Change-Id: I75ac8d85c14230207379b789834256de4254811b Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-28/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* wasm: propagate QWindow format to backing storeMorten Sørvig2022-04-191-5/+10
| | | | | | | | | | | | | | | Qt backing store images should have alpha iff that was requested by the QWindow's surface format. This changes wasm to be in line with the other platforms, and enables use of transparency for Qt windows. Change beginPaint() to clear the backing store only if the format/image has alpha. This is also established behavior Qt's backing stores. Change-Id: Idafe658e24d864f7c4f9e68ee39cb409982b5852 Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: David Skoland <david.skoland@qt.io>
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QPlatformTextureList holds a QRhiTexture instead of GLuint. A QPlatformBackingStore now optionally can own a QRhi and a QRhiSwapChain for the associated window. Non-GL rendering must use this QRhi everywhere, whereas GL (QOpenGLWidget) can choose to still rely on resource sharing between contexts. A widget tells that it wants QRhi and the desired configuration in a new virtual function in QWidgetPrivate returning a QPlatformBackingStoreRhiConfig. This is evaluated (among a top-level's all children) upon create() before creating the repaint manager and the QWidgetWindow. In QOpenGLWidget what do request is obvious: it will request an OpenGL-based QRhi. QQuickWidget (or a potential future QRhiWidget) will be more interesting: it needs to honor the standard Qt Quick env.vars. and QQuickWindow APIs (or, in whatever way the user configured the QRhiWidget), and so will set up the config struct accordingly. In addition, the rhiconfig and surface type is (re)evaluated when (re)parenting a widget to a new tlw. If needed, this will now trigger a destroy - create on the tlw. This should be be safe to do in setParent. When multiple child widgets report an enabled rhiconfig, the first one (the first child encountered) wins. So e.g. attempting to have a QOpenGLWidget and a Vulkan-based QQuickWidget in the same top-level window will fail one of the widgets (it likely won't render). RasterGLSurface is no longer used by widgets. Rather, the appropriate surface type is chosen. The rhi support in the backingstore is usable without widgets as well. To make rhiFlush() functional, one needs to call setRhiConfig() after creating the QBackingStore. (like QWidget does to top-level windows) Most of the QT_NO_OPENGL ifdefs are eliminated all over the place. Everything with QRhi is unconditional code at compile time, except the actual initialization. Having to plumb the widget tlw's shareContext (or, now, the QRhi) through QWindowPrivate is no longer needed. The old approach does not scale: to implement composeAndFlush (now rhiFlush) we need more than just a QRhi object, and this way we no longer pollute everything starting from the widget level (QWidget's topextra -> QWidgetWindow -> QWindowPrivate) just to send data around. The BackingStoreOpenGLSupport interface and the QtGui - QtOpenGL split is all gone. Instead, there is a QBackingStoreDefaultCompositor in QtGui which is what the default implementations of composeAndFlush and toTexture call. (overriding composeAndFlush and co. f.ex. in eglfs should continue working mostly as-is, apart from adapting to the texture list changes and getting the native OpenGL texture id out of the QRhiTexture) As QQuickWidget is way too complicated to just port as-is, an rhi manual test (rhiwidget) is introduced as a first step, in ordewr to exercise a simple, custom render-to-texture widget that does something using a (not necessarily OpenGL-backed) QRhi and acts as fully functional QWidget (modeled after QOpenGLWidget). This can also form the foundation of a potential future QRhiWidget. It is also possible to force the QRhi-based flushing always, regardless of the presence of render-to-texture widgets. To exercise this, set the env.var. QT_WIDGETS_RHI=1. This picks a platform-specific default, and can be overridden with QT_WIDGETS_RHI_BACKEND. (in sync with Qt Quick) This can eventually be extended to query the platform plugin as well to check if the platform plugin prefers to always do flushes with a 3D API. QOpenGLWidget should work like before from the user's perspective, while internally it has to do some things differently to play nice and prevent regressions with the new rendering architecture. To exercise this better, the qopenglwidget example gets a new tab-based view (that could perhaps replace the example's main window later on?). The openglwidget manual test is made compatible with Qt 6, and gets a counterpart in form of the dockedopenglwidget manual test, which is a modified version of the cube example that features dock widgets. This is relevant in particular because render-to-texture widgets within a QDockWidget has its own specific quirks, with logic taking this into account, hence testing is essential. For existing applications there are two important consequences with this patch in place: - Once the rhi-based composition is enabled, it stays active for the lifetime of the top-level window. - Dynamically creating and parenting the first render-to-texture widget to an already created tlw will destroy and recreate the tlw (and the underlying window). The visible effects of this depend on the platform. (e.g. the window may disappear and reappear on some, whereas with other windowing systems it is not noticeable at all - this is not really different from similar situtions with reparenting or when moving windows between screens, so should be acceptable in practice) - On iOS raster windows are flushed with Metal (and rhi) from now on (previously this was through OpenGL by making flush() call composeAndFlush(). Change-Id: Id05bd0f7a26fa845f8b7ad8eedda3b0e78ab7a4e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: always use requestAnimationFrame for updatesMorten Johan Sørvig2022-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | The compositor was posting update events and flushing/redrawing using a zero-timer. Change this to use the request_animation_frame API from Emscripten, which makes sure we flush window content at the next native paint event. This has the additional benefit that hidden canvases (e.g on hidden tabs) won’t get frame events, and then stop painting. We support both well-behaved QWindows, where the window calls requestUpate() and then paints/flushes on the following deliverUpdateRequest(), and also less well behaved windows which paints at any point during event processing. Pick-to: 6.3 Change-Id: I747d6f7ace86ceddaa18ab86b6a0ee833f98991b Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Add ; to Q_UNUSEDLars Schmertmann2020-07-071-1/+1
| | | | | | | | This is required to remove the ; from the macro with Qt 6. Task-number: QTBUG-82978 Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devLars Knoll2020-02-281-5/+22
|\ | | | | | | Change-Id: I469b0501cc65fc5ce4d797a69ae89405cc69c7f8
| * wasm: fix texture leak when window is destroyed in a different contextAlexandra Cherdantseva2020-02-271-5/+22
| | | | | | | | | | | | | | | | | | | | Reproduce: Show first window in first canvas; Show second window in second canvas; After screens are rendered destroy first window in first canvas Change-Id: Ifbeb4824c1fdedecf24d5d20e58613d15c066420 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Move QOpenGLTexture and related classes from QtGui to QtOpenGLJohan Klokkhammer Helsing2020-01-241-1/+1
|/ | | | | | | Task-number: QTBUG-74409 Change-Id: Ied825dd7cb92365505a4aa43fd67488024160341 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* wasm: recreate backing store texture with valid gl contextMorten Johan Sørvig2019-09-181-3/+6
| | | | | | | | The compositor context is not current during the resize() call, but will be during updateTexture(). Change-Id: I29c2e06aa251b564b5d622dc9380ec994e15aab0 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: controlled screen destructionMorten Johan Sørvig2019-05-141-0/+6
| | | | | | | | | | | | | Freeing OpenGL resources requires a current context, which (on wasm) requires a screen. Add a destroy() functions to QWasmScreen, QWasmCompositor, QWasmWindow, and QWasmBackingStore which facilitates OpenGL cleanup before we start deleting screen objects. Task-number: QTBUG-75463 Change-Id: I9954b536416b9147965c74459ccad838d1578778 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* WebAssembly for QtBaseMorten Johan Sørvig2018-08-301-0/+165
This is the squashed diff from wip/webassembly to dev. Done-with: Peng Wu <peng.wu@intopalo.com> Done-with: Sami Enne <sami.enne@intopalo.com> Done-with: Morten Johan Sørvig <morten.sorvig@qt.io> Started-by: Andrew Knight <andrew.knight@intopalo.com> Change-Id: I6562433c0a38d6ec49ab675e0f104f2665f3392d Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>