diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-03-19 16:40:31 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-03-20 00:41:26 +0000 |
commit | a6cfdca7bd97f750bc034ec772f8c42c5458a0ac (patch) | |
tree | 2adcc0bed60905005cc2d5ae2c17c378f374de9b /src/quick/scenegraph | |
parent | 4ae76406515cb61b56f7a8c97529ce65bf21952b (diff) |
Clean up QSGRhiSupport wrt static functions
Make static everything that can be static. At the same time, make
configure() non-static. Does not change behavior in any way, but
this is the more logical approach. Also more future proof.
Change-Id: I601d59a0547106802f330a7551a97186cde481e0
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
(cherry picked from commit fb8ba3f7250f837dd29600d30108ba6f4470a727)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport.cpp | 26 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport_p.h | 14 |
2 files changed, 18 insertions, 22 deletions
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 88bbf77e40..1ccca23596 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -252,12 +252,6 @@ void QSGRhiSupport::adjustToPlatformQuirks() #endif } -QSGRhiSupport *QSGRhiSupport::staticInst() -{ - static QSGRhiSupport inst; - return &inst; -} - void QSGRhiSupport::checkEnvQSgInfo() { // For compatibility with 5.3 and earlier's QSG_INFO environment variables @@ -269,21 +263,25 @@ void QSGRhiSupport::configure(QSGRendererInterface::GraphicsApi api) { if (api == QSGRendererInterface::Unknown) { // behave as if nothing was explicitly requested - QSGRhiSupport *inst = staticInst(); - inst->m_requested.valid = false; - inst->applySettings(); + m_requested.valid = false; + applySettings(); } else { Q_ASSERT(QSGRendererInterface::isApiRhiBased(api)); - QSGRhiSupport *inst = staticInst(); - inst->m_requested.valid = true; - inst->m_requested.api = api; - inst->applySettings(); + m_requested.valid = true; + m_requested.api = api; + applySettings(); } } +QSGRhiSupport *QSGRhiSupport::instance_internal() +{ + static QSGRhiSupport inst; + return &inst; +} + QSGRhiSupport *QSGRhiSupport::instance() { - QSGRhiSupport *inst = staticInst(); + QSGRhiSupport *inst = instance_internal(); if (!inst->m_settingsApplied) inst->applySettings(); return inst; diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h index 73fa2caad1..db710814bc 100644 --- a/src/quick/scenegraph/qsgrhisupport_p.h +++ b/src/quick/scenegraph/qsgrhisupport_p.h @@ -102,10 +102,15 @@ class QOffscreenSurface; class Q_QUICK_PRIVATE_EXPORT QSGRhiSupport { public: - static void configure(QSGRendererInterface::GraphicsApi api); + static QSGRhiSupport *instance_internal(); static QSGRhiSupport *instance(); static QVulkanInstance *defaultVulkanInstance(); static void cleanupDefaultVulkanInstance(); + static int chooseSampleCountForWindowWithRhi(QWindow *window, QRhi *rhi); + static QImage grabAndBlockInCurrentFrame(QRhi *rhi, QRhiCommandBuffer *cb, QRhiTexture *src = nullptr); + static void checkEnvQSgInfo(); + + void configure(QSGRendererInterface::GraphicsApi api); bool isRhiEnabled() const { return m_enableRhi; } QRhi::Implementation rhiBackend() const { return m_rhiBackend; } @@ -123,24 +128,17 @@ public: const QSGDefaultRenderContext *rc, const QQuickWindow *w); - int chooseSampleCountForWindowWithRhi(QWindow *window, QRhi *rhi); - QOffscreenSurface *maybeCreateOffscreenSurface(QWindow *window); QRhi *createRhi(QQuickWindow *window, QOffscreenSurface *offscreenSurface); void destroyRhi(QRhi *rhi); void prepareWindowForRhi(QQuickWindow *window); - QImage grabAndBlockInCurrentFrame(QRhi *rhi, QRhiCommandBuffer *cb, QRhiTexture *src = nullptr); - QImage grabOffscreen(QQuickWindow *window); - static void checkEnvQSgInfo(); - private: QSGRhiSupport(); void applySettings(); void adjustToPlatformQuirks(); - static QSGRhiSupport *staticInst(); struct { bool valid = false; QSGRendererInterface::GraphicsApi api; |