Commit Graph

11 Commits (2fb8c2d5c331b1bc30a54e803e1cd17cf534fc32)

Author SHA1 Message Date
Paul Wicking 2fb8c2d5c3 Doc: Use QDOC_PROPERTY for QRhiWidget::autoRenderTarget
`autoRenderTarget` is a private bool that very much looks like it's
used as a Q_PROPERTY. Use QDOC_PROPERTY for it to generate warning-
free documentation.

Pick-to: 6.7
Change-Id: Ia6255287f139ff23172c4fac96950e1a37eeef83
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2024-02-26 18:59:02 +01:00
Lucie Gérard 039d51835f Correct license in widget/kernel
According to QUIP-18 [1], all module files should be
LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
or
LicenseRef-Qt-Commercial OR GPL-3.0-only
LGPD and non-LGPL licenses should not be mixed in a
given directory.
The files in this patch now match the other files
in the same directory and QUIP-18 rule.

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: Ied60c775fbae38d6edeabc669f782b39d02c28f4
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-02-15 21:34:59 +01:00
Tor Arne Vestbø 986f8b361c QRhiWidget: Register cleanup callback also on first RHI init
The first time ensureRhi() is called we don't have an RHI yet, and will
adopt the top level's repaint manager's RHI. We need to register a
cleanup callback for this RHI, so that if it goes away, we will
reset our RHI pointer to null, just like when we switch from one top
level to another (and get a new potential RHI).

Without the reset, we would be working with a stale QRhi pointer,
which we in most cases updated via a call to ensureRhi(), that
picked up the new QRhi, but for good measure we should reset it
if we can.

Pick-to: 6.7
Change-Id: Iac6d8787b636675bbcb4358e8f0baad26187b0e2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2024-02-14 18:51:29 +01:00
Tor Arne Vestbø 6fbbbef260 QRhiWidget: Tear down resources before window has changed
We were handling QEvent::WindowChangeInternal, but based on what the
code is doing, what the comments say, and what QQuickWidget does,
the right event should be WindowAboutToChangeInternal.

This fixes a crash when reparenting a QRhiWidget into another widget,
where we could call removeCleanupCallback() on an RHI that was already
gone.

The fact that we have a stale RHI pointer at WindowChangeInternal time
is still problematic, and caused by our call to addCleanupCallback not
happening as it should for the first call to ensureRhi(), but this will
be fixed in a follow up.

Pick-to: 6.7
Change-Id: I054120e97a24a1f74af44b2d251470792f03f7f3
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2024-02-14 18:51:29 +01:00
Laszlo Agocs 80e7bcd368 Do more QRhiWidget cleanups based on API review
Pick-to: 6.7
Change-Id: I339fb2ac2546b9d7b4b88cba89191e7a4311017f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-01-22 20:40:19 +01:00
Laszlo Agocs acebb97b58 Update QRhiWidget API based on review comments
Spell out some API names in enum.

Some functions are now protected.

Remove property for autoRenderTarget.

textureFormat -> colorBufferFormat.

Used "fixed" instead of "explicit" and follow
the above naming, so that explicitSize becomes
fixedColorBufferSize.

Pick-to: 6.7
Change-Id: I2fd6ad46033313a3febbb8846146021d5dd11010
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-01-18 12:48:03 +01:00
Topi Reinio c46551e203 Doc: Fix documentation issues
Fix the following QDoc warnings:

* warning: Can't link to 'QRhiWidget::sampleConut'
* warning: Can't link to '`Q_NODISCARD_CTOR'
* warning: Invalid '\relates' (already a member of 'QEventLoopLocker')
* warning: Unknown command '\relatesalso'
* warning: Undocumented parameter 'separator' in QLocale::name()
* warning: clang couldn't find function when parsing \fn void QRhiWidget::framePresented()

In QAtomicPointer, work around the issue of QDoc not supporting
multiple \relates command for a single topic by adding a see-also
link to the global qYieldCpu() function.

Document the qvariant_cast() overload taking an rvalue reference.

Change-Id: I2528eee666149a97a14be059bbed537636d7aa0d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-11 15:56:10 +00:00
Laszlo Agocs 80520c2f52 Enable QWidget::grab() with QRhiWidget in the widget tree
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>
2023-08-28 21:14:28 +02:00
Laszlo Agocs 735a864360 QRhiWidget: Use QRhiRenderTarget as the return type for renderTarget
There is no point in using the more specialized derived class
(QRhiTextureRenderTarget), even though that is what the rt always is.

None of the example and test code needs changes since relying on
QRhiTextureRenderTarget specifics is very rare in practice (now it will
need a static_cast), whereas in the majority of cases the return value
is passed on to other functions, for example, beginPass(), that take
a QRhiRenderTarget.

Change-Id: Ifaebb6320a156ec6a9013e72fede04e520aa9aaf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-28 14:10:02 +02:00
Laszlo Agocs e73d0ffb4c Clean up and fix some things in QRhiWidget doc
Change-Id: Ib941a15e0e051b17dd84c0c59792bfa3da89be03
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2023-08-15 17:04:35 +02:00
Laszlo Agocs 72a453c6a8 Add QRhiWidget
Task-number: QTBUG-113331
Change-Id: I8baa697b4997b05f52acdee0e08d3c368fde5bc2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-14 17:05:36 +02:00