29 if (m_rhi || m_cpuOnly)
32 QRhi::Implementation referenceBackend = referenceRhi ? referenceRhi->backend() : QRhi::Null;
33 const QPlatformIntegration *qpa = QGuiApplicationPrivate::platformIntegration();
35 if (qpa && qpa->hasCapability(QPlatformIntegration::RhiBasedRendering)) {
38 if (referenceBackend == QRhi::Metal || referenceBackend == QRhi::Null) {
39 QRhiMetalInitParams params;
40 m_rhi.reset(QRhi::create(QRhi::Metal, ¶ms));
45 if (referenceBackend == QRhi::D3D11 || referenceBackend == QRhi::Null) {
46 QRhiD3D11InitParams params;
47 m_rhi.reset(QRhi::create(QRhi::D3D11, ¶ms));
52 if (!m_rhi && (referenceBackend == QRhi::OpenGLES2 || referenceBackend == QRhi::Null)) {
53 if (qpa->hasCapability(QPlatformIntegration::OpenGL)
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.";