Add QWidgetPrivate::rhi() helper method
For accessing the RHI managed by the widget compositing machinery. Pick-to: 6.6 6.5 Change-Id: Ia3c1227cc2d9cfebe95611cad3dbcd7aa6f6f8c7 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit f451b01791536fede40c8d4fb90799c2e23e9386) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
0c519efa11
commit
9dbb295279
@ -784,9 +784,7 @@ void QOpenGLWidgetPrivate::ensureRhiDependentResources()
|
|||||||
{
|
{
|
||||||
Q_Q(QOpenGLWidget);
|
Q_Q(QOpenGLWidget);
|
||||||
|
|
||||||
QRhi *rhi = nullptr;
|
QRhi *rhi = QWidgetPrivate::rhi();
|
||||||
if (QWidgetRepaintManager *repaintManager = QWidgetPrivate::get(q->window())->maybeRepaintManager())
|
|
||||||
rhi = repaintManager->rhi();
|
|
||||||
|
|
||||||
// If there is no rhi, because we are completely offscreen, then there's no wrapperTexture either
|
// If there is no rhi, because we are completely offscreen, then there's no wrapperTexture either
|
||||||
if (rhi && rhi->backend() == QRhi::OpenGLES2) {
|
if (rhi && rhi->backend() == QRhi::OpenGLES2) {
|
||||||
@ -832,7 +830,6 @@ void QOpenGLWidgetPrivate::initialize()
|
|||||||
// If no global shared context get our toplevel's context with which we
|
// If no global shared context get our toplevel's context with which we
|
||||||
// will share in order to make the texture usable by the underlying window's backingstore.
|
// will share in order to make the texture usable by the underlying window's backingstore.
|
||||||
QWidget *tlw = q->window();
|
QWidget *tlw = q->window();
|
||||||
QWidgetPrivate *tlwd = get(tlw);
|
|
||||||
|
|
||||||
// Do not include the sample count. Requesting a multisampled context is not necessary
|
// Do not include the sample count. Requesting a multisampled context is not necessary
|
||||||
// since we render into an FBO, never to an actual surface. What's more, attempting to
|
// since we render into an FBO, never to an actual surface. What's more, attempting to
|
||||||
@ -841,9 +838,7 @@ void QOpenGLWidgetPrivate::initialize()
|
|||||||
requestedSamples = requestedFormat.samples();
|
requestedSamples = requestedFormat.samples();
|
||||||
requestedFormat.setSamples(0);
|
requestedFormat.setSamples(0);
|
||||||
|
|
||||||
QRhi *rhi = nullptr;
|
QRhi *rhi = QWidgetPrivate::rhi();
|
||||||
if (QWidgetRepaintManager *repaintManager = tlwd->maybeRepaintManager())
|
|
||||||
rhi = repaintManager->rhi();
|
|
||||||
|
|
||||||
// Could be that something else already initialized the window with some
|
// Could be that something else already initialized the window with some
|
||||||
// other graphics API for the QRhi, that's not good.
|
// other graphics API for the QRhi, that's not good.
|
||||||
@ -1718,8 +1713,8 @@ bool QOpenGLWidget::event(QEvent *e)
|
|||||||
if (!QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts))
|
if (!QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts))
|
||||||
d->reset();
|
d->reset();
|
||||||
}
|
}
|
||||||
if (QWidgetRepaintManager *repaintManager = QWidgetPrivate::get(window())->maybeRepaintManager()) {
|
if (d->rhi()) {
|
||||||
if (!d->initialized && !size().isEmpty() && repaintManager->rhi()) {
|
if (!d->initialized && !size().isEmpty()) {
|
||||||
d->initialize();
|
d->initialize();
|
||||||
if (d->initialized) {
|
if (d->initialized) {
|
||||||
d->recreateFbos();
|
d->recreateFbos();
|
||||||
|
@ -475,14 +475,7 @@ void QRhiWidgetPrivate::releaseResources()
|
|||||||
void QRhiWidgetPrivate::ensureRhi()
|
void QRhiWidgetPrivate::ensureRhi()
|
||||||
{
|
{
|
||||||
Q_Q(QRhiWidget);
|
Q_Q(QRhiWidget);
|
||||||
// the QRhi and infrastructure belongs to the top-level widget, not to this widget
|
QRhi *currentRhi = QWidgetPrivate::rhi();
|
||||||
QWidget *tlw = q->window();
|
|
||||||
QWidgetPrivate *wd = get(tlw);
|
|
||||||
|
|
||||||
QRhi *currentRhi = nullptr;
|
|
||||||
if (QWidgetRepaintManager *repaintManager = wd->maybeRepaintManager())
|
|
||||||
currentRhi = repaintManager->rhi();
|
|
||||||
|
|
||||||
if (currentRhi && currentRhi->backend() != QBackingStoreRhiSupport::apiToRhiBackend(config.api())) {
|
if (currentRhi && currentRhi->backend() != QBackingStoreRhiSupport::apiToRhiBackend(config.api())) {
|
||||||
qWarning("The top-level window is already using another graphics API for composition, "
|
qWarning("The top-level window is already using another graphics API for composition, "
|
||||||
"'%s' is not compatible with this widget",
|
"'%s' is not compatible with this widget",
|
||||||
|
@ -1029,6 +1029,14 @@ void QWidgetPrivate::createRecursively()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRhi *QWidgetPrivate::rhi() const
|
||||||
|
{
|
||||||
|
if (QWidgetRepaintManager *repaintManager = maybeRepaintManager())
|
||||||
|
return repaintManager->rhi();
|
||||||
|
else
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
Returns the closest parent widget that has a QWindow window handle
|
Returns the closest parent widget that has a QWindow window handle
|
||||||
|
@ -221,6 +221,8 @@ public:
|
|||||||
void setSharedPainter(QPainter *painter);
|
void setSharedPainter(QPainter *painter);
|
||||||
QWidgetRepaintManager *maybeRepaintManager() const;
|
QWidgetRepaintManager *maybeRepaintManager() const;
|
||||||
|
|
||||||
|
QRhi *rhi() const;
|
||||||
|
|
||||||
enum class WindowHandleMode {
|
enum class WindowHandleMode {
|
||||||
Direct,
|
Direct,
|
||||||
Closest,
|
Closest,
|
||||||
|
@ -155,14 +155,7 @@ QPlatformBackingStoreRhiConfig QRhiWidgetPrivate::rhiConfig() const
|
|||||||
void QRhiWidgetPrivate::ensureRhi()
|
void QRhiWidgetPrivate::ensureRhi()
|
||||||
{
|
{
|
||||||
Q_Q(QRhiWidget);
|
Q_Q(QRhiWidget);
|
||||||
// the QRhi and infrastructure belongs to the top-level widget, not to this widget
|
QRhi *currentRhi = QWidgetPrivate::rhi();
|
||||||
QWidget *tlw = q->window();
|
|
||||||
QWidgetPrivate *wd = get(tlw);
|
|
||||||
|
|
||||||
QRhi *currentRhi = nullptr;
|
|
||||||
if (QWidgetRepaintManager *repaintManager = wd->maybeRepaintManager())
|
|
||||||
currentRhi = repaintManager->rhi();
|
|
||||||
|
|
||||||
if (currentRhi && currentRhi->backend() != QBackingStoreRhiSupport::apiToRhiBackend(config.api())) {
|
if (currentRhi && currentRhi->backend() != QBackingStoreRhiSupport::apiToRhiBackend(config.api())) {
|
||||||
qWarning("The top-level window is already using another graphics API for composition, "
|
qWarning("The top-level window is already using another graphics API for composition, "
|
||||||
"'%s' is not compatible with this widget",
|
"'%s' is not compatible with this widget",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user