From 768b0f2adefffced84aadd4f44b07e8dedbb8f72 Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Mon, 1 Jun 2020 15:44:10 +0300 Subject: Fix build without opengl ifdef code that is not available without opengl. Change-Id: I200e95e4bcf1ee361e84819454eade0bbcbd6669 Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/qsgrhisupport.cpp | 7 ++++++- src/quickwidgets/qquickwidget.cpp | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 44ba2c54c1..c8aa9ef24f 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -701,13 +701,18 @@ QImage QSGRhiSupport::grabOffscreen(QQuickWindow *window) wd->rhi = rhi.data(); +// ### This condition is a temporary workaround to allow compilation +// with -no-opengl, but Vulkan or Metal enabled, to succeed. Full +// support for RHI-capable -no-opengl builds will be available in +// Qt 6 once the direct OpenGL code path gets removed. +#if QT_CONFIG(opengl) QSGDefaultRenderContext::InitParams params; params.rhi = rhi.data(); params.sampleCount = 1; params.initialSurfacePixelSize = pixelSize; params.maybeSurface = window; wd->context->initialize(¶ms); - +#endif // There was no rendercontrol which means a custom render target // should not be set either. Set our own, temporarily. window->setRenderTarget(QQuickRenderTarget::fromRhiRenderTarget(rt.data())); diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 2fccc7208d..0964d6492e 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -378,11 +378,12 @@ void QQuickWidgetPrivate::renderSceneGraph() return; if (!useSoftwareRenderer) { +#if QT_CONFIG(opengl) if (!context) { qWarning("QQuickWidget: Attempted to render scene with no context"); return; } - +#endif Q_ASSERT(offscreenSurface); } @@ -417,7 +418,11 @@ QImage QQuickWidgetPrivate::grabFramebuffer() // prefer the FBO's toImage() if available. When the software renderer // is in use, however, there will be no FBO and we fall back to grabWindow() // instead. - return fbo != nullptr ? fbo->toImage() : offscreenWindow->grabWindow(); + return +#if QT_CONFIG(opengl) + fbo != nullptr ? fbo->toImage() : +#endif + offscreenWindow->grabWindow(); } // Intentionally not overriding the QQuickWindow's focusObject. -- cgit v1.2.3