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>
This commit is contained in:
Marc Mutz 2016-04-25 11:26:15 +02:00
parent 1a7e5cdeab
commit 80fd691340

View File

@ -250,17 +250,25 @@ QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffs
bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{ {
switch (cap) { switch (cap) {
case ThreadedPixmaps: return true; case OpenGL:
case OpenGL: return m_connections.first()->glIntegration(); case ThreadedOpenGL:
case ThreadedOpenGL: return m_connections.at(0)->threadedEventHandling() {
&& m_connections.at(0)->glIntegration() const auto *connection = qAsConst(m_connections).first();
&& m_connections.at(0)->glIntegration()->supportsThreadedOpenGL(); if (const auto *integration = connection->glIntegration())
case WindowMasks: return true; return cap != ThreadedOpenGL
case MultipleWindows: return true; || (connection->threadedEventHandling() && integration->supportsThreadedOpenGL());
case ForeignWindows: return true; return false;
case SyncState: return true; }
case RasterGLSurface: return true;
case SwitchableWidgetComposition: return true; case ThreadedPixmaps:
case WindowMasks:
case MultipleWindows:
case ForeignWindows:
case SyncState:
case RasterGLSurface:
case SwitchableWidgetComposition:
return true;
default: return QPlatformIntegration::hasCapability(cap); default: return QPlatformIntegration::hasCapability(cap);
} }
} }