41 if (m_rhi || m_cpuOnly)
44 const QPlatformIntegration *qpa = QGuiApplicationPrivate::platformIntegration();
46 if (qpa && qpa->hasCapability(QPlatformIntegration::RhiBasedRendering)) {
49 if (canUseRhiImpl(QRhi::Metal, backend)) {
50 QRhiMetalInitParams params;
51 m_rhi.reset(QRhi::create(QRhi::Metal, ¶ms));
56 if (!m_rhi && canUseRhiImpl(QRhi::D3D11, backend)) {
57 QRhiD3D11InitParams params;
58 m_rhi.reset(QRhi::create(QRhi::D3D11, ¶ms));
63 if (!m_rhi && canUseRhiImpl(QRhi::OpenGLES2, backend)) {
64 if (openGLCapsSupported(*qpa)) {
66 m_fallbackSurface.reset(QRhiGles2InitParams::newFallbackSurface());
67 QRhiGles2InitParams params;
68 params.fallbackSurface = m_fallbackSurface.get();
69 m_rhi.reset(QRhi::create(QRhi::OpenGLES2, ¶ms));
71# if defined(Q_OS_ANDROID)
74 if (!m_appStateChangedConnection) {
75 if (!m_eventsReceiver)
76 m_eventsReceiver = std::make_unique<QObject>();
78 auto onStateChanged = [
this](
auto state) {
79 if (state == Qt::ApplicationSuspended)
83 m_appStateChangedConnection =
84 QObject::connect(qApp, &QGuiApplication::applicationStateChanged,
85 m_eventsReceiver.get(), onStateChanged);
95 qWarning() << Q_FUNC_INFO <<
": No RHI backend. Using CPU conversion.";
111 const QRhi::Implementation reference)
114 if (reference != QRhi::Null)
115 return implementation == reference;
118 if (s_preferredBackend != QRhi::Null)
119 return implementation == s_preferredBackend;