summaryrefslogtreecommitdiffstats
path: root/src/openglwidgets
Commit message (Collapse)AuthorAgeFilesLines
* Long live [[nodiscard]] QFile::openGiuseppe D'Angelo2024-04-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having already caught some bugs in real code because of unchecked calls to QFile::open, this commit marks QFile::open (and open() in other file-I/O classes) as [[nodiscard]]. Since it's going to raise warnings, the plan is to keep the existing behavior up to and including the next LTS. Then the warnings will switch on by default. All of this is protected by system of macros to opt-in or opt-out the behavioral change at any time. A possible counter-argument for doing this is that QFile::open is also used for opening files in the the resource system, and that opening "cannot fail". It clearly can, if the resource is moved away or renamed; code should at a minimum use a Q_ASSERT in debug builds. Another counter-argument is the opening of file handles or descriptors; but again, that opening may fail in case the handle has been closed or if the flags are incompatible. --- Why not marking *every* open() override? Because some are not meant to be called directly -- for instance sockets are supposed to be open via calls to `connectToHost` or similar. One notable exception is QIODevice::open() itself. Although rarely called directly by user code (which just calls open() on a specific subclass, which likely has an override), it may be called: 1) By code that just takes a `QIODevice *` and does something with it. That code is arguably more rare than code using QFile directly. Still, being "generic" code, they have an extra responsibility when making sure to handle a possible opening failure. 2) By QIODevice subclasses, which are even more rare. However, they usually ignore the return from QIODevice::open() as it's unconditionally true. (QIODevice::open() doesn't use the protected virtual pattern.) I'll try and tackle QIODevice in a future commit. [ChangeLog][QtCore][QFileDevice] The open() functions of file-related I/O classes (such as QFile, QSaveFile, QTemporaryFile) can now be marked with the "nodiscard" attribute, in order to prevent a category of bugs where the return value of open() is not checked and the file is then used. In order to avoid warnings in existing code, the marking can be opted in or out, by defining QT_USE_NODISCARD_FILE_OPEN or the QT_NO_USE_NODISCARD_FILE_OPEN macros. By default, Qt will automatically enable nodiscard on these functions starting from Qt 6.10. Change-Id: Ied940e1c0a37344f5200b2c51b05cd1afcb2557d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix offscreen rendering in QOpenGLWidgetInho Lee2024-03-071-3/+5
| | | | | | | | | | | | | Amends 68a4c5da9a080101cccd8a3b2edb1c908da0ca8e In a case sharing QOpenGLContext, offscreen renderings cannot get QOpenGLContext from Rhi. Fixes: QTBUG-123005 Pick-to: 6.7 6.6 6.5 Change-Id: I9baae5e5c77878885f73ee39df5cd39117e8f1c2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Mention QChronoTimer in API docsAhmad Samir2024-03-031-1/+1
| | | | | Change-Id: Iaf9fb31994f1580b2051dbd0b1b8eef2a218aa39 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QWidgetPrivate::rhi() helper methodTor Arne Vestbø2024-03-011-9/+4
| | | | | | | | For accessing the RHI managed by the widget compositing machinery. Pick-to: 6.7 6.6 6.5 Change-Id: Ia3c1227cc2d9cfebe95611cad3dbcd7aa6f6f8c7 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QOpenGLWidget: Call glClear in the default paintGL implementationLaszlo Agocs2023-09-041-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends 8cc8bbb466fb871585bfa1d5c56fc8bc6d6c8a96. With the referenced patch framebuffer invalidation is preferred over clearing with a wider range of OpenGL implementations. This is good and is in line with the documentation. If an existing application does not do glClear() in their reimplemented paintGL(), that we cannot fix, and the docs never actually promised that a glClear() is done automatically. However, there is a special case: when one does not reimplement paintGL(). A QOpenGLWidget is expected to be usable without reimplementing any of its virtuals (i.e., QOpenGLWidget is constructible as-is without subclassing). It is then ideal if this does not lead to showing rendering artifacts due to having potentially random content in the (invalidated, not cleared) color buffer. This problem was never encountered before due to hitting the invalidate-instead-of-clear code path on a limited set of platforms (like with OpenGL ES) only. Do a glClear() in paintGL(). This won't effect the vast majority of applications, that reimplement this function, but plays nice for when it is not. It is in fact also in line with Qt 4's QGLWidget: that also used to do a glClear() in the default paintGL() implementation. Change-Id: I117ce1d3340f6d4d82cde1f52769a3b13ce367fb Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Enable QWidget::grab() with QRhiWidget in the widget treeLaszlo Agocs2023-08-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | This involves reimplementing QWidgetPrivate::grabFramebuffer(). Widgets call this function whenever a texture-based widget is encountered. This implies however that we rename QRhiWidget's own, lightweight grab function, grab(), because it kind of shadows QWidget's grab(). Switch back to grabFramebuffer() which is what QQuickWidget and QOpenGLWidget both use. Supporting QWidget::grab() is particularly important when grabbing an ancestor of the QRhiWidget, because that has no alternative. Right now, due to not reimplementing the QWidgetPrivate function, the place of the QRhiWidget is left empty. In addition, grabFramebuffer() is now const. This is consistent with QQuickWidget, but not with QOpenGLWidget and QOpenGLWindow. Change-Id: I646bd920dab7ba50415dd7ee6b63a209f5673e8f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QOpenGLWidget: invalidate the depth/stencil after renderingGiuseppe D'Angelo2023-07-261-18/+39
| | | | | | | | | We don't need them any more, only the color is used for compositing. In principle this enables a driver to not writeback their contents into main memory. Change-Id: Ibde17af6c14c98ebdca956aaf902dfd728f9219c Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* QOpenGLWidget: use (and prefer) InvalidateFramebufferGiuseppe D'Angelo2023-07-251-4/+3
| | | | | | | | | | | | | | | | | | | | Desktop GL does not have the GL_EXT_discard_framebuffer extension at all. Instead, it may have GL_ARB_invalidate_subdata. Furthermore, GLES >= 3.0 and GL >= 4.3 both support FBO invalidation through glInvalidateFramebuffer. Extend the semantics of OpenGLExtension::DiscardFramebuffer to mean that *any* possibility above is supported, and wrap it in a helper function that calls whatever support is present. (This is all private API anyhow.) Technically speaking glInvalidateFramebuffer supports a superset of what glDiscardFramebufferEXT supports, but we never use such superset, and the two APIs are otherwise identical. Then, make QOpenGLWidget call that wrapper. Change-Id: I64e042daf51493d3834c3ba1b53ae6e224bbc4ed Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Enable QT_NO_CONTEXTLESS_CONNECT for most of QtBaseGiuseppe D'Angelo2023-07-111-0/+1
| | | | | | | | | It's clean now, keep it as such. Enabling it for QtCore is still OK, because it just hides a function template declared in a header. Change-Id: I8e7dfae179732ba04241a6a3258c2d722e8259df Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QOpenGLWidget work with QT_WIDGETS_HIGHDPI_DOWNSCALEMorten Sørvig2023-05-241-8/+2
| | | | | | | | | | Get the DPR from QWidget::metric(), which has a code path for handling the QT_WIDGETS_HIGHDPI_DOWNSCALE case. Fixes: QTBUG-111105 Pick-to: 6.5 Change-Id: I821cbdf00423de211719173ae5c0af7b76594f60 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: Make it a QPA-style private but semi-public APILaszlo Agocs2023-05-211-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qrhi.h, qshader.h, qshaderdescription.h (and qshaderbaker.h from shadertools; done separately) become "RHI APIs", following the concept of QPA APIs. Mirror completely what is done for QPA headers, but using the "rhi" prefix for the headers. This involves updating syncqt to handle the new category of headers. (a note on the regex: matching everything starting with "qrhi" is not acceptable due to incorrectly matching existing and future headers, hence specifying the four header names explicitly) There is going to be one difference to QPA: the documentation for everything RHI is going to be public and part of the regular docs, not hidden with \internal. In addition to the header renaming and adding the comments and documentation notes and warnings, there is one significant change here: there is no longer a need to do API-specific includes, such as qrhid3d11[_p].h, qrhivulkan[_p].h, etc. These are simply merged into a single header that is then included from qrhi.h. This means that users within Qt, and any future applications can just do #include <rhi/qrhi.h> (or rhi/qshader.h if the QRhi stuff is not relevant), no other headers are needed. There are no changes to functionality in this patch. Only the documentation is expanded, quite a lot, to eliminate all qdoc warnings and make the generated API docs complete. An example, with a quite extensive doc page is added as well. Task-number: QTBUG-113331 Change-Id: I91c749826348f14320cb335b1c83e9d1ea2b1d8b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Tune textures example to work with wasm and update docsLaszlo Agocs2023-04-251-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | Old examples inherited from Qt 4 tend to set some state, such as enabling the depth test or culling, in initializeGL(). Newer examples tend not to do this; they rather set the necessary state in paintGL(). This mattered little (or not at all) in the past, but with WebAssembly and WebGL there are limitations in the GL context management in the wasm platform plugin. Under certain conditions, esp. when QOffscreenSurface is involved, it looks like the same native context gets reused, which means there is a chance of unexpected changes to the current state between calls to initializeGL() and paintGL(). (and also between paintGL() calls) See QWasmOpenGLContext for details. Update the textures example the same way we did for the cube one. Add a note to the QOpenGLWidget docs about this problem. Task-number: QTBUG-111304 Pick-to: 6.5 6.4 Change-Id: I29d2b2cdeb07bcecc5dc915d79c12b4323ca9ab3 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Inho Lee <inho.lee@qt.io>
* wasm: QOpenGLWidget: ensure depth write is enabled when calling paintGLLaszlo Agocs2023-04-201-0/+4
| | | | | | | | Task-number: QTBUG-111304 Pick-to: 6.5 6.4 Change-Id: Ibe9f886b12c89fad7431b77b55c259b15d83559b Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QOpenGLWidget: correct the lifetime of the wrapper texture objectsLaszlo Agocs2023-04-181-2/+2
| | | | | | | | | | | | | | | | | If the QOpenGLFramebufferObject (which owns the OpenGL texture object) is destroyed, the wrapper QRhiTexture must be destroyed too. This surfaced with WebAssembly for some reason, likely due to an event (most likely resize) sending pattern that is different from other platforms. Sending more resizes likely triggers another recreateFbos() call which, until now, did not correctly dropped the wrapper QRhiTextures so those continued to refer to the now-destroyed texture IDs. Pick-to: 6.5 6.4 Task-number: QTBUG-111304 Change-Id: Ieed9a11c5c28da0fee497107ebe88da9eb5f45a8 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Add QOpenGLWindow/Widget doc note about depth/stencilLaszlo Agocs2023-03-161-0/+7
| | | | | | | | Pick-to: 6.5 6.2 5.15 Fixes: QTBUG-108050 Change-Id: If011d6efff996870ff23eff3c2d1cf455d31b7a6 Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Doc: fix QOpenGLWidget::defaultFramebufferObject documentationVolker Hilsheimer2023-03-051-7/+5
| | | | | | | | | | | | Fix the link to QSurfaceFormat::StereoBuffers, and clean the text up a bit. If everything is a \note, then we might just as well not have notes, so move the statement about when this function is useful out of a note, and combine the statements elaborating on ownership and lifetime of framebuffer and contexts into a single note. Pick-to: 6.5 6.5.0 Change-Id: I7cb1f9ff78ba760e99d639550130f5c833ad684a Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Introduce events for Window device pixel ratio changesDavid Edmundson2023-02-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | There is a mix between screen device pixel ratio. Currently we store the property on a per-window basis, but the change notifications are still on a per screen basis which can fall apart on edge cases. On wayland we are getting per window DPR changes without as useful screen change events so it's important to fix. It also has potential to clean up the Windows backend in the future where the backend is currently papering over the two concepts. This patch introduces two new events: A QWindowSystemInterface to trigger a window DPR change independently of a screen change. An event to notify windows the new DPR rather than needing to track signals on the screen. This happens either when the window dpr changes or implicitly through a screen change. This can deprecate an existing event ScreenChangeInternal so the value is reused and renamed for clarity. Change-Id: I637a07fd4520ba3184ccc2c987c29d8d23a65ad3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* src: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-101-2/+0
| | | | | | Pick-to: 6.5 Change-Id: Id644d322a602038403bb7f46c532744575fbf6d3 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Add missing underlying type and Q_ENUM to QOpenGLWidget enumsKristoffer Skau2023-01-261-1/+3
| | | | | | | | | The enums are QOpenGLWidget::UpdateBehavior and QOpenGLWidget::TargetBuffer. The latter is a new addition to 6.5. Pick-to: 6.5 Change-Id: I9e73413a944bf4b55e8e308055d79e560ac8668d Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Support stereoscopic rendering with QGraphicsViewKristoffer Skau2022-12-012-18/+79
| | | | | | | | | | | | | | | | This patch adds a manual test and the required work in graphicsview and qwidget private apis to support stereoscopic rendeing. Basically it works by doing the drawing in QGraphicsView::paintEvent twice, once for each buffer. This way the scene items are rendered to both buffers. There's also an update to resolvement in QOpenGLWidgetPrivate so that multisampling works correctly. [ChangeLog][Widgets][QGraphicsView] Added support for stereoscopic rendering. Task-number: QTBUG-64587 Change-Id: I20650682daa805b64fe7f0d2ba086917d3f12229 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Add support for stereoscopic content in QOpenGLWidgetKristoffer Skau2022-11-282-59/+246
| | | | | | | | | | | | | | | | | Need to add the plumbing necessary to support two textures in QOpenGLWidget and use these in the backing store. The changes required on the RHI level is already done in an earlier patch. Then paintGL() needs to be called twice, once for each buffer. Also add overloads for the other functions of QOopenGLWidget where it makes sense to query for left or right buffer. Then finally create an example. [ChangeLog][Widgets][QOpenGLWidget] Added support for stereoscopic rendering. Fixes: QTBUG-64587 Change-Id: I5a5c53506dcf8a56442097290dceb7eb730d50ce Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Fix rhi flush eval perf. and native window problemsLaszlo Agocs2022-11-141-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This effectively reverts a4a51f6a641f4bf0a863251d6d3e026d81de6280 while solving the problem that change intended to fix by an alternative approach: Swap the order of checks for rhi-based flushing. Checking the widgets' wishes first was a mistake. We should first check what is forced, e.g. via the env.vars. Then only move on investigating the child widget hierarchy if there was nothing specific requested. This way having a QOpenGLWidget in a window and running with QT_WIDGETS_RHI=1 QT_WIDGETS_RHI_BACKEND=vulkan will prioritize the forced request (Vulkan) and so the QOpenGLWidget will gracefully not render anything while printing the expected warning to tell what's going on. The expensive recursion plaguing the construction of larger widget hierarchies is now avoided, that should no longer take seconds due to walking the entire widget hierarchy of the top-level window every time a new widget is added to it. However, this then uncovered a set of problems concerning native child widgets. The repaint manager seems to have an obvious mistake where the usage of rhi (and so textures and whatnot) is decided based on 'widget' (which is either a top-level or a native child) instead of 'tlw' (which is the top-level with the backingstore). The usesRhiFlush flag only really matters for a real top-level, not for native child widgets. The rhi-based flushing is tied to the backingstore, and the backingstore comes from the top-level widget. Finally, make the qopenglwidget autotest to actually exercise something when it comes to QOpenGLWidgets (or their ancestors) turned native. The original code from a long time ago does not really test native child widgets, because it turns the top-level into native which is quite superfluous since the toplevel is backed by a native window (and a backingstore) anyway. Pick-to: 6.4 Task-number: QTBUG-105017 Fixes: QTBUG-108344 Fixes: QTBUG-108277 Change-Id: I1785b0ca627cf151aad06a5489f63874d787f087 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-031-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-2/+2
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QOpenGLWidget: Fix a typo in the public documentationLaszlo Papp2022-05-271-1/+1
| | | | | Change-Id: I964f5c6a8901bf93e5e3a5afb33cb456217caf39 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make sure the correct context is current when invoking resizeGLLaszlo Agocs2022-05-241-0/+3
| | | | | | | | | | | | | | | After the 6.4 changes for QRhi-based compositing in widgets there is now a good chance that a different context is current after recreateFbo in case it actually created a new texture and fbo. This is not great if we immediately call resizeGL() afterwards since the contract for the reimplementable functions is that the QOpenGLWidget's context is current. Make sure this contract is followed. Fixes: QTBUG-103319 Change-Id: I59a5fa9500df34b86787927e1114d0a80297678a Reviewed-by: Christian Strømme <christian.stromme@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-163-114/+6
| | | | | | | | | | | | | 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>
* Add missing header files to the module sourcesAlexey Edelev2022-05-121-0/+1
| | | | | | | | | All module header files should be listed in the corresponding sections of modules SOURCEs to be accessible in CMake routines. Task-number: QTBUG-103196 Change-Id: Ieb77ae70557e35e546a5b00387e1e0aa40338239 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Compose render-to-texture widgets through QRhiLaszlo Agocs2022-03-111-87/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix deprecated uses of QScopedPointerMårten Nordheim2022-03-081-2/+2
| | | | | | | | | By changing it to unique_ptr. Pick-to: 6.2 6.3 Change-Id: I91abb69445b537d4c95983ae735341882352b29d Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Migrate to autogenerated cpp exportsAlexey Edelev2021-06-252-14/+2
| | | | | | | | | Replace the hardcoded cpp exports with a generated one where it's applicable. Task-number: QTBUG-90492 Change-Id: Idc160b594987b2c765e75bd669aae851b4366282 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Document QOpenGLWidget limitations without an alpha channelLaszlo Agocs2021-01-151-0/+13
| | | | | | | Pick-to: 6.0 5.15 Task-number: QTBUG-85869 Change-Id: I20fb70a451fc1ed93089ed699539fa12ac38fe73 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-071-13/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Fix missing repaints with QOpenGLWidget in a QDockWidgetLaszlo Agocs2021-01-061-1/+6
| | | | | | | | | | | | | | | | | | When AA_ShareOpenGLContexts is not set, docking or undocking will lead to changing the associated top-level window. This leads to changing the OpenGL context, and tearing down and then recreating all OpenGL resources (assuming a well written application). The problem is, there are no paint events after the Show, meaning the user code's paintGL is often not invoked, which leads to showing an empty QOpenGLWidget until something else triggers a paint event. To remedy this, send a paint event upon Show, which should be harmless enough, while fixing the case of docking/undocking. Pick-to: 6.0 5.15 Fixes: QTBUG-89812 Change-Id: I3c4560f8f069d86645a6314bf7ad1b4ee8e2c716 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Member-initialize QOpenGLWidgetPrivateVolker Hilsheimer2020-11-091-35/+18
| | | | | | | Fix warning about requestedFormat not being initialized in sequence. Change-Id: I7b948cb356b65ea2953424a700eb1a70cd1802f9 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-09-231-1/+1
| | | | | | | | | | | Modify special case locations to use the new API as well. Clean up some stale .prev files that are not needed anymore. Clean up some project files that are not used anymore. Task-number: QTBUG-86815 Change-Id: I9947da921f98686023c6bb053dfcc101851276b5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Port from devicePixelRatioF() to devicePixelRatio()Morten Johan Sørvig2020-09-101-9/+9
| | | | | | | This ports all of QtBase. Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Register QPlatformBackingStoreOpenGLSupport when neededTor Arne Vestbø2020-07-291-0/+3
| | | | | | | | | | | | 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>
* Doc: Change docs from internal to reimpPaul Wicking2020-06-251-4/+4
| | | | | | | Pick-to: 5.15 Fixes: QTBUG-82357 Change-Id: I415ee03dd9d1ac02a435a24fb5ab94bf60c07331 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Docs: Remove lenghty comparison with QGLWidgetJohan Klokkhammer Helsing2020-02-201-62/+6
| | | | | | | | | QGLWidget doesn't exist any more, and has been legacy for a long time, so we shouldn't try to explain what QOpenGLWidget is in terms of QGLWidget any more. Task-number: QTBUG-74409 Change-Id: I87ff6c35dfed1303bd6d74621b244e1ed84ceafe Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Move QOpenGLWidget from QtOpenGL to its own moduleJohan Klokkhammer Helsing2020-02-185-0/+1674
Same pattern as QtQuickWidgets. Gets rid of QtOpenGL's dependency on QtWidgets. Task-number: QTBUG-74409 Change-Id: I4f9b55c23e25a1e0519734037b768a16e870c7d2 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>