diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-04-25 11:26:15 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-04-26 13:28:16 +0000 |
commit | 80fd691340e0e7c43a6216dc37a01e3a6509606e (patch) | |
tree | 21b9d44126a5b59c9acee99e9cedc54a74932a63 /src/plugins/platforms/xcb/qxcbintegration.cpp | |
parent | 1a7e5cdeab91d9461ba9a1217269998643276195 (diff) |
QXcbIntegration: simplify a switch
... by aggregating similar blocks under multiple case
labels, and caching functions's return values.
Even saves a few bytes in text size on optimized GCC 6.0
Linux AMD64 builds.
Change-Id: I5784567a09732b4e55b64163b69e7a946f0783ae
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbintegration.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index b5e03e68fe..703167c0cd 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -250,17 +250,25 @@ QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffs bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { - case ThreadedPixmaps: return true; - case OpenGL: return m_connections.first()->glIntegration(); - case ThreadedOpenGL: return m_connections.at(0)->threadedEventHandling() - && m_connections.at(0)->glIntegration() - && m_connections.at(0)->glIntegration()->supportsThreadedOpenGL(); - case WindowMasks: return true; - case MultipleWindows: return true; - case ForeignWindows: return true; - case SyncState: return true; - case RasterGLSurface: return true; - case SwitchableWidgetComposition: return true; + case OpenGL: + case ThreadedOpenGL: + { + const auto *connection = qAsConst(m_connections).first(); + if (const auto *integration = connection->glIntegration()) + return cap != ThreadedOpenGL + || (connection->threadedEventHandling() && integration->supportsThreadedOpenGL()); + return false; + } + + case ThreadedPixmaps: + case WindowMasks: + case MultipleWindows: + case ForeignWindows: + case SyncState: + case RasterGLSurface: + case SwitchableWidgetComposition: + return true; + default: return QPlatformIntegration::hasCapability(cap); } } |