28 if (m_rhi || m_cpuOnly)
31 QRhi::Implementation referenceBackend = referenceRhi ? referenceRhi->backend() : QRhi::Null;
32 const QPlatformIntegration *qpa = QGuiApplicationPrivate::platformIntegration();
34 if (qpa && qpa->hasCapability(QPlatformIntegration::RhiBasedRendering)) {
37 if (referenceBackend == QRhi::Metal || referenceBackend == QRhi::Null) {
38 QRhiMetalInitParams params;
39 m_rhi.reset(QRhi::create(QRhi::Metal, ¶ms));
44 if (referenceBackend == QRhi::D3D11 || referenceBackend == QRhi::Null) {
45 QRhiD3D11InitParams params;
46 m_rhi.reset(QRhi::create(QRhi::D3D11, ¶ms));
51 if (!m_rhi && (referenceBackend == QRhi::OpenGLES2 || referenceBackend == QRhi::Null)) {
52 if (qpa->hasCapability(QPlatformIntegration::OpenGL)
53 && qpa->hasCapability(QPlatformIntegration::RasterGLSurface)
54 && !QCoreApplication::testAttribute(Qt::AA_ForceRasterWidgets)) {
56 m_fallbackSurface.reset(QRhiGles2InitParams::newFallbackSurface());
57 QRhiGles2InitParams params;
58 params.fallbackSurface = m_fallbackSurface.get();
59 if (referenceBackend == QRhi::OpenGLES2)
60 params.shareContext =
static_cast<
const QRhiGles2NativeHandles *>(
61 referenceRhi->nativeHandles())
63 m_rhi.reset(QRhi::create(QRhi::OpenGLES2, ¶ms));
65# if defined(Q_OS_ANDROID)
68 if (!m_appStateChangedConnection) {
69 if (!m_eventsReceiver)
70 m_eventsReceiver = std::make_unique<QObject>();
72 auto onStateChanged = [
this](
auto state) {
73 if (state == Qt::ApplicationSuspended)
77 m_appStateChangedConnection =
78 QObject::connect(qApp, &QGuiApplication::applicationStateChanged,
79 m_eventsReceiver.get(), onStateChanged);
89 qWarning() << Q_FUNC_INFO <<
": No RHI backend. Using CPU conversion.";