From 410fe7928358c5972e816f276e05e880f22bf1bd Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 17 Jan 2025 12:51:31 +0100 Subject: [PATCH 1/2] 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). --- plugins/quickinspector/quickscreengrabber.cpp | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/plugins/quickinspector/quickscreengrabber.cpp b/plugins/quickinspector/quickscreengrabber.cpp index 57881e3fc..41b816110 100644 --- a/plugins/quickinspector/quickscreengrabber.cpp +++ b/plugins/quickinspector/quickscreengrabber.cpp @@ -567,8 +567,18 @@ OpenGLScreenGrabber::OpenGLScreenGrabber(QQuickWindow *window) // Force DirectConnection else Auto lead to Queued which is not good. connect(m_window.data(), &QQuickWindow::afterSynchronizing, this, &OpenGLScreenGrabber::windowAfterSynchronizing, Qt::DirectConnection); - connect(m_window.data(), &QQuickWindow::afterRendering, - this, &OpenGLScreenGrabber::windowAfterRendering, Qt::DirectConnection); + + connect( + m_window.data(), +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + &QQuickWindow::afterRenderPassRecording, +#else + &QQuickWindow::afterRendering, +#endif + this, + &OpenGLScreenGrabber::windowAfterRendering, + Qt::DirectConnection + ); } OpenGLScreenGrabber::~OpenGLScreenGrabber() = default; @@ -609,6 +619,10 @@ void OpenGLScreenGrabber::windowAfterRendering() // And the gui thread is NOT locked Q_ASSERT(QOpenGLContext::currentContext() == m_window->rendererInterface()->getResource(m_window, QSGRendererInterface::OpenGLContextResource)); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + m_window->beginExternalCommands(); +#endif + if (m_isGrabbing) { const auto window = QRectF(QPoint(0, 0), m_renderInfo.windowSize); const auto intersect = m_userViewport.isValid() ? window.intersected(m_userViewport) : window; @@ -695,6 +709,10 @@ void OpenGLScreenGrabber::windowAfterRendering() } else { emit sceneChanged(); } + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + m_window->endExternalCommands(); +#endif } void OpenGLScreenGrabber::drawDecorations() From 139e5b1b89cbad77f12bf4f4dcd095e901c4e6c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:50:44 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- plugins/quickinspector/quickscreengrabber.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/quickinspector/quickscreengrabber.cpp b/plugins/quickinspector/quickscreengrabber.cpp index 41b816110..b4825c155 100644 --- a/plugins/quickinspector/quickscreengrabber.cpp +++ b/plugins/quickinspector/quickscreengrabber.cpp @@ -577,8 +577,7 @@ OpenGLScreenGrabber::OpenGLScreenGrabber(QQuickWindow *window) #endif this, &OpenGLScreenGrabber::windowAfterRendering, - Qt::DirectConnection - ); + Qt::DirectConnection); } OpenGLScreenGrabber::~OpenGLScreenGrabber() = default;