From 9b0fab6b62df98519ebfab117f14b9d3465d8c68 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 21 Dec 2012 18:35:58 +0200 Subject: Update Qt internals to use QChar::Script ...and remove the outdated QUnicodeTables::Script enum. QFontEngineData now has one extra slot that never used (engines[QChar::Script_Inherited]). engines[QChar::Script_Unknown], if accessed, would be set with a Box engine instance, and could be used as a minor optimization some time later. In order to preserve the existing behavior, we map all scripts up to Latin to Common. Change-Id: Ide4182a0f8447b4bf25713ecc3fe8097b8fed040 Reviewed-by: Pierre Rossi Reviewed-by: Konstantin Ritt --- .../fontdatabases/basic/qbasicfontdatabase.cpp | 8 +- .../fontdatabases/basic/qbasicfontdatabase_p.h | 4 +- .../fontconfig/qfontconfigdatabase.cpp | 139 ++++++++++++++------- .../fontconfig/qfontconfigdatabase_p.h | 6 +- .../fontdatabases/mac/qcoretextfontdatabase.mm | 10 +- .../fontdatabases/mac/qcoretextfontdatabase_p.h | 4 +- 6 files changed, 107 insertions(+), 64 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp index dd6f04f74d..d0755711de 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp @@ -217,8 +217,8 @@ QSupportedWritingSystems QBasicFontDatabase::determineWritingSystemsFromTrueType static inline bool scriptRequiresOpenType(int script) { - return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala) - || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko); + return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala) + || script == QChar::Script_Khmer || script == QChar::Script_Nko); } void QBasicFontDatabase::populateFontDatabase() @@ -242,7 +242,7 @@ void QBasicFontDatabase::populateFontDatabase() } } -QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *usrPtr) +QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, QChar::Script script, void *usrPtr) { QFontEngineFT *engine; FontFile *fontfile = static_cast (usrPtr); @@ -337,7 +337,7 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QByteArray &fontData, qreal pi return fe; } -QStringList QBasicFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const +QStringList QBasicFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { Q_UNUSED(family); Q_UNUSED(style); diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h index 8236f50eb4..3b66a5a985 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h @@ -58,9 +58,9 @@ class QBasicFontDatabase : public QPlatformFontDatabase { public: void populateFontDatabase(); - QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); + QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle); QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference); - QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const; + QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); void releaseHandle(void *handle); diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index cf6ff11acd..784602b596 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -75,10 +75,11 @@ static inline bool requiresOpenType(int writingSystem) return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala) || writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko); } + static inline bool scriptRequiresOpenType(int script) { - return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala) - || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko); + return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala) + || script == QChar::Script_Khmer || script == QChar::Script_Nko); } static int getFCWeight(int fc_weight) @@ -97,14 +98,17 @@ static int getFCWeight(int fc_weight) } static const char *specialLanguages[] = { - "en", // Common + "", // Unknown + "", // Inherited + "", // Common + "en", // Latin "el", // Greek "ru", // Cyrillic "hy", // Armenian "he", // Hebrew "ar", // Arabic "syr", // Syriac - "div", // Thaana + "dv", // Thaana "hi", // Devanagari "bn", // Bengali "pa", // Gurmukhi @@ -121,45 +125,85 @@ static const char *specialLanguages[] = { "my", // Myanmar "ka", // Georgian "ko", // Hangul - "", // Ogham - "", // Runic + "am", // Ethiopic + "chr", // Cherokee + "cr", // CanadianAboriginal + "sga", // Ogham + "non", // Runic "km", // Khmer - "" // N'Ko + "mn", // Mongolian + "ja", // Hiragana + "ja", // Katakana + "zh", // Bopomofo + "zh", // Han + "ii", // Yi + "ett", // OldItalic + "got", // Gothic + "en", // Deseret + "fil", // Tagalog + "hnn", // Hanunoo + "bku", // Buhid + "tbw", // Tagbanwa + "cop", // Coptic + "lif", // Limbu + "tdd", // TaiLe + "grc", // LinearB + "uga", // Ugaritic + "en", // Shavian + "so", // Osmanya + "grc", // Cypriot + "", // Braille + "bug", // Buginese + "khb", // NewTaiLue + "cu", // Glagolitic + "shi", // Tifinagh + "syl", // SylotiNagri + "peo", // OldPersian + "pra", // Kharoshthi + "ban", // Balinese + "akk", // Cuneiform + "phn", // Phoenician + "lzh", // PhagsPa + "man", // Nko + "su", // Sundanese + "lep", // Lepcha + "sat", // OlChiki + "vai", // Vai + "saz", // Saurashtra + "eky", // KayahLi + "rej", // Rejang + "xlc", // Lycian + "xcr", // Carian + "xld", // Lydian + "cjm", // Cham + "nod", // TaiTham + "blt", // TaiViet + "ae", // Avestan + "egy", // EgyptianHieroglyphs + "smp", // Samaritan + "lis", // Lisu + "bax", // Bamum + "jv", // Javanese + "mni", // MeeteiMayek + "arc", // ImperialAramaic + "xsa", // OldSouthArabian + "xpr", // InscriptionalParthian + "pal", // InscriptionalPahlavi + "otk", // OldTurkic + "bh", // Kaithi + "bbc", // Batak + "pra", // Brahmi + "myz", // Mandaic + "ccp", // Chakma + "xmr", // MeroiticCursive + "xmr", // MeroiticHieroglyphs + "hmd", // Miao + "sa", // Sharada + "srb", // SoraSompeng + "doi" // Takri }; enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) }; -static const ushort specialChars[] = { - 0, // English - 0, // Greek - 0, // Cyrillic - 0, // Armenian - 0, // Hebrew - 0, // Arabic - 0, // Syriac - 0, // Thaana - 0, // Devanagari - 0, // Bengali - 0, // Gurmukhi - 0, // Gujarati - 0, // Oriya - 0, // Tamil - 0xc15, // Telugu - 0xc95, // Kannada - 0xd15, // Malayalam - 0xd9a, // Sinhala - 0, // Thai - 0, // Lao - 0, // Tibetan - 0x1000, // Myanmar - 0, // Georgian - 0, // Hangul - 0x1681, // Ogham - 0x16a0, // Runic - 0, // Khmer - 0x7ca // N'Ko -}; -enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) }; - // this could become a list of all languages used for each writing // system, instead of using the single most common language. static const char *languageForWritingSystem[] = { @@ -194,9 +238,9 @@ static const char *languageForWritingSystem[] = { "ko", // Korean "vi", // Vietnamese 0, // Symbol - 0, // Ogham - 0, // Runic - 0 // N'Ko + "sga", // Ogham + "non", // Runic + "man" // N'Ko }; enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; @@ -477,13 +521,12 @@ void QFontconfigDatabase::populateFontDatabase() // QApplication::setFont(font); } -QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine, - QUnicodeTables::Script script) +QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) { return new QFontEngineMultiFontConfig(fontEngine, script); } -QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables::Script script, void *usrPtr) +QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QChar::Script script, void *usrPtr) { if (!usrPtr) return 0; @@ -601,7 +644,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QUnicodeTables:: return engine; } -QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const +QStringList QFontconfigDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { QStringList fallbackFamilies; FcPattern *pattern = FcPatternCreate(); @@ -621,8 +664,8 @@ QStringList QFontconfigDatabase::fallbacksForFamily(const QString family, const slant_value = FC_SLANT_OBLIQUE; FcPatternAddInteger(pattern, FC_SLANT, slant_value); - if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') { - Q_ASSERT(script < QUnicodeTables::ScriptCount); + Q_ASSERT(uint(script) < SpecialLanguageCount); + if (*specialLanguages[script] != '\0') { FcLangSet *ls = FcLangSetCreate(); FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]); FcPatternAddLangSet(pattern, FC_LANG, ls); diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h index dfae207333..7570be7135 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h @@ -51,9 +51,9 @@ class QFontconfigDatabase : public QBasicFontDatabase { public: void populateFontDatabase(); - QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QUnicodeTables::Script script); - QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); - QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const; + QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script); + QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle); + QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); QString resolveFontFamilyAlias(const QString &family) const; QFont defaultFont() const; diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 99a316bef3..ef0c1b5103 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -85,9 +85,9 @@ static const char *languageForWritingSystem[] = { "ko", // Korean "vi", // Vietnamese 0, // Symbol - 0, // Ogham - 0, // Runic - 0 // N'Ko + "sga", // Ogham + "non", // Runic + "man" // N'Ko }; enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; @@ -325,7 +325,7 @@ void QCoreTextFontDatabase::releaseHandle(void *handle) CFRelease(CTFontDescriptorRef(handle)); } -QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, QUnicodeTables::Script script, void *usrPtr) +QFontEngine *QCoreTextFontDatabase::fontEngine(const QFontDef &f, QChar::Script script, void *usrPtr) { Q_UNUSED(script); @@ -375,7 +375,7 @@ QFontEngine *QCoreTextFontDatabase::fontEngine(const QByteArray &fontData, qreal return fontEngine; } -QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const +QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { Q_UNUSED(family); Q_UNUSED(style); diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index 310102f805..59b5acee39 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -52,9 +52,9 @@ public: QCoreTextFontDatabase(); ~QCoreTextFontDatabase(); void populateFontDatabase(); - QFontEngine *fontEngine(const QFontDef &fontDef, QUnicodeTables::Script script, void *handle); + QFontEngine *fontEngine(const QFontDef &fontDef, QChar::Script script, void *handle); QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference); - QStringList fallbacksForFamily(const QString family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script) const; + QStringList fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const; #ifndef Q_OS_IOS QStringList addApplicationFont(const QByteArray &fontData, const QString &fileName); #endif -- cgit v1.2.3 From 1b9fdb9b31c65e1f876fd7b45f21bf0e83bb02cc Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 22 Dec 2012 19:47:20 +0200 Subject: Skip FcCharSetHasChar() call ...if writing system is already known to be supported Change-Id: Id7ea11e92507a283b2fba2ad944dd0a9772e484d Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 784602b596..128ef396db 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -443,7 +443,7 @@ void QFontconfigDatabase::populateFontDatabase() // some languages are not supported by FontConfig, we rather check the // charset to detect these for (int i = 1; i < SampleCharCount; ++i) { - if (!sampleCharForWritingSystem[i]) + if (!sampleCharForWritingSystem[i] || writingSystems.supported(QFontDatabase::WritingSystem(i))) continue; if (FcCharSetHasChar(cs, sampleCharForWritingSystem[i])) writingSystems.setSupported(QFontDatabase::WritingSystem(i)); -- cgit v1.2.3 From 8927084d0acfea2bb3fc8a932069c1d5ceb001d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 10 Jan 2013 15:09:32 +0100 Subject: Refactor paint/font-engine shouldDrawCachedGlyphs and supportsTransformations Some cruft had built up over time, and this is an attempt at cleaning up the naming and use of these functions, and should not have any behavioral effects. The function supportsTransformations() has been renamed in QPaintEngineEx to reflect its use, which is to decide if QPainter needs to pre-transform the coordinates of the static text before asking the paint-engine to draw it. The new name is requiresPretransformedGlyphPositions(). The OpenGL and CoreGraphics (Mac) paint engines keep their behavior of not needing pre-transformed text, while the raster engine needs this when using cached glyphs. The base-class implementation assumes that all transforms that include a projection will need pre-transform, which is also the case for the raster engine. All decisions in the paint engines about whether or not to use the glyph cache when drawing text are now deferred to the function shouldDrawCachedGlyphs(), which has been refactored for the GL paint engine(s) to share more logic. All implementations call the base class implementation, which ensures that large font sizes will not be cached. The raster engine will in addition ask the font engine whether or not it can produce glyphs for the glyph-cache with the given transform. This is the only remaining instance of the supportsTransformations() function, and will for all font engines except the CoreText engine support affine transformations. The CoreText engine on the other hand only supports translations (for now). Change-Id: I8fb5e43e3de3ef62a526a79a6dfeda7f9546771d Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 4 ++-- src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 1087d18891..ace4c982fd 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -600,9 +600,9 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const return new QCoreTextFontEngine(cgFont, newFontDef); } -bool QCoreTextFontEngine::supportsTransformations(const QTransform &transform) const +bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) const { - return transform.type() > QTransform::TxTranslate; + return transform.type() <= QTransform::TxTranslate; } QT_END_NAMESPACE diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index 6c5c557b13..bd52234f41 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -103,7 +103,7 @@ public: virtual qreal minLeftBearing() const; virtual QFixed emSquareSize() const; - bool supportsTransformations(const QTransform &transform) const; + bool supportsTransformation(const QTransform &transform) const; virtual QFontEngine *cloneWithSize(qreal pixelSize) const; virtual int glyphMargin(QFontEngineGlyphCache::Type type) { Q_UNUSED(type); return 0; } -- cgit v1.2.3 From 1161a8a62907796ea45b1877bec31e66aeef77f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 15 Jan 2013 14:09:18 +0100 Subject: CoreText: Add support for providing scaled glyphs to the glyph-cache Useful for not having to fall back to QPainterPath drawing when using the raster engine with a retina screen (which has a 2x scale). Change-Id: I0a9f754d31b0ecd8e8daf7a01331d19716bab680 Reviewed-by: Gunnar Sletta --- .../fontdatabases/mac/qfontengine_coretext.mm | 12 ++++++++++-- .../fontdatabases/mac/qfontengine_coretext_p.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index ace4c982fd..961b28961c 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -508,7 +508,15 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition) { - QImage im = imageForGlyph(glyph, subPixelPosition, false, QTransform()); + return alphaMapForGlyph(glyph, subPixelPosition, QTransform()); +} + +QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &x) +{ + if (x.type() > QTransform::TxScale) + return QFontEngine::alphaMapForGlyph(glyph, subPixelPosition, x); + + QImage im = imageForGlyph(glyph, subPixelPosition, false, x); QImage indexed(im.width(), im.height(), QImage::Format_Indexed8); QVector colors(256); @@ -602,7 +610,7 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) const { - return transform.type() <= QTransform::TxTranslate; + return transform.type() <= QTransform::TxScale; } QT_END_NAMESPACE diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index bd52234f41..b4e94fe889 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -98,6 +98,7 @@ public: virtual bool getSfntTableData(uint /*tag*/, uchar * /*buffer*/, uint * /*length*/) const; virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics); virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition); + virtual QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t); virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t); virtual qreal minRightBearing() const; virtual qreal minLeftBearing() const; -- cgit v1.2.3 From d29aabbca9c98eb66d9cde6058ad96929c816c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 25 Oct 2012 16:53:18 +0200 Subject: eglfs: Introduce way of filtering out unwanted EGL configs. Some times a platform might want to exclude certain configs, for example based on EGL_NATIVE_VISUAL_ID. This patch introduces a new QEglConfigChooser class which has a virtual filterConfig() function which can be re-implemented in a sub-class to give finer control of how configs are chosen. Change-Id: I8b684f01be95a47307b1e429857f01337a9a38d8 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Gunnar Sletta --- .../eglconvenience/qeglconvenience.cpp | 115 +++++++++++++-------- .../eglconvenience/qeglconvenience_p.h | 35 +++++++ .../eglconvenience/qeglplatformcontext.cpp | 16 ++- .../eglconvenience/qeglplatformcontext_p.h | 6 +- 4 files changed, 128 insertions(+), 44 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index a88025a24d..c9f3e89272 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -210,75 +210,106 @@ bool q_reduceConfigAttributes(QVector *configAttributes) return false; } -EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType) +QEglConfigChooser::QEglConfigChooser(EGLDisplay display) + : m_display(display) + , m_surfaceType(EGL_WINDOW_BIT) + , m_ignore(false) + , m_confAttrRed(0) + , m_confAttrGreen(0) + , m_confAttrBlue(0) + , m_confAttrAlpha(0) +{ +} + +QEglConfigChooser::~QEglConfigChooser() { - EGLConfig cfg = 0; - QVector configureAttributes = q_createConfigAttributesFromFormat(format); +} + +EGLConfig QEglConfigChooser::chooseConfig() +{ + QVector configureAttributes = q_createConfigAttributesFromFormat(m_format); configureAttributes.append(EGL_SURFACE_TYPE); - configureAttributes.append(surfaceType); + configureAttributes.append(surfaceType()); configureAttributes.append(EGL_RENDERABLE_TYPE); - if (format.renderableType() == QSurfaceFormat::OpenVG) + if (m_format.renderableType() == QSurfaceFormat::OpenVG) configureAttributes.append(EGL_OPENVG_BIT); #ifdef EGL_VERSION_1_4 - else if (format.renderableType() == QSurfaceFormat::OpenGL) + else if (m_format.renderableType() == QSurfaceFormat::OpenGL) configureAttributes.append(EGL_OPENGL_BIT); #endif - else if (format.majorVersion() == 1) + else if (m_format.majorVersion() == 1) configureAttributes.append(EGL_OPENGL_ES_BIT); else configureAttributes.append(EGL_OPENGL_ES2_BIT); configureAttributes.append(EGL_NONE); + EGLConfig cfg; do { // Get the number of matching configurations for this set of properties. EGLint matching = 0; - if (!eglChooseConfig(display, configureAttributes.constData(), 0, 0, &matching) || !matching) + if (!eglChooseConfig(display(), configureAttributes.constData(), 0, 0, &matching) || !matching) continue; - // If we want the best pixel format, then return the first - // matching configuration. - if (highestPixelFormat) { - eglChooseConfig(display, configureAttributes.constData(), &cfg, 1, &matching); - if (matching < 1) - continue; - return cfg; - } - // Fetch all of the matching configurations and find the // first that matches the pixel format we wanted. int i = configureAttributes.indexOf(EGL_RED_SIZE); - int confAttrRed = configureAttributes.at(i+1); + m_confAttrRed = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_GREEN_SIZE); - int confAttrGreen = configureAttributes.at(i+1); + m_confAttrGreen = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_BLUE_SIZE); - int confAttrBlue = configureAttributes.at(i+1); + m_confAttrBlue = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_ALPHA_SIZE); - int confAttrAlpha = i == -1 ? 0 : configureAttributes.at(i+1); - - EGLint size = matching; - EGLConfig *configs = new EGLConfig [size]; - eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching); - for (EGLint index = 0; index < size; ++index) { - EGLint red, green, blue, alpha; - eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red); - eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green); - eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue); - eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha); - if ((confAttrRed == 0 || red == confAttrRed) && - (confAttrGreen == 0 || green == confAttrGreen) && - (confAttrBlue == 0 || blue == confAttrBlue) && - (confAttrAlpha == 0 || alpha == confAttrAlpha)) { - cfg = configs[index]; - delete [] configs; - return cfg; - } + m_confAttrAlpha = i == -1 ? 0 : configureAttributes.at(i+1); + + QVector configs(matching); + eglChooseConfig(display(), configureAttributes.constData(), configs.data(), configs.size(), &matching); + if (!cfg && matching > 0) + cfg = configs.first(); + + for (int i = 0; i < configs.size(); ++i) { + if (filterConfig(configs[i])) + return configs.at(i); } - delete [] configs; } while (q_reduceConfigAttributes(&configureAttributes)); - qWarning("Cant find EGLConfig, returning null config"); - return 0; + + if (!cfg) + qWarning("Cant find EGLConfig, returning null config"); + return cfg; +} + +bool QEglConfigChooser::filterConfig(EGLConfig config) const +{ + if (m_ignore) + return true; + + EGLint red = 0; + EGLint green = 0; + EGLint blue = 0; + EGLint alpha = 0; + + if (m_confAttrRed) + eglGetConfigAttrib(display(), config, EGL_RED_SIZE, &red); + if (m_confAttrGreen) + eglGetConfigAttrib(display(), config, EGL_GREEN_SIZE, &green); + if (m_confAttrBlue) + eglGetConfigAttrib(display(), config, EGL_BLUE_SIZE, &blue); + if (m_confAttrAlpha) + eglGetConfigAttrib(display(), config, EGL_ALPHA_SIZE, &alpha); + + return red == m_confAttrRed && green == m_confAttrGreen + && blue == m_confAttrBlue && alpha == m_confAttrAlpha; +} + +EGLConfig q_configFromGLFormat(EGLDisplay display, const QSurfaceFormat &format, bool highestPixelFormat, int surfaceType) +{ + QEglConfigChooser chooser(display); + chooser.setSurfaceFormat(format); + chooser.setSurfaceType(surfaceType); + chooser.setIgnoreColorChannels(highestPixelFormat); + + return chooser.chooseConfig(); } QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat) diff --git a/src/platformsupport/eglconvenience/qeglconvenience_p.h b/src/platformsupport/eglconvenience/qeglconvenience_p.h index 5dd132edd3..3efd3991b9 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience_p.h +++ b/src/platformsupport/eglconvenience/qeglconvenience_p.h @@ -56,6 +56,41 @@ QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, bool q_hasEglExtension(EGLDisplay display,const char* extensionName); void q_printEglConfig(EGLDisplay display, EGLConfig config); +class QEglConfigChooser +{ +public: + QEglConfigChooser(EGLDisplay display); + virtual ~QEglConfigChooser(); + + EGLDisplay display() const { return m_display; } + + void setSurfaceType(EGLint surfaceType) { m_surfaceType = surfaceType; } + EGLint surfaceType() const { return m_surfaceType; } + + void setSurfaceFormat(const QSurfaceFormat &format) { m_format = format; } + QSurfaceFormat surfaceFormat() const { return m_format; } + + void setIgnoreColorChannels(bool ignore) { m_ignore = ignore; } + bool ignoreColorChannels() const { return m_ignore; } + + EGLConfig chooseConfig(); + +protected: + virtual bool filterConfig(EGLConfig config) const; + +private: + QSurfaceFormat m_format; + EGLDisplay m_display; + EGLint m_surfaceType; + bool m_ignore; + + int m_confAttrRed; + int m_confAttrGreen; + int m_confAttrBlue; + int m_confAttrAlpha; +}; + + QT_END_NAMESPACE #endif //QEGLCONVENIENCE_H diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 78dc1f7e9b..0b11d96e5c 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -64,8 +64,22 @@ QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatform : m_eglDisplay(display) , m_eglApi(eglApi) , m_eglConfig(q_configFromGLFormat(display, format, true)) - , m_format(q_glFormatFromConfig(display, m_eglConfig)) { + init(format, share); +} + +QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, + EGLConfig config, EGLenum eglApi) + : m_eglDisplay(display) + , m_eglApi(eglApi) + , m_eglConfig(config) +{ + init(format, share); +} + +void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLContext *share) +{ + m_format = q_glFormatFromConfig(m_eglDisplay, m_eglConfig); m_shareContext = share ? static_cast(share)->m_eglContext : 0; QVector contextAttrs; diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h index 0fcf9d47c6..c7918516db 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h @@ -51,6 +51,8 @@ class QEGLPlatformContext : public QPlatformOpenGLContext public: QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLenum eglApi = EGL_OPENGL_ES_API); + QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, + EGLConfig config, EGLenum eglApi = EGL_OPENGL_ES_API); ~QEGLPlatformContext(); bool makeCurrent(QPlatformSurface *surface); @@ -70,12 +72,14 @@ protected: virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0; private: + void init(const QSurfaceFormat &format, QPlatformOpenGLContext *share); + EGLContext m_eglContext; EGLContext m_shareContext; EGLDisplay m_eglDisplay; EGLenum m_eglApi; EGLConfig m_eglConfig; - const QSurfaceFormat m_format; + QSurfaceFormat m_format; }; #endif //QEGLPLATFORMCONTEXT_H -- cgit v1.2.3 From c24a7377dd9cfb503b43ef3f5a2d5cac9a4e1b8c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 14 Jan 2013 10:00:12 +0100 Subject: Regression: Fix setting of custom cursors for native widgets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, there is no concept of not having a cursor set on a Window. Qt::ArrowCursor is always set instead. This causes bugs when native child widgets are involved, for example setting a cursor on the native widget's parent no longer works since the child's Qt::ArrowCursor applies. Introduce QWindowPrivate::hasCursor tracking whether a cursor has been explicitly set and clear in QWindow::unsetCursor(). Handle 0 in QPlatformCursor::changeCursor() to mean "unsetCursor()": - Windows: Introduce default constructor for QWindowsWindowCursor meaning "0". Search for applicable parent cursor in applyCursor. - XCB: No big changes required, set XCB_CURSOR_NONE for no cursor. - Other platforms: Assume Qt::ArrowCursor when cursor = 0 is passed for now. Task-number: QTBUG-28879 Change-Id: Id82722592f3cd5fe577a5b64dcc600c85cfea484 Reviewed-by: Jonathan Liu Reviewed-by: Morten Johan Sørvig Reviewed-by: Samuel Rødal --- src/platformsupport/fbconvenience/qfbcursor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fbconvenience/qfbcursor.cpp b/src/platformsupport/fbconvenience/qfbcursor.cpp index bc44055721..df4fdd135e 100644 --- a/src/platformsupport/fbconvenience/qfbcursor.cpp +++ b/src/platformsupport/fbconvenience/qfbcursor.cpp @@ -120,7 +120,7 @@ void QFbCursor::setCursor(const uchar *data, const uchar *mask, int width, int h void QFbCursor::changeCursor(QCursor * widgetCursor, QWindow *window) { Q_UNUSED(window); - Qt::CursorShape shape = widgetCursor->shape(); + const Qt::CursorShape shape = widgetCursor ? widgetCursor->shape() : Qt::ArrowCursor; if (shape == Qt::BitmapCursor) { // application supplied cursor -- cgit v1.2.3 From 3a2b3fc0d72fe1e52a7830e03f849963f6b73e02 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 23 Jan 2013 15:45:52 +0100 Subject: Don't try to render a pixmap when there isn't any. This happened in cases when QDrag choose not to use a pixmap to represent data in a drag and drop operation. The chain that leads to QPainter errors begins in QBasicDrag::startDrag() where we call setPixmap() with Null pixmap, which later calls updateGeometry() which leads to calling render() before the backing store has been resized. Task-number: QTBUG-29283 Change-Id: I2145159d3f23dbde2cba2ca9aa1788e222aba02a Reviewed-by: Friedemann Kleint --- src/platformsupport/dnd/qshapedpixmapdndwindow.cpp | 4 +++- src/platformsupport/dnd/qsimpledrag.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp b/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp index 67c3cb4701..b3e64b01d0 100644 --- a/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp +++ b/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp @@ -91,7 +91,9 @@ void QShapedPixmapWindow::setHotspot(const QPoint &hotspot) void QShapedPixmapWindow::updateGeometry() { QRect rect(QCursor::pos() - m_hotSpot, m_pixmap.size()); - if (m_backingStore->size() != m_pixmap.size()) + if (m_pixmap.isNull()) + m_backingStore->resize(QSize(1,1)); + else if (m_backingStore->size() != m_pixmap.size()) m_backingStore->resize(m_pixmap.size()); setGeometry(rect); } diff --git a/src/platformsupport/dnd/qsimpledrag.cpp b/src/platformsupport/dnd/qsimpledrag.cpp index 3b73380cab..fe0146afc3 100644 --- a/src/platformsupport/dnd/qsimpledrag.cpp +++ b/src/platformsupport/dnd/qsimpledrag.cpp @@ -207,6 +207,8 @@ void QBasicDrag::resetDndState(bool /* deleteSource */) void QBasicDrag::startDrag() { + // ### TODO Check if its really necessary to have m_drag_icon_window + // when QDrag is used without a pixmap - QDrag::setPixmap() if (!m_drag_icon_window) m_drag_icon_window = new QShapedPixmapWindow(); -- cgit v1.2.3 From cd1e21cf09c2512b58723ad527dcc1aad102787b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 24 Jan 2013 14:59:52 +0100 Subject: Use path-based text when painter has negative scale on raster/coretext The CoreText font-engine is not able to produce glyphs with a negative scale (flipped). We need to report this fact back to the raster paint engine, so that it can fall back to painter-path based text drawing. For the GL engine this is not an issue, as the engine is able to handle the flipping itself, while still using a non-flipped glyph-cache. Task-number: QTBUG-29284 Change-Id: I3c24cee091786faae8a5c5dd756d208163330bfc Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index e2e8f1daa4..70416bc2dd 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -619,7 +619,13 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) const { - return transform.type() <= QTransform::TxScale; + if (transform.type() < QTransform::TxScale) + return true; + else if (transform.type() == QTransform::TxScale && + transform.m11() >= 0 && transform.m22() >= 0) + return true; + else + return false; } QT_END_NAMESPACE -- cgit v1.2.3 From 07e3bcdc106ac42703ae0fb88b6cac2d2bfdd072 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Sat, 26 Jan 2013 21:42:12 +0100 Subject: Remove QT_{BEGIN,END}_HEADER macro usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp Reviewed-by: Jędrzej Nowacki Reviewed-by: hjk --- src/platformsupport/dnd/qshapedpixmapdndwindow_p.h | 4 ---- src/platformsupport/dnd/qsimpledrag_p.h | 4 ---- src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h | 4 ---- src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h | 4 ---- src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h | 4 ---- src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h | 4 ---- src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h | 4 ---- src/platformsupport/input/evdevtablet/qevdevtablet_p.h | 4 ---- src/platformsupport/input/evdevtouch/qevdevtouch_p.h | 4 ---- src/platformsupport/linuxaccessibility/application_p.h | 2 -- src/platformsupport/linuxaccessibility/atspiadaptor_p.h | 2 -- src/platformsupport/linuxaccessibility/bridge_p.h | 2 -- src/platformsupport/linuxaccessibility/cache_p.h | 2 -- src/platformsupport/linuxaccessibility/constant_mappings_p.h | 2 -- src/platformsupport/linuxaccessibility/dbusconnection_p.h | 2 -- src/platformsupport/linuxaccessibility/struct_marshallers_p.h | 2 -- src/platformsupport/services/genericunix/qgenericunixservices_p.h | 4 ---- src/platformsupport/themes/genericunix/qgenericunixthemes_p.h | 4 ---- 18 files changed, 58 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/dnd/qshapedpixmapdndwindow_p.h b/src/platformsupport/dnd/qshapedpixmapdndwindow_p.h index ed0819cf29..20674b6b19 100644 --- a/src/platformsupport/dnd/qshapedpixmapdndwindow_p.h +++ b/src/platformsupport/dnd/qshapedpixmapdndwindow_p.h @@ -48,8 +48,6 @@ QT_BEGIN_NAMESPACE -QT_BEGIN_HEADER - class QShapedPixmapWindow : public QWindow { Q_OBJECT @@ -72,8 +70,6 @@ private: QPoint m_hotSpot; }; -QT_END_HEADER - QT_END_NAMESPACE #endif // QSHAPEDPIXMAPDNDWINDOW_H diff --git a/src/platformsupport/dnd/qsimpledrag_p.h b/src/platformsupport/dnd/qsimpledrag_p.h index 5cf3394919..bb9d215083 100644 --- a/src/platformsupport/dnd/qsimpledrag_p.h +++ b/src/platformsupport/dnd/qsimpledrag_p.h @@ -48,8 +48,6 @@ QT_BEGIN_NAMESPACE -QT_BEGIN_HEADER - #ifndef QT_NO_DRAGANDDROP class QMouseEvent; @@ -120,8 +118,6 @@ private: #endif // QT_NO_DRAGANDDROP -QT_END_HEADER - QT_END_NAMESPACE #endif diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index d481a3a3e6..e7fec4be14 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -54,8 +54,6 @@ #if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class QRawFontPrivate; @@ -143,8 +141,6 @@ CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef); QT_END_NAMESPACE -QT_END_HEADER - #endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) #endif // QFONTENGINE_CORETEXT_P_H diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h index 3e5dcb2ac9..1065b05d51 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h @@ -46,8 +46,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE namespace QEvdevKeyboardMap { @@ -198,6 +196,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif // QEVDEVKEYBOARDHANDLER_P_H diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h index e750f72c3b..37c60c035c 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h @@ -50,8 +50,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class QEvdevKeyboardManager : public QObject @@ -71,8 +69,6 @@ private: QDeviceDiscovery *m_deviceDiscovery; }; -QT_END_HEADER - QT_END_NAMESPACE #endif // QEVDEVKEYBOARDMANAGER_P_H diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h index 6e078b2d70..d419a1913e 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h @@ -45,8 +45,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class QSocketNotifier; @@ -83,6 +81,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif // QEVDEVMOUSEHANDLER_P_H diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h index a2c83c4a1c..6abe933371 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h @@ -50,8 +50,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class QEvdevMouseManager : public QObject @@ -79,8 +77,6 @@ private: int m_yoffset; }; -QT_END_HEADER - QT_END_NAMESPACE #endif // QEVDEVMOUSEMANAGER_P_H diff --git a/src/platformsupport/input/evdevtablet/qevdevtablet_p.h b/src/platformsupport/input/evdevtablet/qevdevtablet_p.h index ce49a01e7b..9222db9907 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablet_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtablet_p.h @@ -46,8 +46,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class QEvdevTabletData; @@ -82,6 +80,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif // QEVDEVTABLET_P_H diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch_p.h b/src/platformsupport/input/evdevtouch/qevdevtouch_p.h index b4de2ca088..ceb57bdf05 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouch_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouch_p.h @@ -48,8 +48,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class QSocketNotifier; @@ -93,6 +91,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif // QEVDEVTOUCH_P_H diff --git a/src/platformsupport/linuxaccessibility/application_p.h b/src/platformsupport/linuxaccessibility/application_p.h index 9b6763f111..5efd7089ea 100644 --- a/src/platformsupport/linuxaccessibility/application_p.h +++ b/src/platformsupport/linuxaccessibility/application_p.h @@ -46,7 +46,6 @@ #include #include -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE /* @@ -81,6 +80,5 @@ private: }; QT_END_NAMESPACE -QT_END_HEADER #endif diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h index b7a29fdc15..1c79cc75c8 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h +++ b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h @@ -53,7 +53,6 @@ #include "dbusconnection_p.h" #include "struct_marshallers_p.h" -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE class QAccessibleInterface; @@ -216,6 +215,5 @@ private: }; QT_END_NAMESPACE -QT_END_HEADER #endif diff --git a/src/platformsupport/linuxaccessibility/bridge_p.h b/src/platformsupport/linuxaccessibility/bridge_p.h index aed437b1e2..8a02847d3d 100644 --- a/src/platformsupport/linuxaccessibility/bridge_p.h +++ b/src/platformsupport/linuxaccessibility/bridge_p.h @@ -48,7 +48,6 @@ class DeviceEventControllerAdaptor; -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE class DBusConnection; @@ -81,6 +80,5 @@ private: }; QT_END_NAMESPACE -QT_END_HEADER #endif diff --git a/src/platformsupport/linuxaccessibility/cache_p.h b/src/platformsupport/linuxaccessibility/cache_p.h index 25680cd8e8..a8128d9320 100644 --- a/src/platformsupport/linuxaccessibility/cache_p.h +++ b/src/platformsupport/linuxaccessibility/cache_p.h @@ -46,7 +46,6 @@ #include #include "struct_marshallers_p.h" -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE class QSpiDBusCache : public QObject @@ -67,6 +66,5 @@ public Q_SLOTS: }; QT_END_NAMESPACE -QT_END_HEADER #endif /* Q_SPI_CACHE_H */ diff --git a/src/platformsupport/linuxaccessibility/constant_mappings_p.h b/src/platformsupport/linuxaccessibility/constant_mappings_p.h index 7410f5f94f..a0287a910b 100644 --- a/src/platformsupport/linuxaccessibility/constant_mappings_p.h +++ b/src/platformsupport/linuxaccessibility/constant_mappings_p.h @@ -95,7 +95,6 @@ #define QSPI_REGISTRY_NAME "org.a11y.atspi.Registry" -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE struct RoleNames { @@ -133,6 +132,5 @@ QSpiUIntList spiStateSetFromSpiStates(quint64 states); AtspiRelationType qAccessibleRelationToAtSpiRelation(QAccessible::Relation relation); QT_END_NAMESPACE -QT_END_HEADER #endif /* Q_SPI_CONSTANT_MAPPINGS_H */ diff --git a/src/platformsupport/linuxaccessibility/dbusconnection_p.h b/src/platformsupport/linuxaccessibility/dbusconnection_p.h index 2875dd89d8..2d55ccb547 100644 --- a/src/platformsupport/linuxaccessibility/dbusconnection_p.h +++ b/src/platformsupport/linuxaccessibility/dbusconnection_p.h @@ -47,7 +47,6 @@ #include #include -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE class QDBusServiceWatcher; @@ -83,6 +82,5 @@ private: }; QT_END_NAMESPACE -QT_END_HEADER #endif // DBUSCONNECTION_H diff --git a/src/platformsupport/linuxaccessibility/struct_marshallers_p.h b/src/platformsupport/linuxaccessibility/struct_marshallers_p.h index 60d06cebb4..0b775d5521 100644 --- a/src/platformsupport/linuxaccessibility/struct_marshallers_p.h +++ b/src/platformsupport/linuxaccessibility/struct_marshallers_p.h @@ -49,7 +49,6 @@ #include #include -QT_BEGIN_HEADER QT_BEGIN_NAMESPACE typedef QList QSpiIntList; @@ -173,5 +172,4 @@ Q_DECLARE_METATYPE(QSpiAttributeSet) Q_DECLARE_METATYPE(QSpiAppUpdate) Q_DECLARE_METATYPE(QSpiDeviceEvent) -QT_END_HEADER #endif /* Q_SPI_STRUCT_MARSHALLERS_H */ diff --git a/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/src/platformsupport/services/genericunix/qgenericunixservices_p.h index 13cf79de01..92166caf7b 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices_p.h +++ b/src/platformsupport/services/genericunix/qgenericunixservices_p.h @@ -45,8 +45,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class QGenericUnixServices : public QPlatformServices @@ -66,6 +64,4 @@ private: QT_END_NAMESPACE -QT_END_HEADER - #endif // QGENERICUNIXDESKTOPSERVICES_H diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h index 370b703204..b0ac13efe4 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h @@ -47,8 +47,6 @@ #include #include -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE class ResourceHelper @@ -132,6 +130,4 @@ QPlatformTheme *qt_createUnixTheme(); QT_END_NAMESPACE -QT_END_HEADER - #endif // QGENERICUNIXTHEMES_H -- cgit v1.2.3 From ebca7d2ea71440b0a5e465774e3abd98ff6298a8 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 29 Jan 2013 17:02:54 +0100 Subject: Introduce a native color dialog for GTK+ 2.x Change-Id: I389e6995b09df85cd6c464779e8d894b7cd33205 Reviewed-by: Friedemann Kleint Reviewed-by: Jens Bache-Wiig --- src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/platformsupport') diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index f2babe41a4..0d90e5d693 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -426,6 +426,9 @@ QStringList QGenericUnixTheme::themeNames() result.push_back(QLatin1String(QKdeTheme::name)); #endif } else { // Gnome, Unity, other Gtk-based desktops like XFCE. + // prefer the GTK2 theme implementation with native dialogs etc. + result.push_back(QStringLiteral("gtk2")); + // fallback to the generic Gnome theme if loading the GTK2 theme fails result.push_back(QLatin1String(QGnomeTheme::name)); } const QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION")); -- cgit v1.2.3 From fe6add818e2ab11fba3d9df12c29dfb29c65b2af Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 4 Feb 2013 17:03:38 +0100 Subject: Enablers in fbconvenience for Android port Additions to make the convenience classes work for the Qt for Android port. Change-Id: I25ba0faf93c7e09ab04a3fa0784e04631e5ab036 Reviewed-by: Gunnar Sletta --- src/platformsupport/fbconvenience/qfbscreen.cpp | 51 ++++++++++++++++++++----- src/platformsupport/fbconvenience/qfbscreen_p.h | 6 +++ src/platformsupport/fbconvenience/qfbwindow.cpp | 3 +- src/platformsupport/fbconvenience/qfbwindow_p.h | 2 +- 4 files changed, 51 insertions(+), 11 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp index efabf6e2a8..5200177fdd 100644 --- a/src/platformsupport/fbconvenience/qfbscreen.cpp +++ b/src/platformsupport/fbconvenience/qfbscreen.cpp @@ -45,6 +45,7 @@ #include "qfbbackingstore_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -72,6 +73,9 @@ void QFbScreen::addWindow(QFbWindow *window) mWindowStack.prepend(window); invalidateRectCache(); setDirty(window->geometry()); + QWindow *w = topWindow(); + QWindowSystemInterface::handleWindowActivated(w); + topWindowChanged(w); } void QFbScreen::removeWindow(QFbWindow *window) @@ -79,6 +83,9 @@ void QFbScreen::removeWindow(QFbWindow *window) mWindowStack.removeOne(window); invalidateRectCache(); setDirty(window->geometry()); + QWindow *w = topWindow(); + QWindowSystemInterface::handleWindowActivated(w); + topWindowChanged(w); } void QFbScreen::raise(QFbWindow *window) @@ -89,6 +96,9 @@ void QFbScreen::raise(QFbWindow *window) mWindowStack.move(index, 0); invalidateRectCache(); setDirty(window->geometry()); + QWindow *w = topWindow(); + QWindowSystemInterface::handleWindowActivated(w); + topWindowChanged(w); } void QFbScreen::lower(QFbWindow *window) @@ -99,20 +109,25 @@ void QFbScreen::lower(QFbWindow *window) mWindowStack.move(index, mWindowStack.size() - 1); invalidateRectCache(); setDirty(window->geometry()); + QWindow *w = topWindow(); + QWindowSystemInterface::handleWindowActivated(w); + topWindowChanged(w); +} + +QWindow *QFbScreen::topWindow() +{ + foreach (QFbWindow *fbw, mWindowStack) + if (fbw->window()->type() == Qt::Window || fbw->window()->type() == Qt::Dialog) + return fbw->window(); + return 0; } QWindow *QFbScreen::topLevelAt(const QPoint & p) const { - Q_UNUSED(p); -#if 0 - for (int i = 0; i < mWindowStack.size(); i++) { - if (mWindowStack[i]->geometry().contains(p, false) && - mWindowStack[i]->visible() && - !mWindowStack[i]->widget()->isMinimized()) { - return mWindowStack[i]->widget(); - } + foreach (QFbWindow *fbw, mWindowStack) { + if (fbw->geometry().contains(p, false) && fbw->window()->isVisible()) + return fbw->window(); } -#endif return 0; } @@ -126,6 +141,24 @@ void QFbScreen::setDirty(const QRect &rect) } } +void QFbScreen::setPhysicalSize(const QSize &size) +{ + mPhysicalSize = size; +} + +void QFbScreen::setGeometry(const QRect &rect) +{ + delete mCompositePainter; + mCompositePainter = 0; + delete mScreenImage; + mGeometry = rect; + mScreenImage = new QImage(mGeometry.size(), mFormat); + invalidateRectCache(); + QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry()); + QWindowSystemInterface::handleScreenAvailableGeometryChange(QPlatformScreen::screen(), availableGeometry()); + resizeMaximizedWindows(); +} + void QFbScreen::generateRects() { mCachedRects.clear(); diff --git a/src/platformsupport/fbconvenience/qfbscreen_p.h b/src/platformsupport/fbconvenience/qfbscreen_p.h index 00e3f9bef4..00847922c5 100644 --- a/src/platformsupport/fbconvenience/qfbscreen_p.h +++ b/src/platformsupport/fbconvenience/qfbscreen_p.h @@ -64,6 +64,7 @@ public: virtual QImage::Format format() const { return mFormat; } virtual QSizeF physicalSize() const { return mPhysicalSize; } + QWindow *topWindow(); virtual QWindow *topLevelAt(const QPoint & p) const; // compositor api @@ -71,7 +72,12 @@ public: virtual void removeWindow(QFbWindow *window); virtual void raise(QFbWindow *window); virtual void lower(QFbWindow *window); + virtual void topWindowChanged(QWindow *){} + +public slots: virtual void setDirty(const QRect &rect); + void setPhysicalSize(const QSize &size); + void setGeometry(const QRect &rect); protected slots: virtual QRegion doRedraw(); diff --git a/src/platformsupport/fbconvenience/qfbwindow.cpp b/src/platformsupport/fbconvenience/qfbwindow.cpp index e052907c79..246f50b4a9 100644 --- a/src/platformsupport/fbconvenience/qfbwindow.cpp +++ b/src/platformsupport/fbconvenience/qfbwindow.cpp @@ -43,6 +43,7 @@ #include "qfbscreen_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -71,7 +72,7 @@ void QFbWindow::setGeometry(const QRect &rect) mOldGeometry = geometry(); platformScreen()->invalidateRectCache(); - //### QWindowSystemInterface::handleGeometryChange(window(), rect); + QWindowSystemInterface::handleGeometryChange(window(), rect); QPlatformWindow::setGeometry(rect); } diff --git a/src/platformsupport/fbconvenience/qfbwindow_p.h b/src/platformsupport/fbconvenience/qfbwindow_p.h index 8c7d5c6b7a..25e2afca14 100644 --- a/src/platformsupport/fbconvenience/qfbwindow_p.h +++ b/src/platformsupport/fbconvenience/qfbwindow_p.h @@ -58,7 +58,7 @@ public: virtual void raise(); virtual void lower(); - void setGeometry(const QRect &rect); + virtual void setGeometry(const QRect &rect); virtual void setWindowFlags(Qt::WindowFlags type); virtual Qt::WindowFlags windowFlags() const; -- cgit v1.2.3 From 183e04a43996f7c4734ab97f20da6ba852dce918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 11 Feb 2013 13:49:42 +0100 Subject: Don't use the fallback list to decide if the CoreText font db was populated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some situation (such as iOS currently) we may end up with an empty fallback list, and we don't want to re-populate the font database on every call to fallbacksForFamily(). We do not guard populateFontDatabase(), since it's called both initially and every time the font database has been invalidated. Change-Id: Ief1342c40f75e5d393e054e9a20bc94bc357d482 Reviewed-by: Tor Arne Vestbø --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 6035aa6755..f6dfea31dc 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -381,8 +381,12 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo Q_UNUSED(family); Q_UNUSED(style); Q_UNUSED(script); - if (fallbackLists.isEmpty()) + + static bool didPopulateFallbackList = false; + if (!didPopulateFallbackList) { const_cast(this)->populateFontDatabase(); + didPopulateFallbackList = true; + } return fallbackLists[styleHint]; } -- cgit v1.2.3 From 74f9664f950e9ea4f385cd70f822e10d7be1aca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 11 Feb 2013 17:31:12 +0100 Subject: Use CTFontCopyDefaultCascadeListForLanguages for font fallback if available On Mac OS 10.8 and iOS 6.0 we can use CTFontCopyDefaultCascadeListForLanguages to get the list of fallback fonts, which is preferable to reading the plist file from the filesystem. The latter doesn't work (is not allowed) on iOS in any case, so for iOS < 6.0 we use a static list of fallback fonts. Change-Id: Ibb5e1b4dedd6bfb936f66b53a20f7ced83536ed7 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 194 ++++++++++++++------- .../fontdatabases/mac/qcoretextfontdatabase_p.h | 3 +- 2 files changed, 129 insertions(+), 68 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index f6dfea31dc..4a4c396828 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -91,22 +91,6 @@ static const char *languageForWritingSystem[] = { }; enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; -QFont::StyleHint styleHintFromNSString(NSString *style) -{ - if ([style isEqual: @"sans-serif"]) - return QFont::SansSerif; - else if ([style isEqual: @"monospace"]) - return QFont::Monospace; - else if ([style isEqual: @"cursive"]) - return QFont::Cursive; - else if ([style isEqual: @"serif"]) - return QFont::Serif; - else if ([style isEqual: @"fantasy"]) - return QFont::Fantasy; - else // if ([style isEqual: @"default"]) - return QFont::AnyStyle; -} - static NSInteger languageMapSort(id obj1, id obj2, void *context) { NSArray *map1 = (NSArray *) obj1; @@ -188,27 +172,6 @@ QCoreTextFontDatabase::~QCoreTextFontDatabase() { } -static QString familyNameFromPostScriptName(QHash &psNameToFamily, - NSString *psName) -{ - QString name = QCFString::toQString(psName); - if (psNameToFamily.contains(name)) - return psNameToFamily[name]; - else { - // Some of the font name in DefaultFontFallbacks.plist are hidden fonts like AquaHiraKaku, - // their family name begins with a dot, like ".AquaHiraKaku" or ".Apple Symbols Fallback", - // the only way (I've found) to get it are actually creating a CTFont with them. We only - // need to do it once though. - QCFType font = CTFontCreateWithName((CFStringRef) psName, 12.0, NULL); - if (font) { - QCFString family = CTFontCopyFamilyName(font); - psNameToFamily[name] = family; - return family; - } - return name; - } -} - void QCoreTextFontDatabase::populateFontDatabase() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -223,7 +186,6 @@ void QCoreTextFontDatabase::populateFontDatabase() QString foundryName = QLatin1String("CoreText"); const int numFonts = CFArrayGetCount(fonts); - QHash psNameToFamily; for (int i = 0; i < numFonts; ++i) { CTFontDescriptorRef font = (CTFontDescriptorRef) CFArrayGetValueAtIndex(fonts, i); QCFString familyName = (CFStringRef) CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL); @@ -289,35 +251,14 @@ void QCoreTextFontDatabase::populateFontDatabase() QPlatformFontDatabase::registerFont(familyName, styleName, foundryName, weight, style, stretch, true /* antialiased */, true /* scalable */, pixelSize, fixedPitch, writingSystems, (void *) font); + + // We need to map back and forth between PostScript-names and family-names for fallback list construction CFStringRef psName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontNameAttribute); - // we need PostScript Name to family name mapping for fallback list construction psNameToFamily[QCFString::toQString((NSString *) psName)] = familyName; + familyNameToPsName[familyName] = QCFString::toQString((NSString *) psName); CFRelease(psName); } - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"]; - - NSDictionary *fallbackDict = [NSDictionary dictionaryWithContentsOfFile: @"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist"]; - - for (NSString *style in [fallbackDict allKeys]) { - NSArray *list = [fallbackDict valueForKey: style]; - QFont::StyleHint styleHint = styleHintFromNSString(style); - QStringList fallbackList; - for (id item in list) { - // sort the array based on system language preferences - if ([item isKindOfClass: [NSArray class]]) { - NSArray *langs = [(NSArray *) item sortedArrayUsingFunction: languageMapSort - context: languages]; - for (NSArray *map in langs) - fallbackList.append(familyNameFromPostScriptName(psNameToFamily, [map objectAtIndex: 1])); - } - else if ([item isKindOfClass: [NSString class]]) - fallbackList.append(familyNameFromPostScriptName(psNameToFamily, item)); - } - fallbackLists[styleHint] = fallbackList; - } - [pool release]; } @@ -376,18 +317,137 @@ QFontEngine *QCoreTextFontDatabase::fontEngine(const QByteArray &fontData, qreal return fontEngine; } +QFont::StyleHint styleHintFromNSString(NSString *style) +{ + if ([style isEqual: @"sans-serif"]) + return QFont::SansSerif; + else if ([style isEqual: @"monospace"]) + return QFont::Monospace; + else if ([style isEqual: @"cursive"]) + return QFont::Cursive; + else if ([style isEqual: @"serif"]) + return QFont::Serif; + else if ([style isEqual: @"fantasy"]) + return QFont::Fantasy; + else // if ([style isEqual: @"default"]) + return QFont::AnyStyle; +} + +static QString familyNameFromPostScriptName(QHash &psNameToFamily, + NSString *psName) +{ + QString name = QCFString::toQString(psName); + if (psNameToFamily.contains(name)) + return psNameToFamily[name]; + else { + // Some of the font name in DefaultFontFallbacks.plist are hidden fonts like AquaHiraKaku, + // their family name begins with a dot, like ".AquaHiraKaku" or ".Apple Symbols Fallback", + // the only way (I've found) to get it are actually creating a CTFont with them. We only + // need to do it once though. + QCFType font = CTFontCreateWithName((CFStringRef) psName, 12.0, NULL); + if (font) { + QCFString family = CTFontCopyFamilyName(font); + psNameToFamily[name] = family; + return family; + } + return name; + } +} + QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { - Q_UNUSED(family); Q_UNUSED(style); Q_UNUSED(script); - static bool didPopulateFallbackList = false; - if (!didPopulateFallbackList) { + static QHash fallbackLists; + +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000 + // CTFontCopyDefaultCascadeListForLanguages is available in the SDK + #if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1080) \ + || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 60000) + // But we have to feature check at runtime + if (&CTFontCopyDefaultCascadeListForLanguages) + #endif + { + if (fallbackLists.contains(family)) + return fallbackLists.value(family); + + if (!familyNameToPsName.contains(family)) + const_cast(this)->populateFontDatabase(); + + QCFType font = CTFontCreateWithName(QCFString(familyNameToPsName[family]), 12.0, NULL); + if (font) { + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"]; + + QCFType cascadeList = (CFArrayRef) CTFontCopyDefaultCascadeListForLanguages(font, (CFArrayRef) languages); + if (cascadeList) { + QStringList fallbackList; + const int numCascades = CFArrayGetCount(cascadeList); + for (int i = 0; i < numCascades; ++i) { + CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i); + QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyLocalizedAttribute(fontFallback, kCTFontFamilyNameAttribute, NULL); + fallbackList.append(QCFString::toQString(fallbackFamilyName)); + } + fallbackLists[family] = fallbackList; + } + } + + if (fallbackLists.contains(family)) + return fallbackLists.value(family); + } +#endif + + // We were not able to find a fallback for the specific family, + // so we fall back to the stylehint. + + static const QString styleLookupKey = QString::fromLatin1(".QFontStyleHint_%1"); + + static bool didPopulateStyleFallbacks = false; + if (!didPopulateStyleFallbacks) { +#if !defined(Q_OS_IOS) + // Ensure we have the psNameToFamily mapping set up const_cast(this)->populateFontDatabase(); - didPopulateFallbackList = true; + + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"]; + + NSDictionary *fallbackDict = [NSDictionary dictionaryWithContentsOfFile: @"/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist"]; + + for (NSString *style in [fallbackDict allKeys]) { + NSArray *list = [fallbackDict valueForKey: style]; + QFont::StyleHint fallbackStyleHint = styleHintFromNSString(style); + QStringList fallbackList; + for (id item in list) { + // sort the array based on system language preferences + if ([item isKindOfClass: [NSArray class]]) { + NSArray *langs = [(NSArray *) item sortedArrayUsingFunction: languageMapSort + context: languages]; + for (NSArray *map in langs) + fallbackList.append(familyNameFromPostScriptName(psNameToFamily, [map objectAtIndex: 1])); + } + else if ([item isKindOfClass: [NSString class]]) + fallbackList.append(familyNameFromPostScriptName(psNameToFamily, item)); + } + fallbackLists[styleLookupKey.arg(fallbackStyleHint)] = fallbackList; + } +#else + QStringList staticFallbackList; + staticFallbackList << QString::fromLatin1("Helvetica,Apple Color Emoji,Geeza Pro,Arial Hebrew,Thonburi,Kailasa" + "Hiragino Kaku Gothic ProN,.Heiti J,Apple SD Gothic Neo,.Heiti K,Heiti SC,Heiti TC" + "Bangla Sangam MN,Devanagari Sangam MN,Gujarati Sangam MN,Gurmukhi MN,Kannada Sangam MN" + "Malayalam Sangam MN,Oriya Sangam MN,Sinhala Sangam MN,Tamil Sangam MN,Telugu Sangam MN" + "Euphemia UCAS,.PhoneFallback").split(QLatin1String(",")); + + for (int i = QFont::Helvetica; i <= QFont::Fantasy; ++i) + fallbackLists[styleLookupKey.arg(i)] = staticFallbackList; +#endif + + didPopulateStyleFallbacks = true; } - return fallbackLists[styleHint]; + + Q_ASSERT(!fallbackLists.isEmpty()); + return fallbackLists[styleLookupKey.arg(styleHint)]; } #ifndef Q_OS_IOS diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h index e4d45ab57a..5b9b8e2329 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h @@ -64,7 +64,8 @@ public: private: mutable QString defaultFontName; - QHash fallbackLists; + mutable QHash psNameToFamily; + mutable QHash familyNameToPsName; }; QT_END_NAMESPACE -- cgit v1.2.3 From d1ee7189553e13337b198fe4ba66d79fb7a7f41d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 11 Feb 2013 18:16:49 +0100 Subject: Add support for color glyphs (Emoji) on Mac OS X and iOS A new glyph type is added to the glyph caches for ARGB bitmap glyphs, and the raster and OpenGL paint engines have been modified to support this glyph type for drawCachedGlyphs(). The CoreText font engine implements support for these glyphs through the CTFontDrawGlyphs API, since CGContextShowGlyphsWithAdvances does not handle color glyphs. Change-Id: Idad9ce75a911cae130d65aebe59142772a16fc12 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../fontdatabases/mac/qfontengine_coretext.mm | 65 ++++++++++++++-------- .../fontdatabases/mac/qfontengine_coretext_p.h | 1 + 2 files changed, 44 insertions(+), 22 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 70416bc2dd..078b639fa8 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -158,7 +158,7 @@ void QCoreTextFontEngine::init() synthesisFlags = 0; CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ctfont); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 +#if defined(Q_OS_IOS) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 if (supportsColorGlyphs() && (traits & kCTFontColorGlyphsTrait)) glyphFormat = QFontEngineGlyphCache::Raster_ARGB; else @@ -457,7 +457,9 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition br.y = QFixed::fromReal(br.y.toReal() * vscale); } - QImage im(qAbs(qRound(br.width))+2, qAbs(qRound(br.height))+2, QImage::Format_RGB32); + bool isColorGlyph = glyphFormat == QFontEngineGlyphCache::Raster_ARGB; + QImage::Format format = isColorGlyph ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; + QImage im(qAbs(qRound(br.width)) + 2, qAbs(qRound(br.height)) + 2, format); im.fill(0); #ifndef Q_OS_IOS @@ -465,7 +467,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition #else CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); #endif - uint cgflags = kCGImageAlphaNoneSkipFirst; + uint cgflags = isColorGlyph ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst; #ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version cgflags |= kCGBitmapByteOrder32Host; #endif @@ -476,38 +478,49 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition CGContextSetShouldAntialias(ctx, (aa || fontDef.pointSize > antialiasingThreshold) && !(fontDef.styleStrategy & QFont::NoAntialias)); CGContextSetShouldSmoothFonts(ctx, aa); - CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx); - CGAffineTransform cgMatrix = CGAffineTransformIdentity; - CGAffineTransformConcat(cgMatrix, oldTextMatrix); + CGAffineTransform cgMatrix = CGAffineTransformIdentity; if (synthesisFlags & QFontEngine::SynthesizedItalic) cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, SYNTHETIC_ITALIC_SKEW, 1, 0, 0)); - cgMatrix = CGAffineTransformConcat(cgMatrix, transform); + if (!isColorGlyph) // CTFontDrawGlyphs incorporates the font's matrix already + cgMatrix = CGAffineTransformConcat(cgMatrix, transform); + if (m.isScaling()) cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMakeScale(m.m11(), m.m22())); - CGContextSetTextMatrix(ctx, cgMatrix); - CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); - CGContextSetTextDrawingMode(ctx, kCGTextFill); - - CGContextSetFont(ctx, cgFont); - + CGGlyph cgGlyph = glyph; qreal pos_x = -br.x.truncate() + subPixelPosition.toReal(); qreal pos_y = im.height() + br.y.toReal(); - CGContextSetTextPosition(ctx, pos_x, pos_y); - CGSize advance; - advance.width = 0; - advance.height = 0; - CGGlyph cgGlyph = glyph; - CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1); + if (!isColorGlyph) { + CGContextSetTextMatrix(ctx, cgMatrix); + CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); + CGContextSetTextDrawingMode(ctx, kCGTextFill); + CGContextSetFont(ctx, cgFont); + CGContextSetTextPosition(ctx, pos_x, pos_y); - if (synthesisFlags & QFontEngine::SynthesizedBold) { - CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y); - CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &advance, 1); + CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1); + + if (synthesisFlags & QFontEngine::SynthesizedBold) { + CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y); + CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1); + } + } +#if defined(Q_OS_IOS) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + else if (supportsColorGlyphs()) { + // CGContextSetTextMatrix does not work with color glyphs, so we use + // the CTM instead. This means we must translate the CTM as well, to + // set the glyph position, instead of using CGContextSetTextPosition. + CGContextTranslateCTM(ctx, pos_x, pos_y); + CGContextConcatCTM(ctx, cgMatrix); + + // CGContextShowGlyphsWithAdvances does not support the 'sbix' color-bitmap + // glyphs in the Apple Color Emoji font, so we use CTFontDrawGlyphs instead. + CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx); } +#endif CGContextRelease(ctx); CGColorSpaceRelease(colorspace); @@ -556,6 +569,14 @@ QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPo return im; } +QImage QCoreTextFontEngine::bitmapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) +{ + if (t.type() > QTransform::TxScale) + return QFontEngine::bitmapForGlyph(glyph, subPixelPosition, t); + + return imageForGlyph(glyph, subPixelPosition, true, t); +} + void QCoreTextFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const { int i, numGlyphs = glyphs->numGlyphs; diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index e7fec4be14..7c8f28aabd 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -98,6 +98,7 @@ public: virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition); virtual QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t); virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t); + virtual QImage bitmapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t); virtual qreal minRightBearing() const; virtual qreal minLeftBearing() const; virtual QFixed emSquareSize() const; -- cgit v1.2.3 From 4804f09c661d29b559a8fc239263f48ac1ce17ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 13 Feb 2013 15:55:53 +0100 Subject: Don't assume CTFontCopyDefaultCascadeListForLanguages is available on 10.8 It's listed in the 10.8 SDK as CT_AVAILABLE_STARTING( __MAC_10_8, __IPHONE_6_0), but not in the release notes for 10.8: http://developer.apple.com/library/mac/#releasenotes/General/APIDiffsMacOSX10_8/CoreText.html The iPhoneOS 6.0 SDK lists it as CT_AVAILABLE_STARTING( __MAC_NA, __IPHONE_6_0), which matches the release notes, and some 10.8 systems in the wild apparently do not have this function declaration in the system headers, so for now we'll be conservative and not assume it's available. Change-Id: Idbadda58ea95bfca75458d77cb2799c49fba013a Reviewed-by: Jens Bache-Wiig --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 4a4c396828..cf094078cb 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -361,10 +361,9 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo static QHash fallbackLists; -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000 +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000 // CTFontCopyDefaultCascadeListForLanguages is available in the SDK - #if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1080) \ - || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 60000) + #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 60000) // But we have to feature check at runtime if (&CTFontCopyDefaultCascadeListForLanguages) #endif -- cgit v1.2.3 From 603e1882736f77102cebec67729aca8464de958c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 13 Feb 2013 14:30:26 +0100 Subject: Manually add Emoji font to fallback list on Mac OS It's not part of the fallback list we read from the plist file. Change-Id: Ieaf306d4cd51a6bb6e6f41048876d3e674a4b99b Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index cf094078cb..aec32e1bca 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -395,6 +395,8 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo if (fallbackLists.contains(family)) return fallbackLists.value(family); } +#else + Q_UNUSED(family); #endif // We were not able to find a fallback for the specific family, @@ -428,6 +430,10 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo else if ([item isKindOfClass: [NSString class]]) fallbackList.append(familyNameFromPostScriptName(psNameToFamily, item)); } + + if (QCoreTextFontEngine::supportsColorGlyphs()) + fallbackList.append(QLatin1String("Apple Color Emoji")); + fallbackLists[styleLookupKey.arg(fallbackStyleHint)] = fallbackList; } #else -- cgit v1.2.3 From 0768920dbdabef25eb7d41e8dbba891704b24f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 16 Feb 2013 14:56:50 +0100 Subject: Remove ifdefs for supporting Mac OS <= 10.5 Qt5 requires Mac OS 10.6, so we can remove checks such as if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 Change-Id: Iea21727a277291148704ecf9677ed0b68c24920f Reviewed-by: Thiago Macieira --- src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 5 ----- src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h | 4 ---- 2 files changed, 9 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 078b639fa8..3e553acd0a 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -46,8 +46,6 @@ #include -#if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) - QT_BEGIN_NAMESPACE static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90); @@ -650,6 +648,3 @@ bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) co } QT_END_NAMESPACE - -#endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) - diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index 7c8f28aabd..a9b1960491 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -52,8 +52,6 @@ #include #endif -#if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) - QT_BEGIN_NAMESPACE class QRawFontPrivate; @@ -142,6 +140,4 @@ CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef); QT_END_NAMESPACE -#endif// !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) - #endif // QFONTENGINE_CORETEXT_P_H -- cgit v1.2.3 From f2191d9900cbb9930e2fbdefb4682ce59769e007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 16 Feb 2013 17:31:58 +0100 Subject: Introduce macros for simplifying platform checks on Mac OS and iOS Change-Id: Ibab8486e1e6d7e4d8922fce96add055e60c6095c Reviewed-by: Thiago Macieira --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index aec32e1bca..7391cbf9df 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -361,9 +361,9 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo static QHash fallbackLists; -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000 +#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_6_0) // CTFontCopyDefaultCascadeListForLanguages is available in the SDK - #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 60000) + #if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_6_0) // But we have to feature check at runtime if (&CTFontCopyDefaultCascadeListForLanguages) #endif -- cgit v1.2.3 From c7a51f1858a8cac5cdc458b575df1f0e064e3853 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 8 Feb 2013 20:05:34 +0100 Subject: Added QOffscreenSurface class. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inherits QSurface and allows to use OpenGL from an arbitrary thread. Platform plugins can implement QPlatformOffscreenSurface, otherwise an invisible QWindow is used by QOffscreenSurface. This patch includes an implementation of QOffscreenSurface for XCB and EglFS platform plugins using pbuffers. Change-Id: I57b4fc1db417331f34826dcfa754b7698782fde4 Reviewed-by: Lars Knoll Reviewed-by: Samuel Rødal --- .../eglconvenience/eglconvenience.pri | 6 +- src/platformsupport/eglconvenience/qeglpbuffer.cpp | 76 ++++++++++++++++++++++ src/platformsupport/eglconvenience/qeglpbuffer_p.h | 69 ++++++++++++++++++++ 3 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 src/platformsupport/eglconvenience/qeglpbuffer.cpp create mode 100644 src/platformsupport/eglconvenience/qeglpbuffer_p.h (limited to 'src/platformsupport') diff --git a/src/platformsupport/eglconvenience/eglconvenience.pri b/src/platformsupport/eglconvenience/eglconvenience.pri index 188eb1ce64..22ade42816 100644 --- a/src/platformsupport/eglconvenience/eglconvenience.pri +++ b/src/platformsupport/eglconvenience/eglconvenience.pri @@ -1,10 +1,12 @@ contains(QT_CONFIG,egl) { HEADERS += \ $$PWD/qeglconvenience_p.h \ - $$PWD/qeglplatformcontext_p.h + $$PWD/qeglplatformcontext_p.h \ + $$PWD/qeglpbuffer_p.h SOURCES += \ $$PWD/qeglconvenience.cpp \ - $$PWD/qeglplatformcontext.cpp + $$PWD/qeglplatformcontext.cpp \ + $$PWD/qeglpbuffer.cpp contains(QT_CONFIG,xlib) { HEADERS += \ diff --git a/src/platformsupport/eglconvenience/qeglpbuffer.cpp b/src/platformsupport/eglconvenience/qeglpbuffer.cpp new file mode 100644 index 0000000000..919314e9aa --- /dev/null +++ b/src/platformsupport/eglconvenience/qeglpbuffer.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "qeglpbuffer_p.h" +#include "qeglconvenience_p.h" + +QT_BEGIN_NAMESPACE + +QEGLPbuffer::QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface) + : QPlatformOffscreenSurface(offscreenSurface) + , m_format(format) + , m_display(display) + , m_pbuffer(EGL_NO_SURFACE) +{ + EGLConfig config = q_configFromGLFormat(m_display, m_format, false, EGL_PBUFFER_BIT); + + if (config) { + const EGLint attributes[] = { + EGL_WIDTH, offscreenSurface->size().width(), + EGL_HEIGHT, offscreenSurface->size().height(), + EGL_LARGEST_PBUFFER, EGL_FALSE, + EGL_NONE + }; + + m_pbuffer = eglCreatePbufferSurface(m_display, config, attributes); + + if (m_pbuffer != EGL_NO_SURFACE) + m_format = q_glFormatFromConfig(m_display, config); + } +} + +QEGLPbuffer::~QEGLPbuffer() +{ + eglDestroySurface(m_display, m_pbuffer); +} + +QT_END_NAMESPACE diff --git a/src/platformsupport/eglconvenience/qeglpbuffer_p.h b/src/platformsupport/eglconvenience/qeglpbuffer_p.h new file mode 100644 index 0000000000..1b4ac6f991 --- /dev/null +++ b/src/platformsupport/eglconvenience/qeglpbuffer_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QEGLPBUFFER_H +#define QEGLPBUFFER_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QEGLPbuffer : public QPlatformOffscreenSurface +{ +public: + QEGLPbuffer(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface); + ~QEGLPbuffer(); + + QSurfaceFormat format() const { return m_format; } + bool isValid() const { return m_pbuffer != EGL_NO_SURFACE; } + + EGLSurface pbuffer() const { return m_pbuffer; } + +private: + QSurfaceFormat m_format; + EGLDisplay m_display; + EGLSurface m_pbuffer; +}; + +QT_END_NAMESPACE + +#endif // QEGLPBUFFER_H -- cgit v1.2.3 From a54b271c390f54b4aafa1b7f7cd5e2c1b82cb8ad Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 18 Feb 2013 16:42:17 -0600 Subject: Fix EGL_BAD_MATCH when requesting a 16-bit surface with eglfs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QEglFSWindow does not request highestPixelFormat, and can obtain a 16-bit config when requested. QEGLPlatformContext does request highestPixelFormat, and can obtain a 32-bit config when a 16-bit config is requested, leading to this error. Change-Id: I418c09a35ec19b2e9ca372b32599034e02384e44 Reviewed-by: Samuel Rødal --- src/platformsupport/eglconvenience/qeglplatformcontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index eafd7a5288..8152f74067 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -63,7 +63,7 @@ QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatform EGLenum eglApi) : m_eglDisplay(display) , m_eglApi(eglApi) - , m_eglConfig(q_configFromGLFormat(display, format, true)) + , m_eglConfig(q_configFromGLFormat(display, format)) { init(format, share); } -- cgit v1.2.3 From f73ddd4dfb80ce8d587a2f85b96b55067e90a3c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 20 Feb 2013 15:00:11 +0100 Subject: Reintroduce use of CTFontCopyDefaultCascadeListForLanguages on Mac OS Now that we always build against an SDK, we can be sure that the function declaration for CTFontCopyDefaultCascadeListForLanguages is available in the CoreText CTFont.h header. Change-Id: I304a701548833e5c7774b4fd2e72eb8c541dd103 Reviewed-by: Jens Bache-Wiig Reviewed-by: Oswald Buddenhagen Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 7391cbf9df..ef5bdbbf0d 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -361,9 +361,9 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo static QHash fallbackLists; -#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_6_0) +#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_6_0) // CTFontCopyDefaultCascadeListForLanguages is available in the SDK - #if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_6_0) + #if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_10_8, __IPHONE_6_0) // But we have to feature check at runtime if (&CTFontCopyDefaultCascadeListForLanguages) #endif -- cgit v1.2.3 From cb8bfeafac537fd8b985eded4b4a0b2adba28b7e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 20 Feb 2013 13:56:14 +0100 Subject: Drop the unused qcgl_createGlContext function Change-Id: I09286388e9af7ec472b394be87204746f8ae22b1 Reviewed-by: James Turner Reviewed-by: Gunnar Sletta --- src/platformsupport/cglconvenience/cglconvenience.mm | 10 ---------- src/platformsupport/cglconvenience/cglconvenience_p.h | 1 - 2 files changed, 11 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm index b0ea2d2225..81e8870ade 100644 --- a/src/platformsupport/cglconvenience/cglconvenience.mm +++ b/src/platformsupport/cglconvenience/cglconvenience.mm @@ -125,13 +125,3 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format) NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()]; return pixelFormat; } - -CGLContextObj qcgl_createGlContext() -{ - CGLContextObj context; - NSOpenGLPixelFormat *format = reinterpret_cast(qcgl_createNSOpenGLPixelFormat(qcgl_surfaceFormat())); - CGLPixelFormatObj cglFormat = static_cast([format CGLPixelFormatObj]); - CGLCreateContext(cglFormat ,NULL, &context); - return context; -} - diff --git a/src/platformsupport/cglconvenience/cglconvenience_p.h b/src/platformsupport/cglconvenience/cglconvenience_p.h index bd2de0abc0..82842a78f0 100644 --- a/src/platformsupport/cglconvenience/cglconvenience_p.h +++ b/src/platformsupport/cglconvenience/cglconvenience_p.h @@ -49,6 +49,5 @@ void (*qcgl_getProcAddress(const QByteArray &procName))(); QSurfaceFormat qcgl_surfaceFormat(); void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format); -CGLContextObj qcgl_createGlContext(); #endif // QMACGLCONVENIENCE_H -- cgit v1.2.3 From 0575baac5e21cbe38a6ceabaa6b17862cbfee7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 1 Nov 2012 22:22:56 +0100 Subject: Don't link QtPlatformSupport to CoreFoundation or Carbon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the Carbon dependency to the Cocoa platform plugin instead, where it's actually used. CoreFoundation was not used by any plugins and could be removed completely. Change-Id: I1c825cdf94e2cc348ea13519b894fd868be0d14a Reviewed-by: Morten Johan Sørvig --- src/platformsupport/platformsupport.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index 57d9b422f4..469c76ffae 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -2,7 +2,7 @@ TARGET = QtPlatformSupport QT = core-private gui-private CONFIG += static internal_module -mac:LIBS += -lz -framework CoreFoundation -framework Carbon +mac:LIBS += -lz load(qt_module) -- cgit v1.2.3 From 7e5750101699a408356439126649e8f49010d1df Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 20 Feb 2013 14:00:52 +0100 Subject: Enforce OpenGL context creation under Cocoa We don't support other context types, so fail in those cases. Also, return OpenGL as the rendereable type of our surface. Change-Id: I3d5632eb8555d73ed14837b662c7450589a8681f Reviewed-by: Gunnar Sletta --- src/platformsupport/cglconvenience/cglconvenience.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'src/platformsupport') diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm index 81e8870ade..12ae5965df 100644 --- a/src/platformsupport/cglconvenience/cglconvenience.mm +++ b/src/platformsupport/cglconvenience/cglconvenience.mm @@ -61,6 +61,7 @@ void (*qcgl_getProcAddress(const QByteArray &procName))() QSurfaceFormat qcgl_surfaceFormat() { QSurfaceFormat format; + format.setRenderableType(QSurfaceFormat::OpenGL); format.setRedBufferSize(8); format.setGreenBufferSize(8); format.setBlueBufferSize(8); -- cgit v1.2.3 From f2b26af2b4db25aeb74279a40365b76f0406a018 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 20 Feb 2013 14:00:52 +0100 Subject: Enforce OpenGL context creation under XCB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't support other context types, so fail in those cases. Also, return OpenGL as the rendereable type of our surface. Change-Id: Ic7b5ed0ec5eaf5c0f88f50f5bceb697ea414c696 Reviewed-by: Samuel Rødal Reviewed-by: Gunnar Sletta --- src/platformsupport/glxconvenience/qglxconvenience.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/platformsupport') diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index e885ecc105..9ce74f55fe 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -224,6 +224,8 @@ XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *f QSurfaceFormat qglx_surfaceFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext) { QSurfaceFormat format; + format.setRenderableType(QSurfaceFormat::OpenGL); + int redSize = 0; int greenSize = 0; int blueSize = 0; -- cgit v1.2.3 From 0077b5f30de7190227317247609c820f37466960 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 21 Feb 2013 16:07:46 +0100 Subject: Pass the surface format to qglx_surfaceFormatFromGLXFBConfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of creating a default-constructed format and filling its field in, pass a pointer to an instance. This way we won't lose the renderable type set on the surface, but just fill in the other parameters. Change-Id: I1fd403671f9c677cc74aaf3c116a05f213d5d556 Reviewed-by: Samuel Rødal --- .../glxconvenience/qglxconvenience.cpp | 25 +++++++++------------- .../glxconvenience/qglxconvenience_p.h | 2 +- 2 files changed, 11 insertions(+), 16 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index 9ce74f55fe..11d9377db7 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -171,7 +171,7 @@ XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *f GLXFBConfig config = qglx_findConfig(display,screen,*format); if (config) { visualInfo = glXGetVisualFromFBConfig(display, config); - *format = qglx_surfaceFormatFromGLXFBConfig(display, config); + qglx_surfaceFormatFromGLXFBConfig(format, display, config); } // attempt to fall back to glXChooseVisual @@ -221,11 +221,8 @@ XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *f return visualInfo; } -QSurfaceFormat qglx_surfaceFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext) +void qglx_surfaceFormatFromGLXFBConfig(QSurfaceFormat *format, Display *display, GLXFBConfig config, GLXContext) { - QSurfaceFormat format; - format.setRenderableType(QSurfaceFormat::OpenGL); - int redSize = 0; int greenSize = 0; int blueSize = 0; @@ -247,20 +244,18 @@ QSurfaceFormat qglx_surfaceFormatFromGLXFBConfig(Display *display, GLXFBConfig c glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleBuffers); glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); - format.setRedBufferSize(redSize); - format.setGreenBufferSize(greenSize); - format.setBlueBufferSize(blueSize); - format.setAlphaBufferSize(alphaSize); - format.setDepthBufferSize(depthSize); - format.setStencilBufferSize(stencilSize); + format->setRedBufferSize(redSize); + format->setGreenBufferSize(greenSize); + format->setBlueBufferSize(blueSize); + format->setAlphaBufferSize(alphaSize); + format->setDepthBufferSize(depthSize); + format->setStencilBufferSize(stencilSize); if (sampleBuffers) { glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); - format.setSamples(sampleCount); + format->setSamples(sampleCount); } - format.setStereo(stereo); - - return format; + format->setStereo(stereo); } QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced) diff --git a/src/platformsupport/glxconvenience/qglxconvenience_p.h b/src/platformsupport/glxconvenience/qglxconvenience_p.h index 70f97d8b38..66548a3479 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience_p.h +++ b/src/platformsupport/glxconvenience/qglxconvenience_p.h @@ -50,7 +50,7 @@ XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *format); GLXFBConfig qglx_findConfig(Display *display, int screen, const QSurfaceFormat &format, int drawableBit = GLX_WINDOW_BIT); -QSurfaceFormat qglx_surfaceFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context = 0); +void qglx_surfaceFormatFromGLXFBConfig(QSurfaceFormat *format, Display *display, GLXFBConfig config, GLXContext context = 0); QVector qglx_buildSpec(const QSurfaceFormat &format, int drawableBit = GLX_WINDOW_BIT); QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced); -- cgit v1.2.3 From 3bc4afc223bcd56245797a0bd3628f02a992301c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 1 Nov 2012 12:31:50 +0100 Subject: iOS: Move Q_OS_IOS out of makesespec to qsystemdetection.h We treat iOS as a variant of Mac OS, so for iOS both Q_OS_MAC and Q_OS_IOS will be defined. This matches what Apple assumes in the header file TargetConditionals.h Change-Id: I55cc851401b748297478e4c32e84e0f6e1fdfc28 Reviewed-by: Thiago Macieira --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index ef5bdbbf0d..fbd836f763 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -39,6 +39,8 @@ ** ****************************************************************************/ +#include "qglobal.h" + #ifndef Q_OS_IOS #import #import -- cgit v1.2.3 From 7b2d98d90642ce7ac4ab0800bd7930f97ba6b10c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 22 Feb 2013 18:17:12 -0800 Subject: Fix some warnings that have crept up since I last fixed warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qgtkstyle.cpp:3177:103: error: suggest parentheses around ‘&&’ within ‘||’ [-Werror=parentheses] qcups.cpp:517:66: error: ‘QString::QString(const char*)’ is deprecated itemviews.cpp:795:13: error: unused parameter ‘actionName’ [-Werror=unused-parameter] qeglconvenience.cpp:268:9: error: ‘cfg’ may be used uninitialized in this function [-Werror=maybe-uninitialized] Change-Id: I9b8a175ff1c2ddc443363e08b92e09cf7c2f91cf Reviewed-by: Giuseppe D'Angelo Reviewed-by: John Layt Reviewed-by: Olivier Goffart --- src/platformsupport/eglconvenience/qeglconvenience.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index 3119356330..b711a2aebd 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -245,7 +245,7 @@ EGLConfig QEglConfigChooser::chooseConfig() configureAttributes.append(EGL_NONE); - EGLConfig cfg; + EGLConfig cfg = 0; do { // Get the number of matching configurations for this set of properties. EGLint matching = 0; -- cgit v1.2.3 From 023644cae1f22bb0d01c0ee540e0eb083abefb25 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 27 Feb 2013 15:19:15 +0100 Subject: Style fixes for android enablers Change-Id: I0b942865c29f4bdf29f0e7f56af0d620acbc39c6 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/platformsupport/fbconvenience/qfbscreen.cpp | 2 +- src/platformsupport/fbconvenience/qfbscreen_p.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp index 5200177fdd..6427b62972 100644 --- a/src/platformsupport/fbconvenience/qfbscreen.cpp +++ b/src/platformsupport/fbconvenience/qfbscreen.cpp @@ -114,7 +114,7 @@ void QFbScreen::lower(QFbWindow *window) topWindowChanged(w); } -QWindow *QFbScreen::topWindow() +QWindow *QFbScreen::topWindow() const { foreach (QFbWindow *fbw, mWindowStack) if (fbw->window()->type() == Qt::Window || fbw->window()->type() == Qt::Dialog) diff --git a/src/platformsupport/fbconvenience/qfbscreen_p.h b/src/platformsupport/fbconvenience/qfbscreen_p.h index 00847922c5..c7106358d9 100644 --- a/src/platformsupport/fbconvenience/qfbscreen_p.h +++ b/src/platformsupport/fbconvenience/qfbscreen_p.h @@ -64,7 +64,7 @@ public: virtual QImage::Format format() const { return mFormat; } virtual QSizeF physicalSize() const { return mPhysicalSize; } - QWindow *topWindow(); + QWindow *topWindow() const; virtual QWindow *topLevelAt(const QPoint & p) const; // compositor api @@ -72,7 +72,7 @@ public: virtual void removeWindow(QFbWindow *window); virtual void raise(QFbWindow *window); virtual void lower(QFbWindow *window); - virtual void topWindowChanged(QWindow *){} + virtual void topWindowChanged(QWindow *) {} public slots: virtual void setDirty(const QRect &rect); -- cgit v1.2.3 From c7fbff7bf255f9fc0123f37fc475bd8ae8cf38e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 4 Dec 2012 15:50:49 +0100 Subject: iOS: Add required public dependencies of the CoreText font database CoreText and CoreGraphics are available on iOS as stand-alone frameworks, but on Mac OS X they are part of the ApplicationServices umbrella framework. Mac OS 10.8 actually introduced both as stand-alone frameworks, but for simplicity we link to ApplicationServices, as there's still symlinks from ApplicationServices to the real frameworks. Change-Id: I7f7ef795629cc37da85857d5c42283754acc4474 Reviewed-by: Richard Moe Gustavsen --- src/platformsupport/fontdatabases/mac/coretext.pri | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/mac/coretext.pri b/src/platformsupport/fontdatabases/mac/coretext.pri index f7977964fe..d1abf123aa 100644 --- a/src/platformsupport/fontdatabases/mac/coretext.pri +++ b/src/platformsupport/fontdatabases/mac/coretext.pri @@ -1,2 +1,10 @@ HEADERS += $$PWD/qcoretextfontdatabase_p.h $$PWD/qfontengine_coretext_p.h OBJECTIVE_SOURCES += $$PWD/qfontengine_coretext.mm $$PWD/qcoretextfontdatabase.mm + +ios: \ + # On iOS CoreText and CoreGraphics are stand-alone frameworks + LIBS += -framework CoreText -framework CoreGraphics +else: \ + # On Mac OS they are part of the ApplicationServices umbrella framework, + # even in 10.8 where they were also made available stand-alone. + LIBS += -framework ApplicationServices -- cgit v1.2.3 From aa5528b050472d1d1097e2665fb346232cbfa7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 15 Feb 2013 11:25:39 +0100 Subject: iOS: Implement socket notifiers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create the QCFSocketNotifier class in platform support which contains shared socket notifier support for the Cocoa and iOS plugins. Remove the old code from the Cocoa plugin. The Cocoa code had one QCocoaEventDispatcher-specific call: maybeCancelWaitForMoreEvents. Create a forwarding function that is passed to QCFSocketNotifier. Change-Id: Ibf9bd4745ba4f577a55f13d0cc00f5ae04447405 Reviewed-by: Tor Arne Vestbø Reviewed-by: Richard Moe Gustavsen --- .../cfsocketnotifier/cfsocketnotifier.pri | 4 + .../cfsocketnotifier/qcfsocketnotifier.cpp | 255 +++++++++++++++++++++ .../cfsocketnotifier/qcfsocketnotifier_p.h | 90 ++++++++ src/platformsupport/platformsupport.pro | 1 + 4 files changed, 350 insertions(+) create mode 100644 src/platformsupport/cfsocketnotifier/cfsocketnotifier.pri create mode 100644 src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp create mode 100644 src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h (limited to 'src/platformsupport') diff --git a/src/platformsupport/cfsocketnotifier/cfsocketnotifier.pri b/src/platformsupport/cfsocketnotifier/cfsocketnotifier.pri new file mode 100644 index 0000000000..9a19d3c278 --- /dev/null +++ b/src/platformsupport/cfsocketnotifier/cfsocketnotifier.pri @@ -0,0 +1,4 @@ +mac { + HEADERS += $$PWD/qcfsocketnotifier_p.h + SOURCES += $$PWD/qcfsocketnotifier.cpp +} diff --git a/src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp new file mode 100644 index 0000000000..5dcd6a4ffd --- /dev/null +++ b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qcfsocketnotifier_p.h" +#include +#include +#include + + +/************************************************************************** + Socket Notifiers + *************************************************************************/ +void qt_mac_socket_callback(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef, + const void *, void *info) +{ + + QCFSocketNotifier *cfSocketNotifier = static_cast(info); + int nativeSocket = CFSocketGetNative(s); + MacSocketInfo *socketInfo = cfSocketNotifier->macSockets.value(nativeSocket); + QEvent notifierEvent(QEvent::SockAct); + + // There is a race condition that happen where we disable the notifier and + // the kernel still has a notification to pass on. We then get this + // notification after we've successfully disabled the CFSocket, but our Qt + // notifier is now gone. The upshot is we have to check the notifier + // every time. + if (callbackType == kCFSocketReadCallBack) { + if (socketInfo->readNotifier) + QGuiApplication::sendEvent(socketInfo->readNotifier, ¬ifierEvent); + } else if (callbackType == kCFSocketWriteCallBack) { + if (socketInfo->writeNotifier) + QGuiApplication::sendEvent(socketInfo->writeNotifier, ¬ifierEvent); + } + + if (cfSocketNotifier->maybeCancelWaitForMoreEvents) + cfSocketNotifier->maybeCancelWaitForMoreEvents(cfSocketNotifier->eventDispatcher); +} + +/* + Adds a loop source for the given socket to the current run loop. +*/ +CFRunLoopSourceRef qt_mac_add_socket_to_runloop(const CFSocketRef socket) +{ + CFRunLoopSourceRef loopSource = CFSocketCreateRunLoopSource(kCFAllocatorDefault, socket, 0); + if (!loopSource) + return 0; + + CFRunLoopAddSource(CFRunLoopGetMain(), loopSource, kCFRunLoopCommonModes); + return loopSource; +} + +/* + Removes the loop source for the given socket from the current run loop. +*/ +void qt_mac_remove_socket_from_runloop(const CFSocketRef socket, CFRunLoopSourceRef runloop) +{ + Q_ASSERT(runloop); + CFRunLoopRemoveSource(CFRunLoopGetMain(), runloop, kCFRunLoopCommonModes); + CFSocketDisableCallBacks(socket, kCFSocketReadCallBack); + CFSocketDisableCallBacks(socket, kCFSocketWriteCallBack); + CFRunLoopSourceInvalidate(runloop); +} + +QCFSocketNotifier::QCFSocketNotifier() +:eventDispatcher(0) +{ + +} + +QCFSocketNotifier::~QCFSocketNotifier() +{ + +} + +void QCFSocketNotifier::setHostEventDispatcher(QAbstractEventDispatcher *hostEventDispacher) +{ + eventDispatcher = hostEventDispacher; +} + +void QCFSocketNotifier::setMaybeCancelWaitForMoreEventsCallback(MaybeCancelWaitForMoreEventsFn callBack) +{ + maybeCancelWaitForMoreEvents = callBack; +} + +void QCFSocketNotifier::registerSocketNotifier(QSocketNotifier *notifier) +{ + Q_ASSERT(notifier); + int nativeSocket = notifier->socket(); + int type = notifier->type(); +#ifndef QT_NO_DEBUG + if (nativeSocket < 0 || nativeSocket > FD_SETSIZE) { + qWarning("QSocketNotifier: Internal error"); + return; + } else if (notifier->thread() != eventDispatcher->thread() + || eventDispatcher->thread() != QThread::currentThread()) { + qWarning("QSocketNotifier: socket notifiers cannot be enabled from another thread"); + return; + } +#endif + + if (type == QSocketNotifier::Exception) { + qWarning("QSocketNotifier::Exception is not supported on iOS"); + return; + } + + // Check if we have a CFSocket for the native socket, create one if not. + MacSocketInfo *socketInfo = macSockets.value(nativeSocket); + if (!socketInfo) { + socketInfo = new MacSocketInfo(); + + // Create CFSocket, specify that we want both read and write callbacks (the callbacks + // are enabled/disabled later on). + const int callbackTypes = kCFSocketReadCallBack | kCFSocketWriteCallBack; + CFSocketContext context = {0, this, 0, 0, 0}; + socketInfo->socket = CFSocketCreateWithNative(kCFAllocatorDefault, nativeSocket, callbackTypes, qt_mac_socket_callback, &context); + if (CFSocketIsValid(socketInfo->socket) == false) { + qWarning("QEventDispatcherMac::registerSocketNotifier: Failed to create CFSocket"); + return; + } + + CFOptionFlags flags = CFSocketGetSocketFlags(socketInfo->socket); + flags |= kCFSocketAutomaticallyReenableWriteCallBack; //QSocketNotifier stays enabled after a write + flags &= ~kCFSocketCloseOnInvalidate; //QSocketNotifier doesn't close the socket upon destruction/invalidation + CFSocketSetSocketFlags(socketInfo->socket, flags); + + // Add CFSocket to runloop. + if (!(socketInfo->runloop = qt_mac_add_socket_to_runloop(socketInfo->socket))) { + qWarning("QEventDispatcherMac::registerSocketNotifier: Failed to add CFSocket to runloop"); + CFSocketInvalidate(socketInfo->socket); + CFRelease(socketInfo->socket); + return; + } + + // Disable both callback types by default. This must be done after + // we add the CFSocket to the runloop, or else these calls will have + // no effect. + CFSocketDisableCallBacks(socketInfo->socket, kCFSocketReadCallBack); + CFSocketDisableCallBacks(socketInfo->socket, kCFSocketWriteCallBack); + + macSockets.insert(nativeSocket, socketInfo); + } + + // Increment read/write counters and select enable callbacks if necessary. + if (type == QSocketNotifier::Read) { + Q_ASSERT(socketInfo->readNotifier == 0); + socketInfo->readNotifier = notifier; + CFSocketEnableCallBacks(socketInfo->socket, kCFSocketReadCallBack); + } else if (type == QSocketNotifier::Write) { + Q_ASSERT(socketInfo->writeNotifier == 0); + socketInfo->writeNotifier = notifier; + CFSocketEnableCallBacks(socketInfo->socket, kCFSocketWriteCallBack); + } +} + +void QCFSocketNotifier::unregisterSocketNotifier(QSocketNotifier *notifier) +{ + Q_ASSERT(notifier); + int nativeSocket = notifier->socket(); + int type = notifier->type(); +#ifndef QT_NO_DEBUG + if (nativeSocket < 0 || nativeSocket > FD_SETSIZE) { + qWarning("QSocketNotifier: Internal error"); + return; + } else if (notifier->thread() != eventDispatcher->thread() || eventDispatcher->thread() != QThread::currentThread()) { + qWarning("QSocketNotifier: socket notifiers cannot be disabled from another thread"); + return; + } +#endif + + if (type == QSocketNotifier::Exception) { + qWarning("QSocketNotifier::Exception is not supported on iOS"); + return; + } + MacSocketInfo *socketInfo = macSockets.value(nativeSocket); + if (!socketInfo) { + qWarning("QEventDispatcherMac::unregisterSocketNotifier: Tried to unregister a not registered notifier"); + return; + } + + // Decrement read/write counters and disable callbacks if necessary. + if (type == QSocketNotifier::Read) { + Q_ASSERT(notifier == socketInfo->readNotifier); + socketInfo->readNotifier = 0; + CFSocketDisableCallBacks(socketInfo->socket, kCFSocketReadCallBack); + } else if (type == QSocketNotifier::Write) { + Q_ASSERT(notifier == socketInfo->writeNotifier); + socketInfo->writeNotifier = 0; + CFSocketDisableCallBacks(socketInfo->socket, kCFSocketWriteCallBack); + } + + // Remove CFSocket from runloop if this was the last QSocketNotifier. + if (socketInfo->readNotifier == 0 && socketInfo->writeNotifier == 0) { + if (CFSocketIsValid(socketInfo->socket)) + qt_mac_remove_socket_from_runloop(socketInfo->socket, socketInfo->runloop); + CFRunLoopSourceInvalidate(socketInfo->runloop); + CFRelease(socketInfo->runloop); + CFSocketInvalidate(socketInfo->socket); + CFRelease(socketInfo->socket); + delete socketInfo; + macSockets.remove(nativeSocket); + } +} + +void QCFSocketNotifier::removeSocketNotifiers() +{ + // Remove CFSockets from the runloop. + for (MacSocketHash::ConstIterator it = macSockets.constBegin(); it != macSockets.constEnd(); ++it) { + MacSocketInfo *socketInfo = (*it); + if (CFSocketIsValid(socketInfo->socket)) { + qt_mac_remove_socket_from_runloop(socketInfo->socket, socketInfo->runloop); + CFRunLoopSourceInvalidate(socketInfo->runloop); + CFRelease(socketInfo->runloop); + CFSocketInvalidate(socketInfo->socket); + CFRelease(socketInfo->socket); + } + } +} diff --git a/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h new file mode 100644 index 0000000000..cd1eb8e4ca --- /dev/null +++ b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCFSOCKETNOTIFIER_P_H +#define QCFSOCKETNOTIFIER_P_H + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +struct MacSocketInfo { + MacSocketInfo() : socket(0), runloop(0), readNotifier(0), writeNotifier(0) {} + CFSocketRef socket; + CFRunLoopSourceRef runloop; + QObject *readNotifier; + QObject *writeNotifier; +}; +typedef QHash MacSocketHash; + +typedef void (*MaybeCancelWaitForMoreEventsFn)(QAbstractEventDispatcher *hostEventDispacher); + +// The CoreFoundationSocketNotifier class implements socket notifiers support using +// CFSocket for event dispatchers running on top of the Core Foundation run loop system. +// (currently Mac and iOS) +// +// The principal functions are registerSocketNotifier() and unregisterSocketNotifier(). +// +// setHostEventDispatcher() should be called at startup. +// removeSocketNotifiers() should be called at shutdown. +// +class QCFSocketNotifier +{ +public: + QCFSocketNotifier(); + ~QCFSocketNotifier(); + void setHostEventDispatcher(QAbstractEventDispatcher *hostEventDispacher); + void setMaybeCancelWaitForMoreEventsCallback(MaybeCancelWaitForMoreEventsFn callBack); + void registerSocketNotifier(QSocketNotifier *notifier); + void unregisterSocketNotifier(QSocketNotifier *notifier); + void removeSocketNotifiers(); + + MacSocketHash macSockets; + QAbstractEventDispatcher *eventDispatcher; + MaybeCancelWaitForMoreEventsFn maybeCancelWaitForMoreEvents; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index 469c76ffae..8e0f396993 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -9,6 +9,7 @@ load(qt_module) DEFINES += QT_NO_CAST_FROM_ASCII PRECOMPILED_HEADER = ../corelib/global/qt_pch.h +include(cfsocketnotifier/cfsocketnotifier.pri) include(cglconvenience/cglconvenience.pri) include(dnd/dnd.pri) include(eglconvenience/eglconvenience.pri) -- cgit v1.2.3 From c63e7f576609e90e7cb6d1b4c107182ae8c2d6c6 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sat, 2 Mar 2013 22:29:48 +0200 Subject: Fix selection of fonts that require OpenType features HB_Face's supported_scripts[] expects HB_Script, so QChar::Script should be remapped via script_to_hbscript(). Change-Id: Ib068c35ab76567fe9a61da7d8ab01133a6f58bc0 Reviewed-by: Lars Knoll --- src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp | 3 +-- src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp index e65a5f5aec..f17eff4dd7 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp @@ -262,8 +262,7 @@ QFontEngine *QBasicFontDatabase::fontEngine(const QFontDef &fontDef, QChar::Scri delete engine; engine = 0; } else if (scriptRequiresOpenType(script)) { - HB_Face hbFace = engine->initializedHarfbuzzFace(); - if (!hbFace || !hbFace->supported_scripts[script]) { + if (!engine->supportsScript(script)) { delete engine; engine = 0; } diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index 728d11500a..329268395e 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -638,8 +638,7 @@ QFontEngine *QFontconfigDatabase::fontEngine(const QFontDef &f, QChar::Script sc delete engine; engine = 0; } else if (scriptRequiresOpenType(script)) { - HB_Face hbFace = engine->initializedHarfbuzzFace(); - if (!hbFace || !hbFace->supported_scripts[script]) { + if (!engine->supportsScript(script)) { delete engine; engine = 0; } -- cgit v1.2.3 From 97fcf3bc987a18f32233fea550eb4a5a22e2b822 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 4 Mar 2013 10:16:42 +0100 Subject: Introducing the Qt Android port MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on the Necessitas project by Bogdan Vatra. Contributors to the Qt5 project: BogDan Vatra Eskil Abrahamsen Blomfeldt hjk Oswald Buddenhagen Paul Olav Tvete Robin Burchell Samuel Rødal Yoann Lopes The full history of the Qt5 port can be found in refs/old-heads/android, SHA-1 249ca9ca2c7d876b91b31df9434dde47f9065d0d Change-Id: Iff1a7b2dbb707c986f2639e65e39ed8f22430120 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/platformsupport/devicediscovery/devicediscovery.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/devicediscovery/devicediscovery.pri b/src/platformsupport/devicediscovery/devicediscovery.pri index 530ae3dbb2..9faf6f24dd 100644 --- a/src/platformsupport/devicediscovery/devicediscovery.pri +++ b/src/platformsupport/devicediscovery/devicediscovery.pri @@ -1,4 +1,4 @@ -linux-*:contains(QT_CONFIG, evdev) { +linux:contains(QT_CONFIG, evdev) { HEADERS += $$PWD/qdevicediscovery_p.h contains(QT_CONFIG, libudev) { -- cgit v1.2.3 From 0666975d6c276139788001cdd4cb686c7073f50c Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 1 Mar 2013 18:32:49 +0100 Subject: Added JNI convenience classes in QtPlatformSupport. This is used for Android. Change-Id: I049138c140a472b1721390cf4ec2bd88bbe9c471 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Oswald Buddenhagen Reviewed-by: Paul Olav Tvete --- .../jniconvenience/jniconvenience.pri | 9 + src/platformsupport/jniconvenience/qjnihelpers.cpp | 115 + src/platformsupport/jniconvenience/qjnihelpers_p.h | 191 ++ src/platformsupport/jniconvenience/qjniobject.cpp | 3098 ++++++++++++++++++++ src/platformsupport/jniconvenience/qjniobject_p.h | 169 ++ src/platformsupport/platformsupport.pro | 1 + 6 files changed, 3583 insertions(+) create mode 100644 src/platformsupport/jniconvenience/jniconvenience.pri create mode 100644 src/platformsupport/jniconvenience/qjnihelpers.cpp create mode 100644 src/platformsupport/jniconvenience/qjnihelpers_p.h create mode 100644 src/platformsupport/jniconvenience/qjniobject.cpp create mode 100644 src/platformsupport/jniconvenience/qjniobject_p.h (limited to 'src/platformsupport') diff --git a/src/platformsupport/jniconvenience/jniconvenience.pri b/src/platformsupport/jniconvenience/jniconvenience.pri new file mode 100644 index 0000000000..991518e370 --- /dev/null +++ b/src/platformsupport/jniconvenience/jniconvenience.pri @@ -0,0 +1,9 @@ +android { + QT += gui-private + + HEADERS += $$PWD/qjnihelpers_p.h \ + $$PWD/qjniobject_p.h + + SOURCES += $$PWD/qjnihelpers.cpp \ + $$PWD/qjniobject.cpp +} diff --git a/src/platformsupport/jniconvenience/qjnihelpers.cpp b/src/platformsupport/jniconvenience/qjnihelpers.cpp new file mode 100644 index 0000000000..3f9b568368 --- /dev/null +++ b/src/platformsupport/jniconvenience/qjnihelpers.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qjnihelpers_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +QString qt_convertJString(jstring string) +{ + QAttachedJNIEnv env; + int strLength = env->GetStringLength(string); + QString res; + res.resize(strLength); + env->GetStringRegion(string, 0, strLength, (jchar*)res.utf16()); + return res; +} + +QJNILocalRef qt_toJString(const QString &string) +{ + QAttachedJNIEnv env; + return QJNILocalRef(env->NewString(reinterpret_cast(string.constData()), + string.length())); +} + + +static JavaVM *g_javaVM = 0; + +static JavaVM *getJavaVM() +{ + if (!g_javaVM){ + QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); + g_javaVM = static_cast(nativeInterface->nativeResourceForIntegration("JavaVM")); + } + return g_javaVM; +} + +QThreadStorage QAttachedJNIEnv::m_refCount; + +QAttachedJNIEnv::QAttachedJNIEnv() +{ + JavaVM *vm = javaVM(); + if (vm->GetEnv((void**)&jniEnv, JNI_VERSION_1_6) == JNI_EDETACHED) { + if (vm->AttachCurrentThread(&jniEnv, 0) < 0) { + jniEnv = 0; + return; + } + } + + if (!m_refCount.hasLocalData()) + m_refCount.setLocalData(1); + else + m_refCount.setLocalData(m_refCount.localData() + 1); +} + +QAttachedJNIEnv::~QAttachedJNIEnv() +{ + if (!jniEnv) + return; + + int newRef = m_refCount.localData() - 1; + m_refCount.setLocalData(newRef); + + if (newRef == 0) + javaVM()->DetachCurrentThread(); + + jniEnv = 0; +} + +JavaVM *QAttachedJNIEnv::javaVM() +{ + return getJavaVM(); +} + +QT_END_NAMESPACE diff --git a/src/platformsupport/jniconvenience/qjnihelpers_p.h b/src/platformsupport/jniconvenience/qjnihelpers_p.h new file mode 100644 index 0000000000..fb44d156bd --- /dev/null +++ b/src/platformsupport/jniconvenience/qjnihelpers_p.h @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QJNIHELPERS_H +#define QJNIHELPERS_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +template +class QJNILocalRef; + +QString qt_convertJString(jstring string); +QJNILocalRef qt_toJString(const QString &string); + + +struct QAttachedJNIEnv +{ + QAttachedJNIEnv(); + ~QAttachedJNIEnv(); + + static JavaVM *javaVM(); + + JNIEnv *operator->() + { + return jniEnv; + } + + operator JNIEnv*() const + { + return jniEnv; + } + + JNIEnv *jniEnv; + +private: + static QThreadStorage m_refCount; +}; + + +template +class QJNILocalRef +{ +public: + inline QJNILocalRef() : m_obj(0) { } + inline explicit QJNILocalRef(T o) : m_obj(o) { } + inline QJNILocalRef(const QJNILocalRef &other) : m_obj(other.m_obj) + { + if (other.m_obj) + m_obj = static_cast(m_env->NewLocalRef(other.m_obj)); + } + + template + inline QJNILocalRef(const QJNILocalRef &other) : m_obj(other.m_obj) + { + if (other.m_obj) + m_obj = static_cast(m_env->NewLocalRef(other.m_obj)); + } + + inline ~QJNILocalRef() { release(); } + + inline QJNILocalRef &operator=(const QJNILocalRef &other) + { + release(); + m_obj = other.m_obj; // for type checking + if (other.m_obj) + m_obj = static_cast(m_env->NewLocalRef(other.m_obj)); + return *this; + } + + template + inline QJNILocalRef &operator=(const QJNILocalRef &other) + { + release(); + m_obj = other.m_obj; // for type checking + if (other.m_obj) + m_obj = static_cast(m_env->NewLocalRef(other.m_obj)); + return *this; + } + + inline QJNILocalRef &operator=(T o) + { + release(); + m_obj = o; + return *this; + } + + template + inline QJNILocalRef &operator=(X o) + { + release(); + m_obj = o; + return *this; + } + + inline bool operator !() const { return !m_obj; } + inline bool isNull() const { return !m_obj; } + inline T object() const { return m_obj; } + +private: + void release() + { + if (m_obj) { + m_env->DeleteLocalRef(m_obj); + m_obj = 0; + } + } + + QAttachedJNIEnv m_env; + T m_obj; + + template friend class QJNILocalRef; +}; + +template +bool operator==(const QJNILocalRef &ptr1, const QJNILocalRef &ptr2) +{ + return ptr1.m_obj == ptr2.m_obj; +} +template +bool operator!=(const QJNILocalRef &ptr1, const QJNILocalRef &ptr2) +{ + return ptr1.m_obj != ptr2.m_obj; +} + +template +bool operator==(const QJNILocalRef &ptr1, X ptr2) +{ + return ptr1.m_obj == ptr2; +} +template +bool operator==(T ptr1, const QJNILocalRef &ptr2) +{ + return ptr1 == ptr2.m_obj; +} +template +bool operator!=(const QJNILocalRef &ptr1, X ptr2) +{ + return !(ptr1 == ptr2); +} +template +bool operator!=(const T *ptr1, const QJNILocalRef &ptr2) +{ + return !(ptr2 == ptr1); +} + +QT_END_NAMESPACE + +#endif // QJNIHELPERS_H diff --git a/src/platformsupport/jniconvenience/qjniobject.cpp b/src/platformsupport/jniconvenience/qjniobject.cpp new file mode 100644 index 0000000000..515e82b2f0 --- /dev/null +++ b/src/platformsupport/jniconvenience/qjniobject.cpp @@ -0,0 +1,3098 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qjniobject_p.h" + +#include "qjnihelpers_p.h" +#include + +QT_BEGIN_NAMESPACE + +static QHash g_cachedClasses; + +static jclass getCachedClass(JNIEnv *env, const char *className) +{ + jclass clazz = 0; + QString key = QLatin1String(className); + QHash::iterator it = g_cachedClasses.find(key); + if (it == g_cachedClasses.end()) { + jclass c = env->FindClass(className); + if (env->ExceptionCheck()) { + c = 0; + env->ExceptionClear(); + } + if (c) + clazz = static_cast(env->NewGlobalRef(c)); + g_cachedClasses.insert(key, clazz); + } else { + clazz = it.value(); + } + return clazz; +} + +static QHash g_cachedMethodIDs; +static QString g_keyBase(QLatin1String("%1%2%3")); + +static jmethodID getCachedMethodID(JNIEnv *env, + jclass clazz, + const char *name, + const char *sig, + bool isStatic = false) +{ + jmethodID id = 0; + QString key = g_keyBase.arg(size_t(clazz)).arg(QLatin1String(name)).arg(QLatin1String(sig)); + QHash::iterator it = g_cachedMethodIDs.find(key); + if (it == g_cachedMethodIDs.end()) { + if (isStatic) + id = env->GetStaticMethodID(clazz, name, sig); + else + id = env->GetMethodID(clazz, name, sig); + + if (env->ExceptionCheck()) { + id = 0; + env->ExceptionClear(); + } + + g_cachedMethodIDs.insert(key, id); + } else { + id = it.value(); + } + return id; +} + +static QHash g_cachedFieldIDs; + +static jfieldID getCachedFieldID(JNIEnv *env, + jclass clazz, + const char *name, + const char *sig, + bool isStatic = false) +{ + jfieldID id = 0; + QString key = g_keyBase.arg(size_t(clazz)).arg(QLatin1String(name)).arg(QLatin1String(sig)); + QHash::iterator it = g_cachedFieldIDs.find(key); + if (it == g_cachedFieldIDs.end()) { + if (isStatic) + id = env->GetStaticFieldID(clazz, name, sig); + else + id = env->GetFieldID(clazz, name, sig); + + if (env->ExceptionCheck()) { + id = 0; + env->ExceptionClear(); + } + + g_cachedFieldIDs.insert(key, id); + } else { + id = it.value(); + } + return id; +} + +QJNIObject::QJNIObject(const char *className) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(false) +{ + QAttachedJNIEnv env; + m_jclass = getCachedClass(env, className); + if (m_jclass) { + // get default constructor + jmethodID constructorId = getCachedMethodID(env, m_jclass, "", "()V"); + if (constructorId) { + jobject obj = env->NewObject(m_jclass, constructorId); + if (obj) { + m_jobject = env->NewGlobalRef(obj); + env->DeleteLocalRef(obj); + } + } + } +} + +QJNIObject::QJNIObject(const char *className, const char *sig, ...) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(false) +{ + QAttachedJNIEnv env; + m_jclass = getCachedClass(env, className); + if (m_jclass) { + jmethodID constructorId = getCachedMethodID(env, m_jclass, "", sig); + if (constructorId) { + va_list args; + va_start(args, sig); + jobject obj = env->NewObjectV(m_jclass, constructorId, args); + va_end(args); + if (obj) { + m_jobject = env->NewGlobalRef(obj); + env->DeleteLocalRef(obj); + } + } + } +} + +QJNIObject::QJNIObject(jclass clazz) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(true) +{ + QAttachedJNIEnv env; + m_jclass = static_cast(env->NewGlobalRef(clazz)); + if (m_jclass) { + // get default constructor + jmethodID constructorId = getCachedMethodID(env, m_jclass, "", "()V"); + if (constructorId) { + jobject obj = env->NewObject(m_jclass, constructorId); + if (obj) { + m_jobject = env->NewGlobalRef(obj); + env->DeleteLocalRef(obj); + } + } + } +} + +QJNIObject::QJNIObject(jclass clazz, const char *sig, ...) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(true) +{ + QAttachedJNIEnv env; + if (clazz) { + m_jclass = static_cast(env->NewGlobalRef(clazz)); + if (m_jclass) { + jmethodID constructorId = getCachedMethodID(env, m_jclass, "", sig); + if (constructorId) { + va_list args; + va_start(args, sig); + jobject obj = env->NewObjectV(m_jclass, constructorId, args); + va_end(args); + if (obj) { + m_jobject = env->NewGlobalRef(obj); + env->DeleteLocalRef(obj); + } + } + } + } +} + +QJNIObject::QJNIObject(jobject obj) + : m_jobject(0) + , m_jclass(0) + , m_own_jclass(true) +{ + QAttachedJNIEnv env; + m_jobject = env->NewGlobalRef(obj); + m_jclass = static_cast(env->NewGlobalRef(env->GetObjectClass(m_jobject))); +} + +QJNIObject::~QJNIObject() +{ + QAttachedJNIEnv env; + if (m_jobject) + env->DeleteGlobalRef(m_jobject); + if (m_jclass && m_own_jclass) + env->DeleteGlobalRef(m_jclass); +} + +bool QJNIObject::isClassAvailable(const char *className) +{ + QAttachedJNIEnv env; + + if (!env.jniEnv) + return false; + + jclass clazz = getCachedClass(env, className); + + return (clazz != 0); +} + +template <> +void QJNIObject::callMethod(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + env->CallVoidMethodV(m_jobject, id, args); + va_end(args); + } +} + +template <> +jboolean QJNIObject::callMethod(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jboolean res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallBooleanMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jbyte QJNIObject::callMethod(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jbyte res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallByteMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jchar QJNIObject::callMethod(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jchar res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallCharMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jshort QJNIObject::callMethod(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jshort res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallShortMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jint QJNIObject::callMethod(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jint res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallIntMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jlong QJNIObject::callMethod(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jlong res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallLongMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jfloat QJNIObject::callMethod(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jfloat res = 0.f; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallFloatMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +jdouble QJNIObject::callMethod(const char *methodName, const char *sig, ...) +{ + QAttachedJNIEnv env; + jdouble res = 0.; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallDoubleMethodV(m_jobject, id, args); + va_end(args); + } + return res; +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jobject res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallObjectMethodV(m_jobject, id, args); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jstring res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jobjectArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jbooleanArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jbyteArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jcharArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jshortArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jintArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jlongArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jfloatArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jdoubleArray res = 0; + jmethodID id = getCachedMethodID(env, m_jclass, methodName, sig); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallObjectMethodV(m_jobject, id, args)); + va_end(args); + } + return QJNILocalRef(res); +} + +template <> +void QJNIObject::callMethod(const char *methodName) +{ + callMethod(methodName, "()V"); +} + +template <> +jboolean QJNIObject::callMethod(const char *methodName) +{ + return callMethod(methodName, "()Z"); +} + +template <> +jbyte QJNIObject::callMethod(const char *methodName) +{ + return callMethod(methodName, "()B"); +} + +template <> +jchar QJNIObject::callMethod(const char *methodName) +{ + return callMethod(methodName, "()C"); +} + +template <> +jshort QJNIObject::callMethod(const char *methodName) +{ + return callMethod(methodName, "()S"); +} + +template <> +jint QJNIObject::callMethod(const char *methodName) +{ + return callMethod(methodName, "()I"); +} + +template <> +jlong QJNIObject::callMethod(const char *methodName) +{ + return callMethod(methodName, "()J"); +} + +template <> +jfloat QJNIObject::callMethod(const char *methodName) +{ + return callMethod(methodName, "()F"); +} + +template <> +jdouble QJNIObject::callMethod(const char *methodName) +{ + return callMethod(methodName, "()D"); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName) +{ + return callObjectMethod(methodName, "()Ljava/lang/String;"); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName) +{ + return callObjectMethod(methodName, "()[Z"); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName) +{ + return callObjectMethod(methodName, "()[B"); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName) +{ + return callObjectMethod(methodName, "()[S"); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName) +{ + return callObjectMethod(methodName, "()[I"); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName) +{ + return callObjectMethod(methodName, "()[J"); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName) +{ + return callObjectMethod(methodName, "()[F"); +} + +template <> +QJNILocalRef QJNIObject::callObjectMethod(const char *methodName) +{ + return callObjectMethod(methodName, "()[D"); +} + +template <> +void QJNIObject::callStaticMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + env->CallStaticVoidMethodV(clazz, id, args); + va_end(args); + } + } +} + +template <> +void QJNIObject::callStaticMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + env->CallStaticVoidMethodV(clazz, id, args); + va_end(args); + } +} + +template <> +jboolean QJNIObject::callStaticMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jboolean res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticBooleanMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jboolean QJNIObject::callStaticMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jboolean res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticBooleanMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jbyte QJNIObject::callStaticMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbyte res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticByteMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jbyte QJNIObject::callStaticMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbyte res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticByteMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jchar QJNIObject::callStaticMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jchar res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticCharMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jchar QJNIObject::callStaticMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jchar res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticCharMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + + +template <> +jshort QJNIObject::callStaticMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jshort res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticShortMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jshort QJNIObject::callStaticMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jshort res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticShortMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jint QJNIObject::callStaticMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jint res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticIntMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jint QJNIObject::callStaticMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jint res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticIntMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jlong QJNIObject::callStaticMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jlong res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticLongMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jlong QJNIObject::callStaticMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jlong res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticLongMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jfloat QJNIObject::callStaticMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jfloat res = 0.f; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticFloatMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jfloat QJNIObject::callStaticMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jfloat res = 0.f; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticFloatMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +jdouble QJNIObject::callStaticMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jdouble res = 0.; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticDoubleMethodV(clazz, id, args); + va_end(args); + } + } + + return res; +} + +template <> +jdouble QJNIObject::callStaticMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jdouble res = 0.; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticDoubleMethodV(clazz, id, args); + va_end(args); + } + + return res; +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jobject res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticObjectMethodV(clazz, id, args); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jobject res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = env->CallStaticObjectMethodV(clazz, id, args); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jstring res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jstring res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jobjectArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jobjectArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbooleanArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbooleanArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbyteArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jbyteArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jcharArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jcharArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jshortArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jshortArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jintArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jintArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jlongArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jlongArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jfloatArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jfloatArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jdoubleArray res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) { + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + } + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, + ...) +{ + QAttachedJNIEnv env; + + jdoubleArray res = 0; + + jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true); + if (id) { + va_list args; + va_start(args, sig); + res = static_cast(env->CallStaticObjectMethodV(clazz, id, args)); + va_end(args); + } + + return QJNILocalRef(res); +} + +template <> +void QJNIObject::callStaticMethod(const char *className, const char *methodName) +{ + callStaticMethod(className, methodName, "()V"); +} + +template <> +void QJNIObject::callStaticMethod(jclass clazz, const char *methodName) +{ + callStaticMethod(clazz, methodName, "()V"); +} + +template <> +jboolean QJNIObject::callStaticMethod(const char *className, const char *methodName) +{ + return callStaticMethod(className, methodName, "()Z"); +} + +template <> +jboolean QJNIObject::callStaticMethod(jclass clazz, const char *methodName) +{ + return callStaticMethod(clazz, methodName, "()Z"); +} + +template <> +jbyte QJNIObject::callStaticMethod(const char *className, const char *methodName) +{ + return callStaticMethod(className, methodName, "()B"); +} + +template <> +jbyte QJNIObject::callStaticMethod(jclass clazz, const char *methodName) +{ + return callStaticMethod(clazz, methodName, "()B"); +} + +template <> +jchar QJNIObject::callStaticMethod(const char *className, const char *methodName) +{ + return callStaticMethod(className, methodName, "()C"); +} + +template <> +jchar QJNIObject::callStaticMethod(jclass clazz, const char *methodName) +{ + return callStaticMethod(clazz, methodName, "()C"); +} + +template <> +jshort QJNIObject::callStaticMethod(const char *className, const char *methodName) +{ + return callStaticMethod(className, methodName, "()S"); +} + +template <> +jshort QJNIObject::callStaticMethod(jclass clazz, const char *methodName) +{ + return callStaticMethod(clazz, methodName, "()S"); +} + +template <> +jint QJNIObject::callStaticMethod(const char *className, const char *methodName) +{ + return callStaticMethod(className, methodName, "()I"); +} + +template <> +jint QJNIObject::callStaticMethod(jclass clazz, const char *methodName) +{ + return callStaticMethod(clazz, methodName, "()I"); +} + +template <> +jlong QJNIObject::callStaticMethod(const char *className, const char *methodName) +{ + return callStaticMethod(className, methodName, "()J"); +} + +template <> +jlong QJNIObject::callStaticMethod(jclass clazz, const char *methodName) +{ + return callStaticMethod(clazz, methodName, "()J"); +} + +template <> +jfloat QJNIObject::callStaticMethod(const char *className, const char *methodName) +{ + return callStaticMethod(className, methodName, "()F"); +} + +template <> +jfloat QJNIObject::callStaticMethod(jclass clazz, const char *methodName) +{ + return callStaticMethod(clazz, methodName, "()F"); +} + +template <> +jdouble QJNIObject::callStaticMethod(const char *className, const char *methodName) +{ + return callStaticMethod(className, methodName, "()D"); +} + +template <> +jdouble QJNIObject::callStaticMethod(jclass clazz, const char *methodName) +{ + return callStaticMethod(clazz, methodName, "()D"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName) +{ + return callStaticObjectMethod(className, methodName, "()Ljava/lang/String;"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod(clazz, methodName, "()Ljava/lang/String;"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName) +{ + return callStaticObjectMethod(className, methodName, "()[Z"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod(clazz, methodName, "()[Z"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName) +{ + return callStaticObjectMethod(className, methodName, "()[B"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod(clazz, methodName, "()[B"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName) +{ + return callStaticObjectMethod(className, methodName, "()[C"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod(clazz, methodName, "()[C"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName) +{ + return callStaticObjectMethod(className, methodName, "()[S"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod(clazz, methodName, "()[S"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName) +{ + return callStaticObjectMethod(className, methodName, "()[I"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod(clazz, methodName, "()[I"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName) +{ + return callStaticObjectMethod(className, methodName, "()[J"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod(clazz, methodName, "()[J"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName) +{ + return callStaticObjectMethod(className, methodName, "()[F"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod(clazz, methodName, "()[F"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(const char *className, + const char *methodName) +{ + return callStaticObjectMethod(className, methodName, "()[D"); +} + +template <> +QJNILocalRef QJNIObject::callStaticObjectMethod(jclass clazz, + const char *methodName) +{ + return callStaticObjectMethod(clazz, methodName, "()[D"); +} + +template <> +jboolean QJNIObject::getField(const char *fieldName) +{ + QAttachedJNIEnv env; + jboolean res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Z"); + if (id) + res = env->GetBooleanField(m_jobject, id); + + return res; +} + +template <> +jbyte QJNIObject::getField(const char *fieldName) +{ + QAttachedJNIEnv env; + jbyte res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "B"); + if (id) + res = env->GetByteField(m_jobject, id); + + return res; +} + +template <> +jchar QJNIObject::getField(const char *fieldName) +{ + QAttachedJNIEnv env; + jchar res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "C"); + if (id) + res = env->GetCharField(m_jobject, id); + + return res; +} + +template <> +jshort QJNIObject::getField(const char *fieldName) +{ + QAttachedJNIEnv env; + jshort res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "S"); + if (id) + res = env->GetShortField(m_jobject, id); + + return res; +} + +template <> +jint QJNIObject::getField(const char *fieldName) +{ + QAttachedJNIEnv env; + jint res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "I"); + if (id) + res = env->GetIntField(m_jobject, id); + + return res; +} + +template <> +jlong QJNIObject::getField(const char *fieldName) +{ + QAttachedJNIEnv env; + jlong res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "J"); + if (id) + res = env->GetLongField(m_jobject, id); + + return res; +} + +template <> +jfloat QJNIObject::getField(const char *fieldName) +{ + QAttachedJNIEnv env; + jfloat res = 0.f; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "F"); + if (id) + res = env->GetFloatField(m_jobject, id); + + return res; +} + +template <> +jdouble QJNIObject::getField(const char *fieldName) +{ + QAttachedJNIEnv env; + jdouble res = 0.; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "D"); + if (id) + res = env->GetDoubleField(m_jobject, id); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName, const char *sig) +{ + QAttachedJNIEnv env; + jobject res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig); + if (id) + res = env->GetObjectField(m_jobject, id); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName) +{ + QAttachedJNIEnv env; + jbooleanArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[Z"); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName) +{ + QAttachedJNIEnv env; + jbyteArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[B"); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName) +{ + QAttachedJNIEnv env; + jcharArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[C"); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName) +{ + QAttachedJNIEnv env; + jshortArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[S"); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName) +{ + QAttachedJNIEnv env; + jintArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[I"); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName) +{ + QAttachedJNIEnv env; + jlongArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[J"); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName) +{ + QAttachedJNIEnv env; + jfloatArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[F"); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName) +{ + QAttachedJNIEnv env; + jdoubleArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[D"); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName) +{ + QAttachedJNIEnv env; + jstring res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Ljava/lang/String;"); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getObjectField(const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + jobjectArray res = 0; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig); + if (id) + res = static_cast(env->GetObjectField(m_jobject, id)); + + return QJNILocalRef(res); +} + +template <> +void QJNIObject::setField(const char *fieldName, jboolean value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Z"); + if (id) + env->SetBooleanField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jbyte value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "B"); + if (id) + env->SetByteField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jchar value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "C"); + if (id) + env->SetCharField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jshort value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "S"); + if (id) + env->SetShortField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jint value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "I"); + if (id) + env->SetIntField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jlong value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "J"); + if (id) + env->SetLongField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jfloat value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "F"); + if (id) + env->SetFloatField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jdouble value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "D"); + if (id) + env->SetDoubleField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jbooleanArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[Z"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jbyteArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[B"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jcharArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[C"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jshortArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[S"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jintArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[I"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jlongArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[J"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jfloatArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[F"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jdoubleArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "[D"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, jstring value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, "Ljava/lang/String;"); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, const char *sig, jobject value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +void QJNIObject::setField(const char *fieldName, + const char *sig, + jobjectArray value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, m_jclass, fieldName, sig); + if (id) + env->SetObjectField(m_jobject, id, value); + +} + +template <> +jboolean QJNIObject::getStaticField(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jboolean res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "Z", true); + if (id) + res = env->GetStaticBooleanField(clazz, id); + + return res; +} + +template <> +jboolean QJNIObject::getStaticField(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jboolean res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField(clazz, fieldName); + + return res; +} + +template <> +jbyte QJNIObject::getStaticField(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jbyte res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "B", true); + if (id) + res = env->GetStaticByteField(clazz, id); + + return res; +} + +template <> +jbyte QJNIObject::getStaticField(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jbyte res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField(clazz, fieldName); + + return res; +} + +template <> +jchar QJNIObject::getStaticField(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jchar res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "C", true); + if (id) + res = env->GetStaticCharField(clazz, id); + + return res; +} + +template <> +jchar QJNIObject::getStaticField(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jchar res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField(clazz, fieldName); + + return res; +} + +template <> +jshort QJNIObject::getStaticField(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jshort res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "S", true); + if (id) + res = env->GetStaticShortField(clazz, id); + + return res; +} + +template <> +jshort QJNIObject::getStaticField(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jshort res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField(clazz, fieldName); + + return res; +} + +template <> +jint QJNIObject::getStaticField(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jint res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "I", true); + if (id) + res = env->GetStaticIntField(clazz, id); + + return res; +} + +template <> +jint QJNIObject::getStaticField(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jint res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField(clazz, fieldName); + + return res; +} + +template <> +jlong QJNIObject::getStaticField(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jlong res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "J", true); + if (id) + res = env->GetStaticLongField(clazz, id); + + return res; +} + +template <> +jlong QJNIObject::getStaticField(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jlong res = 0; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField(clazz, fieldName); + + return res; +} + +template <> +jfloat QJNIObject::getStaticField(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jfloat res = 0.f; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "F", true); + if (id) + res = env->GetStaticFloatField(clazz, id); + + return res; +} + +template <> +jfloat QJNIObject::getStaticField(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jfloat res = 0.f; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField(clazz, fieldName); + + return res; +} + +template <> +jdouble QJNIObject::getStaticField(jclass clazz, const char *fieldName) +{ + QAttachedJNIEnv env; + + jdouble res = 0.; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "D", true); + if (id) + res = env->GetStaticDoubleField(clazz, id); + + return res; +} + +template <> +jdouble QJNIObject::getStaticField(const char *className, const char *fieldName) +{ + QAttachedJNIEnv env; + + jdouble res = 0.; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + + jobject res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true); + if (id) + res = env->GetStaticObjectField(clazz, id); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName, sig); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jstring res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "Ljava/lang/String;", true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jbooleanArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[Z", true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jbyteArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[B", true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jcharArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[C", true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jshortArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[S", true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jintArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[I", true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jlongArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[J", true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jfloatArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[F", true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName) +{ + QAttachedJNIEnv env; + + jdoubleArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, "[D", true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName); + + return res; +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(jclass clazz, + const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + + jobjectArray res = 0; + + jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true); + if (id) + res = static_cast(env->GetStaticObjectField(clazz, id)); + + return QJNILocalRef(res); +} + +template <> +QJNILocalRef QJNIObject::getStaticObjectField(const char *className, + const char *fieldName, + const char *sig) +{ + QAttachedJNIEnv env; + + QJNILocalRef res; + + jclass clazz = getCachedClass(env, className); + if (clazz) + res = getStaticObjectField(clazz, fieldName, sig); + + return res; +} + +template <> +void QJNIObject::setStaticField(jclass clazz, const char *fieldName, jboolean value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "Z", true); + if (id) + env->SetStaticBooleanField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jboolean value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, const char *fieldName, jbyte value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "B", true); + if (id) + env->SetStaticByteField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jbyte value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, const char *fieldName, jchar value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "C", true); + if (id) + env->SetStaticCharField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jchar value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, const char *fieldName, jshort value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "S", true); + if (id) + env->SetStaticShortField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jshort value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, const char *fieldName, jint value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "I", true); + if (id) + env->SetStaticIntField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, const char *fieldName, jint value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, const char *fieldName, jlong value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "J", true); + if (id) + env->SetStaticLongField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jlong value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, const char *fieldName, jfloat value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "F", true); + if (id) + env->SetStaticFloatField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jfloat value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, const char *fieldName, jdouble value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, "D", true); + if (id) + env->SetStaticDoubleField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jdouble value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField(clazz, fieldName, value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, + const char *fieldName, + const char *sig, + jobject value) +{ + QAttachedJNIEnv env; + jfieldID id = getCachedFieldID(env, clazz, fieldName, sig, true); + if (id) + env->SetStaticObjectField(clazz, id, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + const char *sig, + jobject value) +{ + QAttachedJNIEnv env; + jclass clazz = getCachedClass(env, className); + if (clazz) + setStaticField(clazz, fieldName, sig, value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jstring value) +{ + setStaticField(className, fieldName, "Ljava/lang/String;", value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, const char *fieldName, jstring value) +{ + setStaticField(clazz, fieldName, "Ljava/lang/String;", value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jbooleanArray value) +{ + setStaticField(className, fieldName, "[Z", value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, + const char *fieldName, + jbooleanArray value) +{ + setStaticField(clazz, fieldName, "[Z", value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jbyteArray value) +{ + setStaticField(className, fieldName, "[B", value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, + const char *fieldName, + jbyteArray value) +{ + setStaticField(clazz, fieldName, "[B", value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jcharArray value) +{ + setStaticField(className, fieldName, "[C", value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, + const char *fieldName, + jcharArray value) +{ + setStaticField(clazz, fieldName, "[C", value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jshortArray value) +{ + setStaticField(className, fieldName, "[S", value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, + const char *fieldName, + jshortArray value) +{ + setStaticField(clazz, fieldName, "[S", value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jintArray value) +{ + setStaticField(className, fieldName, "[I", value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, + const char *fieldName, + jintArray value) +{ + setStaticField(clazz, fieldName, "[I", value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jlongArray value) +{ + setStaticField(className, fieldName, "[J", value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, + const char *fieldName, + jlongArray value) +{ + setStaticField(clazz, fieldName, "[J", value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jfloatArray value) +{ + setStaticField(className, fieldName, "[F", value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, + const char *fieldName, + jfloatArray value) +{ + setStaticField(clazz, fieldName, "[F", value); +} + +template <> +void QJNIObject::setStaticField(const char *className, + const char *fieldName, + jdoubleArray value) +{ + setStaticField(className, fieldName, "[D", value); +} + +template <> +void QJNIObject::setStaticField(jclass clazz, + const char *fieldName, + jdoubleArray value) +{ + setStaticField(clazz, fieldName, "[D", value); +} + + +QT_END_NAMESPACE diff --git a/src/platformsupport/jniconvenience/qjniobject_p.h b/src/platformsupport/jniconvenience/qjniobject_p.h new file mode 100644 index 0000000000..6874765f06 --- /dev/null +++ b/src/platformsupport/jniconvenience/qjniobject_p.h @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QJNIOBJECT_H +#define QJNIOBJECT_H + +#include +#include + +QT_BEGIN_NAMESPACE + +template +class QJNILocalRef; + +/** + * Allows to wrap any Java class and partially hide some of the jni calls. + * + * Usage example: + * + * QJNIObject javaString("java/lang/String"); + * jchar char = javaString.callMethod("charAt", "(I)C", 0); + * + * ---- + * + * jstring string = QJNIObject::callStaticMethod("java/lang/String", + * "valueOf", + * "(I)Ljava/lang/String;", 2); + * + * ---- + * + * // Constructor with argument + * jstring someString; + * QJNIObject someObject("java/some/Class", "(Ljava/lang/String;)V", someString); + * someObject.setField("fieldName", 10); + * someObject.callMethod("doStuff"); + */ +class QJNIObject +{ +public: + QJNIObject(const char *className); + QJNIObject(const char *className, const char *sig, ...); + QJNIObject(jclass clazz); + QJNIObject(jclass clazz, const char *sig, ...); + QJNIObject(jobject obj); + virtual ~QJNIObject(); + + static bool isClassAvailable(const char *className); + + bool isValid() const { return m_jobject != 0; } + jobject object() const { return m_jobject; } + + template + T callMethod(const char *methodName); + template + T callMethod(const char *methodName, const char *sig, ...); + template + QJNILocalRef callObjectMethod(const char *methodName); + template + QJNILocalRef callObjectMethod(const char *methodName, const char *sig, ...); + + template + static T callStaticMethod(const char *className, const char *methodName); + template + static T callStaticMethod(const char *className, const char *methodName, const char *sig, ...); + template + static QJNILocalRef callStaticObjectMethod(const char *className, const char *methodName); + template + static QJNILocalRef callStaticObjectMethod(const char *className, + const char *methodName, + const char *sig, ...); + template + static T callStaticMethod(jclass clazz, const char *methodName); + template + static T callStaticMethod(jclass clazz, const char *methodName, const char *sig, ...); + template + static QJNILocalRef callStaticObjectMethod(jclass clazz, const char *methodName); + template + static QJNILocalRef callStaticObjectMethod(jclass clazz, + const char *methodName, + const char *sig, ...); + + template + T getField(const char *fieldName); + template + T getField(const char *fieldName, const char *sig); + template + QJNILocalRef getObjectField(const char *fieldName); + template + QJNILocalRef getObjectField(const char *fieldName, const char *sig); + + template + void setField(const char *fieldName, T value); + template + void setField(const char *fieldName, const char *sig, T value); + + template + static QJNILocalRef getStaticObjectField(const char *className, const char *fieldName); + template + static QJNILocalRef getStaticObjectField(const char *className, + const char *fieldName, + const char *sig); + template + static T getStaticField(const char *className, const char *fieldName); + template + static QJNILocalRef getStaticObjectField(jclass clazz, const char *fieldName); + template + static QJNILocalRef getStaticObjectField(jclass clazz, const char *fieldName, const char *sig); + template + static T getStaticField(jclass clazz, const char *fieldName); + + template + static void setStaticField(const char *className, + const char *fieldName, + const char *sig, + T value); + template + static void setStaticField(const char *className, const char *fieldName, T value); + template + static void setStaticField(jclass clazz, const char *fieldName, const char *sig, T value); + template + static void setStaticField(jclass clazz, const char *fieldName, T value); + +protected: + jobject m_jobject; + jclass m_jclass; + bool m_own_jclass; +}; + +QT_END_NAMESPACE + +#endif // QJNIOBJECT_H diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index 8e0f396993..0566e9d3ec 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -22,3 +22,4 @@ include(devicediscovery/devicediscovery.pri) include(services/services.pri) include(themes/themes.pri) include(linuxaccessibility/linuxaccessibility.pri) +include(jniconvenience/jniconvenience.pri) -- cgit v1.2.3 From 341fb50d5b4433193b47cffa0d513f633d9978cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 6 Mar 2013 08:37:07 +0100 Subject: Fixed android-no-sdk build by excluding platformsupport/jniconvenience. Change-Id: I02e45523a0e35aad3afdbef4a4b3a00de32663f3 Reviewed-by: Gunnar Sletta --- src/platformsupport/jniconvenience/jniconvenience.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/jniconvenience/jniconvenience.pri b/src/platformsupport/jniconvenience/jniconvenience.pri index 991518e370..ca7c5b1e96 100644 --- a/src/platformsupport/jniconvenience/jniconvenience.pri +++ b/src/platformsupport/jniconvenience/jniconvenience.pri @@ -1,4 +1,4 @@ -android { +android:!android-no-sdk { QT += gui-private HEADERS += $$PWD/qjnihelpers_p.h \ -- cgit v1.2.3 From 06a65b053e9b8697c0140219fdc3c28495426e77 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 7 Mar 2013 15:21:07 +0200 Subject: Get rid of qt_determine_writing_systems_from_truetype_bits() Move this code to QPlatformFontDatabase and get rid of all dups of it. Change-Id: Idea6c84819039bf3b345b1305305951ade8d1ac4 Reviewed-by: Lars Knoll --- .../fontdatabases/basic/qbasicfontdatabase.cpp | 126 +-------------------- .../fontdatabases/basic/qbasicfontdatabase_p.h | 1 - 2 files changed, 1 insertion(+), 126 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp index f17eff4dd7..49440c8566 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp @@ -60,82 +60,6 @@ QT_BEGIN_NAMESPACE -#define SimplifiedChineseCsbBit 18 -#define TraditionalChineseCsbBit 20 -#define JapaneseCsbBit 17 -#define KoreanCsbBit 21 - -static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = { - // Any, - { 127, 127 }, - // Latin, - { 0, 127 }, - // Greek, - { 7, 127 }, - // Cyrillic, - { 9, 127 }, - // Armenian, - { 10, 127 }, - // Hebrew, - { 11, 127 }, - // Arabic, - { 13, 127 }, - // Syriac, - { 71, 127 }, - //Thaana, - { 72, 127 }, - //Devanagari, - { 15, 127 }, - //Bengali, - { 16, 127 }, - //Gurmukhi, - { 17, 127 }, - //Gujarati, - { 18, 127 }, - //Oriya, - { 19, 127 }, - //Tamil, - { 20, 127 }, - //Telugu, - { 21, 127 }, - //Kannada, - { 22, 127 }, - //Malayalam, - { 23, 127 }, - //Sinhala, - { 73, 127 }, - //Thai, - { 24, 127 }, - //Lao, - { 25, 127 }, - //Tibetan, - { 70, 127 }, - //Myanmar, - { 74, 127 }, - // Georgian, - { 26, 127 }, - // Khmer, - { 80, 127 }, - // SimplifiedChinese, - { 126, 127 }, - // TraditionalChinese, - { 126, 127 }, - // Japanese, - { 126, 127 }, - // Korean, - { 56, 127 }, - // Vietnamese, - { 0, 127 }, // same as latin1 - // Other, - { 126, 127 }, - // Ogham, - { 78, 127 }, - // Runic, - { 79, 127 }, - // Nko, - { 14, 127 }, -}; - typedef struct { quint16 majorVersion; quint16 minorVersion; @@ -167,54 +91,6 @@ typedef struct { quint16 stringOffset; } NAME_RECORD; -QSupportedWritingSystems QBasicFontDatabase::determineWritingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2]) -{ - QSupportedWritingSystems writingSystems; - bool hasScript = false; - - int i; - for(i = 0; i < QFontDatabase::WritingSystemsCount; i++) { - int bit = requiredUnicodeBits[i][0]; - int index = bit/32; - int flag = 1 << (bit&31); - if (bit != 126 && unicodeRange[index] & flag) { - bit = requiredUnicodeBits[i][1]; - index = bit/32; - - flag = 1 << (bit&31); - if (bit == 127 || unicodeRange[index] & flag) { - writingSystems.setSupported(QFontDatabase::WritingSystem(i)); - hasScript = true; - // qDebug("font %s: index=%d, flag=%8x supports script %d", familyName.latin1(), index, flag, i); - } - } - } - if(codePageRange[0] & (1 << SimplifiedChineseCsbBit)) { - writingSystems.setSupported(QFontDatabase::SimplifiedChinese); - hasScript = true; - //qDebug("font %s supports Simplified Chinese", familyName.latin1()); - } - if(codePageRange[0] & (1 << TraditionalChineseCsbBit)) { - writingSystems.setSupported(QFontDatabase::TraditionalChinese); - hasScript = true; - //qDebug("font %s supports Traditional Chinese", familyName.latin1()); - } - if(codePageRange[0] & (1 << JapaneseCsbBit)) { - writingSystems.setSupported(QFontDatabase::Japanese); - hasScript = true; - //qDebug("font %s supports Japanese", familyName.latin1()); - } - if(codePageRange[0] & (1 << KoreanCsbBit)) { - writingSystems.setSupported(QFontDatabase::Korean); - hasScript = true; - //qDebug("font %s supports Korean", familyName.latin1()); - } - if (!hasScript) - writingSystems.setSupported(QFontDatabase::Symbol); - - return writingSystems; -} - static inline bool scriptRequiresOpenType(int script) { return ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala) @@ -414,7 +290,7 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt quint32(os2->ulCodePageRange2) }; - writingSystems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange); + writingSystems = QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange); if (os2->usWeightClass == 0) ; diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h index 8bb574f335..4d6fd2ceeb 100644 --- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase_p.h @@ -65,7 +65,6 @@ public: void releaseHandle(void *handle); static QStringList addTTFile(const QByteArray &fontData, const QByteArray &file); - static QSupportedWritingSystems determineWritingSystemsFromTrueTypeBits(quint32 unicodeRange[4], quint32 codePageRange[2]); static QString fontNameFromTTFile(const QString &filename); }; -- cgit v1.2.3 From 0194fa135b1d84a8c8d70ed8a0ff46eef0289fb7 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sun, 10 Mar 2013 10:55:27 +0200 Subject: Hide Harfbuzz from the outer world Don't export, don't generate private headers, don't mention HB in API. Change-Id: I048ebd178bf4afaf9fda710a00933b95274cf910 Reviewed-by: Josh Faust Reviewed-by: Lars Knoll --- src/platformsupport/fontdatabases/fontdatabases.pri | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/fontdatabases.pri b/src/platformsupport/fontdatabases/fontdatabases.pri index 003017473b..12b06d64cc 100644 --- a/src/platformsupport/fontdatabases/fontdatabases.pri +++ b/src/platformsupport/fontdatabases/fontdatabases.pri @@ -1,5 +1,3 @@ -DEFINES += QT_COMPILES_IN_HARFBUZZ - !win32|contains(QT_CONFIG, freetype):!mac { include($$PWD/basic/basic.pri) } -- cgit v1.2.3 From d1d0df8fb6a3461d37455f87445d9bcef62a0f93 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 12 Mar 2013 15:35:37 +0100 Subject: Make qaccessible2.h internal. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should have been done right from the start, instead we only made the documentation internal. Also remove the classes from the BIC data. Change-Id: I238a7a7cc5d26980b23931c78e7e5a4477d46920 Reviewed-by: Oswald Buddenhagen Reviewed-by: Jan Arve Sæther --- src/platformsupport/linuxaccessibility/atspiadaptor_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h index 1c79cc75c8..0bc3290baa 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h +++ b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include "dbusconnection_p.h" #include "struct_marshallers_p.h" -- cgit v1.2.3 From d1b4857d1718ef50dba64c8700253fed5d187ab2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 10 Mar 2013 13:34:52 -0700 Subject: Make sure that we #include qconfig.h before testing for features. This is mandatory in public headers (qiodevice.h, qopengl*, etc.), but it's a good idea even in private headers, in case someone includes that header first somewhere. In particular, all platformsupport API is private. Change-Id: If287baa5d9ed14e93c1666efa0e6332c4c1cd9a4 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- .../fontdatabases/genericunix/qgenericunixfontdatabase_p.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fontdatabases/genericunix/qgenericunixfontdatabase_p.h b/src/platformsupport/fontdatabases/genericunix/qgenericunixfontdatabase_p.h index 1995ead657..a8a0b8fe9c 100644 --- a/src/platformsupport/fontdatabases/genericunix/qgenericunixfontdatabase_p.h +++ b/src/platformsupport/fontdatabases/genericunix/qgenericunixfontdatabase_p.h @@ -42,6 +42,8 @@ #ifndef QGENERICUNIXFONTDATABASE_H #define QGENERICUNIXFONTDATABASE_H +#include + #ifdef Q_FONTCONFIGDATABASE #include typedef QFontconfigDatabase QGenericUnixFontDatabase; -- cgit v1.2.3