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
{
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);
}
}