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 (canUseRhiImpl(QRhi::Metal, referenceBackend)) {
38 QRhiMetalInitParams params;
39 m_rhi.reset(QRhi::create(QRhi::Metal, ¶ms));
44 if (!m_rhi && canUseRhiImpl(QRhi::D3D11, referenceBackend)) {
45 QRhiD3D11InitParams params;
46 m_rhi.reset(QRhi::create(QRhi::D3D11, ¶ms));
51 if (!m_rhi && canUseRhiImpl(QRhi::OpenGLES2, referenceBackend)) {
52 if (qpa->hasCapability(QPlatformIntegration::OpenGL)
53 && !QCoreApplication::testAttribute(Qt::AA_ForceRasterWidgets)) {
55 m_fallbackSurface.reset(QRhiGles2InitParams::newFallbackSurface());
56 QRhiGles2InitParams params;
57 params.fallbackSurface = m_fallbackSurface.get();
58 if (referenceBackend == QRhi::OpenGLES2)
59 params.shareContext =
static_cast<
const QRhiGles2NativeHandles *>(
60 referenceRhi->nativeHandles())
62 m_rhi.reset(QRhi::create(QRhi::OpenGLES2, ¶ms));
64# if defined(Q_OS_ANDROID)
67 if (!m_appStateChangedConnection) {
68 if (!m_eventsReceiver)
69 m_eventsReceiver = std::make_unique<QObject>();
71 auto onStateChanged = [
this](
auto state) {
72 if (state == Qt::ApplicationSuspended)
76 m_appStateChangedConnection =
77 QObject::connect(qApp, &QGuiApplication::applicationStateChanged,
78 m_eventsReceiver.get(), onStateChanged);
88 qWarning() << Q_FUNC_INFO <<
": No RHI backend. Using CPU conversion.";