summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosbackingstore.mm
Commit message (Collapse)AuthorAgeFilesLines
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-111-95/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Register QPlatformBackingStoreOpenGLSupport when neededTor Arne Vestbø2020-07-291-0/+4
| | | | | | | | | | | | Static builds can not rely on a constructor function in the QtOpenGL library, as that will be linked out unless something in the application pulls it in. Instead we export a helper function that clients that depend on OpenGL support in QPlatformBackingStore can use to bring it it. Change-Id: Ic54058bf413a476287884c78df5624b862f97695 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Let QPlatformBackingStore handle its own QOpenGLContextTor Arne Vestbø2017-10-051-14/+1
| | | | | | | | | | | | | | | | | | | | | The resources allocated by QPlatformBackingStore are owned by the class, and should be allocated in a context the class also owns. This removes the asymmetry of having to pass in a context to composeAndFlush, while having to make the same context current before destroying the platform backingstore. The context owned by QPlatformBackingStore is shared with the associated window though a new QWindowPrivate::shareContext() API. The result is that on e.g. iOS, the backingstore does not need to tie the resource allocation of QPlatformBackingStore to the global share context, but can instead tie them to the per-window context, and hence clean them up after each window is closed. Task-number: QTBUG-56653 Change-Id: Ic1bcae50dafeeafaa8d16a7febd83b840ec6367a Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* iOS: Remove support for OpenGL-backed QBackingStoreTor Arne Vestbø2017-08-241-127/+12
| | | | | | | | | | | | | The default on iOS has been raster for two years now, as of 3e892e4a97, and we haven't seen any major performance regressions that would warrant keeping the OpenGL based code-path alive. This includes the default surface format, which was ony set so that QPainter clip regions would work when using the GL backed backing store. Change-Id: I37b880a758b9c3fad1f23ae60268629ffbe9bc3e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* iOS: Ensure that QPlatformBackingStore can clean up textures in dtorTor Arne Vestbø2017-01-061-1/+11
| | | | | | | | | | | We are using QPlatformBackingStore::composeAndFlush, which allocates textures on our behalf using the context that we pass in, so we need to keep the context alive (and make it current) for the duration of the QPlatformBackingStore destructor, otherwise we're leaking textures every time a window (dialog e.g.) is closed. Change-Id: I1450fa0ff7a170d13ec59920566e4401b50cd513 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* UIKit: Document the history and implementation of QIOSBackingStoreTor Arne Vestbø2016-09-271-0/+27
| | | | | Change-Id: Icca393afa84bc7dae7f28669a3e73268ffed68b7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix namespaced build on iOSJake Petroules2016-09-201-0/+2
| | | | | | Change-Id: I682fabe8891e0325e6545b4499a59af4ad584c41 Reviewed-by: Mike Krus <mike.krus@kdab.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* iOS: Use composeAndFlush() to flush all backing store updatesTor Arne Vestbø2016-03-181-5/+5
| | | | | | | | | | | | | | | | | | | QPlatformBackingStore::composeAndFlush() handles an empty texture list just fine, and results in the same blitting of the backing store image as we're doing today using the OpenGL paint engine, except the compose and flush code path is a lot more optimized. Among other things it clears the render buffer as the first step (as recommended by Apple on iOS), doesn't re-create the backing store texture each pass just because the image has changed, and respects the flushed region for both the texture upload (using glTexSubImage2D) and when blitting the texture. The result is a 10x increase in frames per second when blitting full screen updates. Change-Id: I163fab473751f8201758a5684b18d80bb90d42fb Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* QtBase (remainder): use printf-style qWarning/qDebug where possible (I)Marc Mutz2016-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The printf-style version of QDebug expands to a lot less code than the std::ostream-style version. Of course, you pay in type safety (but compilers warn about it these days), you cannot stream complex Qt types and streaming QStrings is awkward, but in many cases you actually improve on readability. But the main reason is that something that's not supposed to be executed under normal operation has no business bloating executable code size. This is not an attempt at converting all qWarnings() to printf-style, only the low-hanging fruit. In this first part, replace qWarning() << "" with qWarning("..."). Had to fix broken qImDebug() definition. Instead of defining it as a nullary macro in the QT_NO_DEBUG case and as a variadic macro in the other, define it in both cases, as is customary, as a non-function macro so that overload selection works without requiring variadic macro support of the compiler. Saves e.g. ~250b in text size in QtPrintSupport on optimized GCC 5.3 AMD64 builds. Change-Id: Ie30fe2f7942115d5dbf99fff1750ae0d477c379f Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* iOS: Switch backingstore to use raster paint engine, not GLTor Arne Vestbø2015-12-171-73/+38
| | | | | | | | | | | | | | | | | | | | | | | | Now that more of the raster operations are NEON-optimized this should be acceptable. The switch enables antialiased drawing, and makes iOS in line with other platforms in having QBackingStore backed by a QImage. The use of QImage also allows us to remove code from the backingstore implementation that was only needed to support the composeAndFlush code path. The common parts of a raster backingstore implementation have been factored out into QRasterBackingStore in platformsupport, which can be shared with more platforms in the future. [ChangeLog][iOS] QBackingStore now uses the raster paint engine instead of the OpenGL paint engine, enabling improved antialiased drawing. In case of performance regressions, the old code path can be enabled by setting the window's surface type to QSurface::OpenGLSurface. Task-number: QTBUG-35271 Change-Id: Ia300b9a5edf8dc0b4bfb99d84ed3c23a8523c267 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* ios: Add support for QOpenGLWidget and QQuickWidgetLaszlo Agocs2015-05-071-7/+102
| | | | | | | | | | | | The global shared context is now always enabled on iOS. This means that contexts used by QOpenGLWindow/Widget and QQuickWindow/Widget and the iOS backingstore will share with each other. [ChangeLog][QtGui] QOpenGLWidget and QQuickWidget are now supported on iOS. Task-number: QTBUG-40034 Change-Id: Ibfb99ffcb18f8f8d263662fbf237bc348fc730ee Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* Fixed license headersJani Heikkinen2015-02-171-1/+1
| | | | | Change-Id: Ibebe1318d1c2de97601aa07269705c87737083ee Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-22/+14
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* iOS: Keep size and device pixel ratio of QIOSBackingStore in sync with windowTor Arne Vestbø2015-02-021-9/+7
| | | | | | | | | | We were only doing this for the size, which caused problems when moving a window from one screen to another where the two screens had different device pixel ratios. Change-Id: If56df34677417369639ee8e4df05820fddd9198d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
* iOS: Don't warn about QBackingStore::resize() != window.size() for widgetsTor Arne Vestbø2013-11-251-1/+1
| | | | | | | | | | | QtWidgets uses stale geometry data to do its backingstore resizes in a lot of places, eg QWidgetPrivate::setGeometry_sys() and show_sys(). As the resize doesn't have any effect for our GL backingstore anyways we can skip the warning to keep console noise down. Change-Id: Ie578f7faf35985708fddd0bfca4a7080820192c5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* iOS: Allow QBackingStore::flush() without beginPaint()Tor Arne Vestbø2013-11-221-3/+5
| | | | | | | | | The QBackingStore API doesn't require clients to precede flush() with a beginPaint() call, but our backingstore is backed by a GL context, so it's up to us to ensure it's current before swapping. Change-Id: Ia6119bf0e835448b1fd383d933df6f88fa4f298a Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* remove unnecessary beginPaint and endPaint overridesShawn Rutledge2013-09-161-6/+0
| | | | | | | | | | | | | QPlatformBackingStore::endPaint does not take a QRegion parameter. 6ce6b8a378b0d97ba950240ffb048a4b7e485235 set the API, but the platform implementations were not all synced up since then. There was anyway no point in overriding beginPaint and endPaint on platforms which don't need to do anything there. This fixes clang warnings of the form QXcbBackingStore::endPaint hides overloaded virtual function Change-Id: Id6cd0fc2c831a34576ac2c73eeb0d5741d26e622 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* iOS: Don't resize backing store twice in beginPaint()Tor Arne Vestbø2013-04-291-1/+0
| | | | | | | The first call to resize() was a left-over from before we had retina-support. Change-Id: I637e8d40f443f81fe7cfc367650bb28b917da2bc Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: QIOSBackingStore: enable FBO depth and stencil bufferRichard Moe Gustavsen2013-04-191-1/+5
| | | | | | | | | | | | | | Unless we enable those buffers for the FBO that backs the backingstore, setting a clip region on an associated QPainter will not work. One apparent bug from this was the menubar. Without this patch it appeared to never be drawn. The reason was that we ended up drawing the menubar background over the whole menubar instead of inside the clip region. Change-Id: I25660cec6ce9e43fe4cd693127dca6afeb8dcf65 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
* iOS: Skip flushing child windows in QIOSBackingStoreRichard Moe Gustavsen2013-02-271-0/+7
| | | | | | | | | | | | We skip flushing raster-based child windows, to avoid the extra cost of copying from the parent FBO into the child FBO. Since the child is already drawn inside the parent FBO, it will become visible when flushing the parent. The only case we end up not supporting is if the child window overlaps a sibling window that's draws using a separate QOpenGLContext. Change-Id: Ib10414f4494747e5fe67f84b06575fe16ffddf96 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: Retina display support.Morten Johan Sorvig2013-02-271-2/+8
| | | | | | | | Scale the OpenGL paint device size and physical dpi by the device pixel ratio. Change-Id: I8b576f23129aafc47371795151c548663e94ad52 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: Keep QIOSBackingStore's paint device size in sync with the windowTor Arne Vestbø2013-02-271-5/+11
| | | | | | | | | | | | | Treating the paint-device as a thing wrapper around the OpenGL paint engine failed when the window was resized, as the paint engine would clip the drawing to the old size. We need to update the size in beginPaint. QBackingStore resize still behaves like before, and we emit a warning if the user tries to resize the backing-store to some other size than the window size, as that's not a supported use-case for our iOS backing store. Change-Id: I1a0eeb65fa9db8b5538dc69963d6fc84be6e63f1 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: Create QIOSBackingStore paint device lazily in paintDevice()Tor Arne Vestbø2013-02-271-2/+3
| | | | | | | Instead of constructor. Change-Id: I98cddd3f39add3e6f787c858b4d629325cc0f852 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: Don't recreate paint device on beginPaint()Morten Johan Sørvig2013-02-271-3/+3
| | | | | | | | | This causes painting errors. Use one lazily-created device that is used for the lifetime of the backing store. Change-Id: Ib36b6f1d6c9f958304dc8403cf17e5d71136469a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
* iOS: Implement QIOSBackingStore in terms of a QOpenGLPaintDeviceTor Arne Vestbø2013-02-271-91/+56
| | | | | | | | | | | | | | | | We build on top of the QPlatformOpenGLContext implementation to get automatic support for QBackingStore-based painting. Since the OpenGL renderer does not clear the backingstore between frames, we actually also get support for partial updates, and we get the benefit of an accelerated paint engine for Qt Quick 1 without setting a GLWidget as the viewport, which would cause issues such as an extra QWindow. This patch also removes the dependency to QtOpenGL and QtWidgets, which were leftovers from the Qt4 platform plugin. In Qt5 the needed GL bits are in QtGui. Change-Id: Id9b736bfb2e4aec56c0fa9f5b7b4d8bff8e3d1dc Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: Implement QPlatformOpenGLContextTor Arne Vestbø2013-02-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The iOS platform GL context is an EAGLContext, which is wrapped by the new class QIOSContext. The class takes care of makeCurrent() and swapBuffers(), but defers framebuffer management to the corresponding QIOSWindow. At the moment only a single framebuffer is created, and changing the geometry of the QWindow does not trigger any sort of invalidation of the buffers. The implementation assumes OpenGL ES2.x support. Though strictly speaking we could support ES1 for QtGui, it serves little purpose as Qt Quick 2 requires ES2. This patch also disabled touch event synthesization until we have figured out where we will maintain the connection to UIWindow. QPlatformOpenGLContext::getProcAddress() for getting extensions is implemented by using dlsym() to look up the symbol. This should not present any issues for App Store deployment, like dlopen() would. Change-Id: I166f800f3ecc0d180133c590465371ac1642b0ec Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: Change member variable style to be consistent with Qt's de facto standardTor Arne Vestbø2013-02-271-6/+6
| | | | | Change-Id: Idd65ad9cbb77114466c5b69a799b98a7fee5068f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
* iOS: copy brute-force port of Qt4 uikit plugin into Qt5.Richard Moe Gustavsen2013-02-261-0/+139
The plugin has been renamed from uikit to ios. Other than that, the plugin will now build, but do nothing. Most of the Qt4 code is preserved, with a rough translation into the Qt5 qpa API. A lot of code has simply been commented out so far, and most lacking at the moment is the event dispatcher which will need to be rewritten, and the opengl paint device implementation. But it should suffice as a starting ground. Also: The plugin will currently not automatically build when building Qt, this needs to be enabled from configure first. Change-Id: I0d229a453a8477618e06554655bffc5505203b44 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>