Skip to content

Commit 410fe79

Browse files
committed
Fix remote decoration drawing on OpenGL
On Qt 6.8 enabling the "decorate target" button doesn't do anything. If we have to inject custom GL commands, we have to inform QtQuick that we're doing so, so wrap our after-rendering screengrab and overlay drawing in the appropriate calls. Also, apparently can only be done while a pass is being recorded, so switch the connect() from afterRendering (pass has been recorded and finished, but not submitted) to afterRenderPassRecording (QQ2 has drawn itself but the pass is still active).
1 parent 9ced559 commit 410fe79

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

plugins/quickinspector/quickscreengrabber.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,18 @@ OpenGLScreenGrabber::OpenGLScreenGrabber(QQuickWindow *window)
567567
// Force DirectConnection else Auto lead to Queued which is not good.
568568
connect(m_window.data(), &QQuickWindow::afterSynchronizing,
569569
this, &OpenGLScreenGrabber::windowAfterSynchronizing, Qt::DirectConnection);
570-
connect(m_window.data(), &QQuickWindow::afterRendering,
571-
this, &OpenGLScreenGrabber::windowAfterRendering, Qt::DirectConnection);
570+
571+
connect(
572+
m_window.data(),
573+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
574+
&QQuickWindow::afterRenderPassRecording,
575+
#else
576+
&QQuickWindow::afterRendering,
577+
#endif
578+
this,
579+
&OpenGLScreenGrabber::windowAfterRendering,
580+
Qt::DirectConnection
581+
);
572582
}
573583

574584
OpenGLScreenGrabber::~OpenGLScreenGrabber() = default;
@@ -609,6 +619,10 @@ void OpenGLScreenGrabber::windowAfterRendering()
609619
// And the gui thread is NOT locked
610620
Q_ASSERT(QOpenGLContext::currentContext() == m_window->rendererInterface()->getResource(m_window, QSGRendererInterface::OpenGLContextResource));
611621

622+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
623+
m_window->beginExternalCommands();
624+
#endif
625+
612626
if (m_isGrabbing) {
613627
const auto window = QRectF(QPoint(0, 0), m_renderInfo.windowSize);
614628
const auto intersect = m_userViewport.isValid() ? window.intersected(m_userViewport) : window;
@@ -695,6 +709,10 @@ void OpenGLScreenGrabber::windowAfterRendering()
695709
} else {
696710
emit sceneChanged();
697711
}
712+
713+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
714+
m_window->endExternalCommands();
715+
#endif
698716
}
699717

700718
void OpenGLScreenGrabber::drawDecorations()

0 commit comments

Comments
 (0)