From b6d3bae80317d854d78b5880d8d46cacd0d1a64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 15 Sep 2014 21:48:30 +0200 Subject: QtDeclarative fixes and workarounds for NaCl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make QtDeclarative run on Native Client. Some of these should be looked at more closely at a later point in time, but will do as workarounds from now. Change-Id: Ifddcb45b190c3a80c6137772a05ababb5466ea22 Reviewed-by: Morten Johan Sørvig --- src/3rdparty/double-conversion/utils.h | 3 ++- src/plugins/plugins.pro | 3 ++- src/qml/jsruntime/qv4dateobject.cpp | 14 +++++++++----- src/qml/jsruntime/qv4engine.cpp | 2 +- src/qml/qml/qqmldirparser.cpp | 4 ++++ src/qml/qml/qqmlimport.cpp | 11 +++++++++++ src/qml/qml/qqmltypeloader.cpp | 5 +++++ src/qml/qml/v8/qv8engine.cpp | 3 +++ src/quick/scenegraph/qsgcontext.cpp | 5 +++++ 9 files changed, 42 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/3rdparty/double-conversion/utils.h b/src/3rdparty/double-conversion/utils.h index 53eec64282..a14550c5d5 100644 --- a/src/3rdparty/double-conversion/utils.h +++ b/src/3rdparty/double-conversion/utils.h @@ -65,7 +65,8 @@ defined(__sparc__) || defined(__sparc) || defined(__s390__) || \ defined(__SH4__) || defined(__alpha__) || \ defined(_MIPS_ARCH_MIPS32R2) || \ - defined(__AARCH64EL__) + defined(__AARCH64EL__) || \ + defined(__pnacl__) #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 #elif defined(_M_IX86) || defined(__i386__) || defined(__i386) #if defined(_WIN32) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 273407c19d..90bdbd2b27 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs -!contains(QT_CONFIG, no-qml-debug):SUBDIRS += qmltooling +!nacl:!contains(QT_CONFIG, no-qml-debug):SUBDIRS += qmltooling +!nacl:SUBDIRS += qmltooling diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index a6e1f47d91..83032c4dc3 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -609,7 +609,15 @@ static inline QString ToLocaleTimeString(double t) static double getLocalTZA() { -#ifndef Q_OS_WIN +#ifdef Q_OS_WIN + TIME_ZONE_INFORMATION tzInfo; + GetTimeZoneInformation(&tzInfo); + return -tzInfo.Bias * 60.0 * 1000.0; +#elif defined(Q_OS_NACL_NEWLIB) + // ### tzset hidden behind __STRICT_ANSI__ + qWarning("Not implemented: getLocalTZA()"); + return 0; +#else struct tm t; time_t curr; tzset(); @@ -619,10 +627,6 @@ static double getLocalTZA() gmtime_r(&curr, &t); time_t globl = mktime(&t); return (double(locl) - double(globl)) * 1000.0; -#else - TIME_ZONE_INFORMATION tzInfo; - GetTimeZoneInformation(&tzInfo); - return -tzInfo.Bias * 60.0 * 1000.0; #endif } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 2560f065cf..284a9ea88a 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -113,7 +113,7 @@ QT_WARNING_DISABLE_MSVC(4172) // MSVC 2015: warning C4172: returning address of quintptr getStackLimit() { quintptr stackLimit; -#if USE(PTHREADS) && !OS(QNX) +#if USE(PTHREADS) && !OS(QNX) && !defined(Q_OS_NACL) # if OS(DARWIN) pthread_t thread_self = pthread_self(); void *stackTop = pthread_get_stackaddr_np(thread_self); diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp index 57b50733ea..ca3e620996 100644 --- a/src/qml/qml/qqmldirparser.cpp +++ b/src/qml/qml/qqmldirparser.cpp @@ -100,6 +100,10 @@ bool QQmlDirParser::parse(const QString &source) _plugins.clear(); _components.clear(); _scripts.clear(); +#ifdef Q_OS_NACL + // ### Work around "only one module identifier" error below + _typeNamespace.clear(); +#endif _designerSupported = false; quint16 lineNumber = 0; diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index d538199520..10cb377929 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1206,6 +1206,10 @@ bool QQmlImportsPrivate::validateQmldirVersion(const QQmlTypeLoader::QmldirConte } } +#ifdef Q_OS_NACL + // ### This check triggers on NaCl: lowest_min/highest_min do not + // get set to senisble values. Disabling allows loading to continue. +#else if (lowest_min > vmin || highest_min < vmin) { QQmlError error; error.setDescription(QQmlImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri).arg(vmaj).arg(vmin)); @@ -1213,6 +1217,7 @@ bool QQmlImportsPrivate::validateQmldirVersion(const QQmlTypeLoader::QmldirConte return false; } +#endif return true; } @@ -1565,7 +1570,13 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e) // Search order is applicationDirPath(), $QML2_IMPORT_PATH, QLibraryInfo::Qml2ImportsPath +#ifdef Q_OS_NACL + // Hardcode the qml imports to "qml/" relative to the app nexe. + // This should perhaps be set via Qml2Imports in qt.conf. + QString installImportsPath = QStringLiteral("qml/"); +#else QString installImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); +#endif addImportPath(installImportsPath); // env import paths diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 1e671542be..dd6de8f9b3 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1706,9 +1706,14 @@ Returns a QQmlQmldirData for \a url. The QQmlQmldirData may be cached. */ QQmlQmldirData *QQmlTypeLoader::getQmldir(const QUrl &url) { +#ifdef Q_OS_NACL + // ### NaCl asserts here on urls like "qml/QtQuick.2.1/qmldir", + // which are relative urls we want to load over the network. +#else Q_ASSERT(!url.isRelative() && (QQmlFile::urlToLocalFileOrQrc(url).isEmpty() || !QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url)))); +#endif LockHolder holder(this); diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index dae932e705..0915b8f80b 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -123,10 +123,13 @@ QV8Engine::QV8Engine(QJSEngine* qq) , m_xmlHttpRequestData(0) , m_listModelData(0) { + +#ifndef Q_OS_NACL #ifdef Q_PROCESSOR_X86_32 if (!qCpuHasFeature(SSE2)) { qFatal("This program requires an X86 processor that supports SSE2 extension, at least a Pentium 4 or newer"); } +#endif #endif QML_MEMORY_SCOPE_STRING("QV8Engine::QV8Engine"); diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index dd6977e42e..836b043c39 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -634,6 +634,11 @@ void QSGRenderContext::initialize(QOpenGLContext *context) m_brokenIBOs = true; #endif +#ifdef Q_OS_NACL + // Standard path fails with "glBindBuffer: buffer bound to more than 1 target" + m_brokenIBOs = true; +#endif + emit initialized(); } -- cgit v1.2.3