#include "qwindowsglcontext.h"
#include "qwindowscontext.h"
#include "qwindowswindow.h"
+#include "qwindowsintegration.h"
#include <QtCore/QDebug>
#include <QtCore/QSysInfo>
return d;
}
-// Use ARB unless explicitly turned off on command line.
-static inline bool useARB()
-{
- const QVariant glExtension = qApp->platformNativeInterface()->property("gl");
- if (glExtension.type() == QVariant::String
- && !glExtension.toString().compare(QStringLiteral("gdi"), Qt::CaseInsensitive))
- return false;
- return true;
-}
-
/*!
\class QWindowsGLContext
\brief Open GL context.
if (QWindowsContext::verboseGL > 1)
describeFormats(hdc);
- // Preferably use direct rendering and ARB extensions (unless pixmap)
+ // Preferably use direct rendering and ARB extensions (unless pixmap
+ // or explicitly turned off on command line).
const QWindowsOpenGLAdditionalFormat
requestedAdditional(QWindowsGLDirectRendering);
tryExtensions = m_staticContext->hasExtensions()
&& !testFlag(requestedAdditional.formatFlags, QWindowsGLRenderToPixmap)
- && useARB();
+ && !(QWindowsIntegration::instance()->options() & QWindowsIntegration::DisableArb);
QWindowsOpenGLAdditionalFormat obtainedAdditional;
if (tryExtensions) {
m_pixelFormat =
typedef QSharedPointer<QOpenGLStaticContext> QOpenGLStaticContextPtr;
#endif
- QWindowsIntegrationPrivate();
+ explicit QWindowsIntegrationPrivate(const QStringList ¶mList);
~QWindowsIntegrationPrivate();
+ const unsigned m_options;
QWindowsContext m_context;
QPlatformFontDatabase *m_fontDatabase;
QWindowsNativeInterface m_nativeInterface;
QWindowsServices m_services;
};
-QWindowsIntegrationPrivate::QWindowsIntegrationPrivate()
- : m_fontDatabase(0), m_eventDispatcher(new QWindowsGuiEventDispatcher)
+static inline unsigned parseOptions(const QStringList ¶mList)
+{
+ unsigned options = 0;
+ foreach (const QString ¶m, paramList) {
+ if (param.startsWith(QLatin1String("fontengine="))) {
+ if (param.endsWith(QLatin1String("freetype"))) {
+ options |= QWindowsIntegration::FontDatabaseFreeType;
+ } else if (param.endsWith(QLatin1String("native"))) {
+ options |= QWindowsIntegration::FontDatabaseNative;
+ }
+ } else if (param == QLatin1String("gl=gdi")) {
+ options |= QWindowsIntegration::DisableArb;
+ }
+ }
+ return options;
+}
+
+QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mList)
+ : m_options(parseOptions(paramList))
+ , m_fontDatabase(0)
+ , m_eventDispatcher(new QWindowsGuiEventDispatcher)
{
}
delete m_fontDatabase;
}
-QWindowsIntegration::QWindowsIntegration() :
- d(new QWindowsIntegrationPrivate)
+QWindowsIntegration::QWindowsIntegration(const QStringList ¶mList) :
+ d(new QWindowsIntegrationPrivate(paramList))
{
QGuiApplicationPrivate::instance()->setEventDispatcher(d->m_eventDispatcher);
#ifndef QT_NO_CLIPBOARD
/* Workaround for QTBUG-24205: In 'Auto', pick the FreeType engine for
* QML2 applications. */
-enum FontDatabaseOption {
- FontDatabaseFreeType,
- FontDatabaseNative,
- FontDatabaseAuto
-};
-
-static inline FontDatabaseOption fontDatabaseOption(const QObject &nativeInterface)
-{
- const QVariant argumentV = nativeInterface.property("fontengine");
- if (argumentV.isValid()) {
- const QString argument = argumentV.toString();
- if (argument == QLatin1String("freetype"))
- return FontDatabaseFreeType;
- if (argument == QLatin1String("native"))
- return FontDatabaseNative;
- }
- return FontDatabaseAuto;
-}
-
#ifdef Q_OS_WINCE
// It's not easy to detect if we are running a QML application
// Let's try to do so by checking if the QtQuick module is loaded.
#ifdef QT_NO_FREETYPE
d->m_fontDatabase = new QWindowsFontDatabase();
#else // QT_NO_FREETYPE
- FontDatabaseOption option = fontDatabaseOption(d->m_nativeInterface);
- if (option == FontDatabaseFreeType) {
+ if (d->m_options & QWindowsIntegration::FontDatabaseFreeType) {
d->m_fontDatabase = new QWindowsFontDatabaseFT;
- } else if (option == FontDatabaseNative){
+ } else if (d->m_options & QWindowsIntegration::FontDatabaseNative){
d->m_fontDatabase = new QWindowsFontDatabase;
} else {
#ifndef Q_OS_WINCE
return static_cast<QWindowsIntegration *>(QGuiApplicationPrivate::platformIntegration());
}
+unsigned QWindowsIntegration::options() const
+{
+ return d->m_options;
+}
+
QAbstractEventDispatcher * QWindowsIntegration::guiThreadEventDispatcher() const
{
return d->m_eventDispatcher;